Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Added target attribute to a element for action buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
PingusPepan committed Sep 23, 2012
1 parent 4e8fdfa commit d4f1ca6
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion Components/Button.php
Expand Up @@ -23,6 +23,9 @@ class Button extends \Nette\Application\UI\PresenterComponent
/** @var callback|string */
private $text;

/** @var callback|string */
private $target;

/** @var callback|string */
private $class;

Expand Down Expand Up @@ -104,6 +107,29 @@ private function getText($row)
return $this->text;
}

/**
* @param callback|string $target
* @return Button
*/
public function setTarget($target)
{
$this->target = $target;

return $this;
}

/**
* @param array $row
* @return callback|mixed|string
*/
private function getTarget($row)
{
if(is_callable($this->target)){
return call_user_func($this->target, $row);
}
return $this->target;
}

/**
* @param callback|string $class
* @return Button
Expand Down Expand Up @@ -206,7 +232,8 @@ public function render($row)
->setText($this->getText($row))
->addClass("grid-button")
->addClass($this->getClass($row))
->setTitle($this->getLabel($row));
->setTitle($this->getLabel($row))
->setTarget($this->getTarget($row));

if($this->getName() == Grid::ROW_FORM) {
$el->addClass("grid-editable");
Expand Down

0 comments on commit d4f1ca6

Please sign in to comment.