forked from extern/egroupware
18 lines
24 KiB
JavaScript
18 lines
24 KiB
JavaScript
|
//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 = " ";}}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
|
||
|
*/
|