mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Add a tooltip method to PHUIIconView
Summary: We seem to use these a lot. Makes the code cleaner. Test Plan: UIExamples. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D18114
This commit is contained in:
parent
6cb326e58e
commit
2a3022913f
2 changed files with 21 additions and 1 deletions
|
@ -159,7 +159,8 @@ final class PHUIIconExample extends PhabricatorUIExample {
|
|||
->setIcon($icon)
|
||||
->setBackground('bg-blue')
|
||||
->setHref('#')
|
||||
->addClass('mmr');
|
||||
->addClass('mmr')
|
||||
->setTooltip($icon);
|
||||
}
|
||||
|
||||
$layout_cicons = id(new PHUIBoxView())
|
||||
|
|
|
@ -18,6 +18,7 @@ final class PHUIIconView extends AphrontTagView {
|
|||
private $iconFont;
|
||||
private $iconColor;
|
||||
private $iconBackground;
|
||||
private $tooltip;
|
||||
|
||||
public function setHref($href) {
|
||||
$this->href = $href;
|
||||
|
@ -60,6 +61,11 @@ final class PHUIIconView extends AphrontTagView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function setTooltip($text) {
|
||||
$this->tooltip = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getTagName() {
|
||||
$tag = 'span';
|
||||
if ($this->href) {
|
||||
|
@ -100,11 +106,24 @@ final class PHUIIconView extends AphrontTagView {
|
|||
$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,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue