From 099486f294e79bfe1f2c6b431ee4696237f616cd Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 7 Mar 2017 10:46:08 +0100 Subject: Detach accordions from .card --- js/src/collapse.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 28c4493cc..e2c9efe11 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -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 } -- cgit v1.2.3 From fa1504e6f68974114e3ab58b8b18a601bc973103 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 8 Mar 2017 11:15:58 +0100 Subject: Fix code style --- js/src/collapse.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index e2c9efe11..0776519ff 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -78,7 +78,6 @@ const Collapse = (($) => { `[data-toggle="collapse"][href="#${element.id}"],` + `[data-toggle="collapse"][data-target="#${element.id}"]` )) - this._parent = this._config.parent ? this._getParent() : null if (!this._config.parent) { @@ -89,7 +88,7 @@ const Collapse = (($) => { 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' + this._selectorActives = `${childrenSelector} > .show, ${childrenSelector} > .collapsing` } } -- cgit v1.2.3 From 275821bbb081890ffe232d50d4778eb15bdb1d7b Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Sat, 18 Mar 2017 21:24:54 -0400 Subject: HTMLElement.offset* by getBoundingClientRect() (#21788) * Replace element.offet* by getBoundingClientRect() * Use variable to store BoundingClientRect * Fix cc issue... --- js/src/collapse.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 28c4493cc..ed3c064b1 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -211,10 +211,8 @@ const Collapse = (($) => { } const dimension = this._getDimension() - const offsetDimension = dimension === Dimension.WIDTH ? - 'offsetWidth' : 'offsetHeight' - this._element.style[dimension] = `${this._element[offsetDimension]}px` + this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px` Util.reflow(this._element) -- cgit v1.2.3 From 24924c23b24c1b196c42166ebe9a17d31f0ee720 Mon Sep 17 00:00:00 2001 From: Johann Date: Mon, 27 Mar 2017 10:08:39 +0200 Subject: Collapse - do not prevent event for input and textarea --- js/src/collapse.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 13c44502c..6f09fcadd 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -363,7 +363,9 @@ const Collapse = (($) => { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - event.preventDefault() + if (/input|textarea/i.test(event.target.tagName)) { + event.preventDefault() + } const target = Collapse._getTargetFromElement(this) const data = $(target).data(DATA_KEY) -- cgit v1.2.3 From 48c5efa4c3c439d8720b8475ec3e372c6974a12a Mon Sep 17 00:00:00 2001 From: Pierre Vanduynslager Date: Tue, 28 Mar 2017 17:43:16 -0400 Subject: Fix JS components console error "Error: is transitioning" --- js/src/collapse.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index 6f09fcadd..dc2e2a67d 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -120,11 +120,8 @@ const Collapse = (($) => { } show() { - if (this._isTransitioning) { - throw new Error('Collapse is transitioning') - } - - if ($(this._element).hasClass(ClassName.SHOW)) { + if (this._isTransitioning || + $(this._element).hasClass(ClassName.SHOW)) { return } @@ -204,11 +201,8 @@ const Collapse = (($) => { } hide() { - if (this._isTransitioning) { - throw new Error('Collapse is transitioning') - } - - if (!$(this._element).hasClass(ClassName.SHOW)) { + if (this._isTransitioning || + !$(this._element).hasClass(ClassName.SHOW)) { return } -- cgit v1.2.3 From fb42d6e0435bb101c0505090055e8034cb101dc4 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 29 Mar 2017 00:10:27 +0200 Subject: Collapse - Fix check to not prevent event for input and textarea --- js/src/collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src/collapse.js') diff --git a/js/src/collapse.js b/js/src/collapse.js index dc2e2a67d..88428310d 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -357,7 +357,7 @@ const Collapse = (($) => { */ $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - if (/input|textarea/i.test(event.target.tagName)) { + if (!/input|textarea/i.test(event.target.tagName)) { event.preventDefault() } -- cgit v1.2.3