Skip to content

Commit

Permalink
course/view MDL-10142 AJAX move functionality for section content
Browse files Browse the repository at this point in the history
  • Loading branch information
rwijaya committed Oct 30, 2009
1 parent 65db12f commit 69f4711
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
28 changes: 16 additions & 12 deletions lib/ajax/ajaxcourse.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function main_class() {
this.icons = []; this.icons = [];
this.marker = null; this.marker = null;
this.courseformat = null; this.courseformat = null;
this.numsections = null;


//things to process onload //things to process onload
onloadobj.add('main.process_document();'); onloadobj.add('main.process_document();');
Expand Down Expand Up @@ -116,26 +117,29 @@ main_class.prototype.process_document = function() {
this.leftcolumn = new column_class('left-column', "blocks", null, 'l'); this.leftcolumn = new column_class('left-column', "blocks", null, 'l');
this.rightcolumn = new column_class('right-column', "blocks", null, 'r'); this.rightcolumn = new column_class('right-column', "blocks", null, 'r');


//process sections //process sections
var ct = 0; var maxct = this.portal.numsections;
this.courseformat = this.portal.courseformat; 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); for (var ct=0; ct <= maxct; ct++) {
this.sections[ct].addToGroup('resources'); if(document.getElementById('section-'+ct) != null) {
if (ct > 0) { this.sections[ct] = new section_class('section-'+ct, "sections", null, ct!=0?true:false);
var sectiontitle = YAHOO.util.Selector.query('#section-'+ct+' h3.weekdates')[0]; this.sections[ct].addToGroup('resources');
if (undefined !== sectiontitle) { // Only save date for weekly format if (ct > 0) {
this.sectiondates[ct] = sectiontitle.innerHTML; 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) { if (this.debug) {
YAHOO.log("Processed "+ct+" sections"); 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]; this.tempBlock = YAHOO.util.Dom.getElementsByClassName('tempblockhandler')[0];

YAHOO.log("admin - "+this.adminBlock.className); YAHOO.log("admin - "+this.adminBlock.className);
} }


Expand Down
7 changes: 4 additions & 3 deletions lib/ajax/ajaxlib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function block_add($id, $hidden=false){
if ($hidden) { if ($hidden) {
$hidden_binary = 1; $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);
} }




Expand All @@ -156,15 +156,16 @@ function print_javascript($courseid, $return=false) {
if ($i != (count($this->blocks) - 1)) { if ($i != (count($this->blocks) - 1)) {
$blocksoutput .= ','; $blocksoutput .= ',';
} }
} }
$output .= "<script type=\"text/javascript\">\n"; $output .= "<script type=\"text/javascript\">\n";
$output .= " main.portal.id = ".$courseid.";\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['courseformat']='".$COURSE->format."';\n";
$output .= " main.portal.strings['wwwroot']='".$CFG->wwwroot."';\n"; $output .= " main.portal.strings['wwwroot']='".$CFG->wwwroot."';\n";
$output .= " main.portal.strings['pixpath']='".$CFG->pixpath."';\n"; $output .= " main.portal.strings['pixpath']='".$CFG->pixpath."';\n";
$output .= " main.portal.strings['marker']='".get_string('markthistopic', '', '_var_')."';\n"; $output .= " main.portal.strings['marker']='".get_string('markthistopic', '', '_var_')."';\n";
$output .= " main.portal.strings['marked']='".get_string('markedthistopic', '', '_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['hide']='".get_string('hide')."';\n";
$output .= " main.portal.strings['hidesection']='".get_string('hidesection', '', '_var_')."';\n"; $output .= " main.portal.strings['hidesection']='".get_string('hidesection', '', '_var_')."';\n";
$output .= " main.portal.strings['show']='".get_string('show')."';\n"; $output .= " main.portal.strings['show']='".get_string('show')."';\n";
Expand Down

0 comments on commit 69f4711

Please sign in to comment.