1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 04:20:55 +01:00

Add ability to have tooltips on buttons

Summary: Enables a basic tooltip when using icon buttons and a convenience method for setting an icon.

Test Plan: Built a UIExample.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D12172
This commit is contained in:
Chad Little 2015-03-26 11:09:20 -07:00
parent fe89d67663
commit 4bdc51237a
2 changed files with 28 additions and 0 deletions

View file

@ -55,6 +55,7 @@ final class PHUIButtonBarExample extends PhabricatorUIExample {
->setTag('a')
->setColor(PHUIButtonView::SIMPLE)
->setTitle($text)
->setTooltip($text)
->setIcon($image);
$button_bar3->addButton($button);

View file

@ -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,
);
}