Code Duplication    Length = 1-21 lines in 3 locations

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

@@ 1620-1640 (lines=21) @@
1617
*   @param: imgDis - image for the disabled item
1618
*   @type: public
1619
*/
1620
dhtmlXMenuObject.prototype.addNewChild = function(parentId, pos, itemId, itemText, disabled, imgEnabled, imgDisabled) {
1621
	if (parentId == null) {
1622
		if (this.context) {
1623
			parentId = this.topId;
1624
		} else {
1625
			this.addNewSibling(parentId, itemId, itemText, disabled, imgEnabled, imgDisabled);
1626
			if (pos != null) this.setItemPosition(itemId, pos);
1627
			return;
1628
		}
1629
	}
1630
	itemId = this.idPrefix+(itemId!=null?itemId:this._genStr(24));
1631
	// remove hotkey, added in 0.4
1632
	if (this.setHotKey) this.setHotKey(parentId, "");
1633
	//
1634
	parentId = this.idPrefix+parentId;
1635
	this._addItemIntoGlobalStrorage(itemId, parentId, itemText, "item", disabled, imgEnabled, imgDisabled);
1636
	if (this.idPull["polygon_"+parentId] == null) { this._renderSublevelPolygon(parentId, parentId); }
1637
	this._renderSublevelItem(itemId, pos-1);
1638
	// console.log(parentId)
1639
	this._redefineComplexState(parentId);
1640
}
1641
1642
/* add item to storage */
1643
dhtmlXMenuObject.prototype._addItemIntoGlobalStrorage = function(itemId, itemParentId, itemText, itemType, disabled, img, imgDis) {

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

@@ 1588-1608 (lines=21) @@
1585
*   @param: imgDis - image for the disabled item
1586
*   @type: public
1587
*/
1588
dhtmlXMenuObject.prototype.addNewChild = function(parentId, pos, itemId, itemText, disabled, imgEnabled, imgDisabled) {
1589
	if (parentId == null) {
1590
		if (this.context) {
1591
			parentId = this.topId;
1592
		} else {
1593
			this.addNewSibling(parentId, itemId, itemText, disabled, imgEnabled, imgDisabled);
1594
			if (pos != null) this.setItemPosition(itemId, pos);
1595
			return;
1596
		}
1597
	}
1598
	itemId = this.idPrefix+(itemId!=null?itemId:this._genStr(24));
1599
	// remove hotkey, added in 0.4
1600
	if (this.setHotKey) this.setHotKey(parentId, "");
1601
	//
1602
	parentId = this.idPrefix+parentId;
1603
	this._addItemIntoGlobalStrorage(itemId, parentId, itemText, "item", disabled, imgEnabled, imgDisabled);
1604
	if (this.idPull["polygon_"+parentId] == null) { this._renderSublevelPolygon(parentId, parentId); }
1605
	this._renderSublevelItem(itemId, pos-1);
1606
	// console.log(parentId)
1607
	this._redefineComplexState(parentId);
1608
}
1609
1610
/* add item to storage */
1611
dhtmlXMenuObject.prototype._addItemIntoGlobalStrorage = function(itemId, itemParentId, itemText, itemType, disabled, img, imgDis) {

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

@@ 84-84 (lines=1) @@
81
dhtmlXMenuObject.prototype.setItemPosition=function(b,c){b=this.idPrefix+b;if(this.idPull[b]!=null){var a=this.itemPull[b].parent==this.idPrefix+this.topId,d=this.idPull[b],f=this.getItemPosition(b.replace(this.idPrefix,"")),e=this.itemPull[b].parent,g=this.idPull["polygon_"+e]!=null?this.idPull["polygon_"+e].tbd:this.cont;g.removeChild(g.childNodes[f]);c<0&&(c=0);a&&c<1&&(c=1);c<g.childNodes.length?g.insertBefore(d,g.childNodes[c]):g.appendChild(d)}};
82
dhtmlXMenuObject.prototype.getParentId=function(b){b=this.idPrefix+b;return this.itemPull[b]==null?null:(this.itemPull[b].parent!=null?this.itemPull[b].parent:this.topId).replace(this.idPrefix,"")};
83
dhtmlXMenuObject.prototype.addNewSibling=function(b,c,a,d,f,e){var g=this.idPrefix+(c!=null?c:this._genStr(24)),h=this.idPrefix+(b!=null?this.getParentId(b):this.topId);this._addItemIntoGlobalStrorage(g,h,a,"item",d,f,e);h==this.idPrefix+this.topId&&!this.context?this._renderToplevelItem(g,this.getItemPosition(b)):this._renderSublevelItem(g,this.getItemPosition(b))};
84
dhtmlXMenuObject.prototype.addNewChild=function(b,c,a,d,f,e,g){if(b==null)if(this.context)b=this.topId;else{this.addNewSibling(b,a,d,f,e,g);c!=null&&this.setItemPosition(a,c);return}a=this.idPrefix+(a!=null?a:this._genStr(24));this.setHotKey&&this.setHotKey(b,"");b=this.idPrefix+b;this._addItemIntoGlobalStrorage(a,b,d,"item",f,e,g);this.idPull["polygon_"+b]==null&&this._renderSublevelPolygon(b,b);this._renderSublevelItem(a,c-1);this._redefineComplexState(b)};
85
dhtmlXMenuObject.prototype._addItemIntoGlobalStrorage=function(b,c,a,d,f,e,g){var h={id:b,title:a,imgen:e!=null?e:"",imgdis:g!=null?g:"",type:d,state:f==!0?"disabled":"enabled",parent:c,complex:!1,hotkey:"",tip:""};this.itemPull[h.id]=h};
86
dhtmlXMenuObject.prototype._addSubMenuPolygon=function(b,c){for(var a=this._renderSublevelPolygon(b,c),d=this._getMenuNodes(c),f=0;f<d.length;f++)this.itemPull[d[f]].type=="separator"?this._renderSeparator(d[f],null):this._renderSublevelItem(d[f],null);for(var e=b==c?"topLevel":"subLevel",f=0;f<d.length;f++)this.itemPull[d[f]].complex&&this._addSubMenuPolygon(b,this.itemPull[d[f]].id)};
87
dhtmlXMenuObject.prototype._renderSublevelPolygon=function(b,c){var a=document.createElement("DIV");a.className="dhtmlxMenu_"+this.skin+"_SubLevelArea_Polygon "+(this._rtl?"dir_right":"");a.dir="ltr";a.oncontextmenu=function(a){a=a||event;a.returnValue=!1;a.cancelBubble=!0;return!1};a.id="polygon_"+c;a.onclick=function(a){a=a||event;a.cancelBubble=!0};a.style.display="none";document.body.insertBefore(a,document.body.firstChild);var d=document.createElement("TABLE");d.className="dhtmlxMebu_SubLevelArea_Tbl";