Index: platform/inc/nlsmenu.js =================================================================== diff -u -N --- platform/inc/nlsmenu.js (revision 12930) +++ platform/inc/nlsmenu.js (revision 0) @@ -1,860 +0,0 @@ -/** -* nlsmenu.js v.2.0 -* Copyright 2005-2007, 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 = 1000; - this.flowOverFormElement = false; - this.assocMenuMgr = []; - this.defaultEffect=null; - this.icPath=""; - this.memorizeSel=false; - this.rt=new Object(); - - 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; - if(nls_isIE)window.attachEvent("onload", function(){nlsMenuMgr[mgr].init();}); - - return this; -}; - -var NlsMnMgr = NlsMenuManager.prototype; -NlsMnMgr.createMenu = function(mId) { - var m=new NlsMenu(mId) - m.mgr=this; m.mgrId=this.mgrId; m.icPath=this.icPath; - m.useEffect(this.defaultEffect); - if (this.design) { m.$menuItemClick = NlsMenu.$dsItemClick; } - this.menus[mId]=m; - return m; -}; - -NlsMnMgr.createMenubar = function (mbarId) { - if (this.menubar) alert("Menubar already exists!"); - var m=new NlsMenubar(mbarId); - m.mgr=this; m.mgrId=this.mgrId; m.icPath=this.icPath; - if (this.design) { m.$menuItemClick = NlsMenu.$dsItemClick; } - this.menubar=m; - return m; -}; - -NlsMnMgr.renderMenus = function (plc) { - if (plc && plc!="") { - var d=NlsMenu.$GE(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!="") { - NlsMenu.$GE(plc).innerHTML=this.menubar.renderMenubar(); - } else { - document.write(this.menubar.renderMenubar()); - } - } - if(this.memorizeSel) this.loadPath(); -}; - -NlsMnMgr.hideMenus = function () { - for (var it in this.menus) {if (this.menus[it].rt.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]; }; - -NlsMnMgr.init=function() { - if(this.menubar)this.menubar.init(); -} - -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.mgr=null; - this.winElmt=null; - this.container=null; - this.customBorder=null; - this.shadow=new NlsMenuShadow("none", "5px", mId); - this.count=0; - this.isMenubar=false; - this.effect=null; - this.srItems=[]; - - this.rt={ready:true,active:false}; - - /*public*/ - this.mId = mId; - this.items = new Object(); - this.stlprf=""; - this.subMenuIc=null; - this.target="_self"; - this.icPath=""; - this.itemSpc=""; - this.stretchItem=true; - - this.selection=false; - - 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; - it.mId=this.mId; - 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; - var it = this.items[intKey]; - it.subMenuId=subId; - it.subFrame=(subFrame?subFrame:null); - it.crsFrame=(crsFrame?crsFrame:false); - it.subPos = (subPos?subPos:[null,null]); - it.subPosAdj = (subPosAdj?subPosAdj:[0,0]); - it.subDir = (subDir?subDir:["right","down"]); - return it; -}; - -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.setItemText = function (key, tx) { - var intKey = this.mId+"_"+key; - var mnItem = this.items[intKey]; - mnItem.capt=tx; - var oD=NlsMenu.$GE(intKey+"x2"); - if (oD) oD.innerHTML=tx; -} - -NLSMENU.enableItem = function (key, b) { - var it = this.items[this.mId+"_"+key] ; - it.enable=b; - setMnStyle(NlsMenu.$GE(it.intKey), (b?(it.selected?"S":"N"):"D"), NlsMenu.getPrf(it, this)); - setMnIcon(this, it, "N"); -}; - -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 (efN) { - if(efN!=null && efN!="") { - this.effect=new NlsMenuEffect(this.mId, efN); - } -}; - -NLSMENU.renderMenu = function() { - var scPath="", sbIc=null; - var allScs = (document.getElementsByTagName ? document.getElementsByTagName("SCRIPT"): document.scripts); - for (var i=0;i=0) { scPath=allScs[i].src.replace(/nlsmenu.js/gi, ""); } - } - if (!this.subMenuIc) { sbIc=[scPath+"img/submenu.gif", scPath+"img/submenuovr.gif"];} - else {sbIc=[this.icPath+this.subMenuIc[0]]; if(this.subMenuIc[1])sbIc[1]=this.icPath+this.subMenuIc[1];} - - var cs=""; - var tmpCnt=0, prf=this.stlprf, it=null, rt=null, menu=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 { - prf=NlsMenu.getPrf(it, this); - if (this.orient=="V") { smenu+=""; } - if (this.orient=="H") { if (tmpCnt==0) smenu+=""; tmpCnt++; } - smenu+=""; - - if (this.showIcon) { - smenu+=""; - } - - smenu+=""; - if (this.showSubIcon && it.subMenuId!="") { smenu+=""; } - smenu+="
"+it.render()+"
"+it.cstMenu+"
"; - smenu+=cs+(this.stretchItem?"width='100%'":"")+" height='100%'>
"; - if(it.ico) { - if(it.ico[0]) smenu+=""; - if(it.ico[1]) smenu+=""; - if(it.ico[2]) smenu+=""; - } - smenu+=""+it.capt+""+ (it.subMenuId!=""? "" + (sbIc.length>1?"":"") :"") +"
"; - smenu+=""; - if (this.orient=="V") { smenu+=""; } - if (this.orient=="H" && tmpCnt==this.maxItemCol) { smenu+=""; tmpCnt=0; } - } - } - - if(this.orient=="H" && tmpCnt!=0 ) { - if(this.srItems.length>this.maxItemCol) - while(++tmpCnt<=this.maxItemCol) smenu+=" "; - smenu+=""; - } - smenu += ""; - smenu = cs+"class='"+this.stlprf+"nlsmenu' "+ sAbs + ">"+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 && this.mgr.flowOverFormElement) { - smenu += ""; - } - smenu+="
"; - - if (arguments[0]=="content") return smenu; - - smenu = "
" + smenu + "
"; - - return smenu; -}; - -NLSMENU.init=function() { - var v=this.rt.vshade; if(!v) v=NlsMenu.$GE("vshade_"+this.mId); - var itm=this.rt.actmn; if(!itm) itm=NlsMenu.$GE("actmn_"+this.mId); - if(v){ - var o=itm.childNodes[0].offsetHeight-parseInt(this.shadow.offset); - if(o>=0) v.style.height=o+"px"; - } - this.rt.actmn=itm; - this.rt.vshade=v; -}; - -function NlsMenuShadow(pos, offset, mId) { - this.pos=pos; - this.offset=offset; - this.mId=mId; - - this.dropShadow = function (smenu) { - var mn = nlsMenu[this.mId]; - var cs=""; - var hshadow = "
"+cs+"width='100%' height='5px' class='"+mn.stlprf+"horzshadow'>
"; - var vshadow = ""+cs+"id='vshade_"+this.mId+"' width='5px' height='100%' class='"+mn.stlprf+"vertshadow'>"; - var menutd = ""+smenu+""; - var cornertd = ""; - var av=[vshadow.replace(/@@PAD/gi,"top"), vshadow.replace(/@@PAD/gi,"bottom")]; - var ah=[hshadow.replace(/@@PAD/gi,"left"), hshadow.replace(/@@PAD/gi,"right")]; - switch (this.pos) { - case "none": - shadow += ""+menutd+""; - break; - case "bottomright" : - shadow += ""+menutd+av[0]+"" + - ""+ah[0]+cornertd+""; - break; - case "bottomleft" : - shadow += ""+av[0]+menutd+"" + - ""+cornertd+ah[1]+""; - break; - case "topleft" : - shadow += ""+cornertd+ah[1]+"" + - ""+av[1]+menutd+""; - break; - case "topright" : - shadow += ""+ah[0]+cornertd+"" + - ""+menutd+av[1]+""; - break; - } - return shadow + ""; - }; -}; - -NLSMENU.showMenu = function(x1, y1, x2, y2, mnOrient, subDir, subAdj) { - this.mgr.clearTimeout(); - - if(this.menuOnShow(this.mId)==false)return; - - var ctx = NlsMenu.$GE(this.mId); - if (!ctx) { - //create menu if not rendered. - var dv=document.createElement("div"); - dv.innerHTML=this.renderMenu(); - document.body.insertBefore(dv, document.body.childNodes[0]); - ctx = NlsMenu.$GE(this.mId); - }; - ctx.style.visibility="hidden"; - ctx.style.display=""; - if(nls_isIE)this.init(); - - var w=window, d=document.body, de=document.documentElement; - var scrOffX = w.scrollX||d.scrollLeft||de.scrollLeft; - var scrOffY = w.scrollY||d.scrollTop||de.scrollTop; - var cW=w.innerWidth||d.clientWidth; - var cH=w.innerHeight||d.clientHeight; - var mW=ctx.childNodes[0].offsetWidth; - var mH=ctx.childNodes[0].offsetHeight; - var sDir=(subDir?[subDir[0], subDir[1]]:["right", "down"]); - var adjX=(subAdj?subAdj[0]:this.defPos[0]), adjY=(subAdj?subAdj[1]:this.defPos[1]); - - var dmfrm = NlsMenu.$GE(this.mId+"ifrm"); - if (dmfrm) { - var actMn = NlsMenu.$GE("actmn_"+this.mId).children[0]; - dmfrm.width = actMn.offsetWidth; - dmfrm.height = actMn.offsetHeight; - } - var mX=0,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 = NlsMenu.$GE(this.mId); - ctx.style.top=y+"px"; ctx.style.left=x+"px"; - ctx.style.display=""; - this.rt.active=true; -}; - -NLSMENU.hideMenu = function() { - var ctx = NlsMenu.$GE(this.mId); - if (!ctx) return; - if (!this.isMenubar) { - this.rt.active=false; - 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.menuOnHide(this.mId); - } else { - this.isMenuOpened = false; - } - - if (this.lsItm!=null) { - var it=this.items[this.lsItm.id]; - if(it.state!=2 && !it.selected) { - setMnStyle(this.lsItm, (it.enable?"N":"D"), NlsMenu.getPrf(it, this)); - setMnIcon(this, it, "N"); - } - this.lsItm=null; - } - if (this.winElmt!=null && this.winElmt.length>0) { - for (i=0;i 0) { - for (var i=0;i1) { - var k=mnItm.intKey; - var c=NlsMenu.$GE("ic_"+k), o=NlsMenu.$GE("icovr_"+k), d=NlsMenu.$GE("icdis_"+k); - - c.style.display=(tf=="N"||(tf=="D" && !d)?"":"none"); - o.style.display=(tf=="O"?"":"none"); - if(d) d.style.display=(tf=="D"?"":"none"); - } - - if (mn.showSubIcon && mnItm.subMenuId!="") { - var ic=NlsMenu.$GE("subicovr_"+mnItm.intKey); - if(ic){ - ic.style.display=(tf=="O"?"":"none"); - ic=NlsMenu.$GE("subic_"+mnItm.intKey); - if(ic)ic.style.display=(tf=="N"||tf=="D"?"":"none"); - } - } -}; - -function setMnStyle(it, s, prefix) { - var suff=(s=="O"?"over":(s=="S"?"sel":"")); - it.className=prefix+"nlsitemcontainer"+suff; - var r = it.childNodes[0].rows[0], rc=null; - for (var i=0; i 0) { - for (var i=0; i 0) { - for (var i=0; i