egroupware/phpgwapi/js/dhtmlxtree/dhtmlxMenu/codebase/dhtmlxmenu.js

74 lines
81 KiB
JavaScript
Raw Normal View History

//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
*/
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;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.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
};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;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() {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.sk
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.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"?"sub_item":"sub_item_dis");var t1 = document.createElement("TD");t1.className = "sub_item_icon";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.id = "image_"+this.itemPull[id]["id"];img.className = "sub_icon";img.src = this.imagePath+icon;t1.appendChild(img);}};var t2 = document.createElement("TD");t2.className = "sub_item_text";if (this.itemPull[id]["title"] != ""){var t2t = document.createElement("DIV");t2t.className = "sub_item_text";t2t.innerHTML = this.itemPull[id]["title"];t2.appendChild(t2t);}else {t2.innerHTML = "&nbsp;";};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 = "&nbsp;";}};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
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;th
};(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
*/
//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
*/
dhtmlXMenuObject.prototype.extendedModule = "DHXMENUEXT";dhtmlXMenuObject.prototype.setItemEnabled = function(id) {this._changeItemState(id, "enabled", this._getItemLevelType(id));};dhtmlXMenuObject.prototype.setItemDisabled = function(id) {this._changeItemState(id, "disabled", this._getItemLevelType(id));};dhtmlXMenuObject.prototype.isItemEnabled = function(id) {return (this.itemPull[this.idPrefix+id]!=null?(this.itemPull[this.idPrefix+id]["state"]=="enabled"):false);};dhtmlXMenuObject.prototype._changeItemState = function(id, newState, levelType) {var t = false;var j = this.idPrefix + id;if ((this.itemPull[j] != null)&& (this.idPull[j] != null)) {if (this.itemPull[j]["state"] != newState){this.itemPull[j]["state"] = newState;if (this.itemPull[j]["parent"] == this.idPrefix+this.topId && !this.context){this.idPull[j].className = "dhtmlxMenu_"+this.skin+"_TopLevel_Item_"+(this.itemPull[j]["state"]=="enabled"?"Normal":"Disabled");}else {this.idPull[j].className = "sub_item"+(this.itemPull[j]["state"]=="enabled"?"":"_dis");};this._updateItemComplexState(this.idPrefix+id, this.itemPull[this.idPrefix+id]["complex"], false);this._updateItemImage(id, levelType);if ((this.idPrefix + this.menuLastClicked == j)&& (levelType != "TopLevel")) {this._redistribSubLevelSelection(j, this.itemPull[j]["parent"]);};if (levelType == "TopLevel" && !this.context){}}};return t;};dhtmlXMenuObject.prototype.getItemText = function(id) {return (this.itemPull[this.idPrefix+id]!=null?this.itemPull[this.idPrefix+id]["title"]:"");};dhtmlXMenuObject.prototype.setItemText = function(id, text) {id = this.idPrefix + id;if ((this.itemPull[id] != null)&& (this.idPull[id] != null)) {this._clearAndHide();this.itemPull[id]["title"] = text;if (this.itemPull[id]["parent"] == this.idPrefix+this.topId && !this.context){var tObj = null;for (var q=0;q<this.idPull[id].childNodes.length;q++){try {if (this.idPull[id].childNodes[q].className == "top_level_text")tObj = this.idPull[id].childNodes[q];}catch(e) {}};if (String(this.itemPull[id]["title"]).length == "" || this.itemPull[id]["title"] == null) {if (tObj != null)tObj.parentNode.removeChild(tObj);}else {if (!tObj){tObj = document.createElement("DIV");tObj.className = "top_level_text";if (this._rtl && this.idPull[id].childNodes.length > 0)this.idPull[id].insertBefore(tObj,this.idPull[id].childNodes[0]);else this.idPull[id].appendChild(tObj);};tObj.innerHTML = this.itemPull[id]["title"];}}else {var tObj = null;for (var q=0;q<this.idPull[id].childNodes[1].childNodes.length;q++){if (String(this.idPull[id].childNodes[1].childNodes[q].className||"")== "sub_item_text") tObj = this.idPull[id].childNodes[1].childNodes[q];};if (String(this.itemPull[id]["title"]).length == "" || this.itemPull[id]["title"] == null) {if (tObj){tObj.parentNode.removeChild(tObj);tObj = null;this.idPull[id].childNodes[1].innerHTML = "&nbsp;";}}else {if (!tObj){tObj = document.createElement("DIV");tObj.className = "sub_item_text";this.idPull[id].childNodes[1].innerHTML = "";this.idPull[id].childNodes[1].appendChild(tObj);};tObj.innerHTML = this.itemPull[id]["title"];}}}};dhtmlXMenuObject.prototype.loadFromHTML = function(objId, clearAfterAdd, onLoadFunction) {this.itemTagName = "DIV";if (typeof(objId)== "string") {objId = document.getElementById(objId);};this._buildMenu(objId, null);this.init();if (clearAfterAdd){objId.parentNode.removeChild(objId);};if (onLoadFunction != null){onLoadFunction();}};dhtmlXMenuObject.prototype.hideItem = function(id) {this._changeItemVisible(id, false);};dhtmlXMenuObject.prototype.showItem = function(id) {this._changeItemVisible(id, true);};dhtmlXMenuObject.prototype.isItemHidden = function(id) {var isHidden = null;if (this.idPull[this.idPrefix+id] != null){isHidden = (this.idPull[this.idPrefix+id].style.display == "none");};return isHidden;};dhtmlXMenuObject.prototype._changeItemVisible = function(id, visible) {itemId = this.idPrefix+id;if (this.itemPull[itemId] == null)return;if (this.itemPull[itemId]["type"] == "separator"){itemId = "separator_"+itemId;};if (this.idPull[itemId] == null)return;this.idPull[itemId].st
this._checkArrowsState(id);};if (checkArrows){this._checkArrowsState(id);}};dhtmlXMenuObject.prototype._countPolygonItems = function(id) {var count = 0;for (var a in this.itemPull){var par = this.itemPull[a]["parent"];var tp = this.itemPull[a]["type"];if (par == this.idPrefix+id && (tp == "item" || tp == "radio" || tp == "checkbox")) {count++;}};return count;};dhtmlXMenuObject.prototype.setOverflowHeight = function(itemsNum) {if (this.limit == 0 && itemsNum <= 0)return;this._clearAndHide();if (this.limit >= 0 && itemsNum > 0){this.limit = itemsNum;return;};if (this.limit > 0 && itemsNum <= 0){for (var a in this.itemPull){if (this._isArrowExists(a)) {var b = String(a).replace(this.idPrefix, "");this._removeUpArrow(b);this._removeDownArrow(b);this.idPull["polygon_"+a].style.height = "";}};this.limit = 0;return;}};dhtmlXMenuObject.prototype._getRadioImgObj = function(id) {try {var imgObj = this.idPull[this.idPrefix+id].childNodes[(this._rtl?2:0)].childNodes[0] }catch(e) {var imgObj = null;};return imgObj;};dhtmlXMenuObject.prototype._setRadioState = function(id, state) {var imgObj = this._getRadioImgObj(id);if (imgObj != null){var rObj = this.itemPull[this.idPrefix+id];rObj["checked"] = state;rObj["imgen"] = "rdbt_"+(rObj["checked"]?"1":"0");rObj["imgdis"] = rObj["imgen"];imgObj.className = "sub_icon "+rObj["imgen"];}};dhtmlXMenuObject.prototype._radioOnClickHandler = function(id, type, casState) {if (type.charAt(1)=="d" || this.itemPull[this.idPrefix+id]["group"]==null) return;var group = this.itemPull[this.idPrefix+id]["group"];if (this.checkEvent("onRadioClick")) {if (this.callEvent("onRadioClick", [group, this.getRadioChecked(group), id, this.contextMenuZoneId, casState])) {this.setRadioChecked(group, id);}}else {this.setRadioChecked(group, id);};if (this.checkEvent("onClick")) this.callEvent("onClick", [id]);};dhtmlXMenuObject.prototype.getRadioChecked = function(group) {var id = null;for (var q=0;q<this.radio[group].length;q++){var itemId = this.radio[group][q].replace(this.idPrefix, "");var imgObj = this._getRadioImgObj(itemId);if (imgObj != null){var checked = (imgObj.className).match(/rdbt_1$/gi);if (checked != null)id = itemId;}};return id;};dhtmlXMenuObject.prototype.setRadioChecked = function(group, id) {if (this.radio[group] == null)return;for (var q=0;q<this.radio[group].length;q++){var itemId = this.radio[group][q].replace(this.idPrefix, "");this._setRadioState(itemId, (itemId==id));}};dhtmlXMenuObject.prototype.addRadioButton = function(mode, nextToId, pos, itemId, itemText, group, state, disabled) {if (this.context && nextToId == this.topId){}else {if (this.itemPull[this.idPrefix+nextToId] == null)return;if (mode == "child" && this.itemPull[this.idPrefix+nextToId]["type"] != "item")return;};var id = this.idPrefix+(itemId!=null?itemId:this._genStr(24));var img = "rdbt_"+(state?"1":"0");var imgDis = img;if (mode == "sibling"){var parentId = this.idPrefix+this.getParentId(nextToId);this._addItemIntoGlobalStrorage(id, parentId, itemText, "radio", disabled, img, imgDis);this._renderSublevelItem(id, this.getItemPosition(nextToId));}else {var parentId = this.idPrefix+nextToId;this._addItemIntoGlobalStrorage(id, parentId, itemText, "radio", disabled, img, imgDis);if (this.idPull["polygon_"+parentId] == null){this._renderSublevelPolygon(parentId, parentId);};this._renderSublevelItem(id, pos-1);this._redefineComplexState(parentId);};var gr = (group!=null?group:this._genStr(24));this.itemPull[id]["group"] = gr;if (this.radio[gr]==null){this.radio[gr] = new Array();};this.radio[gr][this.radio[gr].length] = id;if (state == true)this.setRadioChecked(gr, String(id).replace(this.idPrefix, ""));};dhtmlXMenuObject.prototype._getCheckboxState = function(id) {if (this.itemPull[this.idPrefix+id] == null)return null;return this.itemPull[this.idPrefix+id]["checked"];};dhtmlXMenuObject.prototype._setCheckboxState = function(id, state) {if (this.itemPull[this.idPrefix+id] == null)return;this.itemPull[this.idPrefix+id]["checked"] = state;};dhtmlXMenuObject.prototype._updateCheckboxImage = function(id) {if (this.idPull[this.idPrefi
//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
*/