Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

course/view MDL-10142 AJAX move functionality for section content

  • Loading branch information...
commit 69f471111c5b9fa9f380fc9305f6dbb6fa61c2f1 1 parent 65db12f
Rossiani Wijaya authored
Showing with 20 additions and 15 deletions.
  1. +16 −12 lib/ajax/ajaxcourse.js
  2. +4 −3 lib/ajax/ajaxlib.php
View
28 lib/ajax/ajaxcourse.js
@@ -63,6 +63,7 @@ function main_class() {
this.icons = [];
this.marker = null;
this.courseformat = null;
+ this.numsections = null;
//things to process onload
onloadobj.add('main.process_document();');
@@ -116,26 +117,29 @@ main_class.prototype.process_document = function() {
this.leftcolumn = new column_class('left-column', "blocks", null, 'l');
this.rightcolumn = new column_class('right-column', "blocks", null, 'r');
- //process sections
- var ct = 0;
+ //process sections
+ var maxct = this.portal.numsections;
this.courseformat = this.portal.courseformat;
- while (document.getElementById('section-'+ct) != null) {
- this.sections[ct] = new section_class('section-'+ct, "sections", null, ct!=0?true:false);
- this.sections[ct].addToGroup('resources');
- if (ct > 0) {
- var sectiontitle = YAHOO.util.Selector.query('#section-'+ct+' h3.weekdates')[0];
- if (undefined !== sectiontitle) { // Only save date for weekly format
- this.sectiondates[ct] = sectiontitle.innerHTML;
+
+ for (var ct=0; ct <= maxct; ct++) {
+ if(document.getElementById('section-'+ct) != null) {
+ this.sections[ct] = new section_class('section-'+ct, "sections", null, ct!=0?true:false);
+ this.sections[ct].addToGroup('resources');
+ if (ct > 0) {
+ var sectiontitle = YAHOO.util.Selector.query('#section-'+ct+' h3.weekdates')[0];
+ if (undefined !== sectiontitle) { // Only save date for weekly format
+ this.sectiondates[ct] = sectiontitle.innerHTML;
+ }
}
- }
- ct++;
+ }
}
if (this.debug) {
YAHOO.log("Processed "+ct+" sections");
}
- this.adminBlock = YAHOO.util.Dom.getElementsByClassName('block_adminblock')[0];
+ this.adminBlock = YAHOO.util.Dom.getElementsByClassName('block_adminblock')[0];
this.tempBlock = YAHOO.util.Dom.getElementsByClassName('tempblockhandler')[0];
+
YAHOO.log("admin - "+this.adminBlock.className);
}
View
7 lib/ajax/ajaxlib.php
@@ -137,7 +137,7 @@ function block_add($id, $hidden=false){
if ($hidden) {
$hidden_binary = 1;
}
- $this->blocks[count($this->blocks)] = array($this->currentblocksection, $id, $hidden_binary);
+ $this->blocks[count($this->blocks)] = array($this->currentblocksection, $id, $hidden_binary);
}
@@ -156,15 +156,16 @@ function print_javascript($courseid, $return=false) {
if ($i != (count($this->blocks) - 1)) {
$blocksoutput .= ',';
}
- }
+ }
$output .= "<script type=\"text/javascript\">\n";
$output .= " main.portal.id = ".$courseid.";\n";
- $output .= " main.portal.blocks = new Array(".$blocksoutput.");\n";
+ $output .= " main.portal.blocks = new Array(".$blocksoutput.");\n";
$output .= " main.portal.strings['courseformat']='".$COURSE->format."';\n";
$output .= " main.portal.strings['wwwroot']='".$CFG->wwwroot."';\n";
$output .= " main.portal.strings['pixpath']='".$CFG->pixpath."';\n";
$output .= " main.portal.strings['marker']='".get_string('markthistopic', '', '_var_')."';\n";
$output .= " main.portal.strings['marked']='".get_string('markedthistopic', '', '_var_')."';\n";
+ $output .= " main.portal.numsections = ".$COURSE->numsections.";\n";
$output .= " main.portal.strings['hide']='".get_string('hide')."';\n";
$output .= " main.portal.strings['hidesection']='".get_string('hidesection', '', '_var_')."';\n";
$output .= " main.portal.strings['show']='".get_string('show')."';\n";
Please sign in to comment.
Something went wrong with that request. Please try again.