MDL-33683 Determine sectionid for activity chooser at display time

Rather than calculate the sectionid for the activity chooser on page load,
we do so when opening the chooser. This resolves issues where sections have
been moved without swapping all of the section IDs around.
This commit is contained in:
Andrew Robert Nicols
2012-06-20 10:32:10 +01:00
parent 3262f547fc
commit ae86017339
+11 -14
View File
@@ -81,21 +81,12 @@ YUI.add('moodle-course-modchooser', function(Y) {
// Setup for site topics
Y.one(baseselector).all(CSS.SITETOPIC).each(function(section) {
// The site topic has a sectionid of 1
this._setup_for_section(section, 1);
}, this);
// Setup for the site menu
Y.one(baseselector).all(CSS.SITEMENU).each(function(section) {
// The site menu has a sectionid of 0
this._setup_for_section(section, 0);
this._setup_for_section(section);
}, this);
// Setup for standard course topics
Y.one(baseselector).all(CSS.SECTION).each(function(section) {
// Determine the sectionid for this section
var sectionid = section.get('id').replace('section-', '');
this._setup_for_section(section, sectionid);
this._setup_for_section(section);
}, this);
},
_setup_for_section : function(section, sectionid) {
@@ -108,7 +99,7 @@ YUI.add('moodle-course-modchooser', function(Y) {
chooserlink.appendChild(node);
});
chooserspan.insertBefore(chooserlink);
chooserlink.on('click', this.display_mod_chooser, this, sectionid);
chooserlink.on('click', this.display_mod_chooser, this);
},
/**
* Display the module chooser
@@ -117,9 +108,15 @@ YUI.add('moodle-course-modchooser', function(Y) {
* @param secitonid integer The ID of the section triggering the dialogue
* @return void
*/
display_mod_chooser : function (e, sectionid) {
display_mod_chooser : function (e) {
// Set the section for this version of the dialogue
this.sectionid = sectionid;
if (e.target.ancestor(CSS.SITETOPIC)) {
// The site topic has a sectionid of 1
this.sectionid = 1;
} else if (e.target.ancestor(CSS.SECTION)) {
var section = e.target.ancestor(CSS.SECTION);
this.sectionid = section.get('id').replace('section-', '');
}
this.display_chooser(e);
},
toggle_mod_chooser : function(e) {