Merge branch 'MDL-33683-master-2' of git://git.luns.net.uk/moodle
authorAparup Banerjee <aparup@moodle.com>
Wed, 20 Jun 2012 11:36:22 +0000 (19:36 +0800)
committerAparup Banerjee <aparup@moodle.com>
Wed, 20 Jun 2012 11:36:22 +0000 (19:36 +0800)
course/yui/modchooser/modchooser.js

index f2c7207..9229714 100644 (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) {