course/ajax MDL-20123 Hide/show buttons appropriately in AJAX mode for different formats/sections
Code written by Rossiani Wijaya, I'm just checking it in for her.
This commit is contained in:
@@ -59,8 +59,10 @@ function main_class() {
|
||||
this.leftcolumn = null;
|
||||
this.rightcolumn = null;
|
||||
this.adminBlock = null;
|
||||
this.tempBlock = null;
|
||||
this.icons = [];
|
||||
this.marker = null;
|
||||
this.courseformat = null;
|
||||
|
||||
//things to process onload
|
||||
onloadobj.add('main.process_document();');
|
||||
@@ -116,6 +118,7 @@ main_class.prototype.process_document = function() {
|
||||
|
||||
//process sections
|
||||
var ct = 0;
|
||||
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');
|
||||
@@ -132,6 +135,7 @@ main_class.prototype.process_document = function() {
|
||||
}
|
||||
|
||||
this.adminBlock = YAHOO.util.Dom.getElementsByClassName('block_adminblock')[0];
|
||||
this.tempBlock = YAHOO.util.Dom.getElementsByClassName('tempblockhandler')[0];
|
||||
YAHOO.log("admin - "+this.adminBlock.className);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ class jsportal {
|
||||
* Prints the JavaScript code needed to set up AJAX for the course.
|
||||
*/
|
||||
function print_javascript($courseid, $return=false) {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $COURSE;
|
||||
|
||||
$blocksoutput = $output = '';
|
||||
for ($i=0; $i<count($this->blocks); $i++) {
|
||||
@@ -160,6 +160,7 @@ class jsportal {
|
||||
$output .= "<script type=\"text/javascript\">\n";
|
||||
$output .= " main.portal.id = ".$courseid.";\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";
|
||||
|
||||
@@ -79,7 +79,7 @@ section_class.prototype.init_section = function(id, group, config, isDraggable)
|
||||
|
||||
|
||||
section_class.prototype.init_buttons = function() {
|
||||
var commandContainer = this.getEl().childNodes[2];
|
||||
var commandContainer = YAHOO.util.Dom.getElementsByClassName('right',null,this.getEl())[0];
|
||||
|
||||
//clear all but show only button
|
||||
var commandContainerCount = commandContainer.childNodes.length;
|
||||
@@ -88,19 +88,21 @@ section_class.prototype.init_buttons = function() {
|
||||
commandContainer.removeChild(commandContainer.childNodes[i])
|
||||
}
|
||||
|
||||
if (!this.isWeekFormat) {
|
||||
if (main.getString('courseformat', this.sectionId) != "weeks" && this.sectionId > 0) {
|
||||
var highlightbutton = main.mk_button('div', '/i/marker.gif', main.getString('marker', this.sectionId));
|
||||
YAHOO.util.Event.addListener(highlightbutton, 'click', this.mk_marker, this, true);
|
||||
commandContainer.appendChild(highlightbutton);
|
||||
this.highlightButton = highlightbutton;
|
||||
}
|
||||
var viewbutton = main.mk_button('div', '/i/hide.gif', main.getString('hidesection', this.sectionId),
|
||||
[['title', main.portal.strings['hide'] ]]);
|
||||
|
||||
if (this.sectionId > 0 ) {
|
||||
var viewbutton = main.mk_button('div', '/i/hide.gif', main.getString('hidesection', this.sectionId), [['title', main.portal.strings['hide'] ]]);
|
||||
YAHOO.util.Event.addListener(viewbutton, 'click', this.toggle_hide, this,true);
|
||||
commandContainer.appendChild(viewbutton);
|
||||
this.viewButton = viewbutton;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
section_class.prototype.add_handle = function() {
|
||||
var handleRef = main.mk_button('a', '/i/move_2d.gif', main.getString('movesection', this.sectionId),
|
||||
|
||||
Reference in New Issue
Block a user