Changeset View
Changeset View
Standalone View
Standalone View
src/view/layout/AphrontSideNavFilterView.php
| Show All 14 Lines | |||||
| * $valid_filter = $nav->selectFilter($user_selection, $default = 'meow'); | * $valid_filter = $nav->selectFilter($user_selection, $default = 'meow'); | ||||
| * | * | ||||
| */ | */ | ||||
| final class AphrontSideNavFilterView extends AphrontView { | final class AphrontSideNavFilterView extends AphrontView { | ||||
| private $items = array(); | private $items = array(); | ||||
| private $baseURI; | private $baseURI; | ||||
| private $selectedFilter = false; | private $selectedFilter = false; | ||||
| private $flexible; | |||||
| private $collapsed = false; | |||||
| private $active; | |||||
| private $menu; | private $menu; | ||||
| private $crumbs; | private $crumbs; | ||||
| private $classes = array(); | private $classes = array(); | ||||
| private $menuID; | private $menuID; | ||||
| private $mainID; | private $mainID; | ||||
| private $isProfileMenu; | private $isProfileMenu; | ||||
| private $footer = array(); | private $footer = array(); | ||||
| private $width; | |||||
| public function setMenuID($menu_id) { | public function setMenuID($menu_id) { | ||||
| $this->menuID = $menu_id; | $this->menuID = $menu_id; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getMenuID() { | public function getMenuID() { | ||||
| return $this->menuID; | return $this->menuID; | ||||
| Show All 21 Lines | public function setIsProfileMenu($is_profile) { | ||||
| $this->isProfileMenu = $is_profile; | $this->isProfileMenu = $is_profile; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getIsProfileMenu() { | public function getIsProfileMenu() { | ||||
| return $this->isProfileMenu; | return $this->isProfileMenu; | ||||
| } | } | ||||
| public function setActive($active) { | |||||
| $this->active = $active; | |||||
| return $this; | |||||
| } | |||||
| public function setFlexible($flexible) { | |||||
| $this->flexible = $flexible; | |||||
| return $this; | |||||
| } | |||||
| public function setCollapsed($collapsed) { | |||||
| $this->collapsed = $collapsed; | |||||
| return $this; | |||||
| } | |||||
| public function setWidth($width) { | |||||
| $this->width = $width; | |||||
| return $this; | |||||
| } | |||||
| public function getMenuView() { | public function getMenuView() { | ||||
| return $this->menu; | return $this->menu; | ||||
| } | } | ||||
| public function addMenuItem(PHUIListItemView $item) { | public function addMenuItem(PHUIListItemView $item) { | ||||
| $this->menu->addMenuItem($item); | $this->menu->addMenuItem($item); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | private function renderFlexNav() { | ||||
| $nav_id = null; | $nav_id = null; | ||||
| $drag_id = null; | $drag_id = null; | ||||
| $content_id = celerity_generate_unique_node_id(); | $content_id = celerity_generate_unique_node_id(); | ||||
| $local_id = null; | $local_id = null; | ||||
| $background_id = null; | $background_id = null; | ||||
| $local_menu = null; | $local_menu = null; | ||||
| $main_id = $this->getMainID(); | $main_id = $this->getMainID(); | ||||
| $width = $this->width; | |||||
| if ($width) { | |||||
| $width = min($width, 600); | |||||
| $width = max($width, 150); | |||||
| } else { | |||||
| $width = null; | |||||
| } | |||||
| if ($width && !$this->collapsed) { | |||||
| $width_drag_style = 'left: '.$width.'px'; | |||||
| $width_panel_style = 'width: '.$width.'px'; | |||||
| $width_margin_style = 'margin-left: '.($width + 7).'px'; | |||||
| } else { | |||||
| $width_drag_style = null; | |||||
| $width_panel_style = null; | |||||
| $width_margin_style = null; | |||||
| } | |||||
| if ($this->flexible) { | |||||
| $drag_id = celerity_generate_unique_node_id(); | |||||
| $flex_bar = phutil_tag( | |||||
| 'div', | |||||
| array( | |||||
| 'class' => 'phabricator-nav-drag', | |||||
| 'id' => $drag_id, | |||||
| 'style' => $width_drag_style, | |||||
| ), | |||||
| ''); | |||||
| } else { | |||||
| $flex_bar = null; | |||||
| } | |||||
| $nav_menu = null; | $nav_menu = null; | ||||
| if ($this->menu->getItems()) { | if ($this->menu->getItems()) { | ||||
| $local_id = celerity_generate_unique_node_id(); | $local_id = celerity_generate_unique_node_id(); | ||||
| $background_id = celerity_generate_unique_node_id(); | $background_id = celerity_generate_unique_node_id(); | ||||
| if (!$this->collapsed) { | |||||
| $nav_classes[] = 'has-local-nav'; | $nav_classes[] = 'has-local-nav'; | ||||
| } | |||||
| $local_menu = phutil_tag( | $local_menu = phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'phabricator-nav-local phabricator-side-menu', | 'class' => 'phabricator-nav-local phabricator-side-menu', | ||||
| 'id' => $local_id, | 'id' => $local_id, | ||||
| 'style' => $width_panel_style, | |||||
| ), | ), | ||||
| $this->menu->setID($this->getMenuID())); | $this->menu->setID($this->getMenuID())); | ||||
| } | } | ||||
| $crumbs = null; | $crumbs = null; | ||||
| if ($this->crumbs) { | if ($this->crumbs) { | ||||
| $crumbs = $this->crumbs->render(); | $crumbs = $this->crumbs->render(); | ||||
| $nav_classes[] = 'has-crumbs'; | $nav_classes[] = 'has-crumbs'; | ||||
| } | } | ||||
| if ($this->flexible) { | |||||
| if (!$this->collapsed) { | |||||
| $nav_classes[] = 'has-drag-nav'; | |||||
| } else { | |||||
| $nav_classes[] = 'has-closed-nav'; | |||||
| } | |||||
| Javelin::initBehavior( | |||||
| 'phabricator-nav', | |||||
| array( | |||||
| 'mainID' => $main_id, | |||||
| 'localID' => $local_id, | |||||
| 'dragID' => $drag_id, | |||||
| 'contentID' => $content_id, | |||||
| 'backgroundID' => $background_id, | |||||
| 'collapsed' => $this->collapsed, | |||||
| 'width' => $width, | |||||
| )); | |||||
| if ($this->active) { | |||||
| Javelin::initBehavior( | |||||
| 'phabricator-active-nav', | |||||
| array( | |||||
| 'localID' => $local_id, | |||||
| )); | |||||
| } | |||||
| } | |||||
| $nav_classes = array_merge($nav_classes, $this->classes); | $nav_classes = array_merge($nav_classes, $this->classes); | ||||
| $menu = phutil_tag( | $menu = phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => implode(' ', $nav_classes), | 'class' => implode(' ', $nav_classes), | ||||
| 'id' => $main_id, | 'id' => $main_id, | ||||
| ), | ), | ||||
| array( | array( | ||||
| $local_menu, | $local_menu, | ||||
| $flex_bar, | |||||
| phutil_tag( | phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'class' => 'phabricator-nav-content plb', | 'class' => 'phabricator-nav-content plb', | ||||
| 'id' => $content_id, | 'id' => $content_id, | ||||
| 'style' => $width_margin_style, | |||||
| ), | ), | ||||
| array( | array( | ||||
| $crumbs, | $crumbs, | ||||
| $this->renderChildren(), | $this->renderChildren(), | ||||
| $this->footer, | $this->footer, | ||||
| )), | )), | ||||
| )); | )); | ||||
| Show All 22 Lines | |||||