]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Detach accordions from .card
authorJohann-S <johann.servoire@gmail.com>
Tue, 7 Mar 2017 09:46:08 +0000 (10:46 +0100)
committerJohann-S <johann.servoire@gmail.com>
Tue, 7 Mar 2017 09:46:08 +0000 (10:46 +0100)
js/src/collapse.js

index 28c4493cc5d362ce9025492f1a696d75a72ac35e..e2c9efe11a54acd38666cfbca1dc1363a7cf7d48 100644 (file)
@@ -57,7 +57,8 @@ const Collapse = (($) => {
 
   const Selector = {
     ACTIVES     : '.card > .show, .card > .collapsing',
-    DATA_TOGGLE : '[data-toggle="collapse"]'
+    DATA_TOGGLE : '[data-toggle="collapse"]',
+    DATA_CHILDREN : 'data-children'
   }
 
 
@@ -84,6 +85,14 @@ const Collapse = (($) => {
         this._addAriaAndCollapsedClass(this._element, this._triggerArray)
       }
 
+      this._selectorActives = Selector.ACTIVES
+      if (this._parent) {
+        const childrenSelector = this._parent.hasAttribute(Selector.DATA_CHILDREN) ? this._parent.getAttribute(Selector.DATA_CHILDREN) : null
+        if (childrenSelector !== null) {
+          this._selectorActives = childrenSelector + ' > .show, ' + childrenSelector + ' > .collapsing'
+        }
+      }
+
       if (this._config.toggle) {
         this.toggle()
       }
@@ -124,7 +133,7 @@ const Collapse = (($) => {
       let activesData
 
       if (this._parent) {
-        actives = $.makeArray($(this._parent).find(Selector.ACTIVES))
+        actives = $.makeArray($(this._parent).find(this._selectorActives))
         if (!actives.length) {
           actives = null
         }