navigation MDL-14632 Minor tweaking as suggested on this issue.

* Fixed focus on search closing tab
 * Added spacing to refresh/moveto icons
 * Made all text in navigation tree's expandable
 * Final element on navbar no longer a link
This commit is contained in:
samhemelryk 2009-08-31 03:58:17 +00:00
parent 65bd8c4cda
commit 9da1ec271f
3 changed files with 45 additions and 9 deletions

View File

@ -146,6 +146,9 @@ navigation_tree.prototype.toggleexpansion = function(e) {
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 {
@ -441,6 +444,9 @@ navigation_tab_panel.prototype.create_tab_panel = function () {
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');
@ -625,6 +631,7 @@ navigation_tab_panel.prototype.show_tab = function (e, tabname) {
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);

View File

@ -586,6 +586,20 @@ class navigation_node {
}
}
/**
* 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
*
@ -1839,21 +1853,22 @@ class navbar extends navigation_node {
$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;
@ -1866,7 +1881,7 @@ class navbar extends navigation_node {
* @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) {
@ -1881,6 +1896,7 @@ class navbar extends navigation_node {
// 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;
@ -1900,8 +1916,17 @@ class navbar extends navigation_node {
// 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

View File

@ -1792,7 +1792,13 @@ a.skip:focus, a.skip:active {
padding:3px;
}
/* Navigation and settings block */
/**
* Navigation and settings block
**/
.customcommand img {
margin-left:2px;
margin-right:2px;
}
.sideblock .block_tree_box {
margin:2px;
}
@ -1888,7 +1894,7 @@ body.has_navigation_bar {
padding:0px;
}
.ie6 .navigation_bar li p {
background-color:inherit;
background-color:inherit;
}
.navigation_bar .sideblock_tab {
@ -1902,8 +1908,6 @@ body.has_navigation_bar {
cursor:pointer;
}
.navigation_bar .bd.oversized_content {
background-color:red;
margin:3px;
overflow-y:auto;
overflow-x:visible;
height:inherit;