diff --git a/src/applications/uiexample/examples/PHUIIconExample.php b/src/applications/uiexample/examples/PHUIIconExample.php --- a/src/applications/uiexample/examples/PHUIIconExample.php +++ b/src/applications/uiexample/examples/PHUIIconExample.php @@ -159,7 +159,8 @@ ->setIcon($icon) ->setBackground('bg-blue') ->setHref('#') - ->addClass('mmr'); + ->addClass('mmr') + ->setTooltip($icon); } $layout_cicons = id(new PHUIBoxView()) diff --git a/src/view/phui/PHUIIconView.php b/src/view/phui/PHUIIconView.php --- a/src/view/phui/PHUIIconView.php +++ b/src/view/phui/PHUIIconView.php @@ -18,6 +18,7 @@ private $iconFont; private $iconColor; private $iconBackground; + private $tooltip; public function setHref($href) { $this->href = $href; @@ -60,6 +61,11 @@ return $this; } + public function setTooltip($text) { + $this->tooltip = $text; + return $this; + } + protected function getTagName() { $tag = 'span'; if ($this->href) { @@ -100,11 +106,24 @@ $this->appendChild($this->text); } + $sigil = null; + $meta = array(); + if ($this->tooltip) { + Javelin::initBehavior('phabricator-tooltips'); + require_celerity_resource('aphront-tooltip-css'); + $sigil = 'has-tooltip'; + $meta = array( + 'tip' => $this->tooltip, + ); + } + return array( 'href' => $this->href, 'style' => $style, 'aural' => false, 'class' => $classes, + 'sigil' => $sigil, + 'meta' => $meta, ); }