Skip to content
Browse files

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.
  • Loading branch information...
1 parent 3262f54 commit ae860173395eb30caac0fbfff8f86120caace11f @andrewnicols andrewnicols committed Jun 13, 2012
Showing with 11 additions and 14 deletions.
  1. +11 −14 course/yui/modchooser/modchooser.js
View
25 course/yui/modchooser/modchooser.js
@@ -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) {

0 comments on commit ae86017

Please sign in to comment.
Something went wrong with that request. Please try again.