MDL-46920 theme_bootstrapbase: fix dropdown to use data-target
authorJetha Chan <jetha@moodle.com>
Mon, 15 Sep 2014 03:53:17 +0000 (11:53 +0800)
committerJetha Chan <jetha@moodle.com>
Wed, 17 Sep 2014 06:25:44 +0000 (14:25 +0800)
theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap-debug.js
theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap-min.js
theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap.js
theme/bootstrapbase/yui/src/bootstrap/js/bootstrap.js

index c3ca9e6..7c1b64d 100644 (file)
Binary files a/theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap-debug.js and b/theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap-debug.js differ
index 5c05647..7d253da 100644 (file)
Binary files a/theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap-min.js and b/theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap-min.js differ
index 927d338..255df0f 100644 (file)
Binary files a/theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap.js and b/theme/bootstrapbase/yui/build/moodle-theme_bootstrapbase-bootstrap/moodle-theme_bootstrapbase-bootstrap.js differ
index 1ab5f55..8e27fd4 100644 (file)
@@ -19,8 +19,7 @@ var CSS = {
     SELECTORS = {
         NAVBAR_BUTTON: '.btn-navbar',
         // FIXME This is deliberately wrong because of a breaking issue in the upstream library.
-        TOGGLECOLLAPSE: '*[data-disabledtoggle="collapse"]',
-        NAV_COLLAPSE: '.nav-collapse'
+        TOGGLECOLLAPSE: '*[data-disabledtoggle="collapse"]'
     },
     NS = Y.namespace('Moodle.theme_bootstrapbase.bootstrap');
 
@@ -96,8 +95,18 @@ NS.setup_toggle_show = function() {
  * @param {EventFacade} e
  */
 NS.toggle_show = function(e) {
-    // Toggle the active class on both the clicked .btn-navbar and the .nav-collapse.
-    // Our CSS will set the height for these.
-    Y.all(SELECTORS.NAV_COLLAPSE).toggleClass(CSS.ACTIVE);
+    // Toggle the active class on both the clicked .btn-navbar and the
+    // associated target, defined by a CSS selector string set as the
+    // data-target attribute on the .btn-navbar element in question.
+    //
+    // This will allow for us to have multiple .btn-navbar elements
+    // each with their own collapse/expand targets - these targets
+    // should be of class .nav-collapse.
+    var myTarget = this.get('parentNode').one(this.getAttribute('data-target'));
+    if (myTarget) {
+        this.siblings(".btn-navbar").removeClass(CSS.ACTIVE);
+        myTarget.siblings(".nav-collapse").removeClass(CSS.ACTIVE);
+        myTarget.toggleClass(CSS.ACTIVE);
+    }
     e.currentTarget.toggleClass(CSS.ACTIVE);
 };