?? menu2.js
字號(hào):
if (this.disabled){ return; } var self = this; var closure = function(){ return function(){ self.openSubmenu(); } }(); this.hover_timer = window.setTimeout(closure, this.parent.submenuDelay); }, stopSubmenuTimer: function(){ if (this.hover_timer){ window.clearTimeout(this.hover_timer); this.hover_timer = null; } }, openSubmenu: function(){ // first close any other open submenu this.parent.closeSubmenu(); var submenu = dojo.widget.getWidgetById(this.submenuId); if (submenu){ this.parent.openSubmenu(submenu, this); } //dojo.debug('open submenu for item '+this.widgetId); }, closedSubmenu: function(){ this.onUnhover(); }, setDisabled: function(value){ this.disabled = value; if (this.disabled){ dojo.html.addClass(this.domNode, 'dojoMenuItem2Disabled'); }else{ dojo.html.removeClass(this.domNode, 'dojoMenuItem2Disabled'); } }, getLabelWidth: function(){ var node = this.labelNode.childNodes[0]; return dojo.style.getOuterWidth(node); }, getAccelWidth: function(){ var node = this.accelNode.childNodes[0]; return dojo.style.getOuterWidth(node); }, menuOpen: function(message) { }});dojo.widget.MenuSeparator2 = function(){ dojo.widget.HtmlWidget.call(this);}dojo.inherits(dojo.widget.MenuSeparator2, dojo.widget.HtmlWidget);dojo.lang.extend(dojo.widget.MenuSeparator2, { widgetType: "MenuSeparator2", domNode: null, topNode: null, bottomNode: null, templateString: '<div class="dojoMenuSeparator2">' +'<div dojoAttachPoint="topNode" class="dojoMenuSeparator2Top"></div>' +'<div dojoAttachPoint="bottomNode" class="dojoMenuSeparator2Bottom"></div>' +'</div>', postCreate: function(){ dojo.html.disableSelection(this.domNode); this.layoutItem(); }, layoutItem: function(label_w, accel_w){ var full_width = this.parent.itemHeight + this.parent.iconGap + label_w + this.parent.accelGap + accel_w + this.parent.submenuGap + this.parent.submenuIconSize + this.parent.finalGap; if (isNaN(full_width)){ return; } dojo.style.setContentHeight(this.domNode, this.parent.separatorHeight); dojo.style.setContentWidth(this.domNode, full_width); }});//// the menu manager makes sure we don't have several menus// open at once. the root menu in an opening sequence calls// opened(). when a root menu closes it calls closed(). then// everything works. lovely.//dojo.widget.html.Menu2Manager = new function(){ this.currentMenu = null; this.currentButton = null; // button that opened current menu (if any) this.focusNode = null; dojo.event.connect(document, 'onmousedown', this, 'onClick'); dojo.event.connect(window, "onscroll", this, "onClick"); this.closed = function(menu){ if (this.currentMenu == menu){ this.currentMenu = null; this.currentButton = null; } }; this.opened = function(menu, button){ if (menu == this.currentMenu){ return; } if (this.currentMenu){ this.currentMenu.close(); } this.currentMenu = menu; this.currentButton = button; }; this.onClick = function(e){ if (!this.currentMenu){ return; } var scrolloffset = dojo.html.getScrollOffset(); var x = e.clientX + scrolloffset[0]; var y = e.clientY + scrolloffset[1]; var m = this.currentMenu; // starting from the base menu, perform a hit test // and exit when one succeeds while (m){ if (m.isPointInMenu(x, y)){ return; } m = m.currentSubmenu; } // Also, if user clicked the button that opened this menu, then // that button will send the menu a close() command, so this code // shouldn't try to close the menu. Closing twice messes up animation. if (this.currentButton && dojo.html.overElement(this.currentButton, e)){ return; } // the click didn't fall within the open menu tree // so close it this.currentMenu.close(); };}// ************************** make contextmenu work in konqueror and opera *********************dojo.widget.Menu2.OperaAndKonqFixer = new function(){ var implement = true; var delfunc = false; /** dom event check * * make a event and dispatch it and se if it calls function below, * if it does its supported and we dont need to implement our own */ // gets called if we have support for oncontextmenu if (!dojo.lang.isFunction(document.oncontextmenu)){ document.oncontextmenu = function(){ implement = false; delfunc = true; } } if (document.createEvent){ // moz, safari has contextmenu event, need to do livecheck on this env. try { var e = document.createEvent("MouseEvents"); e.initMouseEvent("contextmenu", 1, 1, window, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); document.dispatchEvent(e); } catch (e) {/* assume not supported */} } else { // IE no need to implement custom contextmenu implement = false; } // clear this one if it wasn't there before if (delfunc){ delete document.oncontextmenu; } /***** end dom event check *****/ /** * this fixes a dom node by attaching a custom oncontextmenu function that gets called when apropriate * @param node a dom node * * no returns */ this.fixNode = function(node){ if (implement){ // attach stub oncontextmenu function if (!dojo.lang.isFunction(node.oncontextmenu)){ node.oncontextmenu = function(e){/*stub*/} } // attach control function for oncontextmenu if (window.opera){ // opera // listen to ctrl-click events node._menufixer_opera = function(e){ if (e.ctrlKey){ this.oncontextmenu(e); } }; dojo.event.connect(node, "onclick", node, "_menufixer_opera"); } else { // konqueror // rightclick, listen to mousedown events node._menufixer_konq = function(e){ if (e.button==2 ){ e.preventDefault(); // need to prevent browsers menu this.oncontextmenu(e); } }; dojo.event.connect(node, "onmousedown", node, "_menufixer_konq"); } } } /** * this cleans up a fixed node, prevent memoryleak? * @param node node to clean * * no returns */ this.cleanNode = function(node){ if (implement){ // checks needed if we gets a non fixed node if (node._menufixer_opera){ dojo.event.disconnect(node, "onclick", node, "_menufixer_opera"); delete node._menufixer_opera; } else if(node._menufixer_konq){ dojo.event.disconnect(node, "onmousedown", node, "_menufixer_konq"); delete node._menufixer_konq; } if (node.oncontextmenu){ delete node.oncontextmenu; } } }};dojo.widget.MenuBar2 = function(){ dojo.widget.HtmlWidget.call(this);}dojo.inherits(dojo.widget.MenuBar2, dojo.widget.HtmlWidget);dojo.lang.extend(dojo.widget.MenuBar2, { widgetType: "MenuBar2", isContainer: true, snarfChildDomOutput: true, currentItem: null, isExpanded: false, currentSubmenu: null, currentSubmenuTrigger: null, domNode: null, containerNode: null, templateString: '<div class="dojoMenuBar2"><div dojoAttachPoint="containerNode" class="dojoMenuBar2Client"></div></div>', templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlMenu2.css"), itemHeight: 18, openEvent: null, postCreate: function(){ // do something here this.layoutMenuSoon(); }, layoutMenuSoon: function(){ dojo.lang.setTimeout(this, "layoutMenu", 0); }, layoutMenu: function(){ // menu must be attached to DOM for size calculations to work var parent = this.domNode.parentNode; if (! parent || parent == undefined) { document.body.appendChild(this.domNode); } // determine menu height var max_label_h = 0; for(var i=0; i<this.children.length; i++){ if (this.children[i].getLabelHeight){ max_label_h = Math.max(max_label_h, this.children[i].getLabelHeight()); } } if (isNaN(max_label_h)){ // Browser needs some more time to calculate sizes this.layoutMenuSoon(); return; } var clientLeft = dojo.style.getPixelValue(this.domNode, "padding-left", true) + dojo.style.getPixelValue(this.containerNode, "margin-left", true) + dojo.style.getPixelValue(this.containerNode, "padding-left", true); var clientTop = dojo.style.getPixelValue(this.domNode, "padding-top", true) + dojo.style.getPixelValue(this.containerNode, "padding-top", true); if (isNaN(clientLeft) || isNaN(clientTop)){ // Browser needs some more time to calculate sizes this.layoutMenuSoon(); return; } var max_item_height = 0; var x = clientLeft; for (var i=0; i<this.children.length; i++){ var ch = this.children[i]; ch.layoutItem(max_label_h); ch.leftPosition = x; ch.domNode.style.left = x + 'px'; x += dojo.style.getOuterWidth(ch.domNode); max_item_height = Math.max(max_item_height, dojo.style.getOuterHeight(ch.domNode)); } dojo.style.setContentHeight(this.containerNode, max_item_height); dojo.style.setContentHeight(this.domNode, dojo.style.getOuterHeight(this.containerNode)); }, openSubmenu: function(submenu, from_item){ var our_pos = dojo.style.getAbsolutePosition(this.domNode, false); var our_h = dojo.style.getOuterHeight(this.domNode); var item_x = from_item.leftPosition; var x = our_pos.x + item_x; var y = our_pos.y + our_h; this.currentSubmenu = submenu; this.currentSubmenu.open(x, y, this, from_item.domNode); this.currentSubmenu.parentMenuBar = this; }, closeSubmenu: function(){ if (this.currentSubmenu == null){ return; } var menu = this.currentSubmenu; this.currentSubmenu = null; menu.close(); }, itemHover: function(item){ if (item == this.currentItem) return; if (this.currentItem){ this.currentItem.unhighlightItem(); if (this.isExpanded){ this.closeSubmenu(); } } this.currentItem = item; this.currentItem.highlightItem(); if (this.isExpanded){ this.currentItem.expandMenu(); } }, itemUnhover: function(item){ if (item != this.currentItem) return; if (this.currentItem && !this.isExpanded){ this.currentItem.unhighlightItem(); this.currentItem = null; } }, itemClick: function(item){ if (item != this.currentItem){ this.itemHover(item); } if (this.isExpanded){ this.isExpanded = false; this.closeSubmenu(); }else{ this.isExpanded = true; this.currentItem.expandMenu(); } }, closedMenu: function(menu){ if (this.currentSubmenu == menu){ this.isExpanded = false; this.itemUnhover(this.currentItem); } }});dojo.widget.MenuBarItem2 = function(){ dojo.widget.HtmlWidget.call(this);}dojo.inherits(dojo.widget.MenuBarItem2, dojo.widget.HtmlWidget);dojo.lang.extend(dojo.widget.MenuBarItem2, { widgetType: "MenuBarItem2", templateString: '<div class="dojoMenuBarItem2">' +'<span dojoAttachPoint="labelNode" class="dojoMenuBarItem2Label"><span><span></span></span></span>' +'<div dojoAttachPoint="targetNode" class="dojoMenuBarItem2Target" dojoAttachEvent="onMouseOver: onHover; onMouseOut: onUnhover; onClick: _onClick;"> </div>' +'</div>', // // nodes // domNode: null, labelNode: null, targetNode: null, // // internal settings // is_hovering: false, hover_timer: null, is_open: false, // // options // caption: 'Untitled', accelKey: '', iconSrc: '', submenuId: '', disabled: false, eventNaming: "default", postCreate: function(){ dojo.html.disableSelection(this.domNode); if (this.disabled){ this.setDisabled(true); } this.labelNode.childNodes[0].appendChild(document.createTextNode(this.caption)); this.labelShadowNode = this.labelNode.childNodes[0].childNodes[0]; this.labelShadowNode.appendChild(document.createTextNode(this.caption)); if (this.eventNaming == "default") { for (var eventName in this.eventNames) { this.eventNames[eventName] = this.widgetId+"/"+eventName; } } }, layoutItem: function(item_h){ var label_w = dojo.style.getOuterWidth(this.labelNode); var clientLeft = dojo.style.getPixelValue(this.domNode, "padding-left", true); var clientTop = dojo.style.getPixelValue(this.domNode, "padding-top", true); this.labelNode.style.left = clientLeft + 'px'; dojo.style.setOuterHeight(this.labelNode, item_h); dojo.style.setContentWidth(this.domNode, label_w); dojo.style.setContentHeight(this.domNode, item_h); this.labelNode.style.left = '0px'; dojo.style.setOuterWidth(this.targetNode, label_w); dojo.style.setOuterHeight(this.targetNode, item_h); }, getLabelHeight: function(){ return dojo.style.getOuterHeight(this.labelNode); }, onHover: function(){ this.parent.itemHover(this); }, onUnhover: function(){ this.parent.itemUnhover(this); }, _onClick: function(){ this.parent.itemClick(this); }, highlightItem: function(){ dojo.html.addClass(this.domNode, 'dojoMenuBarItem2Hover'); }, unhighlightItem: function(){ dojo.html.removeClass(this.domNode, 'dojoMenuBarItem2Hover'); }, expandMenu: function(){ var submenu = dojo.widget.getWidgetById(this.submenuId); if (submenu){ this.parent.openSubmenu(submenu, this); } }, setDisabled: function(value){ this.disabled = value; if (this.disabled){ dojo.html.addClass(this.domNode, 'dojoMenuBarItem2Disabled'); }else{ dojo.html.removeClass(this.domNode, 'dojoMenuBarItem2Disabled'); } }});// make it a tagdojo.widget.tags.addParseTreeHandler("dojo:MenuBar2");dojo.widget.tags.addParseTreeHandler("dojo:MenuBarItem2");dojo.widget.tags.addParseTreeHandler("dojo:PopupMenu2");dojo.widget.tags.addParseTreeHandler("dojo:MenuItem2");dojo.widget.tags.addParseTreeHandler("dojo:MenuSeparator2");
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -