From d4df8fdcae424b7fdc6b1f3e5279a96397fca414 Mon Sep 17 00:00:00 2001 From: cap2501 Date: Mon, 28 Aug 2006 02:05:02 +0000 Subject: [PATCH] small changes, also de-tabbed and unix fomatted --- lib/ajax/ajaxlib.php | 135 ++-- lib/ajax/block_classes.js | 58 +- lib/ajax/section-resource_classes.js | 1023 +++++++++++++------------- 3 files changed, 610 insertions(+), 606 deletions(-) diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index 818bb8b283..b36665d3bd 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -1,84 +1,79 @@ - "/lib/yui/yahoo/yahoo.js", - "yui_dom" => "/lib/yui/dom/dom.js", - "yui_event" => "/lib/yui/event/event.js", - "yui_dragdrop" => "/lib/yui/dragdrop/dragdrop.js", - "yui_logger" => "/lib/yui/logger/logger.js", - "yui_connection" => "/lib/yui/connection/connection.js", - "ajaxcourse_blocks" => "/lib/ajax/block_classes.js", - "ajaxcourse_sections" => "/lib/ajax/section-resource_classes.js", - "ajaxcourse_topic" => "/course/format/topicsajax/ajaxcourse-topics.js", - "ajaxcourse_week" => "/course/format/weeksajax/ajaxcourse-weeks.js" - ); - - - for ($i=0;$i\n\r"; - } else { - echo "\n\r"; - } - } - -} - -//used to create view of document to be passed to javascript on pageload -class jsportal{ - + "yui_yahoo" => "/lib/yui/yahoo/yahoo.js", + "yui_dom" => "/lib/yui/dom/dom.js", + "yui_event" => "/lib/yui/event/event.js", + "yui_dragdrop" => "/lib/yui/dragdrop/dragdrop.js", + "yui_logger" => "/lib/yui/logger/logger.js", + "yui_connection" => "/lib/yui/connection/connection.js", + "ajaxcourse_blocks" => "/lib/ajax/block_classes.js", + "ajaxcourse_sections" => "/lib/ajax/section-resource_classes.js", + "ajaxcourse_topic" => "/course/format/topicsajax/ajaxcourse-topics.js", + "ajaxcourse_week" => "/course/format/weeksajax/ajaxcourse-weeks.js" + ); + + + for($i=0;$i\n\r"; + else + echo "\n\r"; + + } + + //used to create view of document to be passed to javascript on pageload + class jsportal{ + var $currentblocksection = null; - var $blocks = array(); - var $sections = array(); - + var $blocks = Array(); + var $blocksoutput = ''; + var $output = ''; + //takes id of block and adds it function block_add($id,$hidden=false){ $hidden_binary = 0; - - if ($hidden) { - $hidden_binary = 1; - } - + + if($hidden) + $hidden_binary = 1; + $this->blocks[count($this->blocks)] = Array($this->currentblocksection,$id,$hidden_binary); } - - - function print_javascript($id) { - global $CFG; - - $blocksoutput = ''; - for ($i=0;$iblocks);$i++){ + + + function print_javascript($id){ + $blocksoutput = $output = ''; + for($i=0;$iblocks);$i++){ $blocksoutput.="['".$this->blocks[$i][0]."','".$this->blocks[$i][1]."','".$this->blocks[$i][2]."']"; - if ($i != (count($this->blocks)-1)) { + if($i != (count($this->blocks)-1)) $blocksoutput.=","; - } - } - - $output =""; - echo $output; } - -} - -?> + + } + +?> \ No newline at end of file diff --git a/lib/ajax/block_classes.js b/lib/ajax/block_classes.js index b78b3ce37e..b6e1f7b776 100644 --- a/lib/ajax/block_classes.js +++ b/lib/ajax/block_classes.js @@ -6,8 +6,8 @@ */ - //set Drag and Drop to Intersect mode: - YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT; + //set Drag and Drop to Intersect mode: + YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT; /* * class for draggable block, extends YAHOO.util.DDProxy @@ -17,6 +17,8 @@ function block_class(id,group,config){ } YAHOO.extend(block_class, YAHOO.util.DDProxy); +block_class.prototype.debug = true; + block_class.prototype.init_block = function(id, sGroup, config){ if (!id) { return; } @@ -39,7 +41,7 @@ block_class.prototype.init_block = function(id, sGroup, config){ // specify that this is not currently a drop target this.isTarget = false; - this.region = YAHOO.util.Region.getRegion(this.getEl()); + this.region = YAHOO.util.Region.getRegion(this.getEl()); this.type = block_class.TYPE; @@ -49,8 +51,6 @@ block_class.prototype.init_block = function(id, sGroup, config){ this.originalClass = this.getEl().className; this.init_buttons(); - - this.debug = false; } block_class.prototype.startDrag = function(x, y) { @@ -143,12 +143,12 @@ block_class.prototype.resetTargets = function() { } block_class.prototype.move_block = function(columnid){ - + if(this.debug)YAHOO.log("Dropped on "+columnid[0]); //var column = YAHOO.util.DDM.getDDById(columnid[0].); - column = columnid[0]; + column = columnid[0]; var inserttarget = this.find_target(column); - if(this.debug)YAHOO.log("moving "+this.getEl().id+" before "+inserttarget.getEl().id+" - parentNode="+this.getEl().parentNode.id); + if(this.debug && inserttarget != null)YAHOO.log("moving "+this.getEl().id+" before "+inserttarget.getEl().id+" - parentNode="+this.getEl().parentNode.id); //remove from document @@ -252,6 +252,8 @@ function column_class(id,group,config,ident){ } YAHOO.extend(column_class, YAHOO.util.DDTarget); +column_class.prototype.debug = true; + column_class.prototype.init_column = function(id, group,config,ident){ if (!id) { return; } @@ -259,14 +261,14 @@ column_class.prototype.init_column = function(id, group,config,ident){ this.blocks = new Array(); this.ident = ident; -// YAHOO.log("init_column "+id+"-"+el.id); +// YAHOO.log("init_column "+id+"-"+el.id); this.region = YAHOO.util.Region.getRegion(id); - - this.debug = false; + } column_class.prototype.find_sub_collision = function(dragRegion){ + if(this.debug)YAHOO.log("Finding Collisions on "+this.getEl().id+" with "+this.blocks.length+" blocks"); //find collisions with sub_elements(blocks), return array of collisions with regions of collision var collisions = new Array(); for(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); + } + \ No newline at end of file -- 2.39.5