From 6f00683e9833ad66faa525af6e199b95c56c94ae Mon Sep 17 00:00:00 2001 From: vyshane Date: Thu, 19 Oct 2006 04:33:56 +0000 Subject: [PATCH] Merged from 1.7 --- lib/ajax/section_classes.js | 209 +++++++++++++++++++----------------- 1 file changed, 112 insertions(+), 97 deletions(-) diff --git a/lib/ajax/section_classes.js b/lib/ajax/section_classes.js index 091ed74b0c..689b9cb2f9 100755 --- a/lib/ajax/section_classes.js +++ b/lib/ajax/section_classes.js @@ -80,7 +80,7 @@ section_class.prototype.init_section = function(id, group, config, isDraggable) section_class.prototype.init_buttons = function() { var commandContainer = this.getEl().childNodes[2]; - //clear all but show only button + //clear all but show only button var commandContainerCount = commandContainer.childNodes.length; for (var i=(commandContainerCount-1); i>0; i--) { commandContainer.removeChild(commandContainer.childNodes[i]) @@ -131,7 +131,7 @@ section_class.prototype.process_section = function() { //find/edit resources this.resources_ul = this.content_td.getElementsByTagName('ul')[0]; - if (this.resources_ul == null) { + if (!this.resources_ul) { this.resources_ul = document.createElement('ul'); this.resources_ul.className='section'; this.content_td.insertBefore(this.resources_ul, this.content_td.childNodes[1]); @@ -170,8 +170,9 @@ section_class.prototype.onDragDrop = function(e, id) { // get the drag and drop object that was targeted var target = YAHOO.util.DDM.getDDById(id); - if (this.debug)YAHOO.log("Section dropped on id="+id+" (I am "+this.getEl().id+") x="+YAHOO.util.Dom.getXY(this.getDragEl())); - + if (this.debug) { + YAHOO.log("Section dropped on id="+id+" (I am "+this.getEl().id+") x="+YAHOO.util.Dom.getXY(this.getDragEl())); + } this.move_to_section(target); //add back to resources group @@ -191,43 +192,47 @@ section_class.prototype.move_to_section = function(target) { var found = null; //determine if original is above or below target and adjust loop - var oIndex=main.get_section_index(this); - var tIndex=main.get_section_index(target); - - if (this.debug)YAHOO.log("original is at: "+oIndex+" target is at:"+tIndex+" of "+(sectionCount-1)); + var oIndex = main.get_section_index(this); + var tIndex = main.get_section_index(target); + if (this.debug) { + YAHOO.log("original is at: "+oIndex+" target is at:"+tIndex+" of "+(sectionCount-1)); + } if (oIndex < tIndex) { var loopCondition = 'i 0 && childIndex < this.resources_ul.childNodes.length) - this.resources_ul.removeChild(this.resources_ul.childNodes[childIndex-1]); - YAHOO.log("removing "+el.getEl().id); - if (el.getEl().parentNode != null) - el.getEl().parentNode.removeChild(el.getEl()); - + } + } + if (childIndex > 0 && childIndex < this.resources_ul.childNodes.length) { + this.resources_ul.removeChild(this.resources_ul.childNodes[childIndex - 1]); + } + YAHOO.log("Removing "+el.getEl().id); + if (el.getEl().parentNode != null) { + el.getEl().parentNode.removeChild(el.getEl()); + } this.write_sequence_list(); } @@ -366,7 +376,7 @@ section_class.prototype.insert_resource = function(el, targetel) { //update in backend targetId = ''; - if (targetel != null) { + if (targetel) { targetId = targetel.id; } @@ -377,23 +387,23 @@ section_class.prototype.insert_resource = function(el, targetel) { //if inserting into a hidden resource hide if (this.hidden) { el.hiddenStored = el.hidden; - el.toggle_hide(null,null,true,true); + el.toggle_hide(null, null, true, true); } else { if (el.hiddenStored != null) { - el.toggle_hide(null,null,true,el.hiddenStored); + el.toggle_hide(null, null, true, el.hiddenStored); el.hiddenStored = null; } } //update model - if (targetel == null) { + if (!targetel) { this.resources[this.resources.length] = el; } else { - for (var i=0;i