diff --git a/src/applications/uiexample/examples/PHUIButtonBarExample.php b/src/applications/uiexample/examples/PHUIButtonBarExample.php index 0e983088c1..293cd2336a 100644 --- a/src/applications/uiexample/examples/PHUIButtonBarExample.php +++ b/src/applications/uiexample/examples/PHUIButtonBarExample.php @@ -55,6 +55,7 @@ final class PHUIButtonBarExample extends PhabricatorUIExample { ->setTag('a') ->setColor(PHUIButtonView::SIMPLE) ->setTitle($text) + ->setTooltip($text) ->setIcon($image); $button_bar3->addButton($button); diff --git a/src/view/phui/PHUIButtonView.php b/src/view/phui/PHUIButtonView.php index 3e0854a670..7be6fe080b 100644 --- a/src/view/phui/PHUIButtonView.php +++ b/src/view/phui/PHUIButtonView.php @@ -22,10 +22,12 @@ final class PHUIButtonView extends AphrontTagView { private $tag = 'button'; private $dropdown; private $icon; + private $iconFont; private $href = null; private $title = null; private $disabled; private $name; + private $tooltip; public function setName($name) { $this->name = $name; @@ -81,11 +83,23 @@ final class PHUIButtonView extends AphrontTagView { return $this; } + public function setTooltip($text) { + $this->tooltip = $text; + return $this; + } + public function setIcon(PHUIIconView $icon) { $this->icon = $icon; return $this; } + public function setIconFont($icon) { + $icon = id(new PHUIIconView()) + ->setIconFont($icon); + $this->setIcon($icon); + return $this; + } + protected function getTagName() { return $this->tag; } @@ -117,11 +131,24 @@ final class PHUIButtonView extends AphrontTagView { $classes[] = 'disabled'; } + $sigil = null; + $meta = null; + if ($this->tooltip) { + Javelin::initBehavior('phabricator-tooltips'); + require_celerity_resource('aphront-tooltip-css'); + $sigil = 'has-tooltip'; + $meta = array( + 'tip' => $this->tooltip, + ); + } + return array( 'class' => $classes, 'href' => $this->href, 'name' => $this->name, 'title' => $this->title, + 'sigil' => $sigil, + 'meta' => $meta, ); }