Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUIListItemView.php
| Show All 30 Lines | final class PHUIListItemView extends AphrontTagView { | ||||
| private $icons = array(); | private $icons = array(); | ||||
| private $openInNewWindow = false; | private $openInNewWindow = false; | ||||
| private $tooltip; | private $tooltip; | ||||
| private $actionIcon; | private $actionIcon; | ||||
| private $actionIconHref; | private $actionIconHref; | ||||
| private $count; | private $count; | ||||
| private $rel; | private $rel; | ||||
| private $dropdownMenu; | private $dropdownMenu; | ||||
| private $keyCommand; | |||||
| public function setOpenInNewWindow($open_in_new_window) { | public function setOpenInNewWindow($open_in_new_window) { | ||||
| $this->openInNewWindow = $open_in_new_window; | $this->openInNewWindow = $open_in_new_window; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getOpenInNewWindow() { | public function getOpenInNewWindow() { | ||||
| return $this->openInNewWindow; | return $this->openInNewWindow; | ||||
| ▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | public function setTooltip($tooltip) { | ||||
| $this->tooltip = $tooltip; | $this->tooltip = $tooltip; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function getTagName() { | protected function getTagName() { | ||||
| return 'li'; | return 'li'; | ||||
| } | } | ||||
| public function setKeyCommand($key_command) { | |||||
| $this->keyCommand = $key_command; | |||||
| return $this; | |||||
| } | |||||
| public function getKeyCommand() { | |||||
| return $this->keyCommand; | |||||
| } | |||||
| protected function getTagAttributes() { | protected function getTagAttributes() { | ||||
| $classes = array(); | $classes = array(); | ||||
| $classes[] = 'phui-list-item-view'; | $classes[] = 'phui-list-item-view'; | ||||
| $classes[] = 'phui-list-item-'.$this->type; | $classes[] = 'phui-list-item-'.$this->type; | ||||
| if ($this->icon || $this->profileImage) { | if ($this->icon || $this->profileImage) { | ||||
| $classes[] = 'phui-list-item-has-icon'; | $classes[] = 'phui-list-item-has-icon'; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | final class PHUIListItemView extends AphrontTagView { | ||||
| public function getDisabled() { | public function getDisabled() { | ||||
| return $this->disabled; | return $this->disabled; | ||||
| } | } | ||||
| protected function getTagContent() { | protected function getTagContent() { | ||||
| $name = null; | $name = null; | ||||
| $icon = null; | $icon = null; | ||||
| $meta = null; | $meta = null; | ||||
| $sigil = null; | $sigil = array(); | ||||
| if ($this->name) { | if ($this->name) { | ||||
| if ($this->getRenderNameAsTooltip()) { | if ($this->getRenderNameAsTooltip()) { | ||||
| Javelin::initBehavior('phabricator-tooltips'); | Javelin::initBehavior('phabricator-tooltips'); | ||||
| $sigil = 'has-tooltip'; | $sigil[] = 'has-tooltip'; | ||||
| $meta = array( | $meta = array( | ||||
| 'tip' => $this->name, | 'tip' => $this->name, | ||||
| 'align' => 'E', | 'align' => 'E', | ||||
| ); | ); | ||||
| } else { | } else { | ||||
| if ($this->tooltip) { | if ($this->tooltip) { | ||||
| Javelin::initBehavior('phabricator-tooltips'); | Javelin::initBehavior('phabricator-tooltips'); | ||||
| $sigil = 'has-tooltip'; | $sigil[] = 'has-tooltip'; | ||||
| $meta = array( | $meta = array( | ||||
| 'tip' => $this->tooltip, | 'tip' => $this->tooltip, | ||||
| 'align' => 'E', | 'align' => 'E', | ||||
| 'size' => 300, | 'size' => 300, | ||||
| ); | ); | ||||
| } | } | ||||
| $external = null; | $external = null; | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | protected function getTagContent() { | ||||
| $caret = null; | $caret = null; | ||||
| if ($this->dropdownMenu && !$this->actionIcon) { | if ($this->dropdownMenu && !$this->actionIcon) { | ||||
| $caret = id(new PHUIIconView()) | $caret = id(new PHUIIconView()) | ||||
| ->setIcon('fa-caret-down'); | ->setIcon('fa-caret-down'); | ||||
| } | } | ||||
| $icons = $this->getIcons(); | $icons = $this->getIcons(); | ||||
| $key_command = null; | |||||
| if ($this->keyCommand) { | |||||
| $key_command = phutil_tag( | |||||
| 'span', | |||||
| array( | |||||
| 'class' => 'keyboard-shortcut-key', | |||||
| ), | |||||
| $this->keyCommand); | |||||
| $sigil[] = 'has-key-command'; | |||||
| $meta['keyCommand'] = $this->keyCommand; | |||||
| } | |||||
| $list_item = javelin_tag( | $list_item = javelin_tag( | ||||
| $this->href ? 'a' : 'div', | $this->href ? 'a' : 'div', | ||||
| array( | array( | ||||
| 'href' => $this->href, | 'href' => $this->href, | ||||
| 'class' => implode(' ', $classes), | 'class' => implode(' ', $classes), | ||||
| 'meta' => $meta, | 'meta' => $meta, | ||||
| 'sigil' => $sigil, | 'sigil' => implode(' ', $sigil), | ||||
| 'target' => $this->getOpenInNewWindow() ? '_blank' : null, | 'target' => $this->getOpenInNewWindow() ? '_blank' : null, | ||||
| 'rel' => $this->rel, | 'rel' => $this->rel, | ||||
| ), | ), | ||||
| array( | array( | ||||
| $aural, | $aural, | ||||
| $icon, | $icon, | ||||
| $icons, | $icons, | ||||
| $this->renderChildren(), | $this->renderChildren(), | ||||
| $name, | $name, | ||||
| $count, | $count, | ||||
| $key_command, | |||||
| $caret, | $caret, | ||||
| )); | )); | ||||
| return array($list_item, $action_link); | return array($list_item, $action_link); | ||||
| } | } | ||||
| private function newActionIconView() { | private function newActionIconView() { | ||||
| $action_icon = $this->actionIcon; | $action_icon = $this->actionIcon; | ||||
| Show All 31 Lines | |||||