12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085 |
- /********************************************************************************************************************************
- * Licensed Materials - Property of IBM *
- * *
- * IBM Cognos Products: AGS *
- * *
- * (C) Copyright IBM Corp. 2005, 2008 *
- * *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- *********************************************************************************************************************************/
- function CList (sId, bAllowDuplicates, sStyle,oUiStyle) {
- this.m_sId = sId;
- this.m_bAllowDuplicates = bAllowDuplicates;
- this.childCount = 0;
- this.m_oUiStyle = oUiStyle;
- this.m_bDisabled = false;
- this.m_fOnContextMenu = null;
- this.m_fSingleClickFunc = null;
- this.m_fDoubleClickFunc = null;
- this.m_fDragStartFunc = null;
- this.m_fDragFunc = null;
- this.m_fDragEndFunc = null;
- this.m_fDragEnterFunc = null;
- this.m_fDragLeaveFunc = null;
- this.m_fDragOverFunc = null;
- this.m_fOnDropFunc = null;
- this.m_fEqualityFunc = null;
-
- this.listElement = document.createElement("ul");
- this.listElement.listObject = this;
- this.listElement.getParentListObject = function() {return this.listObject};
- this.listElement.style.cursor = 'default';
- this.listElement.setAttribute("id", sId);
- if (sStyle && sStyle != 'undefined')
- this.listElement.className = sStyle;
- }
- function CList_getListElement() {
- return this.listElement;
- }
- function CList_getId() {
- return this.m_sId;
- }
- function CList_size() {
- return this.childCount;
- }
- function CList_setDisabled(val) {
- this.m_bDisabled = val;
- }
- function CList_isDisabled() {
- return this.m_bDisabled;
- }
- function CList_setDblClickFunc(val) {
- this.m_fDoubleClickFunc = val;
- }
- function CList_setSingleClickFunc(val) {
- this.m_fSingleClickFunc = val;
- }
- function CList_setContextMenuClickFunc(val) {
- this.m_fOnContextMenu = val;
- }
- function CList_setDragStartFunc(val) {
- this.m_fDragStartFunc = val;
- }
- function CList_setDragFunc(val) {
- this.m_fDragFunc = val;
- }
- function CList_setDragEndFunc(val) {
- this.m_fDragEndFunc = val;
- }
- function CList_setDragEnterFunc(val) {
- this.m_fDragEnterFunc = val;
- }
- function CList_setDragLeaveFunc(val) {
- this.m_fDragLeaveFunc = val;
- }
- function CList_setDragOverFunc(val) {
- this.m_fDragOverFunc = val;
- }
- function CList_setOnDropFunc(val) {
- this.m_fOnDropFunc = val;
- }
- function CList_setEqualityFunc(val) {
- this.m_fEqualityFunc = val;
- }
- function CList_getDblClickFunc() {
- return this.m_fDoubleClickFunc;
- }
- function CList_getSingleClickFunc() {
- return this.m_fSingleClickFunc;
- }
- function CList_getContextMenuClickFunc() {
- return this.m_fOnContextMenu;
- }
-
- function CList_getDragStartFunc() {
- return this.m_fDragStartFunc;
- }
- function CList_getDragFunc() {
- return this.m_fDragFunc;
- }
- function CList_getDragEndFunc() {
- return this.m_fDragEndFunc;
- }
- function CList_getDragEnterFunc() {
- return this.m_fDragEnterFunc;
- }
- function CList_getDragLeaveFunc() {
- return this.m_fDragLeaveFunc;
- }
- function CList_getDragOverFunc() {
- return this.m_fDragOverFunc;
- }
- function CList_getOnDropFunc() {
- return this.m_fOnDropFunc;
- }
- function CList_getEqualityFunc() {
- return this.m_fEqualityFunc;
- }
- function CList_getStyle() {
- return this.m_oUiStyle;
- }
- function CList_setStyle(style) {
- this.m_oUiStyle = style;
- }
- function CList_onmouseOver() {
- CList_doMouseOver(this);
- }
- function CList_doMouseOver(object) {
- if (object && object.getParentListObject().isDisabled()) {
- return;
- }
- if (typeof object.getParentListObject().getStyle() == "object") {
- object.className = object.getParentListObject().getStyle().getRolloverState();
- }
- var ul = object.getParentListObject().getListElement();
- ul.overId = object.id;
- }
- function CList_onmouseOut() {
- CList_doMouseOut(this);
- }
- function CList_doMouseOut(object) {
- if (object && object.getParentListObject().isDisabled()) {
- return;
- }
- if (typeof object.getParentListObject().getStyle() == "object") {
- object.className = object.getParentListObject().getStyle().getNormalState();
- }
- var ul = object.getParentListObject().getListElement();
- ul.overId = "";
- }
- function CList_doClick(event,object) {
- if (object && object.getParentListObject().isDisabled()) {
- return;
- }
- if (event.ctrlKey) {
- CList_ctrlClicked(object);
- } else if (event.shiftKey) {
- CList_shiftClicked(object);
- } else {
- CList_clicked(object);
- }
- }
- function CList_clicked(object) {
- var parent = object.getParentListObject();
- var ul = parent.getListElement();
- ul.selectedId = object.id;
- if (object.isSelected && parent.getSelectedNodes().length < 2) {
- parent.deSelectAll();
- } else {
- parent.deSelectAll();
- parent.selectNodeList(object);
- }
- }
- function CList_shiftClicked(object) {
- var parent = object.getParentListObject();
- parent.deSelectAll();
- var ul = parent.getListElement();
- var startIndex = parent.indexById(ul.selectedId);
- var endIndex = parent.indexById(object.id);
- if (startIndex >= endIndex) {
- endIndex = startIndex;
- startIndex = parent.indexById(object.id);
- }
- parent.selectRange(startIndex,endIndex);
- }
- function CList_ctrlClicked(object) {
- var parent = object.getParentListObject();
- var ul = parent.getListElement();
- ul.selectedId = object.id;
- if (object.isSelected) {
- parent.deSelectNodeList(object);
- } else {
- parent.selectNodeList(object);
- }
- }
- function CList_selectRange(start,end) {
- var ul = this.getListElement();
- for (var i = start; i <= end; ++i) {
- var li = ul.childNodes[i];
- if (li && li.tagName == 'LI') {
- this.selectNodeList(li);
- }
- }
- }
- function CList_selectNodeList(object) {
- object.onclick = CList_singleClickCaller;
- if (typeof this.getStyle() == "object") {
- object.className = this.getStyle().getDepressedState();
- }
- object.onmouseover = null;
- object.onmouseout = null;
- object.isSelected = true;
- }
- function CList_deSelectNodeList(object) {
- if (typeof this.getStyle() == "object") {
- object.className = this.getStyle().getNormalState();
- }
- object.onmouseover = CList_onmouseOver;
- object.onmouseout = CList_onmouseOut;
- object.isSelected = false;
- }
- function CList_deSelectAll () {
- var ul = this.getListElement();
- for (var i = 0; i < ul.childNodes.length; ++i) {
- var li = ul.childNodes[i];
- if (li && li.tagName == 'LI') {
- this.deSelectNodeList(li);
- }
- }
- }
- function CList_getAllItems() {
- return this.item(0, this.childCount);
- }
- function CList_getAllNodes() {
- var result = new Array();
- var ul = this.getListElement();
- for (var i = 0; i < ul.childNodes.length; ++i) {
- var li = ul.childNodes[i];
- if (li && li.tagName == 'LI') {
- result.push(li);
- }
- }
- return result;
- }
- function CList_getAllSelectedItems () {
- var result = new Array();
- var ul = this.getListElement();
- for (var i = 0; i < ul.childNodes.length; ++i) {
- var li = ul.childNodes[i];
- if (li && li.tagName == 'LI' && li.isSelected) {
- //Should ever be only one here from our side
- //of the border at least. This is the node
- //The user has given for us to insert.
- result.push(li.childNodes.item(0));
- }
- }
- return result;
- }
- function CList_getNodeByIndex (idx) {
- var ul = this.getListElement();
- if (ul.childNodes.length > 0) {
- return ul.childNodes[idx];
- }
- return null;
- }
- function CList_getNodeByProperty(value, property) {
- var result = new Array();
- var ul = this.getListElement();
- for (var i = 0; i < ul.childNodes.length; ++i) {
- var li = this.getNodeByIndex(i);
- if (li && li.tagName == 'LI' && li[property] == value) {
- result.push(li);
- }
- }
- return result;
- }
- function CList_getNodeById(id) {
- //only one with this id
- var nodeArray = this.getNodeByProperty(id, 'id')
- if (nodeArray.length == 1) {
- return nodeArray[0];
- }
- return null;
- }
- function CList_getSelectedNodes () {
- return this.getNodeByProperty(true,'isSelected');
- /*
- var result = new Array();
-
-
- var ul = this.getListElement();
-
- for (var i = 0; i < ul.childNodes.length; ++i) {
- var li = ul.childNodes[i];
- if (li && li.tagName == 'LI' && li.isSelected) {
- result.push(li);
- }
- }
- return result;
- */
- }
- function CList_containsItem(value) {
- if (this.getEqualityFunc() != null) {
- var equalFunc = this.getEqualityFunc();
- return equalFunc(this,value);
- }
- return false;
- }
- function CList_item(start,end) {
- var ul = this.getListElement();
- if (start && !end || end == 'undefined') {
- //Return the actual node inside the LI
- return ul.childNodes[start].childNodes.item(0);
- }
- var result = new Array();
- for (var i = start; i <= end; ++i) {
- var li = ul.childNodes[i];
- if (li && li.tagName == 'LI') {
- result.push(li.childNodes.item(0));
- }
- }
- return result;
- }
- function CList_add(node,index,existingId) {
- if (!this.m_bAllowDuplicates && this.getEqualityFunc() != null && this.containsItem(node)) {
- //We should not allow duplicates and we have an equality check functions and item
- //exists.
- return false;
- }
-
- var el = this.getListElement();
- var referenceNode =null;
- if (index && index != 'undefined') {
- referenceNode = el.childNodes[index];
- } else if (el.overId && el.overId != "") {
- referenceNode = this.getNodeById(el.overId);
- } else if (this.getSelectedNodes().length == 1) {
- referenceNode = this.getSelectedNodes()[0];
- }
- var insertNode = CList_createNode(this,existingId);
- insertNode.appendChild(node);
- if (referenceNode) {
- el.insertBefore(insertNode,referenceNode);
- } else {
- el.appendChild(insertNode);
- }
-
- insertNode.style.height="16px";
- this.deSelectAll();
- this.selectNodeList(insertNode);
- return true;
- }
- function CList_removeSelected() {
- var selectedNodes = this.getSelectedNodes();
- var ul = this.getListElement();
- for (var i=0; i < selectedNodes.length;i++) {
- ul.removeChild(selectedNodes[i]);
- --this.childCount;
- }
- }
- function CList_remove(index) {
- if (!index || index == 'undefined') {
- index = 0;
- }
- var ul = this.getListElement();
- if (ul && ul.hasChildNodes && ul.removeChild) {
- var node = ul.childNodes[index]
- ul.removeChild(node);
- }
- --this.childCount;
- }
- function CList_removeAllNodes() {
- var rootNode = this.getListElement();
- if (rootNode && rootNode.hasChildNodes && rootNode.removeChild) {
- while (rootNode.hasChildNodes()) {
- rootNode.removeChild(rootNode.firstChild);
- }
- }
- this.childCount = 0;
- }
- function CList_createNode(parent,existingId) {
- var li = document.createElement('li');
- CList_disableAllEvents(li);
- li.onmouseover = CList_onmouseOver;
- li.onmouseout = CList_onmouseOut;
- li.onclick = CList_singleClickCaller;
- li.ondblclick = CList_doubleClickCaller;
- li.oncontextmenu = CList_contextMenuCaller;
- li.ondragstart = CList_dragStartCaller;
- li.ondrag = CList_dragCaller;
- li.ondragend = CList_dragEndCaller;
- li.ondragenter = CList_dragEnterCaller;
- li.ondragleave = CList_dragLeaveCaller;
- li.ondragover = CList_dragOverCaller;
- li.ondrop = CList_OnDropCaller;
-
- ++parent.childCount;
- if (existingId == undefined) {
- li.setAttribute('id',parent.getId() + parent.childCount);
- }
- else {
- li.setAttribute('id',existingId);
- }
-
- li.listObject = parent;
- li.getParentListObject = function() {return this.listObject};
- return li;
- }
- function CList_indexById(id) {
- if (!id || id == 'undefined') {
- return;
- }
- var result = 0;
- var ul = this.getListElement();
- for (var i = 0; i < ul.childNodes.length; ++i) {
- var li = ul.childNodes[i];
- if (li && li.tagName == 'LI' && id == li.id) {
- result = i;
- break;
- }
- }
- return result;
- }
- function CList_contextMenuCaller(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.getContextMenuClickFunc() != null && !rootNode.isDisabled())
- {
- var contextMenuFunc = rootNode.getContextMenuClickFunc();
- contextMenuFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function CList_singleClickCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- if ((evt.keyCode != null) && (evt.keyCode != 13) && (evt.keyCode != 0))
- {
- return false;
- }
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.isDisabled()) {
- return;
- }
- CList_doClick(evt,this);
- if (rootNode.getSingleClickFunc() != null)
- {
- var singleClickFunc = rootNode.getSingleClickFunc();
- singleClickFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function CList_doubleClickCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.getDblClickFunc() != null && !rootNode.isDisabled())
- {
- var doubleClickFunc = rootNode.getDblClickFunc();
- doubleClickFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function CList_dragStartCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.getDragStartFunc() != null && !rootNode.isDisabled())
- {
- var dragStartFunc = rootNode.getDragStartFunc();
- dragStartFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function CList_dragCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.getDragFunc() != null && !rootNode.isDisabled())
- {
- var dragFunc = rootNode.getDragFunc();
- dragFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function CList_dragEndCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.getDragEndFunc() != null && !rootNode.isDisabled())
- {
- var dragEndFunc = rootNode.getDragEndFunc();
- dragEndFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function CList_dragEnterCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- // set the cursor shape
- evt.dataTransfer.dropEffect="move";
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.getDragEnterFunc() != null && !rootNode.isDisabled())
- {
- var dragEnterFunc = rootNode.getDragEnterFunc();
- dragEnterFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- }
- return false;
- }
- function CList_dragLeaveCaller(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
-
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.isDisabled()) {
- return;
- }
- var liNode = CList_getUINode(evt,this);
- if (liNode.isSelected) {
- rootNode.selectNodeList(liNode);
- } else {
- CList_doMouseOut(liNode);
- }
- if (rootNode.getDragLeaveFunc() != null)
- {
- var dragOverFunc = rootNode.getDragLeaveFunc();
- dragLeaveFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- }
- return false;
- }
- function CList_dragOverCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
-
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.isDisabled()) {
- return;
- }
- var liNode = CList_getUINode(evt,this);
- CList_doMouseOver(liNode);
- if (rootNode.getDragOverFunc() != null)
- {
- var dragOverFunc = rootNode.getDragOverFunc();
- dragOverFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- }
- return false;
- }
- function CList_OnDropCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
-
- //cancel any text selection
- CList_clearSelection();
- //prevent the event from bubbling to other elements
- CList_cancelBub(evt);
- var rootNode = this.getParentListObject();
- if (rootNode.isDisabled()) {
- return;
- }
- var liNode = CList_getUINode(evt,this);
- if (rootNode.getOnDropFunc() != null)
- {
- var onDropFunc = rootNode.getOnDropFunc();
- onDropFunc(evt);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- }
- return false;
- }
- //find the element that the event occurred
- function CList_getUINode (evt,parent)
- {
- //get the element that trapped the event in a cross-browser fashion
- var uiNode = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
- //check to see if this is a text node.
- while (uiNode.tagName != 'LI')
- {
- if (uiNode.parentNode.getAttribute('id').toString().localeCompare(parent.id) != 0) {
- //We have reached the parent UL stop here.
- break;
- }
- //this is a text node, get the parent node
- uiNode = uiNode.parentNode;
- }
- return uiNode;
- }
- function CList_disableAllEvents(element) {
- if (document.all)
- {
- element.attachEvent("onmouseover", function() {window.status='';return true;});
- element.attachEvent("onmouseout", function() {window.status='';return true;});
- element.attachEvent("onmouseup", function(e) {window.status='';CList_clearSelection();CList_cancelBub(e);e.returnValue = false;});
- element.attachEvent("onmousedown", function(e) {window.status='';CList_clearSelection();CList_cancelBub(e);e.returnValue = false;});
- element.attachEvent("onmousemove", function(e) {window.status='';CList_clearSelection();CList_cancelBub(e);e.returnValue = false;});
- element.attachEvent("onclick", function(e) {window.status='';CList_clearSelection();CList_cancelBub(e);e.returnValue = false;});
- element.attachEvent("ondblclick", function(e) {window.status='';CList_clearSelection();CList_cancelBub(e);e.returnValue = false;});
- }
- else
- {
- element.addEventListener("mouseover", function() {window.status='';return false;}, true);
- element.addEventListener("mouseout", function() {window.status='';return false;}, true);
- element.addEventListener("mouseup", function(e) {window.status='';e.preventDefault();return false;}, true);
- element.addEventListener("mousedown", function(e) {window.status='';e.preventDefault();return false;}, true);
- element.addEventListener("mousemove", function(e) {window.status='';e.preventDefault();return false;}, true);
- element.addEventListener("click", function(e) {window.status='';e.preventDefault();return false;}, true);
- element.addEventListener("dblclick", function(e) {window.status='';CList_clearSelection();CList_cancelBub(e);e.preventDefault();return false;}, true);
- }
- }
- //prevent the event from bubbling to other elements
- function CList_cancelBub(evt)
- {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- //prevent the click from proceeding to other nodes
- if (typeof evt.cancelBubble != 'undefined')
- {
- evt.cancelBubble = true;
- }
- if (typeof evt.stopPropagation != 'undefined')
- {
- evt.stopPropagation();
- }
- }
- function CList_clearSelection()
- {
- if (typeof document.selection != 'undefined' && document.selection.createRange().text != "")
- {
- //IE specific
- document.selection.empty();
- }
- else if (typeof window.getSelection == 'function' && typeof window.getSelection() == "object")
- {
- //NS6 specific
- window.getSelection().removeAllRanges();
- }
- }
- function CList_up(nodeId)
- {
- var node = this.getNodeById(nodeId);
-
- if (node != null && node.childNodes.length==1) {
-
- var index = this.indexById(nodeId);
-
- //is the node already at the top of the list?
- if (index > 0) {
- var newPos = index-1;
- var el = this.getListElement();
- var previousNode = el.childNodes[newPos];
- //create the new node
- var insertNode = CList_createNode(this,nodeId);
- var nodeContent = node.childNodes[0];
- insertNode.appendChild(nodeContent);
-
- //remove the old one
- this.remove(index);
- //insert the node
- el.insertBefore(insertNode,previousNode);
-
- this.selectRange(newPos,newPos);
- }
- }
- }
- function CList_down(nodeId)
- {
- var index = this.indexById(nodeId);
- var node = this.getNodeById(nodeId);
-
- if (node != null && node.childNodes.length==1) {
-
- var lastIndex = this.size()-1;
-
- //the position of the sibling underneath the one to be inserted
- var nextSiblingPos = index+2;
-
- //the position of the new item
- var newPos = index+1
- if (nextSiblingPos > lastIndex) {
- this.toBottom(nodeId);
- }
- //is the node already the last item in the list?
- else if (index < lastIndex) {
- var el = this.getListElement();
- var nextNode = el.childNodes[nextSiblingPos];
- //create the new node
- var insertNode = CList_createNode(this,nodeId);
- var nodeContent = node.childNodes[0];
- insertNode.appendChild(nodeContent);
-
- //remove the old one
- this.remove(index);
- //insert the node
- el.insertBefore(insertNode,nextNode);
-
- this.selectRange(index+1,index+1);
- }
- }
- }
- function CList_toTop(nodeId)
- {
- var node = this.getNodeById(nodeId);
-
- if (node != null && node.childNodes.length==1) {
- var index = this.indexById(nodeId);
-
- //is the node already the first item in the list?
- if (index > 0) {
- this.remove(index);
- var el = this.getListElement();
- var firstNode = el.childNodes[0];
- //create the new node
- var nodeContent = node.childNodes[0];
- var insertNode = CList_createNode(this,nodeId);
- insertNode.appendChild(nodeContent);
-
- //place the node at the top
- el.insertBefore(insertNode,firstNode);
-
- this.selectRange(0,0);
- }
- }
- }
- function CList_toBottom(nodeId)
- {
- var node = this.getNodeById(nodeId);
-
- if (node != null && node.childNodes.length==1) {
-
- var index = this.indexById(nodeId);
- var lastIndex = this.size()-1;
-
- //is the node already at the bottom of the list?
- if (index < lastIndex) {
- this.remove(index);
- var el = this.getListElement();
- //create the new node
- var nodeContent = node.childNodes[0];
- var insertNode = CList_createNode(this,nodeId);
- insertNode.appendChild(nodeContent);
-
- //place the node at the bottom
- el.appendChild(insertNode);
-
- this.selectRange(lastIndex,lastIndex);
- }
- }
- }
- CList.prototype.getAllSelectedItems = CList_getAllSelectedItems;
- CList.prototype.getSelectedNodes = CList_getSelectedNodes;
- CList.prototype.selectRange = CList_selectRange;
- CList.prototype.selectNodeList = CList_selectNodeList;
- CList.prototype.deSelectNodeList = CList_deSelectNodeList;
- CList.prototype.deSelectAll = CList_deSelectAll;
- CList.prototype.size = CList_size;
- CList.prototype.getAllItems = CList_getAllItems;
- CList.prototype.getAllNodes = CList_getAllNodes;
- CList.prototype.getNodeByIndex = CList_getNodeByIndex;
- CList.prototype.getNodeByProperty = CList_getNodeByProperty;
- CList.prototype.getNodeById = CList_getNodeById;
- CList.prototype.containsItem = CList_containsItem;
- CList.prototype.up = CList_up;
- CList.prototype.down = CList_down;
- CList.prototype.toTop = CList_toTop;
- CList.prototype.toBottom = CList_toBottom;
- CList.prototype.add = CList_add;
- CList.prototype.item = CList_item;
- CList.prototype.remove = CList_remove;
- CList.prototype.removeSelected = CList_removeSelected;
- CList.prototype.removeAllNodes = CList_removeAllNodes;
- CList.prototype.getId = CList_getId;
- CList.prototype.setStyle = CList_setStyle;
- CList.prototype.getStyle = CList_getStyle;
- CList.prototype.getListElement = CList_getListElement;
- CList.prototype.indexById = CList_indexById;
- CList.prototype.setDisabled = CList_setDisabled;
- CList.prototype.isDisabled = CList_isDisabled;
- CList.prototype.setDblClickFunc = CList_setDblClickFunc;
- CList.prototype.setSingleClickFunc = CList_setSingleClickFunc;
- CList.prototype.setContextMenuClickFunc = CList_setContextMenuClickFunc;
- CList.prototype.getDblClickFunc = CList_getDblClickFunc;
- CList.prototype.getSingleClickFunc = CList_getSingleClickFunc;
- CList.prototype.getContextMenuClickFunc = CList_getContextMenuClickFunc;
- CList.prototype.setDragStartFunc = CList_setDragStartFunc;
- CList.prototype.setDragFunc = CList_setDragFunc;
- CList.prototype.setDragEndFunc = CList_setDragEndFunc;
- CList.prototype.setDragEnterFunc = CList_setDragEnterFunc;
- CList.prototype.setDragLeaveFunc = CList_setDragLeaveFunc;
- CList.prototype.setDragOverFunc = CList_setDragOverFunc;
- CList.prototype.setOnDropFunc = CList_setOnDropFunc;
- CList.prototype.setEqualityFunc = CList_setEqualityFunc;
- CList.prototype.getDragStartFunc = CList_getDragStartFunc;
- CList.prototype.getDragFunc = CList_getDragFunc;
- CList.prototype.getDragEndFunc = CList_getDragEndFunc;
- CList.prototype.getDragEnterFunc = CList_getDragEnterFunc;
- CList.prototype.getDragLeaveFunc = CList_getDragLeaveFunc;
- CList.prototype.getDragOverFunc = CList_getDragOverFunc;
- CList.prototype.getOnDropFunc = CList_getOnDropFunc;
- CList.prototype.getEqualityFunc = CList_getEqualityFunc;
|