Browse files

course/ajax MDL-20123 Hide/show buttons appropriately in AJAX mode fo…

…r different formats/sections

            Code written by Rossiani Wijaya, I'm just checking it in for her.
  • Loading branch information...
1 parent 621d9af commit 64c63e6cbb35e00c034ab5e5f04c65a8ca55e2db moodler committed Oct 16, 2009
Showing with 12 additions and 5 deletions.
  1. +4 −0 lib/ajax/ajaxcourse.js
  2. +2 −1 lib/ajax/ajaxlib.php
  3. +6 −4 lib/ajax/section_classes.js
View
4 lib/ajax/ajaxcourse.js
@@ -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);
}
View
3 lib/ajax/ajaxlib.php
@@ -145,7 +145,7 @@ function block_add($id, $hidden=false){
* 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 @@ function print_javascript($courseid, $return=false) {
$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";
View
10 lib/ajax/section_classes.js
@@ -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),

0 comments on commit 64c63e6

Please sign in to comment.