From b791ee3d895571d4b68b99f5a9e19bb9cc98ce56 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 17 Feb 2014 22:30:59 +0800 Subject: [PATCH] MDL-34737 Course: Modchooser should use coursebase to determine the section class --- course/format/upgrade.txt | 4 ++++ .../moodle-course-modchooser-debug.js | 14 ++++++++++---- .../moodle-course-modchooser-min.js | 2 +- .../moodle-course-modchooser.js | 14 ++++++++++---- course/yui/src/modchooser/js/modchooser.js | 14 ++++++++++---- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/course/format/upgrade.txt b/course/format/upgrade.txt index fffbb93c55e..9d6bc3e17a8 100644 --- a/course/format/upgrade.txt +++ b/course/format/upgrade.txt @@ -2,6 +2,10 @@ This files describes API changes for course formats Overview of this plugin type at http://docs.moodle.org/dev/Course_formats +=== 2.8 === +* The activity chooser now uses M.course.format.get_sectionwrapperclass() + to determine the section selector, rather than a hard-coded `li.section`. + === 2.7 === * The ->testedbrowsers array no longer needs to be defined in supports_ajax(). * format_section_renderer_base::section_hidden has an new second optional argument $courseorid. diff --git a/course/yui/build/moodle-course-modchooser/moodle-course-modchooser-debug.js b/course/yui/build/moodle-course-modchooser/moodle-course-modchooser-debug.js index 54312b42917..1689ac9789c 100644 --- a/course/yui/build/moodle-course-modchooser/moodle-course-modchooser-debug.js +++ b/course/yui/build/moodle-course-modchooser/moodle-course-modchooser-debug.js @@ -8,7 +8,7 @@ YUI.add('moodle-course-modchooser', function (Y, NAME) { var CSS = { PAGECONTENT : 'body', - SECTION : 'li.section', + SECTION: null, SECTIONMODCHOOSER : 'span.section-modchooser-link', SITEMENU : 'div.block_site_main_menu', SITETOPIC : 'div.sitetopic' @@ -44,6 +44,10 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, { * @method initializer */ initializer : function() { + var sectionclass = M.course.format.get_sectionwrapperclass(); + if (sectionclass) { + CSS.SECTION = '.' + sectionclass; + } var dialogue = Y.one('.chooserdialoguebody'); var header = Y.one('.choosertitle'); var params = {}; @@ -75,9 +79,11 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, { }, this); // Setup for standard course topics - Y.one(baseselector).all(CSS.SECTION).each(function(section) { - this._setup_for_section(section); - }, this); + if (CSS.SECTION) { + Y.one(baseselector).all(CSS.SECTION).each(function(section) { + this._setup_for_section(section); + }, this); + } // Setup for the block site menu Y.one(baseselector).all(CSS.SITEMENU).each(function(section) { diff --git a/course/yui/build/moodle-course-modchooser/moodle-course-modchooser-min.js b/course/yui/build/moodle-course-modchooser/moodle-course-modchooser-min.js index 042562811a3..1f082870cf6 100644 --- a/course/yui/build/moodle-course-modchooser/moodle-course-modchooser-min.js +++ b/course/yui/build/moodle-course-modchooser/moodle-course-modchooser-min.js @@ -1 +1 @@ -YUI.add("moodle-course-modchooser",function(e,t){var n={PAGECONTENT:"body",SECTION:"li.section",SECTIONMODCHOOSER:"span.section-modchooser-link",SITEMENU:"div.block_site_main_menu",SITETOPIC:"div.sitetopic"},r="course-modchooser",i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.chooserdialogue,{sectionid:null,initializer:function(){var t=e.one(".chooserdialoguebody"),n=e.one(".choosertitle"),r={};this.setup_chooser_dialogue(t,n,r),this.setup_for_section(),M.course.coursebase.register_module(this),e.all(".block_settings #settingsnav .type_course .modchoosertoggle a").on("click",this.toggle_mod_chooser,this)},setup_for_section:function(t){t||(t=n.PAGECONTENT),e.one(t).all(n.SITETOPIC).each(function(e){this._setup_for_section(e)},this),e.one(t).all(n.SECTION).each(function(e){this._setup_for_section(e)},this),e.one(t).all(n.SITEMENU).each(function(e){this._setup_for_section(e)},this)},_setup_for_section:function(t){var r=t.one(n.SECTIONMODCHOOSER);if(!r)return;var i=e.Node.create("");r.get("children").each(function(e){i.appendChild(e)}),r.insertBefore(i),i.on("click",this.display_mod_chooser,this)},display_mod_chooser:function(e){if(e.target.ancestor(n.SITETOPIC))this.sectionid=1;else if(e.target.ancestor(n.SECTION)){var t=e.target.ancestor(n.SECTION);this.sectionid=t.get("id").replace("section-","")}else e.target.ancestor(n.SITEMENU)&&(this.sectionid=0);this.display_chooser(e)},toggle_mod_chooser:function(t){var n=e.all("div.addresourcemodchooser"),r=e.all("div.addresourcedropdown");if(n.size()===0)return;var i=e.one(".block_settings #settingsnav .type_course .modchoosertoggle a"),s=i.get("lastChild"),o;n.item(0).hasClass("visibleifjs")?(o=0,n.removeClass("visibleifjs").addClass("hiddenifjs"),r.addClass("visibleifjs").removeClass("hiddenifjs"),s.set("data",M.util.get_string("modchooserenable","moodle")),i.set("href",i.get("href").replace("off","on"))):(o=1,n.addClass("visibleifjs").removeClass("hiddenifjs"),r.removeClass("visibleifjs").addClass("hiddenifjs"),s.set("data",M.util.get_string("modchooserdisable","moodle")),i.set("href",i.get("href").replace("on","off"))),M.util.set_user_preference("usemodchooser",o),t.preventDefault()},option_selected:function(e){this.hiddenRadioValue.setAttrs({name:"jump",value:e.get("value")+"§ion="+this.sectionid})}},{NAME:r,ATTRS:{maxheight:{value:800}}}),M.course=M.course||{},M.course.init_chooser=function(e){return new i(e)}},"@VERSION@",{requires:["moodle-core-chooserdialogue","moodle-course-coursebase"]}); +YUI.add("moodle-course-modchooser",function(e,t){var n={PAGECONTENT:"body",SECTION:null,SECTIONMODCHOOSER:"span.section-modchooser-link",SITEMENU:"div.block_site_main_menu",SITETOPIC:"div.sitetopic"},r="course-modchooser",i=function(){i.superclass.constructor.apply(this,arguments)};e.extend(i,M.core.chooserdialogue,{sectionid:null,initializer:function(){var t=M.course.format.get_sectionwrapperclass();t&&(n.SECTION="."+t);var r=e.one(".chooserdialoguebody"),i=e.one(".choosertitle"),s={};this.setup_chooser_dialogue(r,i,s),this.setup_for_section(),M.course.coursebase.register_module(this),e.all(".block_settings #settingsnav .type_course .modchoosertoggle a").on("click",this.toggle_mod_chooser,this)},setup_for_section:function(t){t||(t=n.PAGECONTENT),e.one(t).all(n.SITETOPIC).each(function(e){this._setup_for_section(e)},this),n.SECTION&&e.one(t).all(n.SECTION).each(function(e){this._setup_for_section(e)},this),e.one(t).all(n.SITEMENU).each(function(e){this._setup_for_section(e)},this)},_setup_for_section:function(t){var r=t.one(n.SECTIONMODCHOOSER);if(!r)return;var i=e.Node.create("");r.get("children").each(function(e){i.appendChild(e)}),r.insertBefore(i),i.on("click",this.display_mod_chooser,this)},display_mod_chooser:function(e){if(e.target.ancestor(n.SITETOPIC))this.sectionid=1;else if(e.target.ancestor(n.SECTION)){var t=e.target.ancestor(n.SECTION);this.sectionid=t.get("id").replace("section-","")}else e.target.ancestor(n.SITEMENU)&&(this.sectionid=0);this.display_chooser(e)},toggle_mod_chooser:function(t){var n=e.all("div.addresourcemodchooser"),r=e.all("div.addresourcedropdown");if(n.size()===0)return;var i=e.one(".block_settings #settingsnav .type_course .modchoosertoggle a"),s=i.get("lastChild"),o;n.item(0).hasClass("visibleifjs")?(o=0,n.removeClass("visibleifjs").addClass("hiddenifjs"),r.addClass("visibleifjs").removeClass("hiddenifjs"),s.set("data",M.util.get_string("modchooserenable","moodle")),i.set("href",i.get("href").replace("off","on"))):(o=1,n.addClass("visibleifjs").removeClass("hiddenifjs"),r.removeClass("visibleifjs").addClass("hiddenifjs"),s.set("data",M.util.get_string("modchooserdisable","moodle")),i.set("href",i.get("href").replace("on","off"))),M.util.set_user_preference("usemodchooser",o),t.preventDefault()},option_selected:function(e){this.hiddenRadioValue.setAttrs({name:"jump",value:e.get("value")+"§ion="+this.sectionid})}},{NAME:r,ATTRS:{maxheight:{value:800}}}),M.course=M.course||{},M.course.init_chooser=function(e){return new i(e)}},"@VERSION@",{requires:["moodle-core-chooserdialogue","moodle-course-coursebase"]}); diff --git a/course/yui/build/moodle-course-modchooser/moodle-course-modchooser.js b/course/yui/build/moodle-course-modchooser/moodle-course-modchooser.js index 54312b42917..1689ac9789c 100644 --- a/course/yui/build/moodle-course-modchooser/moodle-course-modchooser.js +++ b/course/yui/build/moodle-course-modchooser/moodle-course-modchooser.js @@ -8,7 +8,7 @@ YUI.add('moodle-course-modchooser', function (Y, NAME) { var CSS = { PAGECONTENT : 'body', - SECTION : 'li.section', + SECTION: null, SECTIONMODCHOOSER : 'span.section-modchooser-link', SITEMENU : 'div.block_site_main_menu', SITETOPIC : 'div.sitetopic' @@ -44,6 +44,10 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, { * @method initializer */ initializer : function() { + var sectionclass = M.course.format.get_sectionwrapperclass(); + if (sectionclass) { + CSS.SECTION = '.' + sectionclass; + } var dialogue = Y.one('.chooserdialoguebody'); var header = Y.one('.choosertitle'); var params = {}; @@ -75,9 +79,11 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, { }, this); // Setup for standard course topics - Y.one(baseselector).all(CSS.SECTION).each(function(section) { - this._setup_for_section(section); - }, this); + if (CSS.SECTION) { + Y.one(baseselector).all(CSS.SECTION).each(function(section) { + this._setup_for_section(section); + }, this); + } // Setup for the block site menu Y.one(baseselector).all(CSS.SITEMENU).each(function(section) { diff --git a/course/yui/src/modchooser/js/modchooser.js b/course/yui/src/modchooser/js/modchooser.js index da70ad84813..ef6ac4df1e6 100644 --- a/course/yui/src/modchooser/js/modchooser.js +++ b/course/yui/src/modchooser/js/modchooser.js @@ -6,7 +6,7 @@ var CSS = { PAGECONTENT : 'body', - SECTION : 'li.section', + SECTION: null, SECTIONMODCHOOSER : 'span.section-modchooser-link', SITEMENU : 'div.block_site_main_menu', SITETOPIC : 'div.sitetopic' @@ -42,6 +42,10 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, { * @method initializer */ initializer : function() { + var sectionclass = M.course.format.get_sectionwrapperclass(); + if (sectionclass) { + CSS.SECTION = '.' + sectionclass; + } var dialogue = Y.one('.chooserdialoguebody'); var header = Y.one('.choosertitle'); var params = {}; @@ -73,9 +77,11 @@ Y.extend(MODCHOOSER, M.core.chooserdialogue, { }, this); // Setup for standard course topics - Y.one(baseselector).all(CSS.SECTION).each(function(section) { - this._setup_for_section(section); - }, this); + if (CSS.SECTION) { + Y.one(baseselector).all(CSS.SECTION).each(function(section) { + this._setup_for_section(section); + }, this); + } // Setup for the block site menu Y.one(baseselector).all(CSS.SITEMENU).each(function(section) {