From eba88175b6985af459bbcc5e92f2357d7e72140a Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 24 Aug 2006 03:37:41 +0000 Subject: [PATCH] Formatting fixes --- lib/ajax/section-resource_classes.js | 1014 +++++++++++++------------- 1 file changed, 508 insertions(+), 506 deletions(-) diff --git a/lib/ajax/section-resource_classes.js b/lib/ajax/section-resource_classes.js index aa88f4cb45..dd1554a95a 100755 --- a/lib/ajax/section-resource_classes.js +++ b/lib/ajax/section-resource_classes.js @@ -2,632 +2,634 @@ * library for ajaxcourse formats, the classes and related functions for sections and resources * this library requires a 'main' object created in calling document */ - - + + function section_class(id,group,config,isDraggable){ this.init_section(id,group,config,isDraggable); } + YAHOO.extend(section_class, YAHOO.util.DDProxy); -section_class.prototype.init_section = function(id, group,config,isDraggable){ - - if (!id) { return; } - - this.is = 'section'; - this.sectionId = null; - - - if(!isDraggable){ - this.initTarget(id,group,config); - this.removeFromGroup('sections'); - }else{ - this.init(id,group,config); - this.handle = null; - if(isDraggable)this.add_handle(); - } - - this.createFrame(); - this.isTarget = true; - - this.resources = []; - this.numberDisplay = null; - this.summary = null; - this.content_td = null; - this.hidden = false; - this.highlighted = false; - this.showOnly = false; - this.resources_ul = null; - this.process_section(); - - this.viewButton = null; - this.highlightButton = null; - this.showOnlyButton = null; - this.init_buttons(); - - this.debug = false; - if(this.debug)YAHOO.log("init_section "+id+" draggable="+isDraggable); - - - if(YAHOO.util.Dom.hasClass(this.getEl(),'hidden')) - this.toggle_hide(null,null,true); - - - +section_class.prototype.init_section = function(id, group,config,isDraggable) { + + if (!id) { return; } + + this.is = 'section'; + this.sectionId = null; + + + if(!isDraggable){ + this.initTarget(id,group,config); + this.removeFromGroup('sections'); + } else{ + this.init(id,group,config); + this.handle = null; + if(isDraggable)this.add_handle(); } - + + this.createFrame(); + this.isTarget = true; + + this.resources = []; + this.numberDisplay = null; + this.summary = null; + this.content_td = null; + this.hidden = false; + this.highlighted = false; + this.showOnly = false; + this.resources_ul = null; + this.process_section(); + + this.viewButton = null; + this.highlightButton = null; + this.showOnlyButton = null; + this.init_buttons(); + + this.debug = false; + + if (this.debug) YAHOO.log("init_section "+id+" draggable="+isDraggable); + + if (YAHOO.util.Dom.hasClass(this.getEl(),'hidden')) { + this.toggle_hide(null,null,true); + } + +} + section_class.prototype.init_buttons = function(){ - var commandContainer = this.getEl().childNodes[2]; - - //clear all but show only button - var commandContainerCount = commandContainer.childNodes.length; - for(var i=(commandContainerCount-1);i>0;i--) - commandContainer.removeChild(commandContainer.childNodes[i]) - - - if(!this.isWeekFormat){ - var highlightbutton = main.mk_button('div','/pix/i/marker.gif'); - YAHOO.util.Event.addListener(highlightbutton,'click',this.mk_marker,this,true); - commandContainer.appendChild(highlightbutton); - this.highlightButton = highlightbutton; - } - var viewbutton = main.mk_button('div','/pix/i/hide.gif'); - YAHOO.util.Event.addListener(viewbutton,'click',this.toggle_hide,this,true); - commandContainer.appendChild(viewbutton); - this.viewButton = viewbutton; - - - var deletebutton = main.mk_button('div','/pix/t/delete.gif'); - YAHOO.util.Event.addListener(deletebutton,'click',this.delete_button,this,true); - commandContainer.appendChild(deletebutton); - - + var commandContainer = this.getEl().childNodes[2]; + + //clear all but show only button + var commandContainerCount = commandContainer.childNodes.length; + for (var i=(commandContainerCount-1);i>0;i--) { + commandContainer.removeChild(commandContainer.childNodes[i]) } -section_class.prototype.delete_button = function(){ - this.content_td.childNodes[0].data = ''; - - if(this.hidden) - this.toggle_hide(); - - if(this.highlighted) - this.toggle_highlight(); - - if(this.debug)YAHOO.log('Deleting '+this.getEl().id); - - main.connect('delete','class=section&id='+this.id); - for(var i=0;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()); - - this.write_sequence_list(); - - } - + } + + + //remove "text" nodes to keep DOM clean + var childIndex = null; + var childrenCount = this.resources_ul.childNodes.length; + for(var i=0;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()); + + this.write_sequence_list(); + +} + section_class.prototype.insert_resource = function(el,targetel){ - var resourcecount = this.resources.length; - var found = false; - var tempStore = nextStore = null; - - if(targetel == null){ - this.resources[this.resources.length] = el; - }else - for(var i=0;i 2) - this.currentGroup = 0; - - this.groupButton.getElementsByTagName('img')[0].src = main.portal.wwwroot + this.groupImages[this.currentGroup]; - - main.connect('post','class=resource&field=groupmode',null,'value='+this.currentGroup+'&id='+this.id); - } - + this.currentGroup++; + if(this.currentGroup > 2) + this.currentGroup = 0; + + this.groupButton.getElementsByTagName('img')[0].src = main.portal.wwwroot + this.groupImages[this.currentGroup]; + + main.connect('post','class=resource&field=groupmode',null,'value='+this.currentGroup+'&id='+this.id); +} -- 2.39.5