From: moodler Date: Sat, 23 Sep 2006 14:03:48 +0000 (+0000) Subject: Further centralising of course AJAX and cleanup of code formatting, names etc X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=9bb741780532ae1360549870bbf4d103021303af;p=moodle.git Further centralising of course AJAX and cleanup of code formatting, names etc --- diff --git a/course/format/topics/ajaxcourse-topics.js b/course/format/topics/ajaxcourse-topics.js deleted file mode 100644 index 3a9ca554f2..0000000000 --- a/course/format/topics/ajaxcourse-topics.js +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Contains Main class and supporting functions for topic ajax course layout - */ - - -//hide content body until done loading (manipulation looks ugly elsewise) -document.getElementById('content').style.display='none'; - -//onload object for handling scripts on page load, this insurses they run in my order -function onload_class(){ - this.scripts = new Array(); - this.debug = false; -} - -onload_class.prototype.add = function(script){ - if(this.debug)YAHOO.log("onload.add - adding "+script,"junk"); - this.scripts[this.scripts.length] = script; - } - -onload_class.prototype.load = function(){ - var scriptcount = this.scripts.length; - if(this.debug)YAHOO.log("onload.load - loading "+scriptcount+" scripts","info"); - for(i=0;i= main.connectQueue.length) - return; - - var callback = { - success: function(){ - main.connectQueue_fireNext(); - } - } - - main.connectQueueConnection = main.connect(main.connectQueue[head]['method'],main.connectQueue[head]['urlStub'],callback,main.connectQueue[head]['body']) - - main.connectQueueHead++; - } - -main_class.prototype.update_marker = function(newMarker){ - if(this.marker != null) - this.marker.toggle_highlight(); - - this.marker = newMarker; - this.marker.toggle_highlight(); - - this.connect('post','class=course&field=marker',null,'value='+this.marker.sectionId); - } - - - - -var main = new main_class(); - - - - -function php_portal_class(){ - //portal to php data - - this.id = null; - - //array of id's of blocks set at end of page load by php - this.blocks = new Array(); - this.imagePath = null; - - //flag for week fomat - this.isWeek = false; - - //strings - this.strings = []; - - YAHOO.log("instantiated php_portal_class","info"); -} - - - - diff --git a/course/format/topics/format.php b/course/format/topics/format.php index 7ad4215f9d..1017d93faa 100644 --- a/course/format/topics/format.php +++ b/course/format/topics/format.php @@ -70,7 +70,7 @@ $COURSE->javascriptportal = new jsportal(); print_require_js(array('yui_yahoo','yui_dom','yui_event','yui_dragdrop', 'yui_connection', - 'ajaxcourse_blocks','ajaxcourse_sections','ajaxcourse_topic')); + 'ajaxcourse_blocks','ajaxcourse_sections','ajaxcourse')); //javascript logging facilities if (debugging()) { diff --git a/lib/ajax/ajaxcourse.js b/lib/ajax/ajaxcourse.js new file mode 100644 index 0000000000..88b5f717c6 --- /dev/null +++ b/lib/ajax/ajaxcourse.js @@ -0,0 +1,231 @@ +/* + * Contains Main class and supporting functions for topic ajax course layout + * + * $Id$ + */ + + +//hide content body until done loading (manipulation looks ugly elsewise) +document.getElementById('content').style.display='none'; + +//onload object for handling scripts on page load, this insurses they run in my order +function onload_class() { + this.scripts = new Array(); + this.debug = false; +} + +onload_class.prototype.add = function(script) { + if(this.debug)YAHOO.log("onload.add - adding "+script,"junk"); + this.scripts[this.scripts.length] = script; +} + +onload_class.prototype.load = function(){ + var scriptcount = this.scripts.length; + if(this.debug)YAHOO.log("onload.load - loading "+scriptcount+" scripts","info"); + for (i=0;i= main.connectQueue.length) { + return; + } + + var callback = { +success: function(){ + main.connectQueue_fireNext(); + } + } + + main.connectQueueConnection = main.connect(main.connectQueue[head]['method'],main.connectQueue[head]['urlStub'],callback,main.connectQueue[head]['body']) + + main.connectQueueHead++; +} + +main_class.prototype.update_marker = function(newMarker){ + if (this.marker != null) { + this.marker.toggle_highlight(); + } + + this.marker = newMarker; + this.marker.toggle_highlight(); + + this.connect('post','class=course&field=marker',null,'value='+this.marker.sectionId); +} + +var main = new main_class(); + +function php_portal_class(){ + //portal to php data + + this.id = null; + + //array of id's of blocks set at end of page load by php + this.blocks = new Array(); + this.imagePath = null; + + //flag for week fomat + this.isWeek = false; + + //strings + this.strings = []; + + YAHOO.log("instantiated php_portal_class","info"); +} diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index 7024f2edd7..608ff81dd0 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -1,80 +1,78 @@ - "/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.php", - "ajaxcourse_sections" => "/lib/ajax/section_classes.php", - "ajaxcourse_topic" => "/course/format/topics/ajaxcourse-topics.js", - "ajaxcourse_week" => "/course/format/weeks/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{ - + '/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.php', + 'ajaxcourse_sections' => '/lib/ajax/section_classes.php', + 'ajaxcourse' => '/lib/ajax/ajaxcourse.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 $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; - - $this->blocks[count($this->blocks)] = Array($this->currentblocksection,$id,$hidden_binary); + + if ($hidden) { + $hidden_binary = 1; + } + + $this->blocks[count($this->blocks)] = array($this->currentblocksection,$id,$hidden_binary); } - - + + function print_javascript($id){ + global $CFG; + $blocksoutput = $output = ''; - for($i=0;$iblocks);$i++){ + 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.=","; - } - - global $CFG; + } + } + $output .=""; echo $output; } - - } - +} + ?>