| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233 |
- // v.2.6 build 100722
- /*
- Copyright DHTMLX LTD. http : // www.dhtmlx.com
- You allowed to use this component or parts of it under GPL terms
- To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
- */
- /*
- * 设置HTML元素属性
- * @param object o 要设置属性的HTML元素
- * @param string a 要设置的属性名
- * @param string v 要设置的属性值
- */
- function setAttribute(o, a, v) {
- if (typeof o != 'object' || typeof a != 'string')
- return;
- a == 'class' ? o.className = v : o.setAttribute(a, v);
- }
- /*
- * 获取HTML元素属性值
- * @param object o 要获取属性的HTML元素
- * @param string a 要获取的属性名
- * @return 返回要获取的属性值
- */
- function getAttribute(o, a) {
- if (typeof o != 'object' || typeof a != 'string')
- return;
- return a == 'class' ? o.className : o.getAttribute(a);
- }
- /*
- * 移除HTML元素属性
- * @param object o 要移除属性的HTML元素
- * @param string a 要移除的属性名
- */
- function removeAttribute(o, a) {
- if (typeof o != 'object' || typeof a != 'string')
- return;
- o.removeAttribute(a);
- if (a == 'class')
- o.removeAttribute('className');
- }
- function dhtmlXMenuObject(baseId, skin) {
- var main_self = this;
- this.addBaseIdAsContextZone = null;
- this.isDhtmlxMenuObject = true;
- this.skin = (skin != null ? skin : "dhx_skyblue");
- this.imagePath = "";
- this._isIE6 = false;
- this.parentTitleObject = null;
- if (_isIE)
- this._isIE6 = (window.XMLHttpRequest == null ? true : false);
- if (baseId == null) {
- this.base = document.body;
- } else {
- if (document.getElementById(baseId) != null) {
- this.base = document.getElementById(baseId);
- while (this.base.childNodes.length > 0) {
- this.base.removeChild(this.base.childNodes[0]);
- };
- this.base.className += " dhtmlxMenu_" + this.skin + "_Middle dir_left";
- this.base._autoSkinUpdate = true;
- if (this.base.oncontextmenu)
- this.base._oldContextMenuHandler = this.base.oncontextmenu;
- this.addBaseIdAsContextZone = baseId;
- this.base.onselectstart = function (e) {
- e = e || event;
- e.returnValue = false;
- return false;
- };
- this.base.oncontextmenu = function (e) {
- e = e || event;
- e.returnValue = false;
- return false;
- }
- } else {
- this.base = document.body;
- }
- };
- this.topId = "dhxWebMenuTopId";
- if (!this.extendedModule) {
- var t = function () {
- alert(this.i18n.dhxmenuextalert);
- };
- var extMethods = new Array("setItemEnabled", "setItemDisabled", "isItemEnabled", "_changeItemState", "getItemText", "setItemText",
- "loadFromHTML", "hideItem", "showItem", "isItemHidden", "_changeItemVisible", "setUserData", "getUserData",
- "setOpenMode", "setWebModeTimeout", "enableDynamicLoading", "_updateLoaderIcon", "getItemImage", "setItemImage",
- "clearItemImage", "setAutoShowMode", "setAutoHideMode", "setContextMenuHideAllMode", "getContextMenuHideAllMode",
- "setVisibleArea", "setTooltip", "getTooltip", "setHotKey", "getHotKey", "setItemSelected", "setTopText", "setRTL",
- "setAlign", "setHref", "clearHref", "getCircuit", "_clearAllSelectedSubItemsInPolygon", "_checkArrowsState",
- "_addUpArrow", "_addDownArrow", "_removeUpArrow", "_removeDownArrow", "_isArrowExists", "_doScrollUp", "_doScrollDown",
- "_countPolygonItems", "setOverflowHeight", "_getRadioImgObj", "_setRadioState", "_radioOnClickHandler",
- "getRadioChecked", "setRadioChecked", "addRadioButton", "_getCheckboxState", "_setCheckboxState", "_readLevel",
- "_updateCheckboxImage", "_checkboxOnClickHandler", "setCheckboxState", "getCheckboxState", "addCheckbox", "serialize");
- for (var q = 0; q < extMethods.length; q++)
- if (!this[extMethods[q]])
- this[extMethods[q]] = t;
- extMethods = null;
- };
- this.fixedPosition = false;
- this.menuSelected = - 1;
- this.menuLastClicked = - 1;
- this.idPrefix = "";
- this.dqlm = "个人首页"; // 增加当前栏目纪录 By Rd 2015-11-06
- this.itemTagName = "item";
- this.itemTextTagName = "itemtext";
- this.userDataTagName = "userdata";
- this.itemTipTagName = "tooltip";
- this.itemHotKeyTagName = "hotkey";
- this.itemHrefTagName = "href";
- this.dirTopLevel = "bottom";
- this.dirSubLevel = "right";
- this.menuX1 = null;
- this.menuX2 = null;
- this.menuY1 = null;
- this.menuY2 = null;
- this.menuMode = "web";
- this.menuTimeoutMsec = 400;
- this.menuTimeoutHandler = null;
- this.idPull = {};
- this.itemPull = {};
- this.userData = {};
- this.radio = {};
- this._rtl = false;
- this._align = "left";
- this.menuTouched = false;
- this.zIndInit = 1200;
- this.zInd = this.zIndInit;
- this.zIndStep = 50;
- this.menuModeTopLevelTimeout = true;
- this.menuModeTopLevelTimeoutTime = 200;
- this._topLevelBottomMargin = 1;
- this._topLevelRightMargin = 0;
- this._topLevelOffsetLeft = 1;
- this._arrowFFFix = (_isIE ? (document.compatMode == "BackCompat" ? 0 : - 4) : - 4);
- this.setSkin = function (skin) {
- var oldSkin = this.skin;
- this.skin = skin;
- switch (this.skin) {
- case "dhx_black":
- case "dhx_blue":
- case "dhx_skyblue":
- case "dhx_web":
- this._topLevelBottomMargin = 2;
- this._topLevelRightMargin = 1;
- this._topLevelOffsetLeft = 1;
- this._arrowFFFix = (_isIE ? (document.compatMode == "BackCompat" ? 0 : - 4) : - 4);
- break;
- case "dhx_web":
- this._arrowFFFix = 0;
- break;
- };
- if (this.base._autoSkinUpdate) {
- this.base.className = this.base.className.replace("dhtmlxMenu_" + oldSkin + "_Middle", "") + " dhtmlxMenu_" + this.skin + "_Middle";
- };
- for (var a in this.idPull) {
- this.idPull[a].className = String(this.idPull[a].className).replace(oldSkin, this.skin);
- }
- };
- this.setSkin(this.skin);
- this.dLoad = false;
- this.dLoadUrl = "";
- this.dLoadSign = "?";
- this.loaderIcon = false;
- this.limit = 0;
- this._scrollUpTM = null;
- this._scrollUpTMTime = 20;
- this._scrollUpTMStep = 3;
- this._scrollDownTM = null;
- this._scrollDownTMTime = 20;
- this._scrollDownTMStep = 3;
- this.context = false;
- this.contextZones = {};
- this.contextMenuZoneId = false;
- this.contextAutoShow = true;
- this.contextAutoHide = true;
- this.contextHideAllMode = true;
- this.sxDacProc = null;
- this.dacSpeed = 10;
- this.dacCycles = [];
- for (var q = 0; q < 10; q++) {
- this.dacCycles[q] = q;
- };
- this.dacSpeedIE = 10;
- this.dacCyclesIE = [];
- for (var q = 0; q < 10; q++) {
- this.dacCyclesIE[q] = q;
- };
- this._enableDacSupport = function (dac) {
- this.sxDacProc = dac;
- };
- this._selectedSubItems = new Array();
- this._openedPolygons = new Array();
- this._addSubItemToSelected = function (item, polygon) {
- var t = true;
- for (var q = 0; q < this._selectedSubItems.length;
- q++) {
- if ((this._selectedSubItems[q][0] == item) && (this._selectedSubItems[q][1] == polygon)) {
- t = false;
- }
- };
- if (t == true) {
- this._selectedSubItems.push(new Array(item, polygon));
- };
- return t;
- };
- this._removeSubItemFromSelected = function (item, polygon) {
- var m = new Array();
- var t = false;
- for (var q = 0; q < this._selectedSubItems.length;
- q++) {
- if ((this._selectedSubItems[q][0] == item) && (this._selectedSubItems[q][1] == polygon)) {
- t = true;
- } else {
- m[m.length] = this._selectedSubItems[q];
- }
- };
- if (t == true) {
- this._selectedSubItems = m;
- };
- return t;
- };
- this._getSubItemToDeselectByPolygon = function (polygon) {
- var m = new Array();
- for (var q = 0; q < this._selectedSubItems.length;
- q++) {
- if (this._selectedSubItems[q][1] == polygon) {
- m[m.length] = this._selectedSubItems[q][0];
- m = m.concat(this._getSubItemToDeselectByPolygon(this._selectedSubItems[q][0]));
- var t = true;
- for (var w = 0; w < this._openedPolygons.length;
- w++) {
- if (this._openedPolygons[w] == this._selectedSubItems[q][0]) {
- t = false;
- }
- };
- if (t == true) {
- this._openedPolygons[this._openedPolygons.length] = this._selectedSubItems[q][0];
- };
- this._selectedSubItems[q][0] = - 1;
- this._selectedSubItems[q][1] = - 1;
- }
- };
- return m;
- };
- this._hidePolygon = function (id) {
- if (this.idPull["polygon_" + id] != null) {
- if ((this.sxDacProc != null) && (this.idPull["sxDac_" + id] != null)) {
- this.idPull["sxDac_" + id]._hide();
- } else {
- if (this.idPull["polygon_" + id].style.display == "none")
- return;
- this.idPull["polygon_" + id].style.display = "none";
- if (this.idPull["arrowup_" + id] != null) {
- this.idPull["arrowup_" + id].style.display = "none";
- };
- if (this.idPull["arrowdown_" + id] != null) {
- this.idPull["arrowdown_" + id].style.display = "none";
- };
- this._updateItemComplexState(id, true, false);
- if (this._isIE6) {
- if (this.idPull["polygon_" + id + "_ie6cover"] != null) {
- this.idPull["polygon_" + id + "_ie6cover"].style.display = "none";
- }
- };
- id = String(id).replace(this.idPrefix, "");
- if (id == this.topId)
- id = null;
- this.callEvent("onHide", [id]);
- }
- }
- };
- this._showPolygon = function (id, openType) {
- var itemCount = this._countVisiblePolygonItems(id);
- if (itemCount == 0)
- return;
- var pId = "polygon_" + id;
- if ((this.idPull[pId] != null) && (this.idPull[id] != null)) {
- if (this.menuModeTopLevelTimeout && this.menuMode == "web" && !this.context) {
- if (!this.idPull[id]._mouseOver && openType == this.dirTopLevel)
- return;
- };
- if (!this.fixedPosition)
- this._autoDetectVisibleArea();
- var arrUpH = 0;
- var arrDownH = 0;
- var arrowUp = null;
- var arrowDown = null;
- if (this.limit > 0 && this.limit < itemCount) {
- var auId = "arrowup_" + id;
- var adId = "arrowdown_" + id;
- if (this.idPull["arrowup_" + id] == null)
- this._addUpArrow(String(id).replace(this.idPrefix, ""));
- if (this.idPull["arrowdown_" + id] == null)
- this._addDownArrow(String(id).replace(this.idPrefix, ""));
- arrowUp = this.idPull["arrowup_" + id];
- arrowUp.style.visibility = "hidden";
- arrowUp.style.display = "";
- arrowUp.style.zIndex = this.zInd;
- arrUpH = arrowUp.offsetHeight;
- arrowDown = this.idPull["arrowdown_" + id];
- arrowDown.style.visibility = "hidden";
- arrowDown.style.display = "";
- arrowDown.style.zIndex = this.zInd;
- arrDownH = arrowDown.offsetHeight;
- };
- this.idPull[pId].style.visibility = "hidden";
- this.idPull[pId].style.left = "0px";
- this.idPull[pId].style.top = "0px";
- this.idPull[pId].style.display = "";
- this.idPull[pId].style.zIndex = this.zInd;
- if (this.limit > 0) {
- if (this.limit < itemCount) {
- this.idPull[pId].style.height = 24 * this.limit + "px";
- this.idPull[pId].scrollTop = 0;
- } else {
- this.idPull[pId].style.height = "";
- }
- };
- this.zInd += this.zIndStep;
- if (this.itemPull[id] != null) {
- var parPoly = "polygon_" + this.itemPull[id]["parent"];
- } else if (this.context) {
- var parPoly = this.idPull[this.idPrefix + this.topId];
- };
- var srcX = (this.idPull[id].tagName != null ? getAbsoluteLeft(this.idPull[id]) : this.idPull[id][0]);
- var srcY = (this.idPull[id].tagName != null ? getAbsoluteTop(this.idPull[id]) : this.idPull[id][1]);
- var srcW = (this.idPull[id].tagName != null ? this.idPull[id].offsetWidth : 0);
- var srcH = (this.idPull[id].tagName != null ? this.idPull[id].offsetHeight + arrUpH + arrDownH : 0);
- var x = 0;
- var y = 0;
- var w = this.idPull[pId].offsetWidth;
- var h = this.idPull[pId].offsetHeight;
- if (openType == "bottom") {
- if (this._rtl) {
- x = srcX + (srcW != null ? srcW : 0) - w;
- } else {
- if (this._align == "right") {
- x = srcX + srcW - w;
- } else {
- x = srcX - 1 + (openType == this.dirTopLevel ? this._topLevelRightMargin : 0);
- }
- };
- y = srcY - 1 + srcH - arrUpH - arrDownH + this._topLevelBottomMargin;
- };
- if (openType == "right") {
- x = srcX + srcW - 1;
- y = srcY + 2;
- };
- if (openType == "left") {
- x = srcX - this.idPull[pId].offsetWidth + 2;
- y = srcY + 2;
- };
- if (openType == "top") {
- x = srcX - 1;
- y = srcY - h + 2;
- };
- if (this.fixedPosition) {
- var mx = 65536;
- var my = 65536;
- } else {
- var mx = (this.menuX2 != null ? this.menuX2 : 0);
- var my = (this.menuY2 != null ? this.menuY2 : 0);
- if (mx == 0) {
- if (window.innerWidth) {
- mx = window.innerWidth;
- my = window.innerHeight;
- } else {
- mx = document.body.offsetWidth;
- my = document.body.scrollHeight;
- }
- }
- };
- if (x + w > mx && !this._rtl) {
- x = srcX - w + 2;
- };
- if (x < this.menuX1 && this._rtl) {
- x = srcX + srcW - 2;
- };
- if (x < 0) {
- x = 0;
- };
- if (y + h > my && this.menuY2 != null) {
- y = srcY + srcH - h + 2;
- if (this.itemPull[id] != null && !this.context) {
- if (this.itemPull[id]["parent"] == this.idPrefix + this.topId)
- y = y - this.base.offsetHeight;
- }
- };
- this.idPull[pId].style.left = x + "px";
- this.idPull[pId].style.top = y + arrUpH + "px";
- if ((this.sxDacProc != null) && (this.idPull["sxDac_" + id] != null)) {
- this.idPull["sxDac_" + id]._show();
- } else {
- this.idPull[pId].style.visibility = "";
- if (this.limit > 0 && this.limit < itemCount) {
- arrowUp.style.left = x + "px";
- arrowUp.style.top = y + "px";
- arrowUp.style.width = w + this._arrowFFFix + "px";
- arrowUp.style.visibility = "";
- arrowDown.style.left = x + "px";
- arrowDown.style.top = y + arrUpH + h + "px";
- arrowDown.style.width = w + this._arrowFFFix + "px";
- arrowDown.style.visibility = "";
- this._checkArrowsState(id);
- };
- /*2016-09-02 添加*/
- if (this.idPull[pId].offsetHeight > this._offset(this.idPull[id]).y) { //判断上面的空位是否足够不足则向下展开
- var h_ = this.idPull[id].offsetHeight;
- this.idPull[pId].style.top = this._offset(this.idPull[id]).y + h_ + 'px';
- }
- /*2016-09-02 添加*/
- if (this._isIE6) {
- var pIdIE6 = pId + "_ie6cover";
- if (this.idPull[pIdIE6] == null) {
- var ifr = document.createElement("IFRAME");
- ifr.className = "dhtmlxMenu_IE6CoverFix_" + this.skin;
- ifr.frameBorder = 0;
- ifr.setAttribute("src", "javascript:false;");
- document.body.insertBefore(ifr, document.body.firstChild);
- this.idPull[pIdIE6] = ifr;
- };
- this.idPull[pIdIE6].style.left = this.idPull[pId].style.left;
- this.idPull[pIdIE6].style.top = this.idPull[pId].style.top;
- this.idPull[pIdIE6].style.width = this.idPull[pId].offsetWidth + "px";
- this.idPull[pIdIE6].style.height = this.idPull[pId].offsetHeight + "px";
- this.idPull[pIdIE6].style.zIndex = this.idPull[pId].style.zIndex - 1;
- this.idPull[pIdIE6].style.display = "";
- };
- id = String(id).replace(this.idPrefix, "");
- if (id == this.topId)
- id = null;
- this.callEvent("onShow", [id]);
- }
- }
- };
- /*2016-09-02新增一个获取元素距离父元素的距离*/
- this._offset = function (element, parent) {
- var parent = parent || document;
- var element = element;
- var par = element.offsetParent;
- var Top = element.offsetTop,
- Left = element.offsetLeft;
- while (par != null) {
- if (par === parent)
- break
- Top += par.offsetTop;
- Left += par.offsetLeft;
- par = par.offsetParent;
- }
- return {
- x: Left,
- y: Top
- };
- };
- this._redistribSubLevelSelection = function (id, parentId) {
- while (this._openedPolygons.length > 0)
- this._openedPolygons.pop();
- var i = this._getSubItemToDeselectByPolygon(parentId);
- this._removeSubItemFromSelected( - 1, - 1);
- for (var q = 0; q < i.length; q++) {
- if ((this.idPull[i[q]] != null) && (i[q] != id)) {
- if (this.itemPull[i[q]]["state"] == "enabled") {
- this.idPull[i[q]].className = "menu-item";
- }
- }
- };
- for (var q = 0; q < this._openedPolygons.length;
- q++) {
- if (this._openedPolygons[q] != parentId) {
- this._hidePolygon(this._openedPolygons[q]);
- }
- };
- if (this.itemPull[id]["state"] == "enabled") {
- this.idPull[id].className = "menu-item";
- if (this.itemPull[id]["complex"] && this.dLoad && (this.itemPull[id]["loaded"] == "no")) {
- if (this.loaderIcon == true) {
- this._updateLoaderIcon(id, true);
- };
- var xmlLoader = new dtmlXMLLoaderObject(this._xmlParser, window);
- this.itemPull[id]["loaded"] = "get";
- this.callEvent("onXLS", []);
- xmlLoader.loadXML(this.dLoadUrl + this.dLoadSign + "action=loadMenu&parentId=" + id.replace(this.idPrefix, "") + "&etc=" + new Date().getTime());
- };
- if (this.itemPull[id]["complex"] || (this.dLoad && (this.itemPull[id]["loaded"] == "yes"))) {
- if ((this.itemPull[id]["complex"]) && (this.idPull["polygon_" + id] != null)) {
- this._updateItemComplexState(id, true, true);
- this._showPolygon(id, this.dirSubLevel);
- }
- };
- this._addSubItemToSelected(id, parentId);
- this.menuSelected = id;
- }
- };
- this.setParentTitleObject = function (str) {
- this.parentTitleObject = eval("([" + str + "])");
- };
- this.getcascadeTitle = function (id) {
- var objarr = this.parentTitleObject;
- var obj;
- var wzmc = "";
- for (var i = 0; i < objarr.length; i++) {
- obj = objarr[i];
- if (obj.wzid == id) {
- wzmc = obj.mc;
- }
- }
- if (wzmc == "") {
- //网站名称数据由菜单部件发布时查询yy表并生成到页面,出现该情况可以1.查看更新数据表数据 2.进入菜单部件所属页面重新发布 By Rd 2015-12-10
- wzmc = "未知";
- }
- return wzmc;
- };
- // this.getTargetNode = function (rootElement) {
- // if (document.getElementById("mbwzbj") == null) {
- // var currentNode = rootElement.childNodes;
- // for (var i = 0; i < currentNode.length; i++) {
- // if (currentNode[i].innerHTML == "个人首页") {
- // currentNode[i].setAttribute("id", "mbwzbj");
- // //console.info("目标文字部件设置id为mbwzbj");
- // //currentNode[i].setAttribute("style","position: absolute; top: 0px;");
- // currentNode[i].style.cssText = "position: absolute; top: 0px;";
- // return;
- // }
- // this.getTargetNode(currentNode[i]);
- // }
- // }
- // }
- this._doOnClick = function (id, type, casState) {
- this.menuLastClicked = id;
- //自定义getElementsByName
- // var getElementsByName = function (tag, name) {
- // var returns = document.getElementsByName(name);
- // if (returns.length > 0)
- // return returns;
- // returns = new Array();
- // var e = document.getElementsByTagName(tag);
- // for (var i = 0; i < e.length; i++) {
- // if (e[i].getAttribute("name") == name) {
- // returns[returns.length] = e[i];
- // }
- // }
- // return returns;
- // }
-
- //console.info('目标文字部件名称 :'+this.wzbjname);
- // var mbwzbj = getElementsByName("div", this.wzbjname)[0];
- //var mbwzbj=document.querySelector('wzbjname');
- // if (typeof(mbwzbj) != "undefined") {
- // console.info("文字部件 : 拿到目标部件");
- // this.getTargetNode(mbwzbj); //将真正包含文字的元素增加一个标识id"mbwzbj"
- // }
- var href_link=this.itemPull[this.idPrefix + id]["href_link"];
-
- if (href_link != null&&href_link != 'null') //增加值不等于'null'的判断 By Rd 2015-12-15
- {
- var A = document.createElement("A");
- A.href = String(this.itemPull[this.idPrefix + id]["href_link"]);
- if (this.itemPull[this.idPrefix + id]["href_target"] != null) {
- A.target = this.itemPull[this.idPrefix + id]["href_target"];
- };
- A.style.display = "none";
- document.body.appendChild(A);
- A.click();
- if (A != null) {
- document.body.removeChild(A);
- A = null;
- };
- //<<<<<<<<<<<<<<<<< 关于菜单修改(文字部件显示当期栏目,个人首页开启控制) By Rd 2015-12-10
- //console.info('当前栏目 :'+this.dqlm);
- var userEdit_exit = (typeof(wd.topWindow.gxhymWindow.userEdit) != "undefined") ? 1 : 0;
- var parentItemId;
- var parentWzMC;
- var parentLmMc = "";
- //console.info('userEdit是否存在 :'+userEdit_exit);
- if ((id == 'gxhEdit' || id == 'gfEdit') && userEdit_exit == 0) { //进入个人首页编辑要对当前栏目进行判断 by Rd 2015-11-06
- alert('进入个人首页下才能开启编辑功能');
- return;
- }
- //因为部分菜单item是通过弹窗打开,所以还要加一步控制
- if (id != 'gxhEdit' && id != 'gfEdit' && this.itemPull[this.idPrefix + id]["href_link"].indexOf('popupWindow') == -1) {
- //var bjsy = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsy');
- //if(bjsy != null && (bjsy.style.display == '' || bjsy.style.display == 'inline'))
- // bjsy.style.display = 'none';
- if (wd.topWindow.userEditButton_personal) {
- wd.topWindow.userEditButton_personal.style.display = "none"
- }
- }
- if (id != 'gxhEdit' && id != 'gfEdit' && this.itemPull[this.idPrefix + id]["href_link"].indexOf('popupWindow') == -1) {
- // var bjsymb = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsymb');
- // if(bjsymb != null && (bjsymb.style.display == '' || bjsymb.style.display == 'inline'))
- // bjsymb.style.display = 'none';
- if (wd.topWindow.userEditButton_official) {
- wd.topWindow.userEditButton_official.style.display = "none"
- }
- }
-
- if(href_link.indexOf("wd.base.win2FitHeight")!=-1){
- wd.display.setHomeIconName(this.itemPull[this.idPrefix + id]["title"]);
- }
- // //若为编辑菜单,则title不改变
- // if (document.getElementById("mbwzbj") != null) { //该文字部件可能不存在
- // if (id != "editMenu" && id != "editGfMenu") {
- // this.dqlm = this.itemPull[this.idPrefix + id]["title"]; //改变当前栏目 By Rd 2015-11-06
- // parentItemId = this.itemPull[this.idPrefix + id]["parent"];
- // var url = this.itemPull[this.idPrefix + id]["href_link"].split('.do?')[1];
- // if (url != undefined) {
- // var wzid = url.split('_')[0];
- // parentWzMC = this.getcascadeTitle(wzid);
- //
- // if (this.itemPull[parentItemId] != undefined) {
- // parentLmMc = this.itemPull[parentItemId]["title"];
- // }
- // //路径不显示应用名称
- // // document.getElementById("mbwzbj").innerHTML="/"+parentWzMC+"/"+(parentLmMc==""||parentLmMc==parentWzMC?"":parentLmMc+"/")+this.itemPull[this.idPrefix + id]["title"];
- // document.getElementById("mbwzbj").innerHTML = (parentLmMc == "" || parentLmMc == parentWzMC ? "" : parentLmMc + "/") + this.itemPull[this.idPrefix + id]["title"];
- // } else {
- // document.getElementById("mbwzbj").innerHTML = this.itemPull[this.idPrefix + id]["title"];
- //
- // }
- // }
- // }
- //>>>>>>>>>>>>>>>>>>>>>>>>>>>>
- return;
- } else {
- //点击的是个人首页
- if (id == 'shortcutMenu') {
- // var bjsy = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsy');
- // var bjsymb = document.getElementById('i440163264').contentWindow.document.querySelector('.bjsymb');
- // if(bjsy != null && (bjsy.style.display == '' || bjsy.style.display == 'none'))
- // bjsy.style.display = 'inline';
- // if(bjsymb != null && (bjsymb.style.display == '' || bjsymb.style.display == 'none'))
- // bjsymb.style.display = 'inline';
- if (wd.topWindow.userEditButton_official) {
- wd.topWindow.userEditButton_official.style.display = "none"
- }
- if (wd.topWindow.userEditButton_personal) {
- wd.topWindow.userEditButton_personal.style.display = "none"
- }
- }
- };
- if (type.charAt(0) == "c")
- return;
- if (type.charAt(1) == "d")
- return;
- if (type.charAt(2) == "s")
- return;
-
- if (this.checkEvent("onClick")) {
- this._clearAndHide();
- // if (document.getElementById("mbwzbj") != null) { //该文字部件可能不存在
- // this.dqlm = this.itemPull[this.idPrefix + id]["title"]; //改变当前栏目 By Rd 2015-11-06
- // document.getElementById("mbwzbj").innerHTML = this.itemPull[this.idPrefix + id]["title"]; //系统菜单下项目
- // }
- if (this._isContextMenuVisible() && this.contextAutoHide)
- this._hideContextMenu();
- this.callEvent("onClick", [id, this.contextMenuZoneId, casState]);
- } else {
- if ((type.charAt(1) == "d") || (this.menuMode == "win" && type.charAt(2) == "t"))
- return;
- this._clearAndHide();
- if (this._isContextMenuVisible() && this.contextAutoHide)
- this._hideContextMenu();
- }
- };
- this._doOnTouchMenu = function (id) {
- if (this.menuTouched == false) {
- this.menuTouched = true;
- if (this.checkEvent("onTouch")) {
- this.callEvent("onTouch", [id]);
- }
- }
- };
- this._searchMenuNode = function (node, menu) {
- var m = new Array();
- for (var q = 0; q < menu.length; q++) {
- if (typeof(menu[q]) == "object") {
- if (menu[q].length == 5) {
- if (typeof(menu[q][0]) != "object") {
- if ((menu[q][0].replace(this.idPrefix, "") == node) && (q == 0)) {
- m = menu;
- }
- }
- };
- var j = this._searchMenuNode(node, menu[q]);
- if (j.length > 0) {
- m = j;
- }
- }
- };
- return m;
- };
- this._getMenuNodes = function (node) {
- var m = new Array;
- for (var a in this.itemPull) {
- if (this.itemPull[a]["parent"] == node) {
- m[m.length] = a;
- }
- };
- return m;
- };
- this._genStr = function (w) {
- var s = "";
- var z = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- for (var q = 0; q < w; q++)
- s += z.charAt(Math.round(Math.random() * (z.length - 1)));
- return s;
- };
- this.getItemType = function (id) {
- id = this.idPrefix + id;
- if (this.itemPull[id] == null) {
- return null;
- };
- return this.itemPull[id]["type"];
- };
- this.forEachItem = function (handler) {
- for (var a in this.itemPull) {
- handler(String(a).replace(this.idPrefix, ""));
- }
- };
- this._clearAndHide = function () {
- main_self.menuSelected = - 1;
- main_self.menuLastClicked = - 1;
- while (main_self._openedPolygons.length > 0) {
- main_self._openedPolygons.pop();
- };
- for (var q = 0; q < main_self._selectedSubItems.length;
- q++) {
- var id = main_self._selectedSubItems[q][0];
- if (main_self.idPull[id] != null) {
- if (main_self.itemPull[id]["state"] == "enabled") {
- if (main_self.idPull[id].className == "menu-item")
- main_self.idPull[id].className = "menu-item";
- if (main_self.idPull[id].className == "dhtmlxMenu_" + main_self.skin + "_TopLevel_Item_Selected") {
- if (main_self.itemPull[id]["cssNormal"] != null) {
- main_self.idPull[id].className = main_self.itemPull[id]["cssNormal"];
- } else {
- main_self.idPull[id].className = "dhtmlxMenu_" + main_self.skin + "_TopLevel_Item_Normal";
- }
- }
- }
- };
- main_self._hidePolygon(id);
- };
- main_self.menuTouched = false;
- if (main_self.context) {
- if (main_self.contextHideAllMode) {
- main_self._hidePolygon(main_self.idPrefix + main_self.topId);
- main_self.zInd = main_self.zIndInit;
- } else {
- main_self.zInd = main_self.zIndInit + main_self.zIndStep;
- }
- }
- };
- this._doOnLoad = function () {};
- this.loadXML = function (xmlFile, onLoadFunction) {
- if (onLoadFunction)
- this._doOnLoad = function () {
- onLoadFunction();
- };
- this.callEvent("onXLS", []);
- this._xmlLoader.loadXML(xmlFile);
- };
- this.loadXMLString = function (xmlString, onLoadFunction) {
- if (onLoadFunction)
- this._doOnLoad = function () {
- onLoadFunction();
- };
- this._xmlLoader.loadXMLString(xmlString);
- };
- this._buildMenu = function (t, parentId) {
- var u = 0;
- for (var q = 0; q < t.childNodes.length; q++) {
- if (t.childNodes[q].tagName == this.itemTagName) {
- var r = t.childNodes[q];
- var item = {};
- item["id"] = this.idPrefix + (r.getAttribute("id") || this._genStr(24));
- item["title"] = r.getAttribute("text") || "";
- item["imgen"] = r.getAttribute("img") || "";
- item["imgdis"] = r.getAttribute("imgdis") || "";
- item["tip"] = "";
- item["hotkey"] = "";
- if (r.getAttribute("cssNormal") != null) {
- item["cssNormal"] = r.getAttribute("cssNormal");
- };
- item["type"] = r.getAttribute("type") || "item";
- if (item["type"] == "checkbox") {
- item["checked"] = (r.getAttribute("checked") != null);
- item["imgen"] = "chbx_" + (item["checked"] ? "1" : "0");
- item["imgdis"] = item["imgen"];
- };
- if (item["type"] == "radio") {
- item["checked"] = (r.getAttribute("checked") != null);
- item["imgen"] = "rdbt_" + (item["checked"] ? "1" : "0");
- item["imgdis"] = item["imgen"];
- item["group"] = r.getAttribute("group") || this._genStr(24);
- if (this.radio[item["group"]] == null) {
- this.radio[item["group"]] = new Array();
- };
- this.radio[item["group"]][this.radio[item["group"]].length] = item["id"];
- };
- item["state"] = (r.getAttribute("enabled") != null || r.getAttribute("disabled") != null ? (r.getAttribute("enabled") == "false" || r.getAttribute("disabled") == "true" ? "disabled" : "enabled") : "enabled");
- item["parent"] = (parentId != null ? parentId : this.idPrefix + this.topId);
- item["complex"] = (this.dLoad ? (r.getAttribute("complex") != null ? true : false) : (this._buildMenu(r, item["id"]) > 0));
- if (this.dLoad && item["complex"]) {
- item["loaded"] = "no";
- };
- this.itemPull[item["id"]] = item;
- for (var w = 0; w < r.childNodes.length; w++) {
- var tagNm = r.childNodes[w].tagName;
- if (tagNm != null) {
- tagNm = tagNm.toLowerCase();
- };
- if (tagNm == this.userDataTagName) {
- var d = r.childNodes[w];
- if (d.getAttribute("name") != null) {
- this.userData[item["id"] + "_" + d.getAttribute("name")] = (d.firstChild.nodeValue != null ? d.firstChild.nodeValue : "");
- }
- };
- if (tagNm == this.itemTextTagName) {
- item["title"] = r.childNodes[w].firstChild.nodeValue;
- };
- if (tagNm == this.itemTipTagName) {
- item["tip"] = r.childNodes[w].firstChild.nodeValue;
- };
- if (tagNm == this.itemHotKeyTagName) {
- item["hotkey"] = r.childNodes[w].firstChild.nodeValue;
- };
- if (tagNm == this.itemHrefTagName && item["type"] == "item") {
- item["href_link"] = r.childNodes[w].firstChild.nodeValue;
- if (r.childNodes[w].getAttribute("target") != null) {
- item["href_target"] = r.childNodes[w].getAttribute("target");
- }
- }
- };
- u++;
- }
- };
- return u;
- };
- this._xmlParser = function () {
- if (main_self.dLoad) {
- var t = this.getXMLTopNode("menu");
- parentId = (t.getAttribute("parentId") != null ? t.getAttribute("parentId") : null);
- if (parentId == null) {
- main_self._buildMenu(t, null);
- main_self._initTopLevelMenu();
- } else {
- main_self._buildMenu(t, main_self.idPrefix + parentId);
- main_self._addSubMenuPolygon(main_self.idPrefix + parentId, main_self.idPrefix + parentId);
- if (main_self.menuSelected == main_self.idPrefix + parentId) {
- var pId = main_self.idPrefix + parentId;
- var isTop = main_self.itemPull[main_self.idPrefix + parentId]["parent"] == main_self.idPrefix + main_self.topId;
- var level = ((isTop && (!main_self.context)) ? main_self.dirTopLevel : main_self.dirSubLevel);
- var isShow = false;
- if (isTop && main_self.menuModeTopLevelTimeout && main_self.menuMode == "web" && !main_self.context) {
- var item = main_self.idPull[main_self.idPrefix + parentId];
- if (item._mouseOver == true) {
- var delay = main_self.menuModeTopLevelTimeoutTime - (new Date().getTime() - item._dynLoadTM);
- if (delay > 1) {
- item._menuOpenTM = window.setTimeout(function () {
- main_self._showPolygon(pId, level);
- }, delay);
- isShow = true;
- }
- }
- };
- if (!isShow) {
- main_self._showPolygon(pId, level);
- }
- };
- main_self.itemPull[main_self.idPrefix + parentId]["loaded"] = "yes";
- if (main_self.loaderIcon == true) {
- main_self._updateLoaderIcon(main_self.idPrefix + parentId, false);
- }
- };
- this.destructor();
- main_self.callEvent("onXLE", []);
- } else {
- var t = this.getXMLTopNode("menu");
- main_self._buildMenu(t, null);
- main_self.init();
- main_self.callEvent("onXLE", []);
- main_self._doOnLoad();
- }
- };
- this._xmlLoader = new dtmlXMLLoaderObject(this._xmlParser, window);
- this._showSubLevelItem = function (id, back) {
- if (document.getElementById("arrow_" + this.idPrefix + id) != null) {
- document.getElementById("arrow_" + this.idPrefix + id).style.display = (back ? "none" : "");
- };
- if (document.getElementById("image_" + this.idPrefix + id) != null) {
- document.getElementById("image_" + this.idPrefix + id).style.display = (back ? "none" : "");
- };
- if (document.getElementById(this.idPrefix + id) != null) {
- document.getElementById(this.idPrefix + id).style.display = (back ? "" : "none");
- }
- };
- this._hideSubLevelItem = function (id) {
- this._showSubLevelItem(id, true)
- };
- this.idPrefix = this._genStr(12);
- this._bodyClick = function (e) {
- e = e || event;
- if (e.button == 2 || (_isOpera && e.ctrlKey == true))
- return;
- if (main_self.context) {
- if (main_self.contextAutoHide && (!_isOpera || (main_self._isContextMenuVisible() && _isOpera)))
- main_self._hideContextMenu();
- } else {
- main_self._clearAndHide();
- }
- };
- this._bodyContext = function (e) {
- e = e || event;
- var t = (e.srcElement || e.target).className;
- // console.info("dhtmlxmenu捕获classname :"+t);
- if (t.search("dhtmlxMenu") != - 1 && t.search("SubLevelArea") != - 1)
- return;
- var toHide = true;
- var testZone = e.target || e.srcElement;
- if (testZone.id != null)
- if (main_self.isContextZone(testZone.id))
- toHide = false;
- if (testZone == document.body)
- toHide = false;
- if (toHide)
- main_self.hideContextMenu();
- };
- if (_isIE) {
- document.body.attachEvent("onclick", this._bodyClick);
- document.body.attachEvent("oncontextmenu", this._bodyContext);
- } else {
- window.addEventListener("click", this._bodyClick, false);
- window.addEventListener("contextmenu", this._bodyContext, false);
- };
- this._UID = this._genStr(32);
- dhtmlxMenuObjectLiveInstances[this._UID] = this;
- dhtmlxEventable(this);
- return this;
- };
- dhtmlXMenuObject.prototype.init = function () {
- console.log("TTTTTTTTTTTT init");
- if (this._isInited == true)
- return;
- if (this.dLoad) {
- this.callEvent("onXLS", []);
- this._xmlLoader.loadXML(this.dLoadUrl + this.dLoadSign + "action=loadMenu&etc=" + new Date().getTime());
- } else {
- this._initTopLevelMenu();
- this._isInited = true;
- }
- };
- dhtmlXMenuObject.prototype._countVisiblePolygonItems = function (id) {
- var count = 0;
- for (var a in this.itemPull) {
- var par = this.itemPull[a]["parent"];
- var tp = this.itemPull[a]["type"];
- if (this.idPull[a] != null) {
- if (par == id && (tp == "item" || tp == "radio" || tp == "checkbox") && this.idPull[a].style.display != "none") {
- count++;
- }
- }
- };
- return count;
- };
- dhtmlXMenuObject.prototype._redefineComplexState = function (id) {
- if (this.idPrefix + this.topId == id) {
- return;
- };
- if ((this.idPull["polygon_" + id] != null) && (this.idPull[id] != null)) {
- var u = this._countVisiblePolygonItems(id);
- if ((u > 0) && (!this.itemPull[id]["complex"])) {
- this._updateItemComplexState(id, true, false);
- };
- if ((u == 0) && (this.itemPull[id]["complex"])) {
- this._updateItemComplexState(id, false, false);
- }
- }
- };
- dhtmlXMenuObject.prototype._updateItemComplexState = function (id, state, over) {
- if ((!this.context) && (this._getItemLevelType(id.replace(this.idPrefix, "")) == "TopLevel")) {
- this.itemPull[id]["complex"] = state;
- return;
- };
- if ((this.idPull[id] == null) || (this.itemPull[id] == null)) {
- return;
- };
- this.itemPull[id]["complex"] = state;
- if (id == this.idPrefix + this.topId)
- return;
- var arrowObj = null;
- var item = this.idPull[id].childNodes[this._rtl ? 0 : 2];
- if (item.childNodes[0])
- if (String(item.childNodes[0].className).search("complex_arrow") === 0)
- arrowObj = item.childNodes[0];
- if (this.itemPull[id]["complex"]) {
- if (arrowObj == null) {
- arrowObj = document.createElement("DIV");
- arrowObj.className = "complex_arrow";
- arrowObj.id = "arrow_" + id;
- while (item.childNodes.length > 0)
- item.removeChild(item.childNodes[0]);
- item.appendChild(arrowObj);
- };
- if (this.dLoad && (this.itemPull[id]["loaded"] == "get") && this.loaderIcon) {
- if (arrowObj.className != "complex_arrow_loading")
- arrowObj.className = "complex_arrow_loading";
- } else {
- arrowObj.className = "complex_arrow";
- };
- return;
- };
- if ((!this.itemPull[id]["complex"]) && (arrowObj != null)) {
- item.removeChild(arrowObj);
- if (this.itemPull[id]["hotkey_backup"] != null && this.setHotKey) {
- this.setHotKey(id.replace(this.idPrefix, ""), this.itemPull[id]["hotkey_backup"]);
- }
- }
- };
- dhtmlXMenuObject.prototype._getItemLevelType = function (id) {
- return (this.itemPull[this.idPrefix + id]["parent"] == this.idPrefix + this.topId ? "TopLevel" : "SubLevelArea");
- };
- dhtmlXMenuObject.prototype._redistribTopLevelSelection = function (id, parent) {
- var i = this._getSubItemToDeselectByPolygon("parent");
- this._removeSubItemFromSelected( - 1, - 1);
- for (var q = 0; q < i.length; q++) {
- if (i[q] != id) {
- this._hidePolygon(i[q]);
- };
- if ((this.idPull[i[q]] != null) && (i[q] != id)) {
- this.idPull[i[q]].className = this.idPull[i[q]].className.replace(/Selected/g, "Normal");
- }
- };
- if (this.itemPull[this.idPrefix + id]["state"] == "enabled") {
- this.idPull[this.idPrefix + id].className = "dhtmlxMenu_" + this.skin + "_TopLevel_Item_Selected";
- this._addSubItemToSelected(this.idPrefix + id, "parent");
- this.menuSelected = (this.menuMode == "win" ? (this.menuSelected != - 1 ? id : this.menuSelected) : id);
- if ((this.itemPull[this.idPrefix + id]["complex"]) && (this.menuSelected != - 1)) {
- this._showPolygon(this.idPrefix + id, this.dirTopLevel);
- }
- }
- };
- dhtmlXMenuObject.prototype._initTopLevelMenu = function () {
- this.dirTopLevel = "bottom";
- this.dirSubLevel = (this._rtl ? "left" : "right");
- if (this.context) {
- this.idPull[this.idPrefix + this.topId] = new Array(0, 0);
- this._addSubMenuPolygon(this.idPrefix + this.topId, this.idPrefix + this.topId);
- } else {
- var m = this._getMenuNodes(this.idPrefix + this.topId);
- console.log("TTTTTTTT _initTopLevelMenu"+ m +"("+ m.length +")");
- for (var q = 0; q < m.length; q++) {
- if (this.itemPull[m[q]]["type"] == "item")
- this._renderToplevelItem(m[q], null);
- if (this.itemPull[m[q]]["type"] == "separator")
- this._renderSeparator(m[q], null);
- }
- }
- };
- dhtmlXMenuObject.prototype._renderToplevelItem = function (id, pos) {
- var main_self = this;
- var m = document.createElement("DIV");
- m.id = id;
- if (this.itemPull[id]["state"] == "enabled" && this.itemPull[id]["cssNormal"] != null) {
- // m.className = this.itemPull[id]["cssNormal"];
- m.className = "dhtmlxMenu_" + this.skin + "_TopLevel_Item_" + "Normal";
- m.className += " menu-group";
- } else {
- // m.className = "dhtmlxMenu_" + this.skin + "_TopLevel_Item_" + (this.itemPull[id]["state"] == "enabled" ? "Normal" : "Disabled");
- m.className = "dhtmlxMenu_" + this.skin + "_TopLevel_Item_" + "Normal";
- m.className += " menu-group";
- // m.className
- };
- if (this.itemPull[id]["title"] != "") {
- var t1 = document.createElement("DIV");
- t1.className = "top_level_text";
- var title = this.itemPull[id]["title"];
- if ("系统" == title && id == this.idPrefix + (window.menuRootName?window.menuRootName:"env")) {
- t1.className += " system_menu cursor-click";
- t1.style.backgroundImage = "url(" + (((MenuSetting) || {}).imagePath + 'logo/invertLogo.png') + ")";
- t1.style.backgroundPosition = "center";
- m.className += " menu-vLine cursor-click";
- // m.className -= "menu-group";
- m.className = m.className.replace( new RegExp( "(\\s|^)" + "menu-group" + "(\\s|$)" )," ");
- m.style.float = "left";
- m.style.width = "69px";
- m.style.height = "70px";
- m.style.padding = "0px";
- m.style.verticalAlign = "middle";
- m.style.marginLeft = "0px";
- m.style.marginRight = "0px";
- m.style.marginTop = "-35px";
- m.style.background = "none";
- m.style.fontSize = "0px";
- }
- t1.innerHTML = title;
- m.appendChild(t1);
- };
- if (this.itemPull[id]["tip"].length > 0)
- m.title = this.itemPull[id]["tip"];
- if ((this.itemPull[id]["imgen"] != "") || (this.itemPull[id]["imgdis"] != "")) {
- var imgTop = this.itemPull[id][(this.itemPull[id]["state"] == "enabled") ? "imgen" : "imgdis"];
- if (imgTop) {
- var img = document.createElement("IMG");
- img.border = "0";
- img.id = "image_" + id;
- img.src = this.imagePath + imgTop;
- img.className = "dhtmlxMenu_TopLevel_Item_Icon";
- if (m.childNodes.length > 0 && !this._rtl)
- m.insertBefore(img, m.childNodes[0]);
- else
- m.appendChild(img);
- }
- };
- m.onselectstart = function (e) {
- e = e || event;
- e.returnValue = false;
- return false;
- };
- m.oncontextmenu = function (e) {
- e = e || event;
- e.returnValue = false;
- return false;
- };
- if (!this.cont) {
- this.cont = document.createElement("DIV");
- this.cont.dir = "ltr";
- this.cont.className = (this._align == "right" ? "align_right" : "align_left");
- this.base.appendChild(this.cont);
- };
- if (pos != null) {
- pos++;
- if (pos < 0)
- pos = 0;
- if (pos > this.cont.childNodes.length - 1)
- pos = null;
- };
- if (pos != null)
- this.cont.insertBefore(m, this.cont.childNodes[pos]);
- else
- this.cont.appendChild(m);
- this.idPull[m.id] = m;
- if (this.itemPull[id]["complex"] && (!this.dLoad))
- this._addSubMenuPolygon(this.itemPull[id]["id"], this.itemPull[id]["id"]);
- m.onmouseover = function () {
- if (main_self.menuMode == "web") {
- window.clearTimeout(main_self.menuTimeoutHandler);
- };
- var i = main_self._getSubItemToDeselectByPolygon("parent");
- main_self._removeSubItemFromSelected( - 1, - 1);
- for (var q = 0; q < i.length; q++) {
- if (i[q] != this.id) {
- main_self._hidePolygon(i[q]);
- };
- if ((main_self.idPull[i[q]] != null) && (i[q] != this.id)) {
- if (main_self.itemPull[i[q]]["cssNormal"] != null) {
- main_self.idPull[i[q]].className = main_self.itemPull[i[q]]["cssNormal"];
- } else {
- if (main_self.idPull[i[q]].className == "menu-item")
- main_self.idPull[i[q]].className = "menu-item";
- // main_self.idPull[i[q]].className = main_self.idPull[i[q]].className.replace(/Selected/g, "Normal");
- }
- }
- };
- if (main_self.itemPull[this.id]["state"] == "enabled") {
- // this.className = "dhtmlxMenu_" + main_self.skin + "_TopLevel_Item_Selected";
- main_self._addSubItemToSelected(this.id, "parent");
- main_self.menuSelected = (main_self.menuMode == "win" ? (main_self.menuSelected != - 1 ? this.id : main_self.menuSelected) : this.id);
- if (main_self.dLoad && (main_self.itemPull[this.id]["loaded"] == "no")) {
- if (main_self.menuModeTopLevelTimeout && main_self.menuMode == "web" && !main_self.context) {
- this._mouseOver = true;
- this._dynLoadTM = new Date().getTime();
- };
- var xmlLoader = new dtmlXMLLoaderObject(main_self._xmlParser, window);
- main_self.itemPull[this.id]["loaded"] = "get";
- main_self.callEvent("onXLS", []);
- xmlLoader.loadXML(main_self.dLoadUrl + main_self.dLoadSign + "action=loadMenu&parentId=" + this.id.replace(main_self.idPrefix, "") + "&etc=" + new Date().getTime());
- };
- if ((!main_self.dLoad) || (main_self.dLoad && (main_self.itemPull[this.id]["loaded"] == "yes"))) {
- if ((main_self.itemPull[this.id]["complex"]) && (main_self.menuSelected != - 1)) {
- if (main_self.menuModeTopLevelTimeout && main_self.menuMode == "web" && !main_self.context) {
- this._mouseOver = true;
- var showItemId = this.id;
- this._menuOpenTM = window.setTimeout(function () {
- main_self._showPolygon(showItemId, main_self.dirTopLevel);
- }, main_self.menuModeTopLevelTimeoutTime);
- } else {
- main_self._showPolygon(this.id, main_self.dirTopLevel);
- }
- }
- }
- };
- main_self._doOnTouchMenu(this.id.replace(main_self.idPrefix, ""));
- };
- m.onmouseout = function () {
- if (!((main_self.itemPull[this.id]["complex"]) && (main_self.menuSelected != - 1)) && (main_self.itemPull[this.id]["state"] == "enabled")) {
- if (main_self.itemPull[this.id]["cssNormal"] != null) {
- // m.className = main_self.itemPull[this.id]["cssNormal"];
- } else {
- // m.className = "dhtmlxMenu_" + main_self.skin + "_TopLevel_Item_Normal";
- }
- };
- if (main_self.menuMode == "web") {
- window.clearTimeout(main_self.menuTimeoutHandler);
- main_self.menuTimeoutHandler = window.setTimeout(function () {
- main_self._clearAndHide();
- }, main_self.menuTimeoutMsec, "JavaScript");
- };
- if (main_self.menuModeTopLevelTimeout && main_self.menuMode == "web" && !main_self.context) {
- this._mouseOver = false;
- window.clearTimeout(this._menuOpenTM);
- }
- };
- m.onclick = function (e) {
- if (main_self.menuMode == "web") {
- window.clearTimeout(main_self.menuTimeoutHandler);
- };
- if (main_self.menuMode != "web" && main_self.itemPull[this.id]["state"] == "disabled") {
- return;
- };
- e = e || event;
- e.cancelBubble = true;
- e.returnValue = false;
- if (main_self.menuMode == "win") {
- if (main_self.itemPull[this.id]["complex"]) {
- if (main_self.menuSelected == this.id) {
- main_self.menuSelected = - 1;
- var s = false;
- } else {
- main_self.menuSelected = this.id;
- var s = true;
- };
- if (s) {
- main_self._showPolygon(this.id, main_self.dirTopLevel);
- } else {
- main_self._hidePolygon(this.id);
- }
- }
- };
- var tc = (main_self.itemPull[this.id]["complex"] ? "c" : "-");
- var td = (main_self.itemPull[this.id]["state"] != "enabled" ? "d" : "-");
- var cas = {
- "ctrl": e.ctrlKey,
- "alt": e.altKey,
- "shift": e.shiftKey
- };
- main_self._doOnClick(this.id.replace(main_self.idPrefix, ""), tc + td + "t", cas);
- return false;
- }
- };
- dhtmlXMenuObject.prototype.setImagePath = function () {};
- dhtmlXMenuObject.prototype.setIconsPath = function (path) {
- this.imagePath = path;
- };
- dhtmlXMenuObject.prototype.setIconPath = dhtmlXMenuObject.prototype.setIconsPath;
- dhtmlXMenuObject.prototype._updateItemImage = function (id, levelType) {
- id = this.idPrefix + id;
- var isTopLevel = (this.itemPull[id]["parent"] == this.idPrefix + this.topId && !this.context);
- var imgObj = null;
- if (isTopLevel) {
- for (var q = 0; q < this.idPull[id].childNodes.length;
- q++) {
- try {
- if (this.idPull[id].childNodes[q].className == "dhtmlxMenu_TopLevel_Item_Icon")
- imgObj = this.idPull[id].childNodes[q];
- } catch (e) {}
- }
- } else {
- try {
- var imgObj = this.idPull[id].childNodes[this._rtl ? 2 : 0].childNodes[0];
- } catch (e) {}
- };
- if (this.itemPull[id]["type"] == "radio") {
- var imgSrc = this.itemPull[id][(this.itemPull[id]["state"] == "enabled" ? "imgen" : "imgdis")];
- } else {
- var imgSrc = this.itemPull[id][(this.itemPull[id]["state"] == "enabled" ? "imgen" : "imgdis")];
- };
- if (imgSrc.length > 0) {
- if (imgObj != null) {
- imgObj.src = this.imagePath + imgSrc;
- } else {
- if (isTopLevel) {
- var imgObj = document.createElement("IMG");
- imgObj.className = "dhtmlxMenu_TopLevel_Item_Icon";
- imgObj.src = this.imagePath + imgSrc;
- imgObj.border = "0";
- imgObj.id = "image_" + id;
- if (!this._rtl && this.idPull[id].childNodes.length > 0)
- this.idPull[id].insertBefore(imgObj, this.idPull[id].childNodes[0]);
- else
- this.idPull[id].appendChild(imgObj);
- } else {
- var imgObj = document.createElement("IMG");
- imgObj.className = "sub_icon";
- imgObj.src = this.imagePath + imgSrc;
- imgObj.border = "0";
- imgObj.id = "image_" + id;
- var item = this.idPull[id].childNodes[this._rtl ? 2 : 0];
- while (item.childNodes.length > 0)
- item.removeChild(item.childNodes[0]);
- item.appendChild(imgObj);
- }
- }
- } else {
- if (imgObj != null)
- imgObj.parentNode.removeChild(imgObj);
- }
- };
- dhtmlXMenuObject.prototype.removeItem = function (id, _isTId, _recCall) {
- if (!_isTId)
- id = this.idPrefix + id;
- var pId = null;
- if (id != this.idPrefix + this.topId) {
- if (this.itemPull[id] == null)
- return;
- var t = this.itemPull[id]["type"];
- if (t == "separator") {
- var item = this.idPull["separator_" + id];
- if (this.itemPull[id]["parent"] == this.idPrefix + this.topId) {
- item.onclick = null;
- item.onselectstart = null;
- item.id = null;
- item.parentNode.removeChild(item);
- } else {
- item.childNodes[0].childNodes[0].onclick = null;
- item.childNodes[0].childNodes[0].onselectstart = null;
- item.childNodes[0].childNodes[0].id = null;
- item.childNodes[0].removeChild(item.childNodes[0].childNodes[0]);
- item.removeChild(item.childNodes[0]);
- item.parentNode.removeChild(item);
- };
- this.idPull["separator_" + id] = null;
- this.itemPull[id] = null;
- delete this.idPull["separator_" + id];
- delete this.itemPull[id];
- item = null;
- } else {
- pId = this.itemPull[id]["parent"];
- var item = this.idPull[id];
- item.onclick = null;
- item.oncontextmenu = null;
- item.onmouseover = null;
- item.onmouseout = null;
- item.onselectstart = null;
- item.id = null;
- while (item.childNodes.length > 0)
- item.removeChild(item.childNodes[0]);
- item.parentNode.removeChild(item);
- this.idPull[id] = null;
- this.itemPull[id] = null;
- delete this.idPull[id];
- delete this.itemPull[id];
- item = null;
- };
- t = null;
- };
- for (var a in this.itemPull)
- if (this.itemPull[a]["parent"] == id)
- this.removeItem(a, true, true);
- var p2 = new Array(id);
- if (pId != null && !_recCall) {
- if (this.idPull["polygon_" + pId] != null) {
- if (this.idPull["polygon_" + pId].tbd.childNodes.length == 0) {
- p2.push(pId);
- this._updateItemComplexState(pId, false, false);
- }
- }
- };
- for (var q = 0; q < p2.length; q++) {
- if (this.idPull["polygon_" + p2[q]]) {
- var p = this.idPull["polygon_" + p2[q]];
- p.onclick = null;
- p.oncontextmenu = null;
- p.tbl.removeChild(p.tbd);
- p.tbd = null;
- p.removeChild(p.tbl);
- p.tbl = null;
- p.id = null;
- p.parentNode.removeChild(p);
- p = null;
- if (this._isIE6) {
- var pc = "polygon_" + p2[q] + "_ie6cover";
- if (this.idPull[pc] != null) {
- document.body.removeChild(this.idPull[pc]);
- delete this.idPull[pc];
- }
- };
- if (this.idPull["arrowup_" + id] != null && this._removeArrow)
- this._removeArrow("arrowup_" + id);
- if (this.idPull["arrowdown_" + id] != null && this._removeArrow)
- this._removeArrow("arrowdown_" + id);
- this.idPull["polygon_" + p2[q]] = null;
- delete this.idPull["polygon_" + p2[q]];
- }
- };
- p2 = null;
- };
- dhtmlXMenuObject.prototype._getAllParents = function (id) {
- var parents = new Array();
- for (var a in this.itemPull) {
- if (this.itemPull[a]["parent"] == id) {
- parents[parents.length] = this.itemPull[a]["id"];
- if (this.itemPull[a]["complex"]) {
- var t = this._getAllParents(this.itemPull[a]["id"]);
- for (var q = 0; q < t.length; q++) {
- parents[parents.length] = t[q];
- }
- }
- }
- };
- return parents;
- };
- dhtmlXMenuObject.prototype.renderAsContextMenu = function () {
- this.context = true;
- if (this.base._autoSkinUpdate == true) {
- this.base.className = this.base.className.replace("dhtmlxMenu_" + this.skin + "_Middle", "");
- this.base._autoSkinUpdate = false;
- };
- if (this.addBaseIdAsContextZone != null) {
- this.addContextZone(this.addBaseIdAsContextZone);
- }
- };
- dhtmlXMenuObject.prototype.addContextZone = function (zoneId) {
- if (zoneId == document.body) {
- zoneId = "document.body." + this.idPrefix;
- var zone = document.body;
- } else {
- var zone = document.getElementById(zoneId);
- };
- var zoneExists = false;
- for (var a in this.contextZones) {
- zoneExists = zoneExists || (a == zoneId) || (this.contextZones[a] == zone);
- };
- if (zoneExists == true)
- return false;
- this.contextZones[zoneId] = zone;
- var main_self = this;
- if (_isOpera) {
- this.operaContext = function (e) {
- main_self._doOnContextMenuOpera(e, main_self);
- };
- zone.addEventListener("mouseup", this.operaContext, false);
- } else {
- if (zone.oncontextmenu != null && !zone._oldContextMenuHandler)
- zone._oldContextMenuHandler = zone.oncontextmenu;
- zone.oncontextmenu = function (e) {
- for (var q in dhtmlxMenuObjectLiveInstances) {
- if (q != main_self._UID) {
- if (dhtmlxMenuObjectLiveInstances[q].context) {
- dhtmlxMenuObjectLiveInstances[q]._hideContextMenu();
- }
- }
- };
- e = e || event;
- e.cancelBubble = true;
- e.returnValue = false;
- main_self._doOnContextBeforeCall(e, this);
- return false;
- }
- }
- };
- dhtmlXMenuObject.prototype._doOnContextMenuOpera = function (e, main_self) {
- for (var q in dhtmlxMenuObjectLiveInstances) {
- if (q != main_self._UID) {
- if (dhtmlxMenuObjectLiveInstances[q].context) {
- dhtmlxMenuObjectLiveInstances[q]._hideContextMenu();
- }
- }
- };
- e.cancelBubble = true;
- e.returnValue = false;
- if (e.button == 0 && e.ctrlKey == true) {
- main_self._doOnContextBeforeCall(e, this);
- };
- return false;
- };
- dhtmlXMenuObject.prototype.removeContextZone = function (zoneId) {
- if (!this.isContextZone(zoneId))
- return false;
- if (zoneId == document.body)
- zoneId = "document.body." + this.idPrefix;
- var zone = this.contextZones[zoneId];
- if (_isOpera) {
- zone.removeEventListener("mouseup", this.operaContext, false);
- } else {
- zone.oncontextmenu = (zone._oldContextMenuHandler != null ? zone._oldContextMenuHandler : null);
- zone._oldContextMenuHandler = null;
- };
- try {
- this.contextZones[zoneId] = null;
- delete this.contextZones[zoneId];
- } catch (e) {};
- return true;
- };
- dhtmlXMenuObject.prototype.isContextZone = function (zoneId) {
- if (zoneId == document.body && this.contextZones["document.body." + this.idPrefix] != null)
- return true;
- var isZone = false;
- if (this.contextZones[zoneId] != null) {
- if (this.contextZones[zoneId] == document.getElementById(zoneId))
- isZone = true;
- };
- return isZone;
- };
- dhtmlXMenuObject.prototype._isContextMenuVisible = function () {
- if (this.idPull["polygon_" + this.idPrefix + this.topId] == null)
- return false;
- return (this.idPull["polygon_" + this.idPrefix + this.topId].style.display == "");
- };
- dhtmlXMenuObject.prototype._showContextMenu = function (x, y, zoneId) {
- this._clearAndHide();
- if (this.idPull["polygon_" + this.idPrefix + this.topId] == null)
- return false;
- window.clearTimeout(this.menuTimeoutHandler);
- this.idPull[this.idPrefix + this.topId] = new Array(x, y);
- this._showPolygon(this.idPrefix + this.topId, "bottom");
- this.callEvent("onContextMenu", [zoneId]);
- };
- dhtmlXMenuObject.prototype._hideContextMenu = function () {
- if (this.idPull["polygon_" + this.idPrefix + this.topId] == null)
- return false;
- this._clearAndHide();
- this._hidePolygon(this.idPrefix + this.topId);
- this.zInd = this.zIndInit;
- };
- dhtmlXMenuObject.prototype._doOnContextBeforeCall = function (e, cZone) {
- this.contextMenuZoneId = cZone.id;
- this._clearAndHide();
- this._hideContextMenu();
- var p = (e.srcElement || e.target);
- var px = (_isIE || _isOpera || _KHTMLrv ? e.offsetX : e.layerX);
- var py = (_isIE || _isOpera || _KHTMLrv ? e.offsetY : e.layerY);
- var mx = getAbsoluteLeft(p) + px;
- var my = getAbsoluteTop(p) + py;
- if (this.checkEvent("onBeforeContextMenu")) {
- if (this.callEvent("onBeforeContextMenu", [cZone.id])) {
- if (this.contextAutoShow) {
- this._showContextMenu(mx, my);
- this.callEvent("onAfterContextMenu", [cZone.id]);
- }
- }
- } else {
- if (this.contextAutoShow) {
- this._showContextMenu(mx, my);
- this.callEvent("onAfterContextMenu", [cZone.id]);
- }
- }
- };
- dhtmlXMenuObject.prototype.showContextMenu = function (x, y) {
- this._showContextMenu(x, y, false);
- };
- dhtmlXMenuObject.prototype.hideContextMenu = function () {
- this._hideContextMenu();
- };
- dhtmlXMenuObject.prototype._autoDetectVisibleArea = function () {
- if (this._isVisibleArea)
- return;
- this.menuX1 = document.body.scrollLeft;
- this.menuX2 = this.menuX1 + (window.innerWidth || document.body.clientWidth);
- this.menuY1 = Math.max((_isIE ? document.documentElement : document.getElementsByTagName("html")[0]).scrollTop, document.body.scrollTop);
- this.menuY2 = this.menuY1 + (_isIE ? Math.max(document.documentElement.clientHeight || 0, document.documentElement.offsetHeight || 0, document.body.clientHeight || 0) : window.innerHeight);
- };
- dhtmlXMenuObject.prototype.getItemPosition = function (id) {
- id = this.idPrefix + id;
- var pos = - 1;
- if (this.itemPull[id] == null)
- return pos;
- var parent = this.itemPull[id]["parent"];
- var obj = (this.idPull["polygon_" + parent] != null ? this.idPull["polygon_" + parent].tbd : this.cont);
- for (var q = 0; q < obj.childNodes.length; q++) {
- if (obj.childNodes[q] == this.idPull["separator_" + id] || obj.childNodes[q] == this.idPull[id]) {
- pos = q;
- }
- };
- return pos;
- };
- dhtmlXMenuObject.prototype.setItemPosition = function (id, pos) {
- id = this.idPrefix + id;
- if (this.idPull[id] == null) {
- return;
- };
- var isOnTopLevel = (this.itemPull[id]["parent"] == this.idPrefix + this.topId);
- var itemData = this.idPull[id];
- var itemPos = this.getItemPosition(id.replace(this.idPrefix, ""));
- var parent = this.itemPull[id]["parent"];
- var obj = (this.idPull["polygon_" + parent] != null ? this.idPull["polygon_" + parent].tbd : this.cont);
- obj.removeChild(obj.childNodes[itemPos]);
- if (pos < 0)
- pos = 0;
- if (isOnTopLevel && pos < 1) {
- pos = 1;
- };
- if (pos < obj.childNodes.length) {
- obj.insertBefore(itemData, obj.childNodes[pos]);
- } else {
- obj.appendChild(itemData);
- }
- };
- dhtmlXMenuObject.prototype.getParentId = function (id) {
- id = this.idPrefix + id;
- if (this.itemPull[id] == null) {
- return null;
- };
- return ((this.itemPull[id]["parent"] != null ? this.itemPull[id]["parent"] : this.topId).replace(this.idPrefix, ""));
- };
- dhtmlXMenuObject.prototype.addNewSibling = function (nextToId, itemId, itemText, disabled, imgEnabled, imgDisabled) {
- var id = this.idPrefix + (itemId != null ? itemId : this._genStr(24));
- var parentId = this.idPrefix + (nextToId != null ? this.getParentId(nextToId) : this.topId);
- this._addItemIntoGlobalStrorage(id, parentId, itemText, "item", disabled, imgEnabled, imgDisabled);
- if ((parentId == this.idPrefix + this.topId) && (!this.context)) {
- this._renderToplevelItem(id, this.getItemPosition(nextToId));
- } else {
- this._renderSublevelItem(id, this.getItemPosition(nextToId));
- }
- };
- dhtmlXMenuObject.prototype.addNewChild = function (parentId, pos, itemId, itemText, disabled, imgEnabled, imgDisabled) {
- if (parentId == null) {
- if (this.context) {
- parentId = this.topId;
- } else {
- this.addNewSibling(parentId, itemId, itemText, disabled, imgEnabled, imgDisabled);
- if (pos != null)
- this.setItemPosition(itemId, pos);
- return;
- }
- };
- itemId = this.idPrefix + (itemId != null ? itemId : this._genStr(24));
- if (this.setHotKey)
- this.setHotKey(parentId, "");
- parentId = this.idPrefix + parentId;
- this._addItemIntoGlobalStrorage(itemId, parentId, itemText, "item", disabled, imgEnabled, imgDisabled);
- if (this.idPull["polygon_" + parentId] == null) {
- this._renderSublevelPolygon(parentId, parentId);
- };
- this._renderSublevelItem(itemId, pos - 1);
- this._redefineComplexState(parentId);
- };
- dhtmlXMenuObject.prototype.setWzBjName = function (wzbjname) { // 传入文字部件(已关联菜单部件)名称方法实现 by Rd 2015-11-06
- this.wzbjname = wzbjname;
- }
- dhtmlXMenuObject.prototype._addItemIntoGlobalStrorage = function (itemId, itemParentId, itemText, itemType, disabled, img, imgDis) {
- var item = {
- id: itemId,
- title: itemText,
- imgen: (img != null ? img : ""),
- imgdis: (imgDis != null ? imgDis : ""),
- type: itemType,
- state: (disabled == true ? "disabled" : "enabled"),
- parent: itemParentId,
- complex: false,
- hotkey: "",
- tip: ""
- };
- this.itemPull[item.id] = item;
- };
- dhtmlXMenuObject.prototype._addSubMenuPolygon = function (id, parentId) {
- var s = this._renderSublevelPolygon(id, parentId);
- var j = this._getMenuNodes(parentId);
- for (q = 0; q < j.length; q++) {
- if (this.itemPull[j[q]]["type"] == "separator") {
- this._renderSeparator(j[q], null);
- } else {
- this._renderSublevelItem(j[q], null);
- }
- };
- if (id == parentId) {
- var level = "topLevel";
- } else {
- var level = "subLevel";
- };
- for (var q = 0; q < j.length; q++) {
- if (this.itemPull[j[q]]["complex"]) {
- this._addSubMenuPolygon(id, this.itemPull[j[q]]["id"]);
- }
- }
- };
- dhtmlXMenuObject.prototype._renderSublevelPolygon = function (id, parentId) {
- var s = document.createElement("DIV");
- // s.className = "dhtmlxMenu_" + this.skin + "_SubLevelArea_Polygon " + (this._rtl ? "dir_right" : "");
- s.className = "menu-div";
- s.dir = "ltr";
- s.oncontextmenu = function (e) {
- e = e || event;
- e.returnValue = false;
- e.cancelBubble = true;
- return false;
- };
- s.id = "polygon_" + parentId;
- s.onclick = function (e) {
- e = e || event;
- e.cancelBubble = true;
- };
- s.style.display = "none";
- document.body.insertBefore(s, document.body.firstChild);
- var tbl = document.createElement("TABLE");
- // tbl.className = "dhtmlxMebu_SubLevelArea_Tbl";
- tbl.cellSpacing = 0;
- tbl.cellPadding = 0;
- tbl.border = 0;
- var tbd = document.createElement("TBODY");
- tbl.appendChild(tbd);
- s.appendChild(tbl);
- s.tbl = tbl;
- s.tbd = tbd;
- this.idPull[s.id] = s;
- if (this.sxDacProc != null) {
- this.idPull["sxDac_" + parentId] = new this.sxDacProc(s, s.className);
- if (_isIE) {
- this.idPull["sxDac_" + parentId]._setSpeed(this.dacSpeedIE);
- this.idPull["sxDac_" + parentId]._setCustomCycle(this.dacCyclesIE);
- } else {
- this.idPull["sxDac_" + parentId]._setSpeed(this.dacSpeed);
- this.idPull["sxDac_" + parentId]._setCustomCycle(this.dacCycles);
- }
- };
- return s;
- };
- dhtmlXMenuObject.prototype._renderSublevelItem = function (id, pos) {
- var main_self = this;
- var tr = document.createElement("TR");
- tr.className = (this.itemPull[id]["state"] == "enabled" ? "menu-item" : "sub_item_dis");
- var t1 = document.createElement("TD");
- t1.className = "sub_item_icon";
- t1.style.verticalAlign = "middle";
- t1.style.width = "0px";
- t1.style.paddingLeft = "5px";
- var icon = this.itemPull[id][(this.itemPull[id]["state"] == "enabled" ? "imgen" : "imgdis")];
- if (icon != "") {
- var tp = this.itemPull[id]["type"];
- if (tp == "checkbox" || tp == "radio") {
- var img = document.createElement("DIV");
- img.id = "image_" + this.itemPull[id]["id"];
- img.className = "sub_icon " + icon;
- t1.appendChild(img);
- };
- if (!(tp == "checkbox" || tp == "radio")) {
- var img = document.createElement("IMG");
- img.style.display = "inline-block";
- img.style.width = "15px";
- img.style.marginRight = "5px";
- img.id = "image_" + this.itemPull[id]["id"];
- img.className = "sub_icon";
- img.src = this.imagePath + icon;
- t1.appendChild(img);
- }
- };
- var t2 = document.createElement("TD");
- t2.style.verticalAlign = "middle";
- t2.className = "sub_item_text";
- if (this.itemPull[id]["title"] != "") {
- var t2t = document.createElement("DIV");
- t2t.className = "sub_item_text";
- t2t.style.paddingRight = "15px";
- t2t.innerHTML = this.itemPull[id]["title"];
- t2.appendChild(t2t);
- } else {
- t2.innerHTML = " ";
- };
- var t3 = document.createElement("TD");
- t3.className = "sub_item_hk";
- if (this.itemPull[id]["complex"]) {
- var arw = document.createElement("DIV");
- arw.className = "complex_arrow";
- arw.id = "arrow_" + this.itemPull[id]["id"];
- t3.appendChild(arw);
- } else {
- if (this.itemPull[id]["hotkey"].length > 0 && !this.itemPull[id]["complex"]) {
- var t3t = document.createElement("DIV");
- t3t.className = "sub_item_hk";
- t3t.innerHTML = this.itemPull[id]["hotkey"];
- t3.appendChild(t3t);
- } else {
- t3.innerHTML = " ";
- }
- };
- tr.appendChild(this._rtl ? t3 : t1);
- tr.appendChild(t2);
- // tr.appendChild(this._rtl ? t1 : t3);
- tr.id = this.itemPull[id]["id"];
- tr.parent = this.itemPull[id]["parent"];
- if (this.itemPull[id]["tip"].length > 0)
- tr.title = this.itemPull[id]["tip"];
- tr.onselectstart = function (e) {
- e = e || event;
- e.returnValue = false;
- return false;
- };
- tr.onmouseover = function () {
- if (main_self.menuMode == "web")
- window.clearTimeout(main_self.menuTimeoutHandler);
- main_self._redistribSubLevelSelection(this.id, this.parent);
- };
- if (main_self.menuMode == "web") {
- tr.onmouseout = function () {
- window.clearTimeout(main_self.menuTimeoutHandler);
- main_self.menuTimeoutHandler = window.setTimeout(function () {
- main_self._clearAndHide();
- }, main_self.menuTimeoutMsec, "JavaScript");
- }
- };
- tr.onclick = function (e) {
- if (!main_self.checkEvent("onClick") && main_self.itemPull[this.id]["complex"])
- return;
- e = e || event;
- e.cancelBubble = true;
- e.returnValue = false;
- tc = (main_self.itemPull[this.id]["complex"] ? "c" : "-");
- td = (main_self.itemPull[this.id]["state"] == "enabled" ? "-" : "d");
- var cas = {
- "ctrl": e.ctrlKey,
- "alt": e.altKey,
- "shift": e.shiftKey
- };
- switch (main_self.itemPull[this.id]["type"]) {
- case "checkbox":
- main_self._checkboxOnClickHandler(this.id.replace(main_self.idPrefix, ""), tc + td + "n", cas);
- break;
- case "radio":
- main_self._radioOnClickHandler(this.id.replace(main_self.idPrefix, ""), tc + td + "n", cas);
- break;
- case "item":
- main_self._doOnClick(this.id.replace(main_self.idPrefix, ""), tc + td + "n", cas);
- break;
- };
- return false;
- };
- var polygon = this.idPull["polygon_" + this.itemPull[id]["parent"]];
- if (pos != null) {
- pos++;
- if (pos < 0)
- pos = 0;
- if (pos > polygon.tbd.childNodes.length - 1)
- pos = null;
- };
- if (pos != null && polygon.tbd.childNodes[pos] != null)
- polygon.tbd.insertBefore(tr, polygon.tbd.childNodes[pos]);
- else
- polygon.tbd.appendChild(tr);
- this.idPull[tr.id] = tr;
- };
- dhtmlXMenuObject.prototype._renderSeparator = function (id, pos) {
- var level = (this.context ? "SubLevelArea" : (this.itemPull[id]["parent"] == this.idPrefix + this.topId ? "TopLevel" : "SubLevelArea"));
- if (level == "TopLevel" && this.context)
- return;
- var main_self = this;
- if (level != "TopLevel") {
- var tr = document.createElement("TR");
- tr.className = "sub_sep";
- var td = document.createElement("TD");
- td.colSpan = "3";
- tr.appendChild(td);
- };
- var k = document.createElement("DIV");
- k.id = "separator_" + id;
- k.className = (level == "TopLevel" ? "top_sep" : "sub_sep");
- k.onselectstart = function (e) {
- e = e || event;
- e.returnValue = false;
- };
- k.onclick = function (e) {
- e = e || event;
- e.cancelBubble = true;
- var cas = {
- "ctrl": e.ctrlKey,
- "alt": e.altKey,
- "shift": e.shiftKey
- };
- main_self._doOnClick(this.id.replace("separator_" + main_self.idPrefix, ""), "--s", cas);
- };
- if (level == "TopLevel") {
- if (pos != null) {
- pos++;
- if (pos < 0) {
- pos = 0;
- };
- if (this.cont.childNodes[pos] != null) {
- this.cont.insertBefore(k, this.cont.childNodes[pos]);
- } else {
- this.cont.appendChild(k);
- }
- } else {
- var last = this.cont.childNodes[this.cont.childNodes.length - 1];
- if (String(last).search("TopLevel_Text") == - 1) {
- this.cont.appendChild(k);
- } else {
- this.cont.insertBefore(k, last);
- }
- };
- this.idPull[k.id] = k;
- } else {
- var polygon = this.idPull["polygon_" + this.itemPull[id]["parent"]];
- if (pos != null) {
- pos++;
- if (pos < 0)
- pos = 0;
- if (pos > polygon.tbd.childNodes.length - 1)
- pos = null;
- };
- if (pos != null && polygon.tbd.childNodes[pos] != null)
- polygon.tbd.insertBefore(tr, polygon.tbd.childNodes[pos]);
- else
- polygon.tbd.appendChild(tr);
- td.appendChild(k);
- this.idPull[k.id] = tr;
- }
- };
- dhtmlXMenuObject.prototype.addNewSeparator = function (nextToId, itemId) {
- itemId = this.idPrefix + (itemId != null ? itemId : this._genStr(24));
- var parentId = this.idPrefix + this.getParentId(nextToId);
- this._addItemIntoGlobalStrorage(itemId, parentId, "", "separator", false, "", "");
- this._renderSeparator(itemId, this.getItemPosition(nextToId));
- };
- dhtmlXMenuObject.prototype.hide = function () {
- this._clearAndHide();
- };
- dhtmlXMenuObject.prototype.clearAll = function () {
- this.removeItem(this.idPrefix + this.topId, true);
- this._isInited = false;
- this.idPrefix = this._genStr(12);
- };
- dhtmlXMenuObject.prototype.unload = function () {
- if (_isIE) {
- document.body.detachEvent("onclick", this._bodyClick);
- document.body.detachEvent("oncontextmenu", this._bodyContext);
- } else {
- window.removeEventListener("click", this._bodyClick, false);
- window.removeEventListener("contextmenu", this._bodyContext, false);
- };
- this._bodyClick = null;
- this._bodyContext = null;
- this.removeItem(this.idPrefix + this.topId, true);
- this.itemPull = null;
- this.idPull = null;
- if (this.context)
- for (var a in this.contextZones)
- this.removeContextZone(a);
- if (this.cont != null) {
- this.cont.className = "";
- this.cont.parentNode.removeChild(this.cont);
- this.cont = null;
- };
- if (this.base != null) {
- this.base.className = "";
- if (!this.context)
- this.base.oncontextmenu = (this.base._oldContextMenuHandler || null);
- this.base.onselectstart = null;
- this.base = null;
- };
- this.setSkin = null;
- this.detachAllEvents();
- if (this._xmlLoader) {
- this._xmlLoader.destructor();
- this._xmlLoader = null;
- };
- this._align = null;
- this._arrowFFFix = null;
- this._isIE6 = null;
- this._isInited = null;
- this._rtl = null;
- this._scrollDownTMStep = null;
- this._scrollDownTMTime = null;
- this._scrollUpTMStep = null;
- this._scrollUpTMTime = null;
- this._topLevelBottomMargin = null;
- this._topLevelOffsetLeft = null;
- this._topLevelBottomMargin = null;
- this._topLevelRightMargin = null;
- this.addBaseIdAsContextZone = null;
- this.context = null;
- this.contextAutoHide = null;
- this.contextAutoShow = null;
- this.contextHideAllMode = null;
- this.contextMenuZoneId = null;
- this.dLoad = null;
- this.dLoadSign = null;
- this.dLoadUrl = null;
- this.loaderIcon = null;
- this.fixedPosition = null;
- this.dirSubLevel = null;
- this.dirTopLevel = null;
- this.limit = null;
- this.menuSelected = null;
- this.menuLastClicked = null;
- this.idPrefix = null;
- this.imagePath = null;
- this.menuMode = null;
- this.menuModeTopLevelTimeout = null;
- this.menuModeTopLevelTimeoutTime = null;
- this.menuTimeoutHandler = null;
- this.menuTimeoutMsec = null;
- this.menuTouched = null;
- this.isDhtmlxMenuObject = null;
- this.itemHotKeyTagName = null;
- this.itemHrefTagName = null;
- this.itemTagName = null;
- this.itemTextTagName = null;
- this.itemTipTagName = null;
- this.userDataTagName = null;
- this.skin = null;
- this.topId = null;
- this.dacCycles = null;
- this.dacCyclesIE = null;
- this.dacSpeed = null;
- this.dacSpeedIE = null;
- this.zInd = null;
- this.zIndInit = null;
- this.zIndStep = null;
- this._enableDacSupport = null;
- this._selectedSubItems = null;
- this._openedPolygons = null;
- this._addSubItemToSelected = null;
- this._removeSubItemFromSelected = null;
- this._getSubItemToDeselectByPolygon = null;
- this._hidePolygon = null;
- this._showPolygon = null;
- this._redistribSubLevelSelection = null;
- this._doOnClick = null;
- this._doOnTouchMenu = null;
- this._searchMenuNode = null;
- this._getMenuNodes = null;
- this._genStr = null;
- this._clearAndHide = null;
- this._doOnLoad = null;
- this.getItemType = null;
- this.forEachItem = null;
- this.init = null;
- this.loadXML = null;
- this.loadXMLString = null;
- this._buildMenu = null;
- this._xmlParser = null;
- this._showSubLevelItem = null;
- this._hideSubLevelItem = null;
- this._countVisiblePolygonItems = null;
- this._redefineComplexState = null;
- this._updateItemComplexState = null;
- this._getItemLevelType = null;
- this._redistribTopLevelSelection = null;
- this._initTopLevelMenu = null;
- this._renderToplevelItem = null;
- this.setImagePath = null;
- this.setIconsPath = null;
- this.setIconPath = null;
- this._updateItemImage = null;
- this.removeItem = null;
- this._getAllParents = null;
- this.renderAsContextMenu = null;
- this.addContextZone = null;
- this.removeContextZone = null;
- this.isContextZone = null;
- this._isContextMenuVisible = null;
- this._showContextMenu = null;
- this._doOnContextBeforeCall = null;
- this._autoDetectVisibleArea = null;
- this._addItemIntoGlobalStrorage = null;
- this._addSubMenuPolygon = null;
- this._renderSublevelPolygon = null;
- this._renderSublevelItem = null;
- this._renderSeparator = null;
- this._hideContextMenu = null;
- this.clearAll = null;
- this.getItemPosition = null;
- this.setItemPosition = null;
- this.setWzBjName = null; // test传入参数方法 by Rd 2015-11-06
- this.getParentId = null;
- this.addNewSibling = null;
- this.addNewChild = null;
- this.addNewSeparator = null;
- this.attachEvent = null;
- this.callEvent = null;
- this.checkEvent = null;
- this.eventCatcher = null;
- this.detachEvent = null;
- this.dhx_Event = null;
- this.unload = null;
- this.items = null;
- this.radio = null;
- this.detachAllEvents = null;
- this.hide = null;
- this.showContextMenu = null;
- this.hideContextMenu = null;
- this._changeItemState = null;
- this._changeItemVisible = null;
- this._updateLoaderIcon = null;
- this._clearAllSelectedSubItemsInPolygon = null;
- this._checkArrowsState = null;
- this._addUpArrow = null;
- this._addDownArrow = null;
- this._removeUpArrow = null;
- this._removeDownArrow = null;
- this._isArrowExists = null;
- this._doScrollUp = null;
- this._doScrollDown = null;
- this._countPolygonItems = null;
- this._getRadioImgObj = null;
- this._setRadioState = null;
- this._radioOnClickHandler = null;
- this._getCheckboxState = null;
- this._setCheckboxState = null;
- this._readLevel = null;
- this._updateCheckboxImage = null;
- this._checkboxOnClickHandler = null;
- this._removeArrow = null;
- this.setItemEnabled = null;
- this.setItemDisabled = null;
- this.isItemEnabled = null;
- this.getItemText = null;
- this.setItemText = null;
- this.loadFromHTML = null;
- this.hideItem = null;
- this.showItem = null;
- this.isItemHidden = null;
- this.setUserData = null;
- this.getUserData = null;
- this.setOpenMode = null;
- this.setWebModeTimeout = null;
- this.enableDynamicLoading = null;
- this.getItemImage = null;
- this.setItemImage = null;
- this.clearItemImage = null;
- this.setAutoShowMode = null;
- this.setAutoHideMode = null;
- this.setContextMenuHideAllMode = null;
- this.getContextMenuHideAllMode = null;
- this.setVisibleArea = null;
- this.setTooltip = null;
- this.getTooltip = null;
- this.setHotKey = null;
- this.getHotKey = null;
- this.setItemSelected = null;
- this.setTopText = null;
- this.setRTL = null;
- this.setAlign = null;
- this.setHref = null;
- this.setMbwz = null; //增加目标文字(mbwz) by Rd 2015-10-10
- this.clearHref = null;
- this.getCircuit = null;
- this.contextZones = null;
- this.setOverflowHeight = null;
- this.userData = null;
- this.getRadioChecked = null;
- this.setRadioChecked = null;
- this.addRadioButton = null;
- this.setCheckboxState = null;
- this.getCheckboxState = null;
- this.addCheckbox = null;
- this.serialize = null;
- this.extendedModule = null;
- dhtmlxMenuObjectLiveInstances[this._UID] = null;
- try {
- delete dhtmlxMenuObjectLiveInstances[this._UID];
- } catch (e) {};
- this._UID = null;
- };
- var dhtmlxMenuObjectLiveInstances = {};
- dhtmlXMenuObject.prototype.i18n = {
- dhxmenuextalert: "dhtmlxmenu_ext.js required"
- };
- (function () {
- dhtmlx.extend_api("dhtmlXMenuObject", {
- _init: function (obj) {
- return [obj.parent, obj.skin];
- },
- align: "setAlign",
- top_text: "setTopText",
- context: "renderAsContextMenu",
- icon_path: "setIconsPath",
- open_mode: "setOpenMode",
- rtl: "setRTL",
- skin: "setSkin",
- dynamic: "enableDynamicLoading",
- xml: "loadXML",
- items: "items",
- overflow: "setOverflowHeight"
- }, {
- items: function (arr, parent) {
- var pos = 100000;
- var lastItemId = null;
- for (var i = 0; i < arr.length; i++) {
- var item = arr[i];
- if (item.type == "separator") {
- this.addNewSeparator(lastItemId, pos, item.id);
- lastItemId = item.id;
- } else {
- this.addNewChild(parent, pos, item.id, item.text, item.disabled, item.img, item.img_disabled);
- lastItemId = item.id;
- if (item.items)
- this.items(item.items, item.id);
- }
- }
- }
- });
- })();
- // v.2.6 build 100722
- /*
- Copyright DHTMLX LTD. http : // www.dhtmlx.com
- You allowed to use this component or parts of it under GPL terms
- To use it on other terms or get Professional edition of the component please contact us at sales@dhtmlx.com
- */
|