123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212 |
- /********************************************************************************************************************************
- * Licensed Materials - Property of IBM *
- * *
- * IBM Cognos Products: HTS *
- * *
- * (C) Copyright IBM Corp. 2005, 2010 *
- * *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- *********************************************************************************************************************************/
- function CList (sId, bAllowDuplicates, sStyle,oUiStyle,sMode) {
- 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_fKeyPressFunc = 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;
-
- //set mode, default is 'toggle'
-
- if (sMode==undefined || (sMode != 'button' && sMode != 'toggle')) {
- sMode = 'toggle';
- }
- this.m_sMode = sMode;
- }
- 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_setKeyPressFunc(val) {
- this.m_fKeyPressFunc = 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_getKeyPressFunc() {
- return this.m_fKeyPressFunc;
- }
- 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) {
- if (this.m_sMode=='toggle') {
- 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,cid, dispValue,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);
- if (cid != 'undefined')
- insertNode.setAttribute('cid', cid);
- if (dispValue != 'undefined')
- insertNode.setAttribute('disp', dispValue);
- 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);
- if (parent.m_sMode == 'toggle') {
- li.onmouseover = CList_onmouseOver;
- li.onmouseout = CList_onmouseOut;
- li.onclick = CList_singleClickCaller;
- li.onkeydown = CList_keyPressCaller;
- 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;
- }
- else {
- li.onclick = CList_singleClickCallerButtonMode;
- li.onkeydown = CList_keyPressCallerButtonMode;
- li.onmouseover = CList_onmouseOver;
- li.onmouseout = CList_onmouseOut;
- }
-
- ++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_keyPressCallerButtonMode(evt) {
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- if (_hts_getKeyCode(evt) != null && _hts_getKeyCode(evt) != 13) {
- return true;
- }
- //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;
- }
-
- if (rootNode.getKeyPressFunc() != null)
- {
- var keyPressFunc = rootNode.getKeyPressFunc();
- keyPressFunc(evt,this);
- CList_cancelBub(evt);
- if (!document.all)
- {
- evt.preventDefault();
- }
- return false;
- }
- }
- function CList_singleClickCallerButtonMode(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;
- }
- if (rootNode.getSingleClickFunc() != null)
- {
- var singleClickFunc = rootNode.getSingleClickFunc();
- singleClickFunc(evt,this);
- 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);
- //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_keyPressCaller(evt)
- {
- if (this.parentNode.listObject.isDisabled()) {
- return;
- }
-
- //get the event in a cross-browser fashion
- evt = (evt) ? evt : ((event) ? event : null);
- if (_hts_getKeyCode(evt) != null && _hts_getKeyCode(evt) != 13) {
- return true;
- }
- //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.getKeyPressFunc() != null)
- {
- var keyPressFunc = rootNode.getKeyPressFunc();
- keyPressFunc(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.setKeyPressFunc = CList_setKeyPressFunc;
- CList.prototype.setContextMenuClickFunc = CList_setContextMenuClickFunc;
- CList.prototype.getDblClickFunc = CList_getDblClickFunc;
- CList.prototype.getSingleClickFunc = CList_getSingleClickFunc;
- CList.prototype.getKeyPressFunc = CList_getKeyPressFunc;
- 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;
|