YAHOO.util.Event.stopPropagation(e);
var target = YAHOO.util.Event.getTarget(e);
var parent = target.parentNode;
+ while (parent.nodeName.toUpperCase()!='LI') {
+ parent = parent.parentNode;
+ }
if (YAHOO.util.Dom.hasClass(parent, 'collapsed')) {
YAHOO.util.Dom.removeClass(parent, 'collapsed');
} else {
var navbar = document.createElement('div');
navbar.style.display = 'none';
navbar.setAttribute('id', 'sidebarpopup');
+ var navbarspacer = document.createElement('div');
+ navbarspacer.style.height = '10px';
+ navbar.appendChild(navbarspacer);
YAHOO.util.Dom.addClass(navbar, 'navigation_bar');
if (YAHOO.env.ua.ie > 0 && YAHOO.env.ua.ie < 7) {
YAHOO.util.Dom.setStyle(navbar, 'height', YAHOO.util.Dom.getViewportHeight()+'px');
this.tabpanels[tabname].show(e, this.tabpanel);
YAHOO.util.Dom.addClass(tabname+'_title', 'active_tab');
YAHOO.util.Event.removeListener(tabname+'_sidebarpopup', "mouseover", this.show_tab);
+ YAHOO.util.Event.addListener('navigation_tab_panel_'+tabname, "click", function (e){YAHOO.util.Event.stopPropagation(e);});
YAHOO.util.Event.addListener(tabname+'_sidebarpopup', "click", this.hide_tab, tabname, this);
YAHOO.util.Event.addListener(window, 'resize', this.resize_tab, this, true);
YAHOO.util.Event.addListener(document.body, "click", this.hide_tab, tabname, this);
}
}
+ /**
+ * Returns the child marked as active if there is one, false otherwise.
+ *
+ * @return navigation_node|bool The active node or false
+ */
+ public function get_active_node() {
+ foreach ($this->children as $child) {
+ if ($child->isactive) {
+ return $child;
+ }
+ }
+ return false;
+ }
+
/**
* Mark this node as active
*
$output = get_accesshide(get_string('youarehere','access'), 'h2')."<ul>\n";
$firstnode = true;
+ $customchildren = (count($this->children) > 0);
// Check if navigation contains the active node
if ($this->page->navigation->contains_active_node()) {
// Parse the navigation tree to get the active node
- $output .= $this->parse_branch_to_html($this->page->navigation->children);
+ $output .= $this->parse_branch_to_html($this->page->navigation->children, $firstnode, $customchildren);
$firstnode = false;
} else if ($this->page->settingsnav->contains_active_node()) {
// Parse the settings navigation to get the active node
- $output .= $this->parse_branch_to_html($this->page->settingsnav->children);
+ $output .= $this->parse_branch_to_html($this->page->settingsnav->children, $firstnode, $customchildren);
$firstnode = false;
}
// Check if there are any children added by code
- if (count($this->children)>0) {
+ if ($customchildren) {
// Add the custom children
- $output .= $this->parse_branch_to_html($this->children,$firstnode);
+ $output .= $this->parse_branch_to_html($this->children,$firstnode, false);
}
$output .= "</ul>\n";
$this->content = $output;
* @param bool $firstnode
* @return string HTML
*/
- protected function parse_branch_to_html($navarray, $firstnode=true) {
+ protected function parse_branch_to_html($navarray, $firstnode=true, $moreafterthis) {
$separator = get_separator();
$output = '';
if ($firstnode===true) {
// on the navbar. If we get to 20 items just stop!
$count++;
if ($count>20) {
+ // Maximum number of nodes in the navigation branch
return $output;
}
$child = false;
// We found an/the active node, set navarray to it's children so that
// we come back through this while with the children of the active node
$navarray = $child->children;
+ // If there are not more arrays being processed after this AND this is the last element
+ // then we want to set the action to null so that it is not used
+ if (!$moreafterthis && (!$child->contains_active_node() || ($child->find_active_node()==false || $child->find_active_node()->mainnavonly))) {
+ $oldaction = $child->action;
+ $child->action = null;
+ }
// Now display the node
$output .= '<li>'.$separator.' '.$child->content(true).'</li>';
+ if (isset($oldaction)) {
+ $child->action = $oldaction;
+ }
}
}
// XHTML