1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-02 02:40:58 +01:00

For actions in list views, render name as tooltip if available

Summary: While the icons are sometimes pretty obvious ("X" for delete, "pencil" for edit), some are more obscure ("Disable", "Ignore"), especially if you haven't seen the interface before. If a name is available, render it as a tooltip.

Test Plan: {F49905}

Reviewers: chad, btrahan

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D6434
This commit is contained in:
epriestley 2013-07-12 11:28:18 -07:00
parent 147302dfa6
commit a9690a81c6
2 changed files with 39 additions and 14 deletions

View file

@ -427,7 +427,10 @@ final class PhabricatorObjectItemView extends AphrontTagView {
$actions = array(); $actions = array();
if ($this->actions) { if ($this->actions) {
Javelin::initBehavior('phabricator-tooltips');
foreach (array_reverse($this->actions) as $action) { foreach (array_reverse($this->actions) as $action) {
$action->setRenderNameAsTooltip(true);
$actions[] = $action; $actions[] = $action;
} }
$actions = phutil_tag( $actions = phutil_tag(

View file

@ -19,6 +19,17 @@ final class PHUIListItemView extends AphrontTagView {
private $selected; private $selected;
private $containerAttrs; private $containerAttrs;
private $disabled; private $disabled;
private $renderNameAsTooltip;
public function setRenderNameAsTooltip($render_name_as_tooltip) {
$this->renderNameAsTooltip = $render_name_as_tooltip;
return $this;
}
public function getRenderNameAsTooltip() {
return $this->renderNameAsTooltip;
}
public function setSelected($selected) { public function setSelected($selected) {
$this->selected = $selected; $this->selected = $selected;
@ -117,22 +128,31 @@ final class PHUIListItemView extends AphrontTagView {
protected function getTagContent() { protected function getTagContent() {
$name = null; $name = null;
$icon = null; $icon = null;
$meta = null;
$sigil = null;
if ($this->name) { if ($this->name) {
$external = null; if ($this->getRenderNameAsTooltip()) {
if ($this->isExternal) { $sigil = 'has-tooltip';
$external = " \xE2\x86\x97"; $meta = array(
} 'tip' => $this->name,
);
} else {
$external = null;
if ($this->isExternal) {
$external = " \xE2\x86\x97";
}
$name = phutil_tag( $name = phutil_tag(
'span', 'span',
array( array(
'class' => 'phui-list-item-name', 'class' => 'phui-list-item-name',
), ),
array( array(
$this->name, $this->name,
$external, $external,
)); ));
}
} }
if ($this->icon) { if ($this->icon) {
@ -147,11 +167,13 @@ final class PHUIListItemView extends AphrontTagView {
->setSpriteIcon($icon_name); ->setSpriteIcon($icon_name);
} }
return phutil_tag( return javelin_tag(
$this->href ? 'a' : 'div', $this->href ? 'a' : 'div',
array( array(
'href' => $this->href, 'href' => $this->href,
'class' => $this->href ? 'phui-list-item-href' : null, 'class' => $this->href ? 'phui-list-item-href' : null,
'meta' => $meta,
'sigil' => $sigil,
), ),
array( array(
$icon, $icon,