Code Duplication    Length = 52-52 lines in 2 locations

api/js/dhtmlxMenu/sources/dhtmlxmenu.js 1 location

@@ 1140-1191 (lines=52) @@
1137
*/
1138
dhtmlXMenuObject.prototype.setIconPath = dhtmlXMenuObject.prototype.setIconsPath;
1139
/* real-time update icon in menu */
1140
dhtmlXMenuObject.prototype._updateItemImage = function(id, levelType) {
1141
	// search existsing image
1142
	
1143
	id = this.idPrefix+id;
1144
	var isTopLevel = (this.itemPull[id]["parent"] == this.idPrefix+this.topId && !this.context);
1145
	
1146
	// search existing image
1147
	var imgObj = null;
1148
	if (isTopLevel) {
1149
		for (var q=0; q<this.idPull[id].childNodes.length; q++) {
1150
			try { if (this.idPull[id].childNodes[q].className == "dhtmlxMenu_TopLevel_Item_Icon") imgObj = this.idPull[id].childNodes[q]; } catch(e) {}
1151
		}
1152
	} else {
1153
		try { var imgObj = this.idPull[id].childNodes[this._rtl?2:0].childNodes[0]; } catch(e) { }
1154
	}
1155
	
1156
	if (this.itemPull[id]["type"] == "radio") {
1157
		var imgSrc = this.itemPull[id][(this.itemPull[id]["state"]=="enabled"?"imgen":"imgdis")];
1158
		// console.log(this.itemPull[this.idPrefix+id])
1159
	} else {
1160
		var imgSrc = this.itemPull[id][(this.itemPull[id]["state"]=="enabled"?"imgen":"imgdis")];
1161
	}
1162
	
1163
	if (imgSrc.length > 0) {
1164
		if (imgObj != null) {
1165
			imgObj.src = this.imagePath+imgSrc;
1166
		} else {
1167
			if (isTopLevel) {
1168
				var imgObj = document.createElement("IMG");
1169
				imgObj.className = "dhtmlxMenu_TopLevel_Item_Icon";
1170
				imgObj.src = this.imagePath+imgSrc;
1171
				imgObj.border = "0";
1172
				imgObj.id = "image_"+id;
1173
				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);
1174
				
1175
			} else {
1176
				
1177
				var imgObj = document.createElement("IMG");
1178
				imgObj.className = "sub_icon";
1179
				imgObj.src = this.imagePath+imgSrc;
1180
				imgObj.border = "0";
1181
				imgObj.id = "image_"+id;
1182
				var item = this.idPull[id].childNodes[this._rtl?2:0];
1183
				while (item.childNodes.length > 0) item.removeChild(item.childNodes[0]);
1184
				item.appendChild(imgObj);
1185
				
1186
			}
1187
		}
1188
	} else {
1189
		if (imgObj != null) imgObj.parentNode.removeChild(imgObj);
1190
	}
1191
}
1192
/**
1193
*   @desc: removes an item from the menu with all nested sublevels
1194
*   @param: id - id of the item for removing

api/js/egw_action/test/js/dhtmlxmenu.js 1 location

@@ 1107-1158 (lines=52) @@
1104
*/
1105
dhtmlXMenuObject.prototype.setIconPath = dhtmlXMenuObject.prototype.setIconsPath;
1106
/* real-time update icon in menu */
1107
dhtmlXMenuObject.prototype._updateItemImage = function(id, levelType) {
1108
	// search existsing image
1109
	
1110
	id = this.idPrefix+id;
1111
	var isTopLevel = (this.itemPull[id]["parent"] == this.idPrefix+this.topId && !this.context);
1112
	
1113
	// search existing image
1114
	var imgObj = null;
1115
	if (isTopLevel) {
1116
		for (var q=0; q<this.idPull[id].childNodes.length; q++) {
1117
			try { if (this.idPull[id].childNodes[q].className == "dhtmlxMenu_TopLevel_Item_Icon") imgObj = this.idPull[id].childNodes[q]; } catch(e) {}
1118
		}
1119
	} else {
1120
		try { var imgObj = this.idPull[id].childNodes[this._rtl?2:0].childNodes[0]; } catch(e) { }
1121
	}
1122
	
1123
	if (this.itemPull[id]["type"] == "radio") {
1124
		var imgSrc = this.itemPull[id][(this.itemPull[id]["state"]=="enabled"?"imgen":"imgdis")];
1125
		// console.log(this.itemPull[this.idPrefix+id])
1126
	} else {
1127
		var imgSrc = this.itemPull[id][(this.itemPull[id]["state"]=="enabled"?"imgen":"imgdis")];
1128
	}
1129
	
1130
	if (imgSrc.length > 0) {
1131
		if (imgObj != null) {
1132
			imgObj.src = this.imagePath+imgSrc;
1133
		} else {
1134
			if (isTopLevel) {
1135
				var imgObj = document.createElement("IMG");
1136
				imgObj.className = "dhtmlxMenu_TopLevel_Item_Icon";
1137
				imgObj.src = this.imagePath+imgSrc;
1138
				imgObj.border = "0";
1139
				imgObj.id = "image_"+id;
1140
				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);
1141
				
1142
			} else {
1143
				
1144
				var imgObj = document.createElement("IMG");
1145
				imgObj.className = "sub_icon";
1146
				imgObj.src = this.imagePath+imgSrc;
1147
				imgObj.border = "0";
1148
				imgObj.id = "image_"+id;
1149
				var item = this.idPull[id].childNodes[this._rtl?2:0];
1150
				while (item.childNodes.length > 0) item.removeChild(item.childNodes[0]);
1151
				item.appendChild(imgObj);
1152
				
1153
			}
1154
		}
1155
	} else {
1156
		if (imgObj != null) imgObj.parentNode.removeChild(imgObj);
1157
	}
1158
}
1159
/**
1160
*   @desc: removes an item from the menu with all nested sublevels
1161
*   @param: id - id of the item for removing