Code Duplication    Length = 44-44 lines in 2 locations

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

@@ 1811-1854 (lines=44) @@
1808
}
1809
/****************************************************************************************************************************************************/
1810
/*								 	SEPARATOR								    */
1811
dhtmlXMenuObject.prototype._renderSeparator = function(id, pos) {
1812
	var level = (this.context?"SubLevelArea":(this.itemPull[id]["parent"]==this.idPrefix+this.topId?"TopLevel":"SubLevelArea"));
1813
	if (level == "TopLevel" && this.context) return;
1814
	
1815
	var main_self = this;
1816
	
1817
	if (level != "TopLevel") {
1818
		var tr = document.createElement("TR");
1819
		tr.className = "sub_sep";
1820
		var td = document.createElement("TD");
1821
		td.colSpan = "3";
1822
		tr.appendChild(td);
1823
	}
1824
	
1825
	var k = document.createElement("DIV");
1826
	k.id = "separator_"+id;
1827
	k.className = (level=="TopLevel"?"top_sep":"sub_sep");
1828
	k.onselectstart = function(e) { e = e || event; e.returnValue = false; }
1829
	k.onclick = function(e) {
1830
		e = e || event; e.cancelBubble = true;
1831
		var cas = {"ctrl": e.ctrlKey, "alt": e.altKey, "shift": e.shiftKey};
1832
		main_self._doOnClick(this.id.replace("separator_" + main_self.idPrefix, ""), "--s", cas);
1833
	}
1834
	if (level == "TopLevel") {
1835
		if (pos != null) {
1836
			pos++; if (pos < 0) { pos = 0; }
1837
			// if (this.base.childNodes[pos] != null) { this.base.insertBefore(k, this.base.childNodes[pos]); } else { this.base.appendChild(k); }
1838
			if (this.cont.childNodes[pos] != null) { this.cont.insertBefore(k, this.cont.childNodes[pos]); } else { this.cont.appendChild(k); }
1839
		} else {
1840
			// add as a last item
1841
			// var last = this.base.childNodes[this.base.childNodes.length-1];
1842
			var last = this.cont.childNodes[this.cont.childNodes.length-1];
1843
			// if (String(last).search("TopLevel_Text") == -1) { this.base.appendChild(k); } else { this.base.insertBefore(k, last); }
1844
			if (String(last).search("TopLevel_Text") == -1) { this.cont.appendChild(k); } else { this.cont.insertBefore(k, last); }
1845
		}
1846
		this.idPull[k.id] = k;
1847
	} else {
1848
		var polygon = this.idPull["polygon_"+this.itemPull[id]["parent"]];
1849
		if (pos != null) { pos++; if (pos < 0) pos = 0; if (pos > polygon.tbd.childNodes.length - 1) pos = null; }
1850
		if (pos != null && polygon.tbd.childNodes[pos] != null) polygon.tbd.insertBefore(tr, polygon.tbd.childNodes[pos]); else polygon.tbd.appendChild(tr);
1851
		td.appendChild(k);
1852
		this.idPull[k.id] = tr;
1853
	}
1854
}
1855
/**
1856
*   @desc: add a new separator
1857
*   @param: nextToId - id of the element after which a new separator will be inserted

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

@@ 1786-1829 (lines=44) @@
1783
}
1784
/****************************************************************************************************************************************************/
1785
/*								 	SEPARATOR								    */
1786
dhtmlXMenuObject.prototype._renderSeparator = function(id, pos) {
1787
	var level = (this.context?"SubLevelArea":(this.itemPull[id]["parent"]==this.idPrefix+this.topId?"TopLevel":"SubLevelArea"));
1788
	if (level == "TopLevel" && this.context) return;
1789
	
1790
	var main_self = this;
1791
	
1792
	if (level != "TopLevel") {
1793
		var tr = document.createElement("TR");
1794
		tr.className = "sub_sep";
1795
		var td = document.createElement("TD");
1796
		td.colSpan = "3";
1797
		tr.appendChild(td);
1798
	}
1799
	
1800
	var k = document.createElement("DIV");
1801
	k.id = "separator_"+id;
1802
	k.className = (level=="TopLevel"?"top_sep":"sub_sep");
1803
	k.onselectstart = function(e) { e = e || event; e.returnValue = false; }
1804
	k.onclick = function(e) {
1805
		e = e || event; e.cancelBubble = true;
1806
		var cas = {"ctrl": e.ctrlKey, "alt": e.altKey, "shift": e.shiftKey};
1807
		main_self._doOnClick(this.id.replace("separator_" + main_self.idPrefix, ""), "--s", cas);
1808
	}
1809
	if (level == "TopLevel") {
1810
		if (pos != null) {
1811
			pos++; if (pos < 0) { pos = 0; }
1812
			// if (this.base.childNodes[pos] != null) { this.base.insertBefore(k, this.base.childNodes[pos]); } else { this.base.appendChild(k); }
1813
			if (this.cont.childNodes[pos] != null) { this.cont.insertBefore(k, this.cont.childNodes[pos]); } else { this.cont.appendChild(k); }
1814
		} else {
1815
			// add as a last item
1816
			// var last = this.base.childNodes[this.base.childNodes.length-1];
1817
			var last = this.cont.childNodes[this.cont.childNodes.length-1];
1818
			// if (String(last).search("TopLevel_Text") == -1) { this.base.appendChild(k); } else { this.base.insertBefore(k, last); }
1819
			if (String(last).search("TopLevel_Text") == -1) { this.cont.appendChild(k); } else { this.cont.insertBefore(k, last); }
1820
		}
1821
		this.idPull[k.id] = k;
1822
	} else {
1823
		var polygon = this.idPull["polygon_"+this.itemPull[id]["parent"]];
1824
		if (pos != null) { pos++; if (pos < 0) pos = 0; if (pos > polygon.tbd.childNodes.length - 1) pos = null; }
1825
		if (pos != null && polygon.tbd.childNodes[pos] != null) polygon.tbd.insertBefore(tr, polygon.tbd.childNodes[pos]); else polygon.tbd.appendChild(tr);
1826
		td.appendChild(k);
1827
		this.idPull[k.id] = tr;
1828
	}
1829
}
1830
/**
1831
*   @desc: add a new separator
1832
*   @param: nextToId - id of the element after which a new separator will be inserted