From b1b4c2d75fc63039140c39bc541c2bcb57e76ffa Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Fri, 30 Oct 2009 08:02:16 +0000 Subject: [PATCH] course/view MDL-10142 AJAX move functionality on section content --- lib/ajax/ajaxcourse.js | 24 +++++++++++++++--------- lib/ajax/ajaxlib.php | 1 + 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/ajax/ajaxcourse.js b/lib/ajax/ajaxcourse.js index 23ee24d523..d8fec5fb8b 100644 --- a/lib/ajax/ajaxcourse.js +++ b/lib/ajax/ajaxcourse.js @@ -63,6 +63,7 @@ function main_class() { this.icons = []; this.courseformat = null; this.marker = null; + this.numsections = null; //things to process onload onloadobj.add('main.process_document();'); @@ -117,17 +118,22 @@ main_class.prototype.process_document = function() { this.rightcolumn = new column_class('right-column', "blocks", null, 'r'); //process sections - var ct = 0; - 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; + //var ct = 0; + //while (document.getElementById('section-'+ct) != null) { + var maxct = this.portal.numsections; + this.courseformat = this.portal.courseformat; + 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++; + //ct++; } if (this.debug) { YAHOO.log("Processed "+ct+" sections"); diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index 99cb455878..f53f0cc65a 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -1398,6 +1398,7 @@ class jsportal { $output .= " main.portal.strings['wwwroot']='".$CFG->wwwroot."';\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"; -- 2.39.5