Index: trunk/core/admin_templates/js/nlsmenu.js =================================================================== diff -u -N --- trunk/core/admin_templates/js/nlsmenu.js (revision 7635) +++ trunk/core/admin_templates/js/nlsmenu.js (revision 0) @@ -1,754 +0,0 @@ -/** -* nlsmenu.js v.1.2.1 -* Copyright 2005-2006, addobject.com. All Rights Reserved -* Author Jack Hermanto, www.addobject.com -*/ -var nlsMenu = new Object(); -var nlsMenuMgr = new Object(); -var nlsWinElmt = []; - -var ag0=window.navigator.userAgent; -var nls_isIE = (ag0.indexOf("MSIE") >=0); -var nls_isIE5 = (ag0.indexOf("MSIE 5.0") >=0); -var nls_isSafari = (ag0.indexOf("Safari") >=0); -var nls_isOpera = (ag0.indexOf("Opera") >=0); -if (nls_isOpera) {nls_isIE=false; nls_isIE5=false;}; - -function NlsMenuManager(mgr) { - this.mgrId = mgr; - this.menus = new Object(); - this.menubar = null; - this.timeout = 1500; - this.flowOverFormElement = false; - this.assocMenuMgr = []; - this.defaultEffect=null; - - this.tmId = null; - this.setTimeout=function(a, t) { this.tmId = window.setTimeout(a, t); }; - this.clearTimeout=function() { if (this.tmId!=null) { window.clearTimeout(this.tmId); this.tmId=null;}}; - - nlsMenuMgr[mgr] = this; - return this; -}; - -var NlsMnMgr = NlsMenuManager.prototype; -NlsMnMgr.createMenu = function(mId) { - var m = new NlsMenu(mId); - m.mgrId = this.mgrId; - if (this.defaultEffect!=null && this.defaultEffect!="") m.useEffect(this.defaultEffect); - this.menus[mId] = m; - return m; -}; - -NlsMnMgr.createMenubar = function (mbarId) { - if (this.menubar) alert("Menubar already exists!"); - var m = new NlsMenubar(mbarId); - m.mgrId = this.mgrId; - this.menubar = m; - return m; -}; - -NlsMnMgr.renderMenus = function (plc) { - if (plc && plc!="") { - var d=NlsGetElementById(plc); var s=""; - for (it in this.menus) { s+=this.menus[it].renderMenu(); } - d.innerHTML=s; - } else { - for (it in this.menus) { document.write(this.menus[it].renderMenu()); } - } -}; - -NlsMnMgr.renderMenubar = function (plc) { - if (this.menubar) { - if (plc && plc!="") { - NlsGetElementById(plc).innerHTML=this.menubar.renderMenubar(); - } else { - document.write(this.menubar.renderMenubar()); - } - } -}; - -NlsMnMgr.hideMenus = function () { - for (it in this.menus) {if (this.menus[it].active) this.menus[it].hideMenu();} - if (this.menubar) this.menubar.hideMenu(); -}; - -NlsMnMgr.addAssocMenuMgr = function(frm, mgrId) { - this.assocMenuMgr[this.assocMenuMgr.length] = [frm, mgrId]; -}; - -NlsMnMgr.getMenu= function(mId) { return this.menus[mId]; }; - -function listAllWinElmt() { - nlsWinElmt = []; - var arrWinEl = document.getElementsByTagName("SELECT"); - var elm; var tmp; var x; var y; - for(var i=0; i" + - "" + - ""); - }; - - this.toString=function() {return "NlsMenuSeparator";}; -}; - -function NlsCustomMenuItem(cst) { - this.intKey = ""; - this.cstMenu = (cst?cst:" "); - this.toString=function() {return "NlsCustomMenuItem";}; -}; - -function NlsMenu(mId) { - /*private*/ - this.lsItm=null; - this.mgrId = ""; - this.winElmt=null; - this.container=null; - this.customBorder=null; - this.shadow=new NlsMenuShadow("bottomright", "5px", mId); - this.count=0; - this.active = false; - this.isMenubar=false; - this.effect=null; - this.srItems=[]; - this.imgPath=""; - this.ready=true; - - /*public*/ - this.mId = mId; - this.items = new Object(); - this.stlprf=""; - this.subMenuIc=[]; - this.target="_self"; - - this.showIcon=false; - this.showSubIcon=true; - - this.absWidth=""; - this.orient="V"; - - this.defItmEff=null; - this.defPos=[0,0]; - - this.maxItemCol=100; - this.zIndex = 100; - - this.wnd = window; - nlsMenu[mId] = this; - return this; -}; - -var NLSMENU=NlsMenu.prototype; - -NLSMENU.addItem = function(key, capt, url, ico, enb, xtra, subId, title) { - var intKey = this.mId+"_"+key; - var it = new NlsMenuItem(key, capt, url, ico, enb, xtra, subId, title); - it.intKey = intKey; - this.items[intKey]=it; - this.srItems[this.srItems.length]=it; - if (this.defItmEff!=null && typeof(NlsMenuItemEffect) != "undefined") { it.useItemEffect(this.defItmEff); } - this.count++; - return it; -}; - -NLSMENU.addSeparator = function(separator) { - var intKey = "sep_"+this.count; - var it = (separator ? separator : new NlsMenuSeparator()); - it.stlprf = this.stlprf; - it.intKey = intKey; - this.items[intKey] = it; - this.srItems[this.srItems.length]=it; - this.count++; - return it; -}; - -NLSMENU.addSubmenu = function(key, subId, crsFrame, subFrame, subPos, subPosAdj, subDir) { - var intKey = this.mId+"_"+key; - alert('intKey: '+intKey); - var mnItem = this.items[intKey]; - alert('subId '+subId) - mnItem.subMenuId=subId; - mnItem.subFrame=(subFrame?subFrame:null); - mnItem.crsFrame=(crsFrame?crsFrame:false); - mnItem.subPos = (subPos?subPos:[null,null]); - mnItem.subPosAdj = (subPosAdj?subPosAdj:[0,0]); - mnItem.subDir = (subDir?subDir:["right","down"]); -}; - -NLSMENU.addCustomMenu = function (custom) { - var intKey = "cst_"+this.count; - var it = new NlsCustomMenuItem(custom); - it.intKey = intKey; - this.items[intKey] = it; - this.srItems[this.srItems.length]=it; - this.count++; - return it; -}; - -NLSMENU.getItemById = function (key) { - return this.items[this.mId+"_"+key]; -}; - -NLSMENU.setItemStyle = function (key, stlprf) { - var intKey = this.mId+"_"+key; - var mnItem = this.items[intKey]; - mnItem.stlprf=stlprf; -}; - -NLSMENU.enableItem = function (key, b) { - var intKey = this.mId+"_"+key; - this.items[intKey].enable=b; - setMnStyle(NlsGetElementById(intKey), (b?"N":"D"), (this.items[intKey].stlprf==""?this.stlprf:this.items[intKey].stlprf)); -}; - -NLSMENU.dropShadow = function (pos, offset) { - if (this.shadow) { this.shadow.pos=pos; this.shadow.offset=(offset?offset:"5px"); } else - { this.shadow=new NlsMenuShadow(pos, offset, this.mId); } -}; - -NLSMENU.applyBorder = function (bTop, bBottom, bLeft, bRight) { - if (!bTop && !bBottom && !bLeft && !bRight) { - this.customBorder=null; - } else { - this.customBorder=new NlsMenuBorder(bTop, bBottom, bLeft, bRight); - } -}; - -NLSMENU.useEffect = function (effName) { - this.effect=new NlsMenuEffect(this.mId, effName); -}; - -NLSMENU.renderMenu = function() { - var allScs = (document.getElementsByTagName ? document.getElementsByTagName("SCRIPT"): document.scripts); - for (var i=0;i=0) { this.imgPath=allScs[i].src.replace(/nlsmenu_1_2_1.js/gi, ""); } - } - if (!this.subMenuIc||this.subMenuIc=="") { this.subMenuIc=[this.imgPath+"img/submenu.gif", this.imgPath+"img/submenuovr.gif"];} - - var sAbs=(this.absWidth==""?"":"width='"+this.absWidth+"'"); - var smenu=""; - var tmpCnt=0;var prf=this.stlprf; var it=null; - for (var i=0; i":""); - smenu+=(""); - smenu+=(this.orient=="V"?"":""); - } else - if (it.toString()=="NlsCustomMenuItem") { - smenu+=(this.orient=="V"?"":""); - smenu+=(""); - smenu+=(this.orient=="V"?"":""); - } else { - if (it.stlprf) prf=it.stlprf; else prf=this.stlprf; - if (this.orient=="V") { smenu+=""; } - if (this.orient=="H") { if (tmpCnt==0) smenu+=""; tmpCnt++; } - smenu+=""; - if (this.orient=="V") { smenu+=""; } - if (this.orient=="H" && tmpCnt==this.maxItemCol) { smenu+=""; tmpCnt=0; } - } - } - - smenu+=(this.orient=="H" && tmpCnt!=0 ?"":""); - smenu += "
"+it.render()+"
"+it.cstMenu+"
"; - smenu+=""; - if (this.showIcon) { smenu+=""; } - smenu+=""; - if (this.showSubIcon && it.subMenuId!="") { smenu+=""; } - smenu+="
"+(it.ico && it.ico.length>0?"" + (it.ico.length>1?"":"") :"")+""+it.capt+""+ (it.subMenuId!=""? "" + (this.subMenuIc.length>1?"":"") :"") +"
"; - smenu+="
"; - smenu = "
"+smenu+"
"; - - if (this.customBorder!=null) smenu = this.customBorder.applyBorder(smenu, this.stlprf); - smenu = this.shadow.dropShadow(smenu); - - smenu = "
" + smenu; - if (!this.isMenubar && nls_isIE && !nls_isIE5 && nlsMenuMgr[this.mgrId].flowOverFormElement) { - smenu += ""; - } - smenu+="
"; - - smenu = "
" + smenu + "
"; - - return smenu; -}; - -function NlsMenuShadow(pos, offset, mId) { - this.pos=pos; - this.offset=offset; - this.mId=mId; - - this.dropShadow = function (smenu) { - //return smenu; - var mn = nlsMenu[this.mId]; - var shadow = "
"; - var hshadow = "
"; - var vshadow = "
"; - var menutd = ""+smenu+""; - var cornertd = ""; - switch (this.pos) { - case "none": - shadow += ""+menutd+""; - break; - case "bottomright" : - shadow += ""+menutd+""+vshadow+"" + - ""+hshadow+""+cornertd+""; - break; - case "bottomleft" : - shadow += ""+vshadow+""+menutd+"" + - ""+cornertd+""+hshadow+""; - break; - case "topleft" : - shadow += ""+cornertd+""+hshadow+"" + - ""+vshadow+""+menutd+""; - break; - case "topright" : - shadow += ""+hshadow+""+cornertd+"" + - ""+menutd+""+vshadow+""; - break; - } - return shadow.replace(/OFFSET/gi, this.offset) + "
"; - }; -}; - -NLSMENU.showMenu = function(x1, y1, x2, y2, mnOrient, subDir, subAdj) { - - if (this.lsItm!=null) {setMnStyle(this.lsItm, "N", (this.lsItm.stlprf==""?this.stlprf:this.lsItm.stlprf)); this.lsItm=null;} - - var flag= this.menuOnShow(this.mId); - if (flag==false) return; - - var ctx = NlsGetElementById(this.mId); - if (!ctx) return; - var dmfrm = NlsGetElementById(this.mId+"ifrm"); - ctx.style.visibility="hidden"; - ctx.style.display=""; - - var scrOffX = window.scrollX?window.scrollX:document.body.scrollLeft; - var scrOffY = window.scrollY?window.scrollY:document.body.scrollTop; - var cW=(window.innerWidth?window.innerWidth:document.body.clientWidth); - var cH=(window.innerHeight?window.innerHeight:document.body.clientHeight); - var mW=(ctx.children?ctx.children[0]:ctx.childNodes[0]).offsetWidth; - var mH=(ctx.children?ctx.children[0]:ctx.childNodes[0]).offsetHeight; - var sDir=(subDir?[subDir[0], subDir[1]]:["right", "down"]); - var adjX=(subAdj?subAdj[0]:this.defPos[0]); var adjY=(subAdj?subAdj[1]:this.defPos[1]); - - if (dmfrm) { - var actMn = NlsGetElementById("actmn_"+this.mId); - if (actMn) { - dmfrm.width = actMn.children[0].offsetWidth; - dmfrm.height = actMn.children[0].offsetHeight; - } - } - var mX=0; var mY=0; - if (mnOrient=="V") { - if (sDir[0]=="right") { - if(x2+mW>cW){if(x1>=mW){mX=x1-mW+adjX+scrOffX;sDir[0]="left"}else{mX=cW-mW-1+scrOffX;}}else{mX=x2+scrOffX-adjX;} - } else { - if(x1-mW<0){if(x2+mWcH){if(y2>=mH){mY=y2-mH+scrOffY-adjY;sDir[1]="up"}else{mY=cH-mH-1+scrOffY;}}else{mY=y1+scrOffY+adjY;} - } else { - if(y1-mH<0){if(y1+mHcW){if(x2>=mW){mX=x2-mW+scrOffX-adjX;sDir[0]="left"}else{mX=cW-mW-1+scrOffX;}}else{mX=x1+scrOffX+adjX;} - } else { - if(x2-mW<0){if(x1+mWcH){if(y1>=mH){mY=y1-mH+scrOffY+adjY;sDir[1]="up"}else{mY=cH-mH-1+scrOffY;}}else{mY=y2+scrOffY-adjY;} - } else { - if(y1-mH<0){if(y2+mH=mX1 && oe.eX1<=mX2 && oe.eY1>=mY1 && oe.eY1<=mY2) || - (oe.eX1>=mX1 && oe.eX1<=mX2 && oe.eY2>=mY1 && oe.eY2<=mY2) || - (oe.eX2>=mX1 && oe.eX2<=mX2 && oe.eY1>=mY1 && oe.eY1<=mY2) || - (oe.eX2>=mX1 && oe.eX2<=mX2 && oe.eY2>=mY1 && oe.eY2<=mY2) || - (mX1>=oe.eX1 && mX1<=oe.eX2 && mY1>=oe.eY1 && mY1<=oe.eY2) || - (mX1>=oe.eX1 && mX1<=oe.eX2 && mY2>=oe.eY1 && mY2<=oe.eY2) || - (mX2>=oe.eX1 && mX2<=oe.eX2 && mY1>=oe.eY1 && mY1<=oe.eY2) || - (mX2>=oe.eX1 && mX2<=oe.eX2 && mY2>=oe.eY1 && mY2<=oe.eY2) || - (oe.eX1mX2 && oe.eY1>=mY1 && oe.eY1<=mY2) || - (oe.eX1mX2 && oe.eY2>=mY1 && oe.eY2<=mY2) - ) { - if (oe.e.style.visibility!="hidden") { - oe.e.style.visibility="hidden"; - if (mn.winElmt==null) mn.winElmt=[]; - mn.winElmt[mn.winElmt.length]=oe.e; - } - } - } -}; - -NLSMENU.showMenuAbs = function(x, y) { - var ctx = NlsGetElementById(this.mId); - ctx.style.top=y+"px"; ctx.style.left=x+"px"; - ctx.style.display=""; - this.active=true; -}; - -NLSMENU.hideMenu = function() { - var ctx = NlsGetElementById(this.mId); - if (!ctx) return; - if (!this.isMenubar) { - if (this.effect) { - this.effect.start(true); - if ((nls_isIE && this.effect.effName!="aoslide") || nls_isOpera && this.effect.effName!="aoslide") {ctx.style.visibility="hidden";} else { this.effect.onHide=function() {ctx.style.visibility="hidden";}; }; - this.effect.run(); - } else { ctx.style.visibility="hidden"; } - - this.active=false; - } else { - this.isMenuOpened = false; - } - if (this.lsItm!=null) { - setMnStyle(this.lsItm, "N", (this.items[this.lsItm.id].stlprf==""?this.stlprf:this.items[this.lsItm.id].stlprf)); - setMnIcon(this, this.items[this.lsItm.id], "N"); - this.lsItm=null; - } - if (this.winElmt!=null && this.winElmt.length>0) { - for (i=0;i 0) { - for (var i=0; i1) { - NlsGetElementById("ic_"+mnItm.intKey).style.display=(flg=="N"?"":"none"); - NlsGetElementById("icovr_"+mnItm.intKey).style.display=(flg=="O"?"":"none"); - } - if (mn.showSubIcon && mnItm.subMenuId!="" && mn.subMenuIc && mn.subMenuIc.length>1) { - NlsGetElementById("subic_"+mnItm.intKey).style.display=(flg=="N"?"":"none"); - NlsGetElementById("subicovr_"+mnItm.intKey).style.display=(flg=="O"?"":"none"); - } -}; - -function setMnStyle(it, s, prefix) { - var suff=(s=="O"?"over":""); - it.className=prefix+"nlsitemcontainer"+suff; - var r = (it.children?it.children[0]:it.childNodes[0]).rows[0]; - for (var i=0; i 0) { - for (var i=0; i 0) { - for (var i=0; i"; - if (sBottom!="") sBottom=""+sBottom+""; - border=border+sTop+""+sLeft+"@menu"+sRight+""+sBottom; - border+=""; - - this.applyBorder = function (smenu, stlprf) { - var b=border.replace(/@stlprf_/gi, stlprf); - return b.replace(/@menu/gi, smenu); - }; - - return this; -}; - -/*===================================================*/ -/*NlsMenuBar class*/ -/*===================================================*/ - -NLSMENU.isMenuOpened = false; - -NLSMENU.dropOnClick = false; - -NLSMENU.renderMenubar = function () { - return this.renderMenu(); -}; - -function NlsMenubar(mId) { - var mnBar = new NlsMenu(mId); - mnBar.isMenubar=true; - mnBar.active=true; - return mnBar; -}; - -/*===================================================*/ -/*Public general methods*/ -/*===================================================*/ - -function hideAllNlsMenu() { - for (it in nlsMenu) {if (nlsMenu[it].active) nlsMenu[it].hideMenu();} -}; - -/**Cross browser related methods*/ -function NlsGetElementById(id) { - if (document.all) { - return document.all(id); - } else - if (document.getElementById) { - return document.getElementById(id); - } -}; -