⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zpmenu.js

📁 zapatec suite 最新版 20070204,非常棒的ajax widgets 工具包
💻 JS
📖 第 1 页 / 共 3 页
字号:
var subMenu=this._getTree(item.__zp_subtree);if(!subMenu){return;}var parMenu=this._getTree(item.__zp_parent);if(!subMenu.offsetHeight){subMenu.style.visibility='visible';}if(subMenu.style.zIndex===''){subMenu.style.zIndex='inherit';}var subMenuBorderLeft,subMenuBorderTop;if(typeof subMenu.clientLeft!='undefined'){subMenuBorderLeft=subMenu.clientLeft;subMenuBorderTop=subMenu.clientTop;}else{subMenuBorderLeft=(subMenu.offsetWidth-subMenu.clientWidth)/2;subMenuBorderTop=(subMenu.offsetHeight-subMenu.clientHeight)/2;}var fc=subMenu.firstChild;var subMenuMarginLeft=fc.offsetLeft;var subMenuMarginTop=fc.offsetTop;var scrollX=window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft||0;var scrollY=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop||0;var objWindowSize=Zapatec.Utils.getWindowSize();var winW=objWindowSize.width;var winH=objWindowSize.height;if(!subMenu.style.width||!subMenu.style.height){var maxHeight=winH-7;if(subMenu.offsetHeight>maxHeight){var iSubMenuOffsetHeight=subMenu.offsetHeight;fc.__zp_first=fc.firstChild;fc.__zp_last=fc.lastChild;var objUp=Zapatec.Utils.createElement("div");objUp.__zp_tree=fc.firstChild.__zp_tree;objUp.className='zpMenuScrollUpInactive';objUp.__zp_mouseover=false;objUp.__zp_timer=null;var funcMoveUp=function(){var objContainer=objUp.parentNode;var iContainerHeight=objContainer.parentNode.clientHeight;var objUpArrow=objContainer.firstChild;var objDownArrow=objContainer.lastChild;if(objContainer.__zp_first.previousSibling!=objUpArrow){if(objContainer.__zp_first.style.height){objContainer.__zp_first.style.height='';objContainer.__zp_first.style.overflow='';}else{objContainer.__zp_first=objContainer.__zp_first.previousSibling;objContainer.__zp_first.style.display='block';}var iNewHeight=objContainer.offsetHeight;while(iNewHeight>iContainerHeight){objContainer.__zp_last.style.display='none';if(objContainer.__zp_last.style.height){objContainer.__zp_last.style.height='';objContainer.__zp_last.style.overflow='';}objContainer.__zp_last=objContainer.__zp_last.previousSibling;iNewHeight=objContainer.offsetHeight;}var iSpace=iContainerHeight-iNewHeight;if(iSpace>0){objContainer.__zp_last=objContainer.__zp_last.nextSibling;objContainer.__zp_last.style.display='block';var iItemHeight=iSpace-(objContainer.__zp_last.offsetHeight-objContainer.__zp_last.clientHeight);if(iItemHeight>=0){objContainer.__zp_last.style.display='none';objContainer.__zp_last.style.height=iItemHeight+'px';objContainer.__zp_last.style.overflow='hidden';objContainer.__zp_last.style.display='block';iNewHeight=objContainer.offsetHeight;if(iNewHeight!=iContainerHeight){iItemHeight-=iNewHeight-iContainerHeight;if(iItemHeight>0){objContainer.__zp_last.style.height=iItemHeight+'px';}else{objContainer.__zp_last.style.display='none';objContainer.__zp_last.style.height='';objContainer.__zp_last.style.overflow='';objContainer.__zp_last=objContainer.__zp_last.previousSibling;}}}else{objContainer.__zp_last.style.display='none';objContainer.__zp_last=objContainer.__zp_last.previousSibling;}}objDownArrow.className='zpMenuScrollDownActive';if(objContainer.__zp_first.previousSibling==objUpArrow){objUpArrow.className='zpMenuScrollUpInactive';}if(objUp.__zp_timer)clearTimeout(objUp.__zp_timer);if(objUp.__zp_mouseover){objUp.__zp_timer=setTimeout(funcMoveUp,50);}}return true;};objUp.onmouseover=function(){objUp.__zp_mouseover=true;return funcMoveUp();}objUp.onmouseout=function(){objUp.__zp_mouseover=false;if(objUp.__zp_timer){clearTimeout(objUp.__zp_timer);objUp.__zp_timer=null;}};fc.insertBefore(objUp,fc.firstChild);var objDown=Zapatec.Utils.createElement("div");objDown.__zp_tree=fc.firstChild.__zp_tree;objDown.className='zpMenuScrollDownActive';objDown.__zp_mouseover=false;objDown.__zp_timer=null;var funcMoveDown=function(){var objContainer=objDown.parentNode;var iContainerHeight=objContainer.parentNode.clientHeight;var objUpArrow=objContainer.firstChild;var objDownArrow=objContainer.lastChild;if(objContainer.__zp_last.nextSibling!=objDownArrow){if(objContainer.__zp_last.style.height){objContainer.__zp_last.style.height='';objContainer.__zp_last.style.overflow='';}else{objContainer.__zp_last=objContainer.__zp_last.nextSibling;objContainer.__zp_last.style.display='block';}var iNewHeight=objContainer.offsetHeight;while(iNewHeight>iContainerHeight){objContainer.__zp_first.style.display='none';if(objContainer.__zp_first.style.height){objContainer.__zp_first.style.height='';objContainer.__zp_first.style.overflow='';}objContainer.__zp_first=objContainer.__zp_first.nextSibling;iNewHeight=objContainer.offsetHeight;}var iSpace=iContainerHeight-iNewHeight;if(iSpace>0){objContainer.__zp_first=objContainer.__zp_first.previousSibling;objContainer.__zp_first.style.display='block';var iItemHeight=iSpace-(objContainer.__zp_first.offsetHeight-objContainer.__zp_first.clientHeight);if(iItemHeight>0){objContainer.__zp_first.style.display='none';objContainer.__zp_first.style.height=iItemHeight+'px';objContainer.__zp_first.style.overflow='hidden';objContainer.__zp_first.style.display='block';iNewHeight=objContainer.offsetHeight;if(iNewHeight!=iContainerHeight){iItemHeight-=iNewHeight-iContainerHeight;if(iItemHeight>0){objContainer.__zp_first.style.height=iItemHeight+'px';}else{objContainer.__zp_first.style.display='none';objContainer.__zp_first.style.height='';objContainer.__zp_first.style.overflow='';objContainer.__zp_first=objContainer.__zp_first.nextSibling;}}}else{objContainer.__zp_first.style.display='none';objContainer.__zp_first=objContainer.__zp_first.nextSibling;}}objUpArrow.className='zpMenuScrollUpActive';if(objContainer.__zp_last.nextSibling==objDownArrow){objDownArrow.className='zpMenuScrollDownInactive';}if(objDown.__zp_timer)clearTimeout(objDown.__zp_timer);if(objDown.__zp_mouseover){objDown.__zp_timer=setTimeout(funcMoveDown,50);}}return true;};objDown.onmouseover=function(){objDown.__zp_mouseover=true;return funcMoveDown();}objDown.onmouseout=function(){objDown.__zp_mouseover=false;if(objDown.__zp_timer){clearTimeout(objDown.__zp_timer);objDown.__zp_timer=null;}};fc.appendChild(objDown);var lc=fc.__zp_last;iSubMenuOffsetHeight+=objUp.offsetHeight+objDown.offsetHeight;while(iSubMenuOffsetHeight>maxHeight){iSubMenuOffsetHeight-=lc.offsetHeight;lc.style.display='none';lc=lc.previousSibling;fc.__zp_last=lc;}}var width=fc.offsetWidth;var height=fc.offsetHeight;if(typeof subMenu.clientLeft!='undefined'&&!window.opera&&!(document.compatMode&&document.compatMode=='CSS1Compat')){width+=subMenuBorderLeft*2+subMenuMarginLeft*2;height+=subMenuBorderTop*2+subMenuMarginTop*2;}subMenu.style.width=width+'px';subMenu.style.height=height+'px';if(subMenu.__zp_dropshadow){subMenu.__zp_dropshadow.style.width=subMenu.offsetWidth+'px';subMenu.__zp_dropshadow.style.height=subMenu.offsetHeight+'px';}fc.style.position='absolute';fc.style.visibility='inherit';}var newLeft=0,newTop=0;var menuPos=Zapatec.Utils.getAbsolutePos(parMenu);if((/zpMenu-top/.test(this.trees[item.__zp_parent].className))&&(!(this.config.vertical))){newLeft=item.offsetLeft;newTop=item.offsetHeight;if(menuPos.x+newLeft+subMenu.offsetWidth+subMenuMarginLeft+7>scrollX+winW){newLeft+=item.offsetWidth-subMenu.offsetWidth-subMenuMarginLeft;if(subMenu.__zp_dropshadow)newLeft-=6;}else{newLeft-=subMenuBorderLeft;}if(menuPos.y+newTop+subMenu.offsetHeight+subMenuMarginTop+7>scrollY+winH){newTop=-subMenu.offsetHeight;if(subMenu.__zp_dropshadow)newTop-=5;}}else{newLeft=item.offsetWidth;newTop=item.offsetTop;if(menuPos.x+newLeft+subMenu.offsetWidth+subMenuMarginLeft+7>scrollX+winW){newLeft=-subMenu.offsetWidth;if(subMenu.__zp_dropshadow)newLeft-=5;}if(menuPos.y+newTop+subMenu.offsetHeight+subMenuMarginTop+7>scrollY+winH){newTop-=subMenu.offsetHeight-item.offsetHeight;if(subMenu.__zp_dropshadow)newTop-=5;}else{newTop-=subMenuBorderTop;}}if(menuPos.x+newLeft<0){newLeft=0-menuPos.x;}if(menuPos.y+newTop<0){newTop=0-menuPos.y;}subMenu.style.left=newLeft+'px';subMenu.style.top=newTop+'px';if(subMenu.__zp_dropshadow){subMenu.__zp_dropshadow.style.left=newLeft+5+'px';subMenu.__zp_dropshadow.style.top=newTop+5+'px';}if(Zapatec.is_ie&&!Zapatec.is_ie5&&!Zapatec.is_ie7){if(!subMenu.__zp_wch){subMenu.__zp_wch=Zapatec.Utils.createWCH(subMenu);}if(subMenu.__zp_wch){subMenu.__zp_wch.style.zIndex=-1;if(this.config.dropShadow){Zapatec.Utils.setupWCH(subMenu.__zp_wch,-subMenuBorderLeft,-subMenuBorderTop,subMenu.offsetWidth+6,subMenu.offsetHeight+5);}else{Zapatec.Utils.setupWCH(subMenu.__zp_wch,-subMenuBorderLeft,-subMenuBorderTop,subMenu.offsetWidth,subMenu.offsetHeight);}}}this.toggleItem(item_id,true);};Zapatec.Menu.prototype.itemHide=function(item_id){var item=this.items[item_id];var subMenu=this._getTree(item.__zp_subtree);var parMenu=this._getTree(item.__zp_parent);if(subMenu){this.toggleItem(item_id,false);parMenu.__zp_activeitem='';subMenu.__zp_activeitem='';for(var i in this.items){if(this.items[i].__zp_state)return;}this.clickDone=false;}};Zapatec.Menu.dragStart=function(ev,menu){ev||(ev=window.event);if(menu.dragging){return true;}var rootMenu=menu.rootMenu;if(!(/(absolute|fixed)/).test(rootMenu.style.position)){rootMenu.style.position='absolute';var pos=Zapatec.Utils.getAbsolutePos(rootMenu);rootMenu.style.left=pos.x+'px';rootMenu.style.top=pos.y+'px';}var testElm=ev.srcElement||ev.target;while(1){if(testElm==rootMenu)break;else testElm=testElm.parentNode;if(!testElm)return true;}menu.dragging=true;var posX=ev.pageX||ev.clientX+window.document.body.scrollLeft||0;var posY=ev.pageY||ev.clientY+window.document.body.scrollTop||0;var L=parseInt(rootMenu.style.left)||0;var T=parseInt(rootMenu.style.top)||0;menu.xOffs=(posX-L);menu.yOffs=(posY-T);if(menu.config.scrollWithWindow){Zapatec.ScrollWithWindow.unregister(menu.rootMenu);}};Zapatec.Menu.dragMove=function(ev,menu){ev||(ev=window.event);var rootMenu=menu.rootMenu;if(!(menu&&menu.dragging)){return false;}var posX=ev.pageX||ev.clientX+window.document.body.scrollLeft||0;var posY=ev.pageY||ev.clientY+window.document.body.scrollTop||0;var st=rootMenu.style,L=posX-menu.xOffs,T=posY-menu.yOffs;st.left=L+"px";st.top=T+"px";return Zapatec.Utils.stopEvent(ev);};Zapatec.Menu.dragEnd=function(ev,menu){if(!menu){return false;}if(menu.dragging){menu.dragging=false;var rootMenu=menu.rootMenu;var st=rootMenu.style,L=parseInt(st.left),T=parseInt(st.top);var scrollX=window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft||0;var scrollY=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop||0;var objWindowSize=Zapatec.Utils.getWindowSize();var winW=objWindowSize.width;var winH=objWindowSize.height;if(L<0){st.left='0px';}else if(L+rootMenu.offsetWidth>scrollX+winW){st.left=scrollX+winW-rootMenu.offsetWidth+'px';}if(T<0){st.top='0px';}else if(T+rootMenu.offsetHeight>scrollY+winH){st.top=scrollY+winH-rootMenu.offsetHeight+'px';}if(menu.config.scrollWithWindow){Zapatec.ScrollWithWindow.register(rootMenu);}}};Zapatec.Menu.prototype.itemDisable=function(item_id){var item=this.items[item_id];if(item){Zapatec.Utils.addClass(item,"zpMenuDisabled");}};Zapatec.Menu.prototype.itemEnable=function(item_id){var item=this.items[item_id];if(item){Zapatec.Utils.removeClass(item,"zpMenuDisabled");}};Zapatec.Menu.prototype.popupMenu=function(iLeft,iTop){for(var menuId in Zapatec.Menu.all){if(!Zapatec.Menu.all.hasOwnProperty(menuId)){continue;}var menu=Zapatec.Menu.all[menuId];if(menu.config.triggerEvent){menu.hideMenu();}}if(arguments.length>1){this.showMenu(iLeft,iTop);}else{this.showMenu();}};Zapatec.Menu.prototype.showMenu=function(iLeft,iTop){var objTopParent=this.top_parent;var objMenu=objTopParent.__zp_menu;var objWindowSize=Zapatec.Utils.getWindowSize();var iScrollX=Zapatec.Utils.getPageScrollX();var iScrollY=Zapatec.Utils.getPageScrollY();if(arguments.length>1){objTopParent.style.position='absolute';objTopParent.style.left=iLeft+'px';objTopParent.style.top=iTop+'px';}objTopParent.style.display='block';if(!objMenu.style.width){if(objMenu.childNodes){var iMenuWidth=0;for(var iItem=0;iItem<objMenu.childNodes.length;iItem++){var objItem=objMenu.childNodes[iItem];var iItemMargin=0;if(iItem==0){iItemMargin=objItem.offsetLeft;}if(this.config.vertical){if(objItem.offsetWidth>iMenuWidth){iMenuWidth=objItem.offsetWidth+iItemMargin;}}else{iMenuWidth+=objItem.offsetWidth+iItemMargin;}}if(typeof objMenu.clientLeft!='undefined'){iMenuWidth+=objMenu.clientLeft*2;}else{iMenuWidth+=objMenu.offsetWidth-objMenu.clientWidth;}if(objMenu.clientWidth>iMenuWidth){objMenu.style.width=objMenu.clientWidth+'px';}else{objMenu.style.width=iMenuWidth+'px';}}}if(arguments.length>1){if(iLeft+objTopParent.offsetWidth>iScrollX+objWindowSize.width){objTopParent.style.left=iScrollX+objWindowSize.width-objTopParent.offsetWidth+'px';}if(iTop+objTopParent.offsetHeight>iScrollY+objWindowSize.height){objTopParent.style.top=iScrollY+objWindowSize.height-objTopParent.offsetHeight+'px';}}else{if(typeof this.config.top!='object'||typeof this.config.right!='object'||typeof this.config.bottom!='object'||typeof this.config.left!='object'){objTopParent.style.position='absolute';if(typeof this.config.top!='object'){objTopParent.style.top=parseInt(this.config.top)+'px';}else if(typeof this.config.bottom!='object'){objTopParent.style.top=(objWindowSize.height-parseInt(this.config.bottom)-objMenu.offsetHeight-(objTopParent.offsetHeight-objTopParent.clientHeight))+'px';}if(typeof this.config.left!='object'){objTopParent.style.left=parseInt(this.config.left)+'px';}else if(typeof this.config.right!='object'){objTopParent.style.left=(objWindowSize.width-parseInt(this.config.right)-objMenu.offsetWidth-(objTopParent.offsetWidth-objTopParent.clientWidth))+'px';}}else if(window.opera&&(this.config.drag||this.config.scrollWithWindow)){objTopParent.style.position='absolute';var pos=Zapatec.Utils.getElementOffset(objTopParent);objTopParent.style.left=pos.left+'px';objTopParent.style.top=pos.top+'px';}}objTopParent.style.zIndex=this.config.zIndex;if((this.config.rememberPath||this.config.pathCookie!='__zp_item')&&this.path){this.highlightPath(this.path);if(this.config.rememberPath=='expand'){this.sync(this.path);}}if(Zapatec.is_ie&&!Zapatec.is_ie5&&!Zapatec.is_ie7){if(!objTopParent.__zp_wch){objTopParent.__zp_wch=Zapatec.Utils.createWCH(objTopParent);}if(objTopParent.__zp_wch){objTopParent.__zp_wch.style.zIndex=-1;Zapatec.Utils.setupWCH(objTopParent.__zp_wch,-objTopParent.clientLeft,-objTopParent.clientTop,objTopParent.offsetWidth,objTopParent.offsetHeight);}}this.fireEvent('menuShown');};Zapatec.Menu.prototype.hideMenu=function(){this.collapseAll();this.top_parent.style.display='none';this.fireEvent('menuHidden');};Zapatec.Menu.selectedItemsStack=[];Zapatec.Menu.selectItem=function(item){Zapatec.Utils.addClass(item,"zpMenu-item-selected");if(/zpMenu-item-collapsed/i.test(item.className)){Zapatec.Utils.addClass(item,"zpMenu-item-selected-collapsed");}for(var i=Zapatec.Menu.selectedItemsStack.length-1;i>=0;i--){if(Zapatec.Menu.selectedItemsStack[i]==item){Zapatec.Menu.selectedItemsStack.splice(i,1);}}Zapatec.Menu.selectedItemsStack.push(item);};Zapatec.Menu.unselectItem=function(item){Zapatec.Utils.removeClass(item,"zpMenu-item-selected");Zapatec.Utils.removeClass(item,"zpMenu-item-selected-collapsed");for(var i=Zapatec.Menu.selectedItemsStack.length-1;i>=0;i--){if(Zapatec.Menu.selectedItemsStack[i]==item){Zapatec.Menu.selectedItemsStack.splice(i,1);}}};Zapatec.Utils.addEvent(window, 'load', Zapatec.Utils.checkActivation);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -