var Tree = Class.create({ expireTimeSec: 1800, startTimeSec: (new Date()).getUTCSeconds(), initialize: function(nodeId) { this.ID_=nodeId + '_div'; this.tree = $(this.ID_); this.hasFocus = false; this.tree.JSControl=this; this.parentNode=this.tree; this.callbacks = []; this.inlineControls = []; this.nodes = []; this.openers = []; this.levels = []; this.expandOnClick = []; this.oShortcuts={}; if(this.tree.hasAttribute("shortcut")) this.shortcut=this.tree.getAttribute("shortcut"); this.AddNode({ 'nodeId': nodeId, level: 0, hasChildren: false, expandOnClick: false }); this.selected = -1; // if (Prototype.Browser.IE || Prototype.Browser.WebKit) { this.tree.observe('keydown', this.OnKeyPress.bind(this)); // } // else { // this.tree.observe('keypress', this.OnKeyPress.bind(this)); // } var self = this; this.tree.observe('click', function() { if (!self.hasFocus) self.tree.focus(); }); this.tree.observe('focus', this.OnFocus.bind(this)); this.tree.observe('blur', this.OnBlur.bind(this)); this.OnResize(); GWindowManager.ObserveResize(this.ID()); var oWindow = AControl.GetParentWindow(this.tree); if (oWindow) oWindow.RegisterNewControl(this); }, Shortcut: function(key) { if(key==this.shortcut) { this.tree.focus(); return; } for(var n=0; n invisibleLevel) { continue; } invisibleLevel = undefined; if (this.openers[i] && !this.openers[i].open) { invisibleLevel = this.levels[i]; } var node = $(this.nodes[i]); var width = node.cumulativeOffset()["left"] - this.tree.cumulativeOffset()["left"] + node.offsetWidth; if (!maxwidth || maxwidth < width) maxwidth = width; } var div2 = $(this.nodes[0] + '_div2'); div2.setStyle({ width: (maxwidth ? maxwidth + 5 + 'px' : '') }); }, OnFocus: function(evt) { if (this.selected == -1) { this.ClearSelection(); this.selected = 0; this.ShowSelection(); } this.hasFocus = true; this.tree.addClassName('tree_wrapper_focus'); }, OnBlur: function(evt) { this.hasFocus = false; this.tree.removeClassName('tree_wrapper_focus'); }, SubscribeOnClick: function(nodeNo, callback) { if (!this.callbacks) this.callbacks = []; if (this.callbacks.length <= nodeNo) this.callbacks.length = nodeNo + 1; this.callbacks[nodeNo] = callback; }, AddNode: function(p) { this.nodes.push( p.nodeId ); this.levels.push( p.level ); var opener = ( p.hasChildren && this.OpenerClass ? new this.OpenerClass(p.nodeId, undefined, this) : null ); this.openers.push( opener ); this.expandOnClick.push( p.expandOnClick ); var nodeNo = this.nodes.length - 1; if (p.controls) { this.inlineControls.push( p.controls ); var wnd = AControl.GetParentWindow(this.tree); for (var i = 0; i < p.controls.length; ++i) { if (!p.controls[i]) continue; new AEvent ('REGISTERCHILDCONTROL', { controlId: wnd.ControlHTMLID( p.controls[i] ), subscribeOnClick: this.SubscribeOnClick.bind(this, nodeNo) }, this); } } if (!p.external) { $(p.nodeId).observe("mousedown", this.OnNodeClick.bind(this, nodeNo)); $(p.nodeId).observe("click", function(evt) { evt.stop(); return false; }); var image = $(p.nodeId + "_img"); if (image) image.observe("mousedown", this.OnNodeClick.bind(this, nodeNo)); } if(p.shortcut) { this.oShortcuts[p.shortcut]=p.nodeId; } }, OnNodeClick: function(nodeNo, evt) { var lbl = $(this.nodes[nodeNo] + "_label"); if (evt && (!evt.isLeftClick() || evt.target != $(this.nodes[nodeNo]) && evt.target != lbl)) return; if (evt && this.openers[nodeNo] && this.expandOnClick[nodeNo] && (!this.openers[nodeNo].open || this.hasFocus && nodeNo == this.selected && !this.callbacks[nodeNo])) { this.openers[nodeNo].OnClick(); } if (!this.hasFocus) this.tree.focus(); this.SelectNode( this.nodes[nodeNo] ); if (this.callbacks[nodeNo]) this.callbacks[nodeNo]() var id = this.nodes[nodeNo]; var src = $(id).readAttribute('src'); if (src && src.length > 1) { // This should prevent major memory leaks. var now = (new Date()).getUTCSeconds() if (now - this.startTimeSec < this.expireTimeSec) { new AEvent('WM_CLEAR', { 'src': src }, id); } else { window.location.hash = '#' + src; window.location.reload(false); } } //if (this.UpdateWidth) this.UpdateWidth(); if (evt) evt.stop(); return false; }, OnKeyPress: function(evt) { var key = evt.which || evt.keyCode; if (key == 27) { // Esc this.ClearSelection(); this.selected = -1; this.ShowSelection(); evt.stop(); return false; } else if (key == 38) { // Up this.SelectPrev(); evt.stop(); return false; } else if (key == 40) { // Down this.SelectNext(); evt.stop(); return false; } else if (key == 37) { // Left var opener = this.openers[this.selected]; if (opener && opener.open) opener.OnClick(); evt.stop(); return false; } else if (key == 39) { // Right var opener = this.openers[this.selected]; if (opener && !opener.open) opener.OnClick(); evt.stop(); return false; } else if (key == 32 || key == 13) { // space or enter if (this.selected < 0) { evt.stop(); return false; } var src = $(this.nodes[this.selected]).readAttribute('src'); if (this.expandOnClick[this.selected] && this.openers[this.selected] && (!this.openers[this.selected].open || !this.callbacks[this.selected] && !src)) { this.openers[this.selected].OnClick(); } this.OnNodeClick(this.selected); evt.stop(); return false; } }, ClearSelection: function() { if (this.selected != -1) { this.Select( $(this.nodes[this.selected]), false ); } }, ShowSelection: function() { if (this.selected != -1) { this.Select( $(this.nodes[this.selected]), true ); } //if (this.UpdateWidth) this.UpdateWidth(); }, SelectionVisible: function() { var prnt = this.selected; while (prnt != 0) { var level = this.levels[prnt]; while (this.levels[prnt] >= level) prnt--; if (this.openers[prnt] && !this.openers[prnt].open) return false; } return true; }, SelectNode: function(nd) { this.ClearSelection(); for (var i = 0; i < this.nodes.length; ++i) { if (this.nodes[i] == nd) { this.selected = i; break; } } this.ShowSelection(); }, SelectNext: function() { this.ClearSelection(); var level = this.levels[this.selected]; do { this.selected++; this.selected = this.selected % this.nodes.length; } while (!this.SelectionVisible()); this.ShowSelection(); }, SelectPrev: function() { this.ClearSelection(); var level = this.levels[this.selected]; do { this.selected--; this.selected = (this.selected + this.nodes.length) % this.nodes.length; } while (!this.SelectionVisible()); this.ShowSelection(); }, ID: function() { return this.ID_; } }); var BlueTreeOpener = Class.create({ initialize: function(nodeId, overlayClass, tree) { this.tree = tree; this.link = $(nodeId); this.opener = $(nodeId + '_node'); this.row = $(nodeId + '_tr'); this.childrenRow = $(nodeId + '_children'); this.childBlock = $(nodeId + '_div'); this.overlay = SlideMenuDrawer.AddOverlay(nodeId, overlayClass); this.opener.observe('mousedown', this.OnClick.bind(this)); this.open = false; this.childrenRow.hide(); this.UpdateBullet(); }, Animate: function() { if (this.open) { var left = 0; for (var i = 0; i < this.row.cells.length - 1; ++i) { if (!$(this.row.cells[i + 1]).hasClassName('tree_icon')) break; left += $(this.row.cells[i]).offsetWidth; } this.overlay.hide(); this.overlay.setStyle({ left: left + "px", height: '1px' }); this.childrenRow.show(); this.overlay.show(); var height = this.childBlock.offsetHeight; this.childBlock.setStyle({marginTop: -height + 1 + "px"}); var speed = 18 * ( 1. + 30. / height); if (!Prototype.Browser.IE) { var slide = new Animation(this.childBlock, speed,undefined, this.UpdateState.bind(this), Animation.prototype.decelerate); slide.addAnimation('marginTop', (-height + 1) + 'px', '0px'); slide.run(); } var overAnim = new Animation(this.overlay, speed, undefined, (Prototype.Browser.IE ? this.UpdateState.bind(this) : undefined), Animation.prototype.decelerate); overAnim.addAnimation('height', '1px', height - 1 + 'px'); overAnim.run(); if (this.tree && this.tree.UpdateWidth) this.tree.UpdateWidth(); } else { var speed = 70 * ( 1. + 30. / this.childBlock.scrollHeight); if (Prototype.Browser.IE) { this.childBlock.setStyle({ marginTop: (-this.childBlock.scrollHeight) + 'px' }); this.overlay.setStyle({ display: 'block', height: this.childBlock.scrollHeight + 'px' }); var slide = new Animation(this.overlay, speed, undefined, this.UpdateState.bind(this), Animation.prototype.accelerate); slide.addAnimation('height', (this.childBlock.scrollHeight) + 'px', '0px'); slide.run(); } else { this.overlay.setStyle({display: 'block', height: '20px'}); var slide = new Animation(this.childBlock, speed, undefined, this.UpdateState.bind(this), Animation.prototype.accelerate); slide.addAnimation('marginTop', "0px", (-this.childBlock.scrollHeight) + 'px'); slide.run(); } this.UpdateBullet(); } }, HideOverlay: function() { this.childBlock.setStyle({marginTop: "0px"}); this.overlay.setStyle({ display: 'none', opacity: '' }); this.UpdateBullet(); }, UpdateBullet: function() { if (this.opener.hasClassName('tree_node_open_noroot') && !this.open) { this.opener.removeClassName('tree_node_open_noroot'); this.opener.addClassName('tree_node_closed_noroot'); } else if (!this.open) { this.opener.removeClassName('tree_node_open'); this.opener.addClassName('tree_node_closed'); } else if (this.opener.hasClassName('tree_node_closed_noroot')) { this.opener.addClassName('tree_node_open_noroot'); this.opener.removeClassName('tree_node_closed_noroot'); } else { this.opener.addClassName('tree_node_open'); this.opener.removeClassName('tree_node_closed'); } }, UpdateState: function() { if (!this.open) { this.childBlock.setStyle({marginTop: -this.childBlock.scrollHeight + "px"}); this.childrenRow.hide(); this.HideOverlay(); if (this.tree && this.tree.UpdateWidth) this.tree.UpdateWidth(); } else { var overAnim = new Animation(this.overlay, 80, undefined, this.HideOverlay.bind(this), Animation.prototype.accelerate); overAnim.addAnimation('opacity', '1', '0'); overAnim.run(); } }, OnClick: function(evt) { this.open = !this.open; this.Animate(); if (evt && evt.stop) evt.stop(); return false; } }); var BlueTree = Class.create(Tree, { initialize: function($super, nodeId) { this.OpenerClass = BlueTreeOpener; $super(nodeId); }, Select: function(n, selected) { if (selected) $(n).addClassName('Green_treeline_sel'); else $(n).removeClassName('Green_treeline_sel'); } }); var SlideMenuDrawer = Class.create({ initialize: function(nodeId, hasChildren, menu) { if (menu.drawers === undefined) menu.drawers = []; var n = menu.drawers.length; if (menu.currentDrawer === undefined && hasChildren) menu.currentDrawer = n; if (n != menu.currentDrawer) $(nodeId + "_contents").hide(); else $(nodeId + '_td').addClassName('slide_menu_item_selected'); this.pins = []; this.nodeId = nodeId; this.hasChildren = hasChildren; this.menu = menu; this.n = n; this.pinned = false; SlideMenuDrawer.AddOverlay(nodeId); $(nodeId + '_td').observe('click', this.OnClick.bind(this)); $(nodeId + '_contents').observe('click', this.OnClick.bind(this)); if (hasChildren) { this.pin = this.menu.AddPinTo(nodeId + '_td'); this.pin.observe('click', this.OnPinClick.bind(this)); } menu.drawers.push(this); }, OnClick: function(evt) { this.menu.SelectNode(this.nodeId); this.menu.menu.focus(); if (evt) evt.stop(); if (this.hasChildren && this.menu.currentDrawer != this.n) { var oldDrawer = this.menu.drawers[this.menu.currentDrawer]; if (!oldDrawer.pinned) SlideMenuDrawer.Hide(oldDrawer.nodeId, null, oldDrawer.pins); $(oldDrawer.nodeId + '_td').removeClassName('slide_menu_item_selected'); this.menu.currentDrawer = this.n; if (!this.pinned) SlideMenuDrawer.Show(this.nodeId, null, this.pins); $(this.nodeId + '_td').addClassName('slide_menu_item_selected'); } if ($(this.nodeId).onclick) $(this.nodeId).onclick(); }, OnPinClick: function(evt) { if (this.pinned) { if (this.menu.currentDrawer != this.n) { SlideMenuDrawer.Hide(this.nodeId, null, this.pins); } this.pin.addClassName('slide_menu_pin_up'); this.pin.removeClassName('slide_menu_pin_down'); this.pinned = false; } else { if (this.menu.currentDrawer != this.n) { SlideMenuDrawer.Show(this.nodeId, null, this.pins); } this.pinned = true; this.pin.addClassName('slide_menu_pin_down'); this.pin.removeClassName('slide_menu_pin_up'); } evt.stop(); return false; } }) SlideMenuDrawer.AddOverlay = function(nodeId, className, overName) { var overlay = $(document.createElement("div")); overlay.writeAttribute({id: nodeId + "_overlay" + (overName || '')}); overlay.innerHTML = " "; overlay.setStyle({ height: '20px', overflow: 'hidden', position: 'relative' }); var cl = (className || 'tree_blend_overlay'); overlay.innerHTML = "" + "" + "" + "" + "" + "" + "" + "
"; overlay.hide(); $(nodeId + "_contents").insert({ top: overlay.wrap('div').setStyle({ height: '0px', overflow: 'visible' }) }); return overlay; } SlideMenuDrawer.Show = function(nodeId, overname, pins) { for (var i = 0; pins && i < pins.length; ++i) { pins[i].hide(); } var obj = $(nodeId + "_contents"); var overlay = $(nodeId + "_overlay" + (overname || '')); var hider = $(nodeId + "_hider"); obj.show(); hider.setStyle({marginTop: (-hider.scrollHeight + 1) }); overlay.setStyle({ opacity: '1', height: '1px' }) overlay.show(); if (!Prototype.Browser.IE) { var speed = 30 * ( 1. + 20. / hider.scrollHeight); var slide = new Animation(hider, speed, undefined, SlideMenuDrawer.OverlayFade.bind(this, overlay, nodeId, pins), Animation.prototype.decelerate); slide.addAnimation('marginTop', (-hider.scrollHeight + 1) + 'px', '1px'); slide.run(); } var overlayGrow = new Animation(overlay, speed,undefined, Prototype.Browser.IE ? SlideMenuDrawer.OverlayFade.bind(this, overlay, nodeId, pins) : undefined, Animation.prototype.decelerate); overlayGrow.addAnimation('height', '1px', (hider.scrollHeight - 1) + 'px'); overlayGrow.run(); } SlideMenuDrawer.OverlayFade = function(overobj, node, pins) { for (var i = 0; pins && i < pins.length; ++i) { pins[i].show(); } var overAnim = new Animation(overobj, 100, undefined, function() { overobj.hide(); $(node + '_hider').setStyle({ marginTop: '0px' }); }, Animation.prototype.accelerate ); overAnim.addAnimation('opacity', '1', '0'); overAnim.run(); } SlideMenuDrawer.Hide = function(nodeId, overname, pins) { for (var i = 0; pins && i < pins.length; ++i) { pins[i].hide(); } var obj = $(nodeId + "_contents"); var hider = $(nodeId + "_hider"); var overlay = $(nodeId + "_overlay" + (overname || '')); var speed = 150 * ( 1. + 30. / hider.scrollHeight); if (!Prototype.Browser.IE) { var slide = new Animation(hider, speed, undefined, function() { obj.hide(); }, Animation.prototype.accelerate); slide.addAnimation('marginTop', "1px", (-hider.scrollHeight) + 'px'); overlay.setStyle({ opacity: '1', height: '32px' }) overlay.show(); var overlayShrink = new Animation(overlay, speed, undefined, function() { overlay.hide(); }, Animation.prototype.accelerate); overlayShrink.addAnimation('opacity', '1', '0'); overlayShrink.run(); slide.run(); } else { overlay.setStyle({ opacity: '1', height: (hider.offsetHeight - 1) + 'px' }); hider.setStyle({ marginTop: (-hider.offsetHeight) + 'px' }); overlay.show(); var slide = new Animation(overlay, speed, undefined, function() { obj.hide(); overlay.hide(); }, Animation.prototype.accelerate); slide.addAnimation('height', (hider.offsetHeight) + 'px', '1px'); slide.run(); } } var SlideMenuDrawerItem = Class.create({ initialize: function(nodeId, hasChildren, drawer) { if (drawer.items === undefined) drawer.items = []; if (drawer.curItem === undefined) drawer.curItem = -1; $(nodeId + '_contents').hide(); this.nodeId = nodeId; this.drawer = drawer; $(nodeId + '_td').observe('click', this.OnClick.bind(this)); this.hasChildren = hasChildren; if (!hasChildren) return; this.nodeIds = []; this.nodeLevels = []; this.openers = []; this.expandOnClick = [] this.n = drawer.items.length; this.pinned = false; SlideMenuDrawer.AddOverlay(nodeId, 'slide_sel_blend_overlay', 'sel'); SlideMenuDrawer.AddOverlay(nodeId, 'slide_blend_overlay', 'unsel'); this.pin = this.drawer.menu.AddPinTo(nodeId + '_td'); this.pin.observe('click', this.OnPinClick.bind(this)); this.drawer.pins.push(this.pin); this.drawer.items.push(this); }, AddNode: function(nodeId, level, hasChildren, expandOnClick) { this.nodeIds.push(nodeId); this.nodeLevels.push(level); this.openers.push(hasChildren ? new TreeNodeOpener(nodeId, 'slide_sel_blend_overlay', this.drawer.menu) : null); this.expandOnClick.push(expandOnClick); var nodeNo = this.nodeIds.length - 1; $(nodeId).observe("mousedown", this.OnNodeClick.bind(this, nodeNo)); $(nodeId).observe("click", function(evt) { evt.stop(); return false; }); var image = $(nodeId + "_img"); if (image) image.observe("mousedown", this.OnNodeClick.bind(this, nodeNo)); $(nodeId).observe("click", function(evt) { evt.stop(); return false; }); }, OnNodeClick: function(nodeNo, evt) { if (this.openers[nodeNo] && this.expandOnClick[nodeNo] && (!this.openers[nodeNo].open || this.hasFocus && nodeNo == this.selected)) { this.openers[nodeNo].OnClick(); } this.drawer.menu.SelectNode( this.nodeIds[nodeNo] ); this.drawer.menu.menu.focus(); evt.stop(); return false; }, IsVisible: function(n) { var drawerVisible = $(this.drawer.nodeId + '_contents').visible(); if (n == this.nodeId) return drawerVisible; LogL(this.nodeId); if (!drawerVisible || !$(this.nodeId + '_contents').visible()) return false; var i; for (i = 0; i < this.nodeIds.length; ++i) { if (this.nodeIds[i] == n) break; } if (i == this.nodeIds.length) return false; var level = this.nodeLevels[i]; for (i = i - 1; i >= 0; --i) { if (level <= this.nodeLevels[i]) continue; if (!$(this.nodeIds[i] + '_contents').visible()) return false; level = this.nodeLevels[i]; } return true; }, OnPinClick: function(evt) { if (this.pinned) { this.Deselect(); this.pinned = false; this.pin.addClassName('slide_menu_pin_up'); this.pin.removeClassName('slide_menu_pin_down'); } else { if (this.drawer.curItem == this.n) this.drawer.curItem = -1; else this.Select(); this.pinned = true; this.pin.addClassName('slide_menu_pin_down'); this.pin.removeClassName('slide_menu_pin_up'); } if (evt) evt.stop(); return false; }, OnClick: function(evt, noLink) { this.drawer.menu.SelectNode(this.nodeId); this.drawer.menu.menu.focus(); if (evt) evt.stop(); if (!this.hasChildren) return false; if (!noLink && $(this.nodeId).onclick) $(this.nodeId).onclick(); if (this.drawer.curItem == this.n && !this.pinned) { this.Deselect(); this.drawer.curItem = -1; } else { if (!this.pinned) this.Select(); if (this.drawer.curItem >= 0) { this.drawer.items[this.drawer.curItem].Deselect(); } this.drawer.curItem = (this.pinned ? -1 : this.n); } return false; }, Select: function() { if (this.drawer.curItem == this.n) return; $(this.nodeId + '_td').addClassName('slide_menu_subitem_selected'); $(this.nodeId + '_contents').addClassName('slide_menu_subitem_contents_selected'); SlideMenuDrawer.Show(this.nodeId, 'sel'); }, Deselect: function() { $(this.nodeId + '_td').removeClassName('slide_menu_subitem_selected'); $(this.nodeId + '_contents').removeClassName('slide_menu_subitem_contents_selected'); SlideMenuDrawer.Hide(this.nodeId, 'unsel'); } }); var SlideNode = Class.create({ initialize: function(obj, level, nodeId) { this.obj = obj; this.level = level; this.nodeId = nodeId; }, IsVisible: function() { if (this.level == 1) return true; return this.obj.IsVisible(this.nodeId); }, Deselect: function() { $(this.nodeId).removeClassName('slide_it_selected'); }, Select: function() { $(this.nodeId).addClassName('slide_it_selected'); }, GetOpener: function() { if (!this.obj) return; for (var i = 0; i < this.obj.nodeIds.length; ++i) { if (this.obj.nodeIds[i] == this.nodeId) break; } if (i == this.obj.nodeIds.length) return; return this.obj.openers[i]; } , Expand: function() { if (this.level == 1 && !$(this.nodeId + '_contents').visible()) { this.Click(); } else if (this.level == 2 && !$(this.nodeId + '_contents').visible()) { this.obj.OnClick(null, true); } else { var o = this.GetOpener(); if (o && !o.open) o.OnClick(); } }, Collapse: function() { if (this.level == 1) return; else if (this.level == 2 && $(this.nodeId + '_contents').visible()) { if (this.obj.pinned) { this.obj.OnPinClick(); } else this.obj.OnClick(null, true); } else { var o = this.GetOpener(); if (o && o.open) o.OnClick(); } }, Click: function() { if (this.level == 1) { return this.obj.OnClick(); } var o = $(this.nodeId); if (o && o.onclick) o.onclick(); } }); var SlideMenu = Class.create({ initialize: function(nodeId) { this.menu = $(nodeId); this.selectedItem = -1; this.menu.observe('focus', this.OnFocus.bind(this)); this.menu.observe('blur', this.OnBlur.bind(this)); this.nodeList = []; BindKeyDown(this.menu, this.OnKeyPress.bind(this)); }, OnKeyPress: function(evt) { var key = evt.which || evt.keyCode; if (key == 27) { if (this.selectedItem != -1) this.nodeList[this.selectedItem].Deselect(); this.selectedItem = -1; evt.stop(); return false; } else if (key == 38) { this.SelectPrev(); evt.stop(); return false; } else if (key == 40) { this.SelectNext(); evt.stop(); return false; } else if (key == 39) { if (this.selectedItem != -1) this.nodeList[this.selectedItem].Expand(); evt.stop(); return false; } else if (key == 37) { if (this.selectedItem != -1) this.nodeList[this.selectedItem].Collapse(); evt.stop(); return false; } else if (key == 32 || key == 13) { if (this.selectedItem != -1) this.nodeList[this.selectedItem].Click(); evt.stop(); return false; } }, SelectNode: function(nodeId) { LogL("selecting: " + nodeId + " ( " + this.selectedItem +" ) "); if (this.selectedItem != -1 && this.nodeList[this.selectedItem] == nodeId) { return; } else if (this.selectedItem != -1) this.nodeList[this.selectedItem].Deselect(); for (var s = 0; s < this.nodeList.length; ++s) { if (this.nodeList[s].nodeId == nodeId) { this.nodeList[s].Select(); this.selectedItem = s; LogL("selected: " + s); return; } } }, SelectNext: function() { if (this.selectedItem != -1) this.nodeList[this.selectedItem].Deselect(); var s = this.selectedItem; for (++s; s < this.nodeList.length; ++s) { if (this.nodeList[s].IsVisible()) break; } for (s = s % this.nodeList.length; s < this.nodeList.length; ++s) { if (this.nodeList[s].IsVisible()) break; } if (s == this.nodeList.length) s = -1; else this.nodeList[s].Select(); this.selectedItem = s; }, SelectPrev: function() { if (this.selectedItem != -1) this.nodeList[this.selectedItem].Deselect(); var s = (this.selectedItem - 1 + this.nodeList.length) % this.nodeList.length; for (; s >= 0; --s) { if (this.nodeList[s].IsVisible()) break; } if (s == -1) s = this.nodeList.length; for (; s >= 0; --s) { if (this.nodeList[s].IsVisible()) break; } if (s != -1) this.nodeList[s].Select(); this.selectedItem = s; }, OnFocus: function(evt) { this.menu.addClassName('slide_menu_focus'); }, OnBlur: function(evt) { this.menu.removeClassName('slide_menu_focus'); }, AddNode: function(nodeId, level, hasChildren, expandOnClick) { var obj; if (level == 1) { obj = this.lastDrawer = new SlideMenuDrawer(nodeId, hasChildren, this); } else if (level == 2) { obj = this.lastItem = new SlideMenuDrawerItem(nodeId, hasChildren, this.lastDrawer); } else { obj = this.lastItem; this.lastItem.AddNode(nodeId, level, hasChildren, expandOnClick); } this.nodeList.push( new SlideNode(obj, level, nodeId) ); }, AddPinTo: function(nodeId) { var pin = $(document.createElement('div')); pin.innerHTML = " "; pin.addClassName('slide_menu_pin_up'); pin.setStyle({position: 'absolute'}); var pinWrapper = pin.wrap('div').setStyle({ position: 'relative', top: 0, bottom: 0, height: 0, width: 0, overflow: 'visible' }); $(nodeId).insert({ top: pinWrapper }); // The first pin is always visible and belongs to the first level if (!this.pinPos) this.pinPos = $(nodeId).clientWidth - pin.offsetWidth; pin.setStyle({ left: this.pinPos + "px", top: 0 }) return pin; } })