From 2ae5fdf9ddbff98c55e47b81d7150b8d960ad342 Mon Sep 17 00:00:00 2001 From: Bernardo Gurgel Filho Date: Sun, 23 Aug 2015 01:59:48 -0300 Subject: Convert tooltip's arrows to generated CSS content via :before --- js/src/tooltip.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index aa5c73945..099a47482 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -28,7 +28,6 @@ const Tooltip = (($) => { const Default = { animation : true, template : '', trigger : 'hover focus', title : '', -- cgit v1.2.3 From 8ef66df6d793afbda487c1a4505d0a6576252ec4 Mon Sep 17 00:00:00 2001 From: Bernardo Gurgel Filho Date: Sun, 23 Aug 2015 17:54:38 -0300 Subject: Convert popover's arrows to generated CSS content via :before/:after --- js/src/popover.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'js/src') diff --git a/js/src/popover.js b/js/src/popover.js index 99e48e64f..6ea8b00fb 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -28,7 +28,6 @@ const Popover = (($) => { trigger : 'click', content : '', template : '' }) @@ -44,8 +43,7 @@ const Popover = (($) => { const Selector = { TITLE : '.popover-title', - CONTENT : '.popover-content', - ARROW : '.popover-arrow' + CONTENT : '.popover-content' } const Event = { -- cgit v1.2.3 From 32f9a5d6a594aaa4afd62b2410b45804edb737c5 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 11 Sep 2015 10:45:08 +0200 Subject: fix resetting style on closing collapse --- js/src/collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/collapse.js b/js/src/collapse.js index e46d3ec60..d95d6f28e 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -235,7 +235,7 @@ const Collapse = (($) => { .trigger(Event.HIDDEN) } - this._element.style[dimension] = 0 + this._element.style[dimension] = '' if (!Util.supportsTransitionEnd()) { complete() -- cgit v1.2.3 From 6d451ad99d02ed60ced937901a9d8b8323999af3 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 16 Sep 2015 09:46:55 +0200 Subject: Change destroy -> dispose --- js/src/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 151cd6f51..55b9d5898 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -612,7 +612,7 @@ const Tooltip = (($) => { let _config = typeof config === 'object' ? config : null - if (!data && /destroy|hide/.test(config)) { + if (!data && /dispose|hide/.test(config)) { return } -- cgit v1.2.3 From 866e99b00cb12dcfa0d9b88edf4f4d0ef06ca3f3 Mon Sep 17 00:00:00 2001 From: Kotas Vlastimil Date: Thu, 14 Jan 2016 17:41:36 +0100 Subject: Button toggling - trigger change event on input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bootstrap’s .button styles can be applied to other elements, such as labels, to provide checkbox or radio style button toggling. When the checkbox or radio state is changed, there should be triggered the change event. Currently, the change event is triggered on the Button, which is not correct. Only input fields do support the change event. --- js/src/button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/button.js b/js/src/button.js index 3144a3f10..f5551f169 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -90,7 +90,7 @@ const Button = (($) => { if (triggerChangeEvent) { input.checked = !$(this._element).hasClass(ClassName.ACTIVE) - $(this._element).trigger('change') + $(input).trigger('change') } } } else { -- cgit v1.2.3 From 14ec4fdfc10a965477314078c1a9531a1d02fb8f Mon Sep 17 00:00:00 2001 From: Johann-S Date: Mon, 1 Feb 2016 00:06:07 +0100 Subject: Carousel - Do not prevent on keydown for input and textarea --- js/src/carousel.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index 34cab4391..0ed4b7b5f 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -229,11 +229,10 @@ const Carousel = (($) => { } _keydown(event) { - event.preventDefault() - if (/input|textarea/i.test(event.target.tagName)) { return } + event.preventDefault() switch (event.which) { case 37: this.prev(); break -- cgit v1.2.3 From 1a23279237b5360dab15d91aac85cbf8306e560a Mon Sep 17 00:00:00 2001 From: "Michael J. Ryan" Date: Mon, 14 Mar 2016 13:18:08 -0700 Subject: Update tooltip.js Don't reference `Tether` via attachment to `window`, with the update one can import bootstrap providing the dependencies in webpack with: ``` new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', Tether: 'tether', }); ``` Then inside one's own bootstrap/globals, `import 'bootstrap';` will simply work, and $/jQuery can be used from there. I had wanted to do this, but also expose jQuery, Tether, etc when in development build in my code, but if I provide `window.Tether`, I can't then expose it to the outside... --- js/src/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 77803dc40..03d9e4cc8 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -16,7 +16,7 @@ const Tooltip = (($) => { * Check for Tether dependency * Tether - http://github.hubspot.com/tether/ */ - if (window.Tether === undefined) { + if ('undefined' === typeof Tether) { throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)') } -- cgit v1.2.3 From 681d390a0504c7a1c855a6eb052ea70409e41cde Mon Sep 17 00:00:00 2001 From: "Michael J. Ryan" Date: Mon, 14 Mar 2016 13:29:03 -0700 Subject: Update tooltip.js match project's style check --- js/src/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 03d9e4cc8..b98a56134 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -16,7 +16,7 @@ const Tooltip = (($) => { * Check for Tether dependency * Tether - http://github.hubspot.com/tether/ */ - if ('undefined' === typeof Tether) { + if (typeof Tether === 'undefined') { throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)') } -- cgit v1.2.3 From bfa714ae1e91e2f77017d02489cbc39fada032c7 Mon Sep 17 00:00:00 2001 From: Max Beatty Date: Thu, 4 Aug 2016 13:47:30 -0700 Subject: prevent navigating to area href when modal target. fixes #18796 --- js/src/modal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index 9b3a99ddd..fd13a687c 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -491,7 +491,7 @@ const Modal = (($) => { let config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()) - if (this.tagName === 'A') { + if (this.tagName === 'A' || this.tagName === 'AREA') { event.preventDefault() } -- cgit v1.2.3 From dc1b4e78d49e7c3caedc2918298b646cf8c8200b Mon Sep 17 00:00:00 2001 From: Max Beatty Date: Thu, 4 Aug 2016 16:57:08 -0700 Subject: add support for ol in tab plugin. fixes #17754 --- js/src/tab.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/src') diff --git a/js/src/tab.js b/js/src/tab.js index 7bd8f2f9c..7a698851b 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -44,7 +44,7 @@ const Tab = (($) => { A : 'a', LI : 'li', DROPDOWN : '.dropdown', - UL : 'ul:not(.dropdown-menu)', + LIST : 'ul:not(.dropdown-menu), ol:not(.dropdown-menu)', FADE_CHILD : '> .nav-item .fade, > .fade', ACTIVE : '.active', ACTIVE_CHILD : '> .nav-item > .active, > .active', @@ -85,11 +85,11 @@ const Tab = (($) => { let target let previous - let ulElement = $(this._element).closest(Selector.UL)[0] + let listElement = $(this._element).closest(Selector.LIST)[0] let selector = Util.getSelectorFromElement(this._element) - if (ulElement) { - previous = $.makeArray($(ulElement).find(Selector.ACTIVE)) + if (listElement) { + previous = $.makeArray($(listElement).find(Selector.ACTIVE)) previous = previous[previous.length - 1] } @@ -118,7 +118,7 @@ const Tab = (($) => { this._activate( this._element, - ulElement + listElement ) let complete = () => { -- cgit v1.2.3 From edc43a4ea63312d95bd0779832c534cd3c14895b Mon Sep 17 00:00:00 2001 From: J2TeaM Date: Wed, 7 Sep 2016 02:55:48 +0700 Subject: Remove classes at one time --- js/src/carousel.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index ff00d8aaf..ea14d0c9a 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -353,15 +353,10 @@ const Carousel = (($) => { $(activeElement) .one(Util.TRANSITION_END, () => { $(nextElement) - .removeClass(directionalClassName) - .removeClass(direction) + .removeClass(directionalClassName + ' ' + direction) + .addClass(ClassName.ACTIVE) - $(nextElement).addClass(ClassName.ACTIVE) - - $(activeElement) - .removeClass(ClassName.ACTIVE) - .removeClass(direction) - .removeClass(directionalClassName) + $(activeElement).removeClass(ClassName.ACTIVE + ' ' + direction + ' ' + directionalClassName) this._isSliding = false -- cgit v1.2.3 From 4f5a7c96e73071d2d75a0fa135797c9ee15969ed Mon Sep 17 00:00:00 2001 From: J2TeaM Date: Wed, 7 Sep 2016 03:17:19 +0700 Subject: Fix eslint (prefer-template) --- js/src/carousel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index ea14d0c9a..92d91ff2f 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -353,10 +353,10 @@ const Carousel = (($) => { $(activeElement) .one(Util.TRANSITION_END, () => { $(nextElement) - .removeClass(directionalClassName + ' ' + direction) + .removeClass(`${directionalClassName} ${direction}`) .addClass(ClassName.ACTIVE) - $(activeElement).removeClass(ClassName.ACTIVE + ' ' + direction + ' ' + directionalClassName) + $(activeElement).removeClass(`${ClassName.ACTIVE} ${direction} ${directionalClassName}`) this._isSliding = false -- cgit v1.2.3 From 4f520c7ff301ce42f01e32bd77606ce94384cd13 Mon Sep 17 00:00:00 2001 From: J2TeaM Date: Wed, 7 Sep 2016 10:09:54 +0700 Subject: Merge #20563 and #20567 --- js/src/popover.js | 4 +--- js/src/tooltip.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'js/src') diff --git a/js/src/popover.js b/js/src/popover.js index 7ea560812..eae17f1d3 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -119,9 +119,7 @@ const Popover = (($) => { this.setElementContent($tip.find(Selector.TITLE), this.getTitle()) this.setElementContent($tip.find(Selector.CONTENT), this._getContent()) - $tip - .removeClass(ClassName.FADE) - .removeClass(ClassName.IN) + $tip.removeClass(`${ClassName.FADE} ${ClassName.IN}`) this.cleanupTether() } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 08daae2f2..e0691f14c 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -371,9 +371,7 @@ const Tooltip = (($) => { this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle()) - $tip - .removeClass(ClassName.FADE) - .removeClass(ClassName.IN) + $tip.removeClass(`${ClassName.FADE} ${ClassName.IN}`) this.cleanupTether() } -- cgit v1.2.3 From 2e69dfa8c1679238579ef6f5ec85deb755e4fb6d Mon Sep 17 00:00:00 2001 From: Bardi Harborow Date: Tue, 4 Oct 2016 02:55:59 +1000 Subject: Fix broken/redirected links, moving to HTTPS where possible. (#20557) --- js/src/tooltip.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 08daae2f2..d012b2907 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -14,10 +14,10 @@ const Tooltip = (($) => { /** * Check for Tether dependency - * Tether - http://github.hubspot.com/tether/ + * Tether - http://tether.io/ */ if (window.Tether === undefined) { - throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)') + throw new Error('Bootstrap tooltips require Tether (http://tether.io/)') } -- cgit v1.2.3 From de1255b14e9d1bbfc1a3b055477f4fc15cc974af Mon Sep 17 00:00:00 2001 From: Johann-S Date: Tue, 1 Dec 2015 23:17:35 +0100 Subject: Collapse using card component --- js/src/collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/collapse.js b/js/src/collapse.js index 3fb0245e7..560ab2cbd 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -56,7 +56,7 @@ const Collapse = (($) => { } const Selector = { - ACTIVES : '.panel > .in, .panel > .collapsing', + ACTIVES : '.card > .in, .card > .collapsing', DATA_TOGGLE : '[data-toggle="collapse"]' } -- cgit v1.2.3 From 9bc7de93950444eee1e4cae8b5a029bcb4907640 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Mon, 11 Jan 2016 20:42:35 +0100 Subject: Fix bug multiple accordions collapse --- js/src/collapse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/collapse.js b/js/src/collapse.js index 560ab2cbd..b784b82b6 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -121,7 +121,7 @@ const Collapse = (($) => { let activesData if (this._parent) { - actives = $.makeArray($(Selector.ACTIVES)) + actives = $.makeArray($(this._parent).find(Selector.ACTIVES)) if (!actives.length) { actives = null } -- cgit v1.2.3 From 8ff7edaab4f55b6612df3fe670aa9b9ac0984eae Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Wed, 19 Oct 2016 08:27:41 -0700 Subject: version bump to alpha 5 --- js/src/alert.js | 4 ++-- js/src/button.js | 4 ++-- js/src/carousel.js | 4 ++-- js/src/collapse.js | 4 ++-- js/src/dropdown.js | 4 ++-- js/src/modal.js | 4 ++-- js/src/popover.js | 4 ++-- js/src/scrollspy.js | 4 ++-- js/src/tab.js | 4 ++-- js/src/tooltip.js | 4 ++-- js/src/util.js | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) (limited to 'js/src') diff --git a/js/src/alert.js b/js/src/alert.js index cff86dcdd..a46494070 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): alert.js + * Bootstrap (v4.0.0-alpha.5): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Alert = (($) => { */ const NAME = 'alert' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.alert' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/button.js b/js/src/button.js index 24b0cd414..a7eed1826 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): button.js + * Bootstrap (v4.0.0-alpha.5): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -15,7 +15,7 @@ const Button = (($) => { */ const NAME = 'button' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.button' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/carousel.js b/js/src/carousel.js index ff00d8aaf..54249039e 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): carousel.js + * Bootstrap (v4.0.0-alpha.5): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Carousel = (($) => { */ const NAME = 'carousel' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.carousel' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/collapse.js b/js/src/collapse.js index 560ab2cbd..1e2d4a63e 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): collapse.js + * Bootstrap (v4.0.0-alpha.5): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Collapse = (($) => { */ const NAME = 'collapse' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.collapse' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/dropdown.js b/js/src/dropdown.js index e38792d3b..656a05e77 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): dropdown.js + * Bootstrap (v4.0.0-alpha.5): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Dropdown = (($) => { */ const NAME = 'dropdown' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.dropdown' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/modal.js b/js/src/modal.js index ebd3e4a34..ee78070dd 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): modal.js + * Bootstrap (v4.0.0-alpha.5): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Modal = (($) => { */ const NAME = 'modal' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.modal' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/popover.js b/js/src/popover.js index 26ad988d4..115cfef9e 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -3,7 +3,7 @@ import Tooltip from './tooltip' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): popover.js + * Bootstrap (v4.0.0-alpha.5): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Popover = (($) => { */ const NAME = 'popover' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.popover' const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index a664090fb..604815f4e 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): scrollspy.js + * Bootstrap (v4.0.0-alpha.5): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const ScrollSpy = (($) => { */ const NAME = 'scrollspy' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.scrollspy' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/tab.js b/js/src/tab.js index bf059d367..4424a7a41 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): tab.js + * Bootstrap (v4.0.0-alpha.5): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Tab = (($) => { */ const NAME = 'tab' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.tab' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' diff --git a/js/src/tooltip.js b/js/src/tooltip.js index e854b1bb4..c21eb0cda 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -5,7 +5,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): tooltip.js + * Bootstrap (v4.0.0-alpha.5): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ const Tooltip = (($) => { */ const NAME = 'tooltip' - const VERSION = '4.0.0-alpha.4' + const VERSION = '4.0.0-alpha.5' const DATA_KEY = 'bs.tooltip' const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] diff --git a/js/src/util.js b/js/src/util.js index d117dfcd5..f9e7f77fa 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0-alpha.4): util.js + * Bootstrap (v4.0.0-alpha.5): util.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3 From 9d129a43d6c24d9e60cc8fc7cfbddaaa4c586fdf Mon Sep 17 00:00:00 2001 From: Johann-S Date: Mon, 24 Oct 2016 10:57:32 +0200 Subject: Use a single class name for opened/expanded/shown state of widgets --- js/src/alert.js | 8 ++++---- js/src/collapse.js | 16 ++++++++-------- js/src/dropdown.js | 12 ++++++------ js/src/modal.js | 10 +++++----- js/src/popover.js | 6 +++--- js/src/tooltip.js | 28 ++++++++++++++-------------- 6 files changed, 40 insertions(+), 40 deletions(-) (limited to 'js/src') diff --git a/js/src/alert.js b/js/src/alert.js index a46494070..0456c677d 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -36,9 +36,9 @@ const Alert = (($) => { } const ClassName = { - ALERT : 'alert', - FADE : 'fade', - IN : 'in' + ALERT : 'alert', + FADE : 'fade', + ACTIVE : 'active' } @@ -108,7 +108,7 @@ const Alert = (($) => { } _removeElement(element) { - $(element).removeClass(ClassName.IN) + $(element).removeClass(ClassName.ACTIVE) if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { diff --git a/js/src/collapse.js b/js/src/collapse.js index 782d82a2f..f700979e0 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -44,7 +44,7 @@ const Collapse = (($) => { } const ClassName = { - IN : 'in', + ACTIVE : 'active', COLLAPSE : 'collapse', COLLAPSING : 'collapsing', COLLAPSED : 'collapsed' @@ -56,7 +56,7 @@ const Collapse = (($) => { } const Selector = { - ACTIVES : '.card > .in, .card > .collapsing', + ACTIVES : '.card > .active, .card > .collapsing', DATA_TOGGLE : '[data-toggle="collapse"]' } @@ -104,7 +104,7 @@ const Collapse = (($) => { // public toggle() { - if ($(this._element).hasClass(ClassName.IN)) { + if ($(this._element).hasClass(ClassName.ACTIVE)) { this.hide() } else { this.show() @@ -113,7 +113,7 @@ const Collapse = (($) => { show() { if (this._isTransitioning || - $(this._element).hasClass(ClassName.IN)) { + $(this._element).hasClass(ClassName.ACTIVE)) { return } @@ -168,7 +168,7 @@ const Collapse = (($) => { $(this._element) .removeClass(ClassName.COLLAPSING) .addClass(ClassName.COLLAPSE) - .addClass(ClassName.IN) + .addClass(ClassName.ACTIVE) this._element.style[dimension] = '' @@ -194,7 +194,7 @@ const Collapse = (($) => { hide() { if (this._isTransitioning || - !$(this._element).hasClass(ClassName.IN)) { + !$(this._element).hasClass(ClassName.ACTIVE)) { return } @@ -215,7 +215,7 @@ const Collapse = (($) => { $(this._element) .addClass(ClassName.COLLAPSING) .removeClass(ClassName.COLLAPSE) - .removeClass(ClassName.IN) + .removeClass(ClassName.ACTIVE) this._element.setAttribute('aria-expanded', false) @@ -293,7 +293,7 @@ const Collapse = (($) => { _addAriaAndCollapsedClass(element, triggerArray) { if (element) { - let isOpen = $(element).hasClass(ClassName.IN) + let isOpen = $(element).hasClass(ClassName.ACTIVE) element.setAttribute('aria-expanded', isOpen) if (triggerArray.length) { diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 656a05e77..3246e6bef 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -41,7 +41,7 @@ const Dropdown = (($) => { const ClassName = { BACKDROP : 'dropdown-backdrop', DISABLED : 'disabled', - OPEN : 'open' + ACTIVE : 'active' } const Selector = { @@ -86,7 +86,7 @@ const Dropdown = (($) => { } let parent = Dropdown._getParentFromElement(this) - let isActive = $(parent).hasClass(ClassName.OPEN) + let isActive = $(parent).hasClass(ClassName.ACTIVE) Dropdown._clearMenus() @@ -116,7 +116,7 @@ const Dropdown = (($) => { this.focus() this.setAttribute('aria-expanded', 'true') - $(parent).toggleClass(ClassName.OPEN) + $(parent).toggleClass(ClassName.ACTIVE) $(parent).trigger($.Event(Event.SHOWN, relatedTarget)) return false @@ -171,7 +171,7 @@ const Dropdown = (($) => { let parent = Dropdown._getParentFromElement(toggles[i]) let relatedTarget = { relatedTarget : toggles[i] } - if (!$(parent).hasClass(ClassName.OPEN)) { + if (!$(parent).hasClass(ClassName.ACTIVE)) { continue } @@ -190,7 +190,7 @@ const Dropdown = (($) => { toggles[i].setAttribute('aria-expanded', 'false') $(parent) - .removeClass(ClassName.OPEN) + .removeClass(ClassName.ACTIVE) .trigger($.Event(Event.HIDDEN, relatedTarget)) } } @@ -220,7 +220,7 @@ const Dropdown = (($) => { } let parent = Dropdown._getParentFromElement(this) - let isActive = $(parent).hasClass(ClassName.OPEN) + let isActive = $(parent).hasClass(ClassName.ACTIVE) if ((!isActive && event.which !== ESCAPE_KEYCODE) || (isActive && event.which === ESCAPE_KEYCODE)) { diff --git a/js/src/modal.js b/js/src/modal.js index ee78070dd..252637428 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -60,7 +60,7 @@ const Modal = (($) => { BACKDROP : 'modal-backdrop', OPEN : 'modal-open', FADE : 'fade', - IN : 'in' + ACTIVE : 'active' } const Selector = { @@ -169,7 +169,7 @@ const Modal = (($) => { $(document).off(Event.FOCUSIN) - $(this._element).removeClass(ClassName.IN) + $(this._element).removeClass(ClassName.ACTIVE) $(this._element).off(Event.CLICK_DISMISS) $(this._dialog).off(Event.MOUSEDOWN_DISMISS) @@ -231,7 +231,7 @@ const Modal = (($) => { Util.reflow(this._element) } - $(this._element).addClass(ClassName.IN) + $(this._element).addClass(ClassName.ACTIVE) if (this._config.focus) { this._enforceFocus() @@ -343,7 +343,7 @@ const Modal = (($) => { Util.reflow(this._backdrop) } - $(this._backdrop).addClass(ClassName.IN) + $(this._backdrop).addClass(ClassName.ACTIVE) if (!callback) { return @@ -359,7 +359,7 @@ const Modal = (($) => { .emulateTransitionEnd(BACKDROP_TRANSITION_DURATION) } else if (!this._isShown && this._backdrop) { - $(this._backdrop).removeClass(ClassName.IN) + $(this._backdrop).removeClass(ClassName.ACTIVE) let callbackRemove = () => { this._removeBackdrop() diff --git a/js/src/popover.js b/js/src/popover.js index 115cfef9e..289853b32 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -37,8 +37,8 @@ const Popover = (($) => { }) const ClassName = { - FADE : 'fade', - IN : 'in' + FADE : 'fade', + ACTIVE : 'active' } const Selector = { @@ -119,7 +119,7 @@ const Popover = (($) => { $tip .removeClass(ClassName.FADE) - .removeClass(ClassName.IN) + .removeClass(ClassName.ACTIVE) this.cleanupTether() } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index c21eb0cda..90e782dc9 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -70,8 +70,8 @@ const Tooltip = (($) => { } const HoverState = { - IN : 'in', - OUT : 'out' + ACTIVE : 'active', + OUT : 'out' } const Event = { @@ -88,8 +88,8 @@ const Tooltip = (($) => { } const ClassName = { - FADE : 'fade', - IN : 'in' + FADE : 'fade', + ACTIVE : 'active' } const Selector = { @@ -205,7 +205,7 @@ const Tooltip = (($) => { } else { - if ($(this.getTipElement()).hasClass(ClassName.IN)) { + if ($(this.getTipElement()).hasClass(ClassName.ACTIVE)) { this._leave(null, this) return } @@ -291,7 +291,7 @@ const Tooltip = (($) => { Util.reflow(tip) this._tether.position() - $(tip).addClass(ClassName.IN) + $(tip).addClass(ClassName.ACTIVE) let complete = () => { let prevHoverState = this._hoverState @@ -319,7 +319,7 @@ const Tooltip = (($) => { let tip = this.getTipElement() let hideEvent = $.Event(this.constructor.Event.HIDE) let complete = () => { - if (this._hoverState !== HoverState.IN && tip.parentNode) { + if (this._hoverState !== HoverState.ACTIVE && tip.parentNode) { tip.parentNode.removeChild(tip) } @@ -338,7 +338,7 @@ const Tooltip = (($) => { return } - $(tip).removeClass(ClassName.IN) + $(tip).removeClass(ClassName.ACTIVE) if (Util.supportsTransitionEnd() && ($(this.tip).hasClass(ClassName.FADE))) { @@ -372,7 +372,7 @@ const Tooltip = (($) => { $tip .removeClass(ClassName.FADE) - .removeClass(ClassName.IN) + .removeClass(ClassName.ACTIVE) this.cleanupTether() } @@ -492,15 +492,15 @@ const Tooltip = (($) => { ] = true } - if ($(context.getTipElement()).hasClass(ClassName.IN) || - (context._hoverState === HoverState.IN)) { - context._hoverState = HoverState.IN + if ($(context.getTipElement()).hasClass(ClassName.ACTIVE) || + (context._hoverState === HoverState.ACTIVE)) { + context._hoverState = HoverState.ACTIVE return } clearTimeout(context._timeout) - context._hoverState = HoverState.IN + context._hoverState = HoverState.ACTIVE if (!context.config.delay || !context.config.delay.show) { context.show() @@ -508,7 +508,7 @@ const Tooltip = (($) => { } context._timeout = setTimeout(() => { - if (context._hoverState === HoverState.IN) { + if (context._hoverState === HoverState.ACTIVE) { context.show() } }, context.config.delay.show) -- cgit v1.2.3 From bf439363775c98d900f7ef3d6d0297fa8887ef58 Mon Sep 17 00:00:00 2001 From: Ilias Date: Sun, 30 Oct 2016 23:47:14 +0200 Subject: Fix #17964 (#17997) * Fix #17964 Some browsers are lazy when updating dom elements after transition effects. This can be fixed by reading element properties such as offsetHeight or offsetWidth. However, creating a function using the Function constructor just to access such element, results in a violation of Content Security Policy (where applied), which in turn crashes the application. This fix actually reverts to the way this was handled in v3 and should work as intended. --- js/src/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/util.js b/js/src/util.js index f9e7f77fa..5ddbbbf13 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -121,7 +121,7 @@ const Util = (($) => { }, reflow(element) { - new Function('bs', 'return bs')(element.offsetHeight) + return element.offsetHeight }, triggerTransitionEnd(element) { -- cgit v1.2.3 From 0974267b8c2b137d563d36c2390b4491fb1e0309 Mon Sep 17 00:00:00 2001 From: Bardi Harborow Date: Tue, 1 Nov 2016 14:32:36 +1100 Subject: Move from $.proxy to es6 arrow functions. (#21049) --- js/src/alert.js | 2 +- js/src/carousel.js | 8 ++++---- js/src/modal.js | 10 ++++------ js/src/scrollspy.js | 2 +- js/src/tab.js | 4 +--- js/src/tooltip.js | 6 +++--- 6 files changed, 14 insertions(+), 18 deletions(-) (limited to 'js/src') diff --git a/js/src/alert.js b/js/src/alert.js index 0456c677d..27411e276 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -117,7 +117,7 @@ const Alert = (($) => { } $(element) - .one(Util.TRANSITION_END, $.proxy(this._destroyElement, this, element)) + .one(Util.TRANSITION_END, (event) => this._destroyElement(element, event)) .emulateTransitionEnd(TRANSITION_DURATION) } diff --git a/js/src/carousel.js b/js/src/carousel.js index 54249039e..17bfebc68 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -161,7 +161,7 @@ const Carousel = (($) => { if (this._config.interval && !this._isPaused) { this._interval = setInterval( - $.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval + (document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval ) } } @@ -219,14 +219,14 @@ const Carousel = (($) => { _addEventListeners() { if (this._config.keyboard) { $(this._element) - .on(Event.KEYDOWN, $.proxy(this._keydown, this)) + .on(Event.KEYDOWN, (event) => this._keydown(event)) } if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) { $(this._element) - .on(Event.MOUSEENTER, $.proxy(this.pause, this)) - .on(Event.MOUSELEAVE, $.proxy(this.cycle, this)) + .on(Event.MOUSEENTER, (event) => this.pause(event)) + .on(Event.MOUSELEAVE, (event) => this.cycle(event)) } } diff --git a/js/src/modal.js b/js/src/modal.js index 252637428..a52dcb07f 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -133,7 +133,7 @@ const Modal = (($) => { $(this._element).on( Event.CLICK_DISMISS, Selector.DATA_DISMISS, - $.proxy(this.hide, this) + (event) => this.hide(event) ) $(this._dialog).on(Event.MOUSEDOWN_DISMISS, () => { @@ -144,9 +144,7 @@ const Modal = (($) => { }) }) - this._showBackdrop( - $.proxy(this._showElement, this, relatedTarget) - ) + this._showBackdrop(() => this._showElement(relatedTarget)) } hide(event) { @@ -178,7 +176,7 @@ const Modal = (($) => { ($(this._element).hasClass(ClassName.FADE))) { $(this._element) - .one(Util.TRANSITION_END, $.proxy(this._hideModal, this)) + .one(Util.TRANSITION_END, (event) => this._hideModal(event)) .emulateTransitionEnd(TRANSITION_DURATION) } else { this._hideModal() @@ -284,7 +282,7 @@ const Modal = (($) => { _setResizeEvent() { if (this._isShown) { - $(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this)) + $(window).on(Event.RESIZE, (event) => this._handleUpdate(event)) } else { $(window).off(Event.RESIZE) } diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 604815f4e..648173b33 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -87,7 +87,7 @@ const ScrollSpy = (($) => { this._activeTarget = null this._scrollHeight = 0 - $(this._scrollElement).on(Event.SCROLL, $.proxy(this._process, this)) + $(this._scrollElement).on(Event.SCROLL, (event) => this._process(event)) this.refresh() this._process() diff --git a/js/src/tab.js b/js/src/tab.js index c625a010d..012d2f76f 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -156,9 +156,7 @@ const Tab = (($) => { && ((active && $(active).hasClass(ClassName.FADE)) || Boolean($(container).find(Selector.FADE_CHILD)[0])) - let complete = $.proxy( - this._transitionComplete, - this, + let complete = () => this._transitionComplete( element, active, isTransitioning, diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 90e782dc9..6c23b9f9d 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -426,7 +426,7 @@ const Tooltip = (($) => { $(this.element).on( this.constructor.Event.CLICK, this.config.selector, - $.proxy(this.toggle, this) + (event) => this.toggle(event) ) } else if (trigger !== Trigger.MANUAL) { @@ -441,12 +441,12 @@ const Tooltip = (($) => { .on( eventIn, this.config.selector, - $.proxy(this._enter, this) + (event) => this._enter(event) ) .on( eventOut, this.config.selector, - $.proxy(this._leave, this) + (event) => this._leave(event) ) } }) -- cgit v1.2.3 From a7f1b59959b12ab2e78c32e6954d083601ad45ba Mon Sep 17 00:00:00 2001 From: Johann Date: Tue, 1 Nov 2016 04:33:53 +0100 Subject: Making .tooltip('show') throw an error on elements with display:none (#20940) --- js/src/tooltip.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 6c23b9f9d..c4fdbff59 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -239,6 +239,9 @@ const Tooltip = (($) => { } show() { + if ($(this.element).css('display') === 'none') { + throw new Error('Please use show on visible elements') + } let showEvent = $.Event(this.constructor.Event.SHOW) if (this.isWithContent() && this._isEnabled) { -- cgit v1.2.3 From c2616fb74e6bdc0cd46a5678a2c5cffcbe422106 Mon Sep 17 00:00:00 2001 From: Bardi Harborow Date: Tue, 22 Nov 2016 01:36:00 +1100 Subject: Make JS compliant with the new ESLint rules. --- js/src/alert.js | 14 ++++----- js/src/button.js | 8 +++--- js/src/carousel.js | 55 ++++++++++++++++++------------------ js/src/collapse.js | 40 +++++++++++++------------- js/src/dropdown.js | 49 +++++++++++++++++--------------- js/src/modal.js | 44 ++++++++++++++--------------- js/src/popover.js | 8 +++--- js/src/scrollspy.js | 30 ++++++++++---------- js/src/tab.js | 40 +++++++++++++------------- js/src/tooltip.js | 81 ++++++++++++++++++++++++++--------------------------- js/src/util.js | 30 +++++++++----------- 11 files changed, 200 insertions(+), 199 deletions(-) (limited to 'js/src') diff --git a/js/src/alert.js b/js/src/alert.js index 27411e276..8e5524950 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -67,8 +67,8 @@ const Alert = (($) => { close(element) { element = element || this._element - let rootElement = this._getRootElement(element) - let customEvent = this._triggerCloseEvent(rootElement) + const rootElement = this._getRootElement(element) + const customEvent = this._triggerCloseEvent(rootElement) if (customEvent.isDefaultPrevented()) { return @@ -86,8 +86,8 @@ const Alert = (($) => { // private _getRootElement(element) { - let selector = Util.getSelectorFromElement(element) - let parent = false + const selector = Util.getSelectorFromElement(element) + let parent = false if (selector) { parent = $(selector)[0] @@ -101,7 +101,7 @@ const Alert = (($) => { } _triggerCloseEvent(element) { - let closeEvent = $.Event(Event.CLOSE) + const closeEvent = $.Event(Event.CLOSE) $(element).trigger(closeEvent) return closeEvent @@ -133,8 +133,8 @@ const Alert = (($) => { static _jQueryInterface(config) { return this.each(function () { - let $element = $(this) - let data = $element.data(DATA_KEY) + const $element = $(this) + let data = $element.data(DATA_KEY) if (!data) { data = new Alert(this) diff --git a/js/src/button.js b/js/src/button.js index a7eed1826..8b9511765 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -66,12 +66,12 @@ const Button = (($) => { toggle() { let triggerChangeEvent = true - let rootElement = $(this._element).closest( + const rootElement = $(this._element).closest( Selector.DATA_TOGGLE )[0] if (rootElement) { - let input = $(this._element).find(Selector.INPUT)[0] + const input = $(this._element).find(Selector.INPUT)[0] if (input) { if (input.type === 'radio') { @@ -80,7 +80,7 @@ const Button = (($) => { triggerChangeEvent = false } else { - let activeElement = $(rootElement).find(Selector.ACTIVE)[0] + const activeElement = $(rootElement).find(Selector.ACTIVE)[0] if (activeElement) { $(activeElement).removeClass(ClassName.ACTIVE) @@ -151,7 +151,7 @@ const Button = (($) => { Button._jQueryInterface.call($(button), 'toggle') }) .on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, (event) => { - let button = $(event.target).closest(Selector.BUTTON)[0] + const button = $(event.target).closest(Selector.BUTTON)[0] $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)) }) diff --git a/js/src/carousel.js b/js/src/carousel.js index 17bfebc68..b7f3b3a7a 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -161,7 +161,8 @@ const Carousel = (($) => { if (this._config.interval && !this._isPaused) { this._interval = setInterval( - (document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval + (document.visibilityState ? this.nextWhenVisible : this.next).bind(this), + this._config.interval ) } } @@ -169,9 +170,9 @@ const Carousel = (($) => { to(index) { this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0] - let activeIndex = this._getItemIndex(this._activeElement) + const activeIndex = this._getItemIndex(this._activeElement) - if (index > (this._items.length - 1) || index < 0) { + if (index > this._items.length - 1 || index < 0) { return } @@ -186,7 +187,7 @@ const Carousel = (($) => { return } - let direction = index > activeIndex ? + const direction = index > activeIndex ? Direction.NEXT : Direction.PREVIOUS @@ -255,19 +256,19 @@ const Carousel = (($) => { } _getItemByDirection(direction, activeElement) { - let isNextDirection = direction === Direction.NEXT - let isPrevDirection = direction === Direction.PREVIOUS - let activeIndex = this._getItemIndex(activeElement) - let lastItemIndex = (this._items.length - 1) - let isGoingToWrap = (isPrevDirection && activeIndex === 0) || - (isNextDirection && activeIndex === lastItemIndex) + const isNextDirection = direction === Direction.NEXT + const isPrevDirection = direction === Direction.PREVIOUS + const activeIndex = this._getItemIndex(activeElement) + const lastItemIndex = this._items.length - 1 + const isGoingToWrap = isPrevDirection && activeIndex === 0 || + isNextDirection && activeIndex === lastItemIndex if (isGoingToWrap && !this._config.wrap) { return activeElement } - let delta = direction === Direction.PREVIOUS ? -1 : 1 - let itemIndex = (activeIndex + delta) % this._items.length + const delta = direction === Direction.PREVIOUS ? -1 : 1 + const itemIndex = (activeIndex + delta) % this._items.length return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex] @@ -275,7 +276,7 @@ const Carousel = (($) => { _triggerSlideEvent(relatedTarget, directionalClassname) { - let slideEvent = $.Event(Event.SLIDE, { + const slideEvent = $.Event(Event.SLIDE, { relatedTarget, direction: directionalClassname }) @@ -291,7 +292,7 @@ const Carousel = (($) => { .find(Selector.ACTIVE) .removeClass(ClassName.ACTIVE) - let nextIndicator = this._indicatorsElement.children[ + const nextIndicator = this._indicatorsElement.children[ this._getItemIndex(element) ] @@ -302,13 +303,13 @@ const Carousel = (($) => { } _slide(direction, element) { - let activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0] - let nextElement = element || activeElement && + const activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0] + const nextElement = element || activeElement && this._getItemByDirection(direction, activeElement) - let isCycling = Boolean(this._interval) + const isCycling = Boolean(this._interval) - let directionalClassName = direction === Direction.NEXT ? + const directionalClassName = direction === Direction.NEXT ? ClassName.LEFT : ClassName.RIGHT @@ -317,7 +318,7 @@ const Carousel = (($) => { return } - let slideEvent = this._triggerSlideEvent(nextElement, directionalClassName) + const slideEvent = this._triggerSlideEvent(nextElement, directionalClassName) if (slideEvent.isDefaultPrevented()) { return } @@ -335,7 +336,7 @@ const Carousel = (($) => { this._setActiveIndicatorElement(nextElement) - let slidEvent = $.Event(Event.SLID, { + const slidEvent = $.Event(Event.SLID, { relatedTarget: nextElement, direction: directionalClassName }) @@ -389,13 +390,13 @@ const Carousel = (($) => { static _jQueryInterface(config) { return this.each(function () { let data = $(this).data(DATA_KEY) - let _config = $.extend({}, Default, $(this).data()) + const _config = $.extend({}, Default, $(this).data()) if (typeof config === 'object') { $.extend(_config, config) } - let action = typeof config === 'string' ? config : _config.slide + const action = typeof config === 'string' ? config : _config.slide if (!data) { data = new Carousel(this, _config) @@ -417,20 +418,20 @@ const Carousel = (($) => { } static _dataApiClickHandler(event) { - let selector = Util.getSelectorFromElement(this) + const selector = Util.getSelectorFromElement(this) if (!selector) { return } - let target = $(selector)[0] + const target = $(selector)[0] if (!target || !$(target).hasClass(ClassName.CAROUSEL)) { return } - let config = $.extend({}, $(target).data(), $(this).data()) - let slideIndex = this.getAttribute('data-slide-to') + const config = $.extend({}, $(target).data(), $(this).data()) + const slideIndex = this.getAttribute('data-slide-to') if (slideIndex) { config.interval = false @@ -459,7 +460,7 @@ const Carousel = (($) => { $(window).on(Event.LOAD_DATA_API, () => { $(Selector.DATA_RIDE).each(function () { - let $carousel = $(this) + const $carousel = $(this) Carousel._jQueryInterface.call($carousel, $carousel.data()) }) }) diff --git a/js/src/collapse.js b/js/src/collapse.js index f700979e0..ebc3e24cf 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -134,7 +134,7 @@ const Collapse = (($) => { } } - let startEvent = $.Event(Event.SHOW) + const startEvent = $.Event(Event.SHOW) $(this._element).trigger(startEvent) if (startEvent.isDefaultPrevented()) { return @@ -147,7 +147,7 @@ const Collapse = (($) => { } } - let dimension = this._getDimension() + const dimension = this._getDimension() $(this._element) .removeClass(ClassName.COLLAPSE) @@ -164,7 +164,7 @@ const Collapse = (($) => { this.setTransitioning(true) - let complete = () => { + const complete = () => { $(this._element) .removeClass(ClassName.COLLAPSING) .addClass(ClassName.COLLAPSE) @@ -182,8 +182,8 @@ const Collapse = (($) => { return } - let capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1) - let scrollSize = `scroll${capitalizedDimension}` + const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1) + const scrollSize = `scroll${capitalizedDimension}` $(this._element) .one(Util.TRANSITION_END, complete) @@ -198,14 +198,14 @@ const Collapse = (($) => { return } - let startEvent = $.Event(Event.HIDE) + const startEvent = $.Event(Event.HIDE) $(this._element).trigger(startEvent) if (startEvent.isDefaultPrevented()) { return } - let dimension = this._getDimension() - let offsetDimension = dimension === Dimension.WIDTH ? + const dimension = this._getDimension() + const offsetDimension = dimension === Dimension.WIDTH ? 'offsetWidth' : 'offsetHeight' this._element.style[dimension] = `${this._element[offsetDimension]}px` @@ -227,7 +227,7 @@ const Collapse = (($) => { this.setTransitioning(true) - let complete = () => { + const complete = () => { this.setTransitioning(false) $(this._element) .removeClass(ClassName.COLLAPSING) @@ -272,13 +272,13 @@ const Collapse = (($) => { } _getDimension() { - let hasWidth = $(this._element).hasClass(Dimension.WIDTH) + const hasWidth = $(this._element).hasClass(Dimension.WIDTH) return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT } _getParent() { - let parent = $(this._config.parent)[0] - let selector = + const parent = $(this._config.parent)[0] + const selector = `[data-toggle="collapse"][data-parent="${this._config.parent}"]` $(parent).find(selector).each((i, element) => { @@ -293,7 +293,7 @@ const Collapse = (($) => { _addAriaAndCollapsedClass(element, triggerArray) { if (element) { - let isOpen = $(element).hasClass(ClassName.ACTIVE) + const isOpen = $(element).hasClass(ClassName.ACTIVE) element.setAttribute('aria-expanded', isOpen) if (triggerArray.length) { @@ -308,15 +308,15 @@ const Collapse = (($) => { // static static _getTargetFromElement(element) { - let selector = Util.getSelectorFromElement(element) + const selector = Util.getSelectorFromElement(element) return selector ? $(selector)[0] : null } static _jQueryInterface(config) { return this.each(function () { - let $this = $(this) - let data = $this.data(DATA_KEY) - let _config = $.extend( + const $this = $(this) + let data = $this.data(DATA_KEY) + const _config = $.extend( {}, Default, $this.data(), @@ -353,9 +353,9 @@ const Collapse = (($) => { $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { event.preventDefault() - let target = Collapse._getTargetFromElement(this) - let data = $(target).data(DATA_KEY) - let config = data ? 'toggle' : $(this).data() + const target = Collapse._getTargetFromElement(this) + const data = $(target).data(DATA_KEY) + const config = data ? 'toggle' : $(this).data() Collapse._jQueryInterface.call($(target), config) }) diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 3246e6bef..644659266 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -85,8 +85,8 @@ const Dropdown = (($) => { return false } - let parent = Dropdown._getParentFromElement(this) - let isActive = $(parent).hasClass(ClassName.ACTIVE) + const parent = Dropdown._getParentFromElement(this) + const isActive = $(parent).hasClass(ClassName.ACTIVE) Dropdown._clearMenus() @@ -95,17 +95,19 @@ const Dropdown = (($) => { } if ('ontouchstart' in document.documentElement && - (!$(parent).closest(Selector.NAVBAR_NAV).length)) { + !$(parent).closest(Selector.NAVBAR_NAV).length) { // if mobile we use a backdrop because click events don't delegate - let dropdown = document.createElement('div') + const dropdown = document.createElement('div') dropdown.className = ClassName.BACKDROP $(dropdown).insertBefore(this) $(dropdown).on('click', Dropdown._clearMenus) } - let relatedTarget = { relatedTarget : this } - let showEvent = $.Event(Event.SHOW, relatedTarget) + const relatedTarget = { + relatedTarget : this + } + const showEvent = $.Event(Event.SHOW, relatedTarget) $(parent).trigger(showEvent) @@ -114,7 +116,7 @@ const Dropdown = (($) => { } this.focus() - this.setAttribute('aria-expanded', 'true') + this.setAttribute('aria-expanded', true) $(parent).toggleClass(ClassName.ACTIVE) $(parent).trigger($.Event(Event.SHOWN, relatedTarget)) @@ -140,10 +142,11 @@ const Dropdown = (($) => { static _jQueryInterface(config) { return this.each(function () { - let data = $(this).data(DATA_KEY) + let data = $(this).data(DATA_KEY) if (!data) { - $(this).data(DATA_KEY, (data = new Dropdown(this))) + data = new Dropdown(this) + $(this).data(DATA_KEY, data) } if (typeof config === 'string') { @@ -160,28 +163,30 @@ const Dropdown = (($) => { return } - let backdrop = $(Selector.BACKDROP)[0] + const backdrop = $(Selector.BACKDROP)[0] if (backdrop) { backdrop.parentNode.removeChild(backdrop) } - let toggles = $.makeArray($(Selector.DATA_TOGGLE)) + const toggles = $.makeArray($(Selector.DATA_TOGGLE)) for (let i = 0; i < toggles.length; i++) { - let parent = Dropdown._getParentFromElement(toggles[i]) - let relatedTarget = { relatedTarget : toggles[i] } + const parent = Dropdown._getParentFromElement(toggles[i]) + const relatedTarget = { + relatedTarget : toggles[i] + } if (!$(parent).hasClass(ClassName.ACTIVE)) { continue } if (event && event.type === 'click' && - (/input|textarea/i.test(event.target.tagName)) && - ($.contains(parent, event.target))) { + /input|textarea/i.test(event.target.tagName) && + $.contains(parent, event.target)) { continue } - let hideEvent = $.Event(Event.HIDE, relatedTarget) + const hideEvent = $.Event(Event.HIDE, relatedTarget) $(parent).trigger(hideEvent) if (hideEvent.isDefaultPrevented()) { continue @@ -197,7 +202,7 @@ const Dropdown = (($) => { static _getParentFromElement(element) { let parent - let selector = Util.getSelectorFromElement(element) + const selector = Util.getSelectorFromElement(element) if (selector) { parent = $(selector)[0] @@ -219,14 +224,14 @@ const Dropdown = (($) => { return } - let parent = Dropdown._getParentFromElement(this) - let isActive = $(parent).hasClass(ClassName.ACTIVE) + const parent = Dropdown._getParentFromElement(this) + const isActive = $(parent).hasClass(ClassName.ACTIVE) - if ((!isActive && event.which !== ESCAPE_KEYCODE) || - (isActive && event.which === ESCAPE_KEYCODE)) { + if (!isActive && event.which !== ESCAPE_KEYCODE || + isActive && event.which === ESCAPE_KEYCODE) { if (event.which === ESCAPE_KEYCODE) { - let toggle = $(parent).find(Selector.DATA_TOGGLE)[0] + const toggle = $(parent).find(Selector.DATA_TOGGLE)[0] $(toggle).trigger('focus') } diff --git a/js/src/modal.js b/js/src/modal.js index a52dcb07f..5c2c0208a 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -110,7 +110,7 @@ const Modal = (($) => { } show(relatedTarget) { - let showEvent = $.Event(Event.SHOW, { + const showEvent = $.Event(Event.SHOW, { relatedTarget }) @@ -152,7 +152,7 @@ const Modal = (($) => { event.preventDefault() } - let hideEvent = $.Event(Event.HIDE) + const hideEvent = $.Event(Event.HIDE) $(this._element).trigger(hideEvent) @@ -173,7 +173,7 @@ const Modal = (($) => { $(this._dialog).off(Event.MOUSEDOWN_DISMISS) if (Util.supportsTransitionEnd() && - ($(this._element).hasClass(ClassName.FADE))) { + $(this._element).hasClass(ClassName.FADE)) { $(this._element) .one(Util.TRANSITION_END, (event) => this._hideModal(event)) @@ -212,11 +212,11 @@ const Modal = (($) => { } _showElement(relatedTarget) { - let transition = Util.supportsTransitionEnd() && + const transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE) if (!this._element.parentNode || - (this._element.parentNode.nodeType !== Node.ELEMENT_NODE)) { + this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { // don't move modals dom position document.body.appendChild(this._element) } @@ -235,11 +235,11 @@ const Modal = (($) => { this._enforceFocus() } - let shownEvent = $.Event(Event.SHOWN, { + const shownEvent = $.Event(Event.SHOWN, { relatedTarget }) - let transitionComplete = () => { + const transitionComplete = () => { if (this._config.focus) { this._element.focus() } @@ -261,7 +261,7 @@ const Modal = (($) => { .on(Event.FOCUSIN, (event) => { if (document !== event.target && this._element !== event.target && - (!$(this._element).has(event.target).length)) { + !$(this._element).has(event.target).length) { this._element.focus() } }) @@ -290,7 +290,7 @@ const Modal = (($) => { _hideModal() { this._element.style.display = 'none' - this._element.setAttribute('aria-hidden', 'true') + this._element.setAttribute('aria-hidden', true) this._showBackdrop(() => { $(document.body).removeClass(ClassName.OPEN) this._resetAdjustments() @@ -307,11 +307,11 @@ const Modal = (($) => { } _showBackdrop(callback) { - let animate = $(this._element).hasClass(ClassName.FADE) ? + const animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : '' if (this._isShown && this._config.backdrop) { - let doAnimate = Util.supportsTransitionEnd() && animate + const doAnimate = Util.supportsTransitionEnd() && animate this._backdrop = document.createElement('div') this._backdrop.className = ClassName.BACKDROP @@ -359,7 +359,7 @@ const Modal = (($) => { } else if (!this._isShown && this._backdrop) { $(this._backdrop).removeClass(ClassName.ACTIVE) - let callbackRemove = () => { + const callbackRemove = () => { this._removeBackdrop() if (callback) { callback() @@ -367,7 +367,7 @@ const Modal = (($) => { } if (Util.supportsTransitionEnd() && - ($(this._element).hasClass(ClassName.FADE))) { + $(this._element).hasClass(ClassName.FADE)) { $(this._backdrop) .one(Util.TRANSITION_END, callbackRemove) .emulateTransitionEnd(BACKDROP_TRANSITION_DURATION) @@ -391,7 +391,7 @@ const Modal = (($) => { } _adjustDialog() { - let isModalOverflowing = + const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight if (!this._isBodyOverflowing && isModalOverflowing) { @@ -414,7 +414,7 @@ const Modal = (($) => { } _setScrollbar() { - let bodyPadding = parseInt( + const bodyPadding = parseInt( $(Selector.FIXED_CONTENT).css('padding-right') || 0, 10 ) @@ -432,10 +432,10 @@ const Modal = (($) => { } _getScrollbarWidth() { // thx d.walsh - let scrollDiv = document.createElement('div') + const scrollDiv = document.createElement('div') scrollDiv.className = ClassName.SCROLLBAR_MEASURER document.body.appendChild(scrollDiv) - let scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth + const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth document.body.removeChild(scrollDiv) return scrollbarWidth } @@ -445,8 +445,8 @@ const Modal = (($) => { static _jQueryInterface(config, relatedTarget) { return this.each(function () { - let data = $(this).data(DATA_KEY) - let _config = $.extend( + let data = $(this).data(DATA_KEY) + const _config = $.extend( {}, Modal.Default, $(this).data(), @@ -480,20 +480,20 @@ const Modal = (($) => { $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { let target - let selector = Util.getSelectorFromElement(this) + const selector = Util.getSelectorFromElement(this) if (selector) { target = $(selector)[0] } - let config = $(target).data(DATA_KEY) ? + const config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()) if (this.tagName === 'A') { event.preventDefault() } - let $target = $(target).one(Event.SHOW, (showEvent) => { + const $target = $(target).one(Event.SHOW, (showEvent) => { if (showEvent.isDefaultPrevented()) { // only register focus restorer if modal will actually get shown return diff --git a/js/src/popover.js b/js/src/popover.js index 289853b32..01804eda6 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -107,11 +107,11 @@ const Popover = (($) => { } getTipElement() { - return (this.tip = this.tip || $(this.config.template)[0]) + return this.tip = this.tip || $(this.config.template)[0] } setContent() { - let $tip = $(this.getTipElement()) + const $tip = $(this.getTipElement()) // we use append for html objects to maintain js events this.setElementContent($tip.find(Selector.TITLE), this.getTitle()) @@ -138,8 +138,8 @@ const Popover = (($) => { static _jQueryInterface(config) { return this.each(function () { - let data = $(this).data(DATA_KEY) - let _config = typeof config === 'object' ? config : null + let data = $(this).data(DATA_KEY) + const _config = typeof config === 'object' ? config : null if (!data && /destroy|hide/.test(config)) { return diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 648173b33..98582f918 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -108,13 +108,13 @@ const ScrollSpy = (($) => { // public refresh() { - let autoMethod = this._scrollElement !== this._scrollElement.window ? + const autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET - let offsetMethod = this._config.method === 'auto' ? + const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method - let offsetBase = offsetMethod === OffsetMethod.POSITION ? + const offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0 this._offsets = [] @@ -122,12 +122,12 @@ const ScrollSpy = (($) => { this._scrollHeight = this._getScrollHeight() - let targets = $.makeArray($(this._selector)) + const targets = $.makeArray($(this._selector)) targets .map((element) => { let target - let targetSelector = Util.getSelectorFromElement(element) + const targetSelector = Util.getSelectorFromElement(element) if (targetSelector) { target = $(targetSelector)[0] @@ -197,9 +197,9 @@ const ScrollSpy = (($) => { } _process() { - let scrollTop = this._getScrollTop() + this._config.offset - let scrollHeight = this._getScrollHeight() - let maxScroll = this._config.offset + const scrollTop = this._getScrollTop() + this._config.offset + const scrollHeight = this._getScrollHeight() + const maxScroll = this._config.offset + scrollHeight - this._scrollElement.offsetHeight @@ -208,7 +208,7 @@ const ScrollSpy = (($) => { } if (scrollTop >= maxScroll) { - let target = this._targets[this._targets.length - 1] + const target = this._targets[this._targets.length - 1] if (this._activeTarget !== target) { this._activate(target) @@ -222,7 +222,7 @@ const ScrollSpy = (($) => { } for (let i = this._offsets.length; i--;) { - let isActiveTarget = this._activeTarget !== this._targets[i] + const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (this._offsets[i + 1] === undefined || scrollTop < this._offsets[i + 1]) @@ -244,7 +244,7 @@ const ScrollSpy = (($) => { `${selector}[href="${target}"]` }) - let $link = $(queries.join(',')) + const $link = $(queries.join(',')) if ($link.hasClass(ClassName.DROPDOWN_ITEM)) { $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE) @@ -269,8 +269,8 @@ const ScrollSpy = (($) => { static _jQueryInterface(config) { return this.each(function () { - let data = $(this).data(DATA_KEY) - let _config = typeof config === 'object' && config || null + let data = $(this).data(DATA_KEY) + const _config = typeof config === 'object' && config if (!data) { data = new ScrollSpy(this, _config) @@ -297,10 +297,10 @@ const ScrollSpy = (($) => { */ $(window).on(Event.LOAD_DATA_API, () => { - let scrollSpys = $.makeArray($(Selector.DATA_SPY)) + const scrollSpys = $.makeArray($(Selector.DATA_SPY)) for (let i = scrollSpys.length; i--;) { - let $spy = $(scrollSpys[i]) + const $spy = $(scrollSpys[i]) ScrollSpy._jQueryInterface.call($spy, $spy.data()) } }) diff --git a/js/src/tab.js b/js/src/tab.js index 012d2f76f..c5d205bcf 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -78,26 +78,26 @@ const Tab = (($) => { show() { if (this._element.parentNode && - (this._element.parentNode.nodeType === Node.ELEMENT_NODE) && - ($(this._element).hasClass(ClassName.ACTIVE))) { + this._element.parentNode.nodeType === Node.ELEMENT_NODE && + $(this._element).hasClass(ClassName.ACTIVE)) { return } let target let previous - let listElement = $(this._element).closest(Selector.LIST)[0] - let selector = Util.getSelectorFromElement(this._element) + const listElement = $(this._element).closest(Selector.LIST)[0] + const selector = Util.getSelectorFromElement(this._element) if (listElement) { previous = $.makeArray($(listElement).find(Selector.ACTIVE)) previous = previous[previous.length - 1] } - let hideEvent = $.Event(Event.HIDE, { + const hideEvent = $.Event(Event.HIDE, { relatedTarget: this._element }) - let showEvent = $.Event(Event.SHOW, { + const showEvent = $.Event(Event.SHOW, { relatedTarget: previous }) @@ -108,7 +108,7 @@ const Tab = (($) => { $(this._element).trigger(showEvent) if (showEvent.isDefaultPrevented() || - (hideEvent.isDefaultPrevented())) { + hideEvent.isDefaultPrevented()) { return } @@ -121,12 +121,12 @@ const Tab = (($) => { listElement ) - let complete = () => { - let hiddenEvent = $.Event(Event.HIDDEN, { + const complete = () => { + const hiddenEvent = $.Event(Event.HIDDEN, { relatedTarget: this._element }) - let shownEvent = $.Event(Event.SHOWN, { + const shownEvent = $.Event(Event.SHOWN, { relatedTarget: previous }) @@ -150,13 +150,13 @@ const Tab = (($) => { // private _activate(element, container, callback) { - let active = $(container).find(Selector.ACTIVE_CHILD)[0] - let isTransitioning = callback + const active = $(container).find(Selector.ACTIVE_CHILD)[0] + const isTransitioning = callback && Util.supportsTransitionEnd() - && ((active && $(active).hasClass(ClassName.FADE)) + && (active && $(active).hasClass(ClassName.FADE) || Boolean($(container).find(Selector.FADE_CHILD)[0])) - let complete = () => this._transitionComplete( + const complete = () => this._transitionComplete( element, active, isTransitioning, @@ -181,7 +181,7 @@ const Tab = (($) => { if (active) { $(active).removeClass(ClassName.ACTIVE) - let dropdownChild = $(active).find( + const dropdownChild = $(active).find( Selector.DROPDOWN_ACTIVE_CHILD )[0] @@ -203,9 +203,9 @@ const Tab = (($) => { } if (element.parentNode && - ($(element.parentNode).hasClass(ClassName.DROPDOWN_MENU))) { + $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) { - let dropdownElement = $(element).closest(Selector.DROPDOWN)[0] + const dropdownElement = $(element).closest(Selector.DROPDOWN)[0] if (dropdownElement) { $(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE) } @@ -223,11 +223,11 @@ const Tab = (($) => { static _jQueryInterface(config) { return this.each(function () { - let $this = $(this) - let data = $this.data(DATA_KEY) + const $this = $(this) + let data = $this.data(DATA_KEY) if (!data) { - data = data = new Tab(this) + data = new Tab(this) $this.data(DATA_KEY, data) } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index c4fdbff59..822ae3652 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -121,11 +121,11 @@ const Tooltip = (($) => { constructor(element, config) { // private - this._isEnabled = true - this._timeout = 0 - this._hoverState = '' - this._activeTrigger = {} - this._tether = null + this._isEnabled = true + this._timeout = 0 + this._hoverState = '' + this._activeTrigger = {} + this._tether = null // protected this.element = element @@ -184,7 +184,7 @@ const Tooltip = (($) => { toggle(event) { if (event) { - let dataKey = this.constructor.DATA_KEY + const dataKey = this.constructor.DATA_KEY let context = $(event.currentTarget).data(dataKey) if (!context) { @@ -227,11 +227,11 @@ const Tooltip = (($) => { $(this.tip).remove() } - this._isEnabled = null - this._timeout = null - this._hoverState = null - this._activeTrigger = null - this._tether = null + this._isEnabled = null + this._timeout = null + this._hoverState = null + this._activeTrigger = null + this._tether = null this.element = null this.config = null @@ -242,12 +242,12 @@ const Tooltip = (($) => { if ($(this.element).css('display') === 'none') { throw new Error('Please use show on visible elements') } - let showEvent = $.Event(this.constructor.Event.SHOW) + const showEvent = $.Event(this.constructor.Event.SHOW) if (this.isWithContent() && this._isEnabled) { $(this.element).trigger(showEvent) - let isInTheDom = $.contains( + const isInTheDom = $.contains( this.element.ownerDocument.documentElement, this.element ) @@ -256,8 +256,8 @@ const Tooltip = (($) => { return } - let tip = this.getTipElement() - let tipId = Util.getUID(this.constructor.NAME) + const tip = this.getTipElement() + const tipId = Util.getUID(this.constructor.NAME) tip.setAttribute('id', tipId) this.element.setAttribute('aria-describedby', tipId) @@ -268,11 +268,11 @@ const Tooltip = (($) => { $(tip).addClass(ClassName.FADE) } - let placement = typeof this.config.placement === 'function' ? + const placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement - let attachment = this._getAttachment(placement) + const attachment = this._getAttachment(placement) $(tip) .data(this.constructor.DATA_KEY, this) @@ -296,9 +296,9 @@ const Tooltip = (($) => { $(tip).addClass(ClassName.ACTIVE) - let complete = () => { - let prevHoverState = this._hoverState - this._hoverState = null + const complete = () => { + const prevHoverState = this._hoverState + this._hoverState = null $(this.element).trigger(this.constructor.Event.SHOWN) @@ -319,9 +319,9 @@ const Tooltip = (($) => { } hide(callback) { - let tip = this.getTipElement() - let hideEvent = $.Event(this.constructor.Event.HIDE) - let complete = () => { + const tip = this.getTipElement() + const hideEvent = $.Event(this.constructor.Event.HIDE) + const complete = () => { if (this._hoverState !== HoverState.ACTIVE && tip.parentNode) { tip.parentNode.removeChild(tip) } @@ -344,7 +344,7 @@ const Tooltip = (($) => { $(tip).removeClass(ClassName.ACTIVE) if (Util.supportsTransitionEnd() && - ($(this.tip).hasClass(ClassName.FADE))) { + $(this.tip).hasClass(ClassName.FADE)) { $(tip) .one(Util.TRANSITION_END, complete) @@ -365,11 +365,11 @@ const Tooltip = (($) => { } getTipElement() { - return (this.tip = this.tip || $(this.config.template)[0]) + return this.tip = this.tip || $(this.config.template)[0] } setContent() { - let $tip = $(this.getTipElement()) + const $tip = $(this.getTipElement()) this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle()) @@ -381,7 +381,7 @@ const Tooltip = (($) => { } setElementContent($element, content) { - let html = this.config.html + const html = this.config.html if (typeof content === 'object' && (content.nodeType || content.jquery)) { // content is a DOM node or a jQuery if (html) { @@ -422,7 +422,7 @@ const Tooltip = (($) => { } _setListeners() { - let triggers = this.config.trigger.split(' ') + const triggers = this.config.trigger.split(' ') triggers.forEach((trigger) => { if (trigger === 'click') { @@ -433,10 +433,10 @@ const Tooltip = (($) => { ) } else if (trigger !== Trigger.MANUAL) { - let eventIn = trigger === Trigger.HOVER ? + const eventIn = trigger === Trigger.HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN - let eventOut = trigger === Trigger.HOVER ? + const eventOut = trigger === Trigger.HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT @@ -465,9 +465,9 @@ const Tooltip = (($) => { } _fixTitle() { - let titleType = typeof this.element.getAttribute('data-original-title') + const titleType = typeof this.element.getAttribute('data-original-title') if (this.element.getAttribute('title') || - (titleType !== 'string')) { + titleType !== 'string') { this.element.setAttribute( 'data-original-title', this.element.getAttribute('title') || '' @@ -477,7 +477,7 @@ const Tooltip = (($) => { } _enter(event, context) { - let dataKey = this.constructor.DATA_KEY + const dataKey = this.constructor.DATA_KEY context = context || $(event.currentTarget).data(dataKey) @@ -496,7 +496,7 @@ const Tooltip = (($) => { } if ($(context.getTipElement()).hasClass(ClassName.ACTIVE) || - (context._hoverState === HoverState.ACTIVE)) { + context._hoverState === HoverState.ACTIVE) { context._hoverState = HoverState.ACTIVE return } @@ -518,7 +518,7 @@ const Tooltip = (($) => { } _leave(event, context) { - let dataKey = this.constructor.DATA_KEY + const dataKey = this.constructor.DATA_KEY context = context || $(event.currentTarget).data(dataKey) @@ -557,7 +557,7 @@ const Tooltip = (($) => { } _isWithActiveTrigger() { - for (let trigger in this._activeTrigger) { + for (const trigger in this._activeTrigger) { if (this._activeTrigger[trigger]) { return true } @@ -591,10 +591,10 @@ const Tooltip = (($) => { } _getDelegateConfig() { - let config = {} + const config = {} if (this.config) { - for (let key in this.config) { + for (const key in this.config) { if (this.constructor.Default[key] !== this.config[key]) { config[key] = this.config[key] } @@ -609,9 +609,8 @@ const Tooltip = (($) => { static _jQueryInterface(config) { return this.each(function () { - let data = $(this).data(DATA_KEY) - let _config = typeof config === 'object' ? - config : null + let data = $(this).data(DATA_KEY) + const _config = typeof config === 'object' && config if (!data && /dispose|hide/.test(config)) { return diff --git a/js/src/util.js b/js/src/util.js index 5ddbbbf13..06424fbfe 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -27,7 +27,7 @@ const Util = (($) => { // shoutout AngusCroll (https://goo.gl/pxwQGp) function toType(obj) { - return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() + return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() } function isElement(obj) { @@ -52,11 +52,13 @@ const Util = (($) => { return false } - let el = document.createElement('bootstrap') + const el = document.createElement('bootstrap') - for (let name in TransitionEndEvent) { + for (const name in TransitionEndEvent) { if (el.style[name] !== undefined) { - return { end: TransitionEndEvent[name] } + return { + end: TransitionEndEvent[name] + } } } @@ -96,15 +98,14 @@ const Util = (($) => { * -------------------------------------------------------------------------- */ - let Util = { + const Util = { TRANSITION_END: 'bsTransitionEnd', getUID(prefix) { do { - /* eslint-disable no-bitwise */ + // eslint-disable-next-line no-bitwise prefix += ~~(Math.random() * MAX_UID) // "~~" acts like a faster Math.floor() here - /* eslint-enable no-bitwise */ } while (document.getElementById(prefix)) return prefix }, @@ -133,17 +134,12 @@ const Util = (($) => { }, typeCheckConfig(componentName, config, configTypes) { - for (let property in configTypes) { + for (const property in configTypes) { if (configTypes.hasOwnProperty(property)) { - let expectedTypes = configTypes[property] - let value = config[property] - let valueType - - if (value && isElement(value)) { - valueType = 'element' - } else { - valueType = toType(value) - } + const expectedTypes = configTypes[property] + const value = config[property] + const valueType = value && isElement(value) ? + 'element' : toType(value) if (!new RegExp(expectedTypes).test(valueType)) { throw new Error( -- cgit v1.2.3 From b1b1f30cbd0f4f620047dc158cf91e328eeecc6b Mon Sep 17 00:00:00 2001 From: Matt Hernandez Date: Fri, 25 Nov 2016 14:56:41 -0800 Subject: [Fix #17371][V4] Deactivating dropdown links in nav tab (#17642) * Fix bug with dropdown tab links not deactivating when other tab or dropdown link is clicked * Revise bug fix for more stability --- js/src/tab.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/tab.js b/js/src/tab.js index 012d2f76f..9dc33e4da 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -181,7 +181,7 @@ const Tab = (($) => { if (active) { $(active).removeClass(ClassName.ACTIVE) - let dropdownChild = $(active).find( + let dropdownChild = $(active.parentNode).find( Selector.DROPDOWN_ACTIVE_CHILD )[0] -- cgit v1.2.3 From 39d7861f34e01933ebee4f6b05e3ed24bca7f116 Mon Sep 17 00:00:00 2001 From: matus Date: Sat, 9 Jan 2016 03:20:40 +0800 Subject: Scrollspy selecting the last element when at the bottom of the page (fixes #17739) --- js/src/scrollspy.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 98582f918..9b39acd36 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -196,12 +196,17 @@ const ScrollSpy = (($) => { ) } + _getOffsetHeight() { + return this._scrollElement === window ? + window.innerHeight : this._scrollElement.offsetHeight + } + _process() { const scrollTop = this._getScrollTop() + this._config.offset const scrollHeight = this._getScrollHeight() const maxScroll = this._config.offset + scrollHeight - - this._scrollElement.offsetHeight + - this._getOffsetHeight() if (this._scrollHeight !== scrollHeight) { this.refresh() @@ -213,6 +218,7 @@ const ScrollSpy = (($) => { if (this._activeTarget !== target) { this._activate(target) } + return } if (this._activeTarget && scrollTop < this._offsets[0]) { -- cgit v1.2.3 From 0ded703f6bb7b0c60b1ec8e90592c845ca07d46e Mon Sep 17 00:00:00 2001 From: andyexeter Date: Thu, 15 Sep 2016 10:33:11 +0100 Subject: Implement container option for tooltips and popovers. --- js/src/tooltip.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 822ae3652..94f77a2a4 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -46,7 +46,8 @@ const Tooltip = (($) => { selector : false, placement : 'top', offset : '0 0', - constraints : [] + constraints : [], + container : false } const DefaultType = { @@ -59,7 +60,8 @@ const Tooltip = (($) => { selector : '(string|boolean)', placement : '(string|function)', offset : 'string', - constraints : 'array' + constraints : 'array', + container : '(string|element|boolean)' } const AttachmentMap = { @@ -274,9 +276,11 @@ const Tooltip = (($) => { const attachment = this._getAttachment(placement) + const container = this.config.container === false ? document.body : $(this.config.container) + $(tip) .data(this.constructor.DATA_KEY, this) - .appendTo(document.body) + .appendTo(container) $(this.element).trigger(this.constructor.Event.INSERTED) -- cgit v1.2.3 From 3606c5b9c5b288f17b29ea451470b260d4c1f327 Mon Sep 17 00:00:00 2001 From: Pierre-Denis Vanduynslager Date: Sat, 26 Nov 2016 03:35:49 -0500 Subject: Dropdown perf - on keyboard nav, find active item in the active dropdown rather than the whole document (#19953) --- js/src/dropdown.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'js/src') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 644659266..324eef793 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -239,11 +239,7 @@ const Dropdown = (($) => { return } - let items = $.makeArray($(Selector.VISIBLE_ITEMS)) - - items = items.filter((item) => { - return item.offsetWidth || item.offsetHeight - }) + let items = $(parent).find(Selector.VISIBLE_ITEMS).get() if (!items.length) { return -- cgit v1.2.3 From b110070dcd5b957c1674bd08238e96faa9c2691e Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 26 Nov 2016 01:04:02 -0800 Subject: Follow up fix to #19953 for linting error in builds See https://travis-ci.org/twbs/bootstrap/jobs/179010884 for build failure --- js/src/dropdown.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 324eef793..8b2164aa9 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -239,7 +239,7 @@ const Dropdown = (($) => { return } - let items = $(parent).find(Selector.VISIBLE_ITEMS).get() + const items = $(parent).find(Selector.VISIBLE_ITEMS).get() if (!items.length) { return -- cgit v1.2.3 From 5eddb0b0fdfd7215d5764c5315ce7f0be4ca3d83 Mon Sep 17 00:00:00 2001 From: Rob Ruana Date: Sun, 27 Nov 2016 16:20:33 -0800 Subject: Closes #21055: Prevents ScrollSpy from clearing active item when Safari rubberbands (#21056) When the rubberband effect causes Safari to scroll past the top of the page, the value of scrollTop becomes negative. If the offset of the first ScrollSpy target is 0 - essentially if the target is at the top of the page - then ScrollSpy should not clear the active item. Conceptually, the first item should remain active when rubberbanding past the top of the page. This commit fixes issue #21055 by verifying the first scrollspy target is not at the top of the page before clearing the active nav-item. --- js/src/scrollspy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 9b39acd36..9cb1438ca 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -221,7 +221,7 @@ const ScrollSpy = (($) => { return } - if (this._activeTarget && scrollTop < this._offsets[0]) { + if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { this._activeTarget = null this._clear() return -- cgit v1.2.3 From 8c17e5fb3c77da66a682355effe9ce336ead690e Mon Sep 17 00:00:00 2001 From: Juno_okyo Date: Tue, 29 Nov 2016 04:42:32 +0700 Subject: Use multi-selector to remove the same event handler (#20642) --- js/src/modal.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index 447e32acf..61a28dbf5 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -186,10 +186,7 @@ const Modal = (($) => { dispose() { $.removeData(this._element, DATA_KEY) - $(window).off(EVENT_KEY) - $(document).off(EVENT_KEY) - $(this._element).off(EVENT_KEY) - $(this._backdrop).off(EVENT_KEY) + $(window, document, this._element, this._backdrop).off(EVENT_KEY) this._config = null this._element = null -- cgit v1.2.3 From 535fec93cf8892d1a83f6bb8cb97adc589af2b39 Mon Sep 17 00:00:00 2001 From: Bardi Harborow Date: Wed, 30 Nov 2016 04:45:14 +1100 Subject: Hide popovers when their containing modal is closed. (#21227) --- js/src/tooltip.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index dbc9cf18c..2b659b885 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -224,6 +224,7 @@ const Tooltip = (($) => { $.removeData(this.element, this.constructor.DATA_KEY) $(this.element).off(this.constructor.EVENT_KEY) + $(this.element).closest('.modal').off('hide.bs.modal') if (this.tip) { $(this.tip).remove() @@ -454,6 +455,11 @@ const Tooltip = (($) => { (event) => this._leave(event) ) } + + $(this.element).closest('.modal').on( + 'hide.bs.modal', + () => this.hide() + ) }) if (this.config.selector) { -- cgit v1.2.3 From 297c47c3fdbb58e3d9824afdee83ef3c4b9d141a Mon Sep 17 00:00:00 2001 From: Johann Date: Fri, 2 Dec 2016 18:52:19 +0100 Subject: [V4] Throw error when a plugin is in transition (#17823) * Throw error when a plugin is in transition * Add unit tests about plugins in transition --- js/src/carousel.js | 10 ++++++---- js/src/collapse.js | 14 ++++++++++---- js/src/modal.js | 28 +++++++++++++++++++++++----- js/src/tooltip.js | 26 ++++++++++++++++++-------- 4 files changed, 57 insertions(+), 21 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index e56d4f0f2..7fda8f615 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -116,9 +116,10 @@ const Carousel = (($) => { // public next() { - if (!this._isSliding) { - this._slide(Direction.NEXT) + if (this._isSliding) { + throw new Error('Carousel is sliding') } + this._slide(Direction.NEXT) } nextWhenVisible() { @@ -129,9 +130,10 @@ const Carousel = (($) => { } prev() { - if (!this._isSliding) { - this._slide(Direction.PREVIOUS) + if (this._isSliding) { + throw new Error('Carousel is sliding') } + this._slide(Direction.PREVIOUS) } pause(event) { diff --git a/js/src/collapse.js b/js/src/collapse.js index ebc3e24cf..1e4730ff7 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -112,8 +112,11 @@ const Collapse = (($) => { } show() { - if (this._isTransitioning || - $(this._element).hasClass(ClassName.ACTIVE)) { + if (this._isTransitioning) { + throw new Error('Collapse is transitioning') + } + + if ($(this._element).hasClass(ClassName.ACTIVE)) { return } @@ -193,8 +196,11 @@ const Collapse = (($) => { } hide() { - if (this._isTransitioning || - !$(this._element).hasClass(ClassName.ACTIVE)) { + if (this._isTransitioning) { + throw new Error('Collapse is transitioning') + } + + if (!$(this._element).hasClass(ClassName.ACTIVE)) { return } diff --git a/js/src/modal.js b/js/src/modal.js index 61a28dbf5..70bb68e42 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -87,6 +87,7 @@ const Modal = (($) => { this._isShown = false this._isBodyOverflowing = false this._ignoreBackdropClick = false + this._isTransitioning = false this._originalBodyPadding = 0 this._scrollbarWidth = 0 } @@ -110,6 +111,14 @@ const Modal = (($) => { } show(relatedTarget) { + if (this._isTransitioning) { + throw new Error('Modal is transitioning') + } + + if (Util.supportsTransitionEnd() && + $(this._element).hasClass(ClassName.FADE)) { + this._isTransitioning = true + } const showEvent = $.Event(Event.SHOW, { relatedTarget }) @@ -152,8 +161,17 @@ const Modal = (($) => { event.preventDefault() } - const hideEvent = $.Event(Event.HIDE) + if (this._isTransitioning) { + throw new Error('Modal is transitioning') + } + const transition = Util.supportsTransitionEnd() && + $(this._element).hasClass(ClassName.FADE) + if (transition) { + this._isTransitioning = true + } + + const hideEvent = $.Event(Event.HIDE) $(this._element).trigger(hideEvent) if (!this._isShown || hideEvent.isDefaultPrevented()) { @@ -172,9 +190,7 @@ const Modal = (($) => { $(this._element).off(Event.CLICK_DISMISS) $(this._dialog).off(Event.MOUSEDOWN_DISMISS) - if (Util.supportsTransitionEnd() && - $(this._element).hasClass(ClassName.FADE)) { - + if (transition) { $(this._element) .one(Util.TRANSITION_END, (event) => this._hideModal(event)) .emulateTransitionEnd(TRANSITION_DURATION) @@ -240,6 +256,7 @@ const Modal = (($) => { if (this._config.focus) { this._element.focus() } + this._isTransitioning = false $(this._element).trigger(shownEvent) } @@ -287,7 +304,8 @@ const Modal = (($) => { _hideModal() { this._element.style.display = 'none' - this._element.setAttribute('aria-hidden', true) + this._element.setAttribute('aria-hidden', 'true') + this._isTransitioning = false this._showBackdrop(() => { $(document.body).removeClass(ClassName.OPEN) this._resetAdjustments() diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 2b659b885..dc291a72c 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -123,11 +123,12 @@ const Tooltip = (($) => { constructor(element, config) { // private - this._isEnabled = true - this._timeout = 0 - this._hoverState = '' - this._activeTrigger = {} - this._tether = null + this._isEnabled = true + this._timeout = 0 + this._hoverState = '' + this._activeTrigger = {} + this._isTransitioning = false + this._tether = null // protected this.element = element @@ -245,9 +246,12 @@ const Tooltip = (($) => { if ($(this.element).css('display') === 'none') { throw new Error('Please use show on visible elements') } - const showEvent = $.Event(this.constructor.Event.SHOW) + const showEvent = $.Event(this.constructor.Event.SHOW) if (this.isWithContent() && this._isEnabled) { + if (this._isTransitioning) { + throw new Error('Tooltip is transitioning') + } $(this.element).trigger(showEvent) const isInTheDom = $.contains( @@ -303,7 +307,8 @@ const Tooltip = (($) => { const complete = () => { const prevHoverState = this._hoverState - this._hoverState = null + this._hoverState = null + this._isTransitioning = false $(this.element).trigger(this.constructor.Event.SHOWN) @@ -313,6 +318,7 @@ const Tooltip = (($) => { } if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { + this._isTransitioning = true $(this.tip) .one(Util.TRANSITION_END, complete) .emulateTransitionEnd(Tooltip._TRANSITION_DURATION) @@ -326,6 +332,9 @@ const Tooltip = (($) => { hide(callback) { const tip = this.getTipElement() const hideEvent = $.Event(this.constructor.Event.HIDE) + if (this._isTransitioning) { + throw new Error('Tooltip is transitioning') + } const complete = () => { if (this._hoverState !== HoverState.ACTIVE && tip.parentNode) { tip.parentNode.removeChild(tip) @@ -333,6 +342,7 @@ const Tooltip = (($) => { this.element.removeAttribute('aria-describedby') $(this.element).trigger(this.constructor.Event.HIDDEN) + this._isTransitioning = false this.cleanupTether() if (callback) { @@ -350,7 +360,7 @@ const Tooltip = (($) => { if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { - + this._isTransitioning = true $(tip) .one(Util.TRANSITION_END, complete) .emulateTransitionEnd(TRANSITION_DURATION) -- cgit v1.2.3 From 94e2d80af4554080b286d8b4012f75902932342a Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sun, 4 Dec 2016 19:53:16 -0800 Subject: pull in js changes from #18830 --- js/src/carousel.js | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index b7f3b3a7a..f987fc186 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -45,7 +45,9 @@ const Carousel = (($) => { const Direction = { NEXT : 'next', - PREVIOUS : 'prev' + PREVIOUS : 'prev', + LEFT : 'left', + RIGHT : 'right' } const Event = { @@ -62,8 +64,10 @@ const Carousel = (($) => { CAROUSEL : 'carousel', ACTIVE : 'active', SLIDE : 'slide', - RIGHT : 'right', - LEFT : 'left', + RIGHT : 'carousel-item-right', + LEFT : 'carousel-item-left', + NEXT : 'carousel-item-next', + PREVIOUS : 'carousel-item-prev', ITEM : 'carousel-item' } @@ -71,7 +75,7 @@ const Carousel = (($) => { ACTIVE : '.active', ACTIVE_ITEM : '.active.carousel-item', ITEM : '.carousel-item', - NEXT_PREV : '.next, .prev', + NEXT_PREV : '.carousel-item-next, .carousel-item-prev', INDICATORS : '.carousel-indicators', DATA_SLIDE : '[data-slide], [data-slide-to]', DATA_RIDE : '[data-ride="carousel"]' @@ -275,10 +279,10 @@ const Carousel = (($) => { } - _triggerSlideEvent(relatedTarget, directionalClassname) { + _triggerSlideEvent(relatedTarget, eventDirectionName) { const slideEvent = $.Event(Event.SLIDE, { relatedTarget, - direction: directionalClassname + direction: eventDirectionName }) $(this._element).trigger(slideEvent) @@ -309,16 +313,30 @@ const Carousel = (($) => { const isCycling = Boolean(this._interval) - const directionalClassName = direction === Direction.NEXT ? - ClassName.LEFT : - ClassName.RIGHT + let directionalClassName + let orderClassName + let eventDirectionName + + if (direction === Direction.NEXT) { + directionalClassName = ClassName.LEFT + orderClassName = ClassName.NEXT + eventDirectionName = Direction.LEFT + } else { + directionalClassName = ClassName.RIGHT + orderClassName = ClassName.PREV + eventDirectionName = Direction.RIGHT + } + + // const directionalClassName = direction === Direction.NEXT ? + // ClassName.LEFT : + // ClassName.RIGHT if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) { this._isSliding = false return } - const slideEvent = this._triggerSlideEvent(nextElement, directionalClassName) + const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName) if (slideEvent.isDefaultPrevented()) { return } @@ -338,13 +356,13 @@ const Carousel = (($) => { const slidEvent = $.Event(Event.SLID, { relatedTarget: nextElement, - direction: directionalClassName + direction: eventDirectionName }) if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) { - $(nextElement).addClass(direction) + $(nextElement).addClass(orderClassName) Util.reflow(nextElement) @@ -355,13 +373,13 @@ const Carousel = (($) => { .one(Util.TRANSITION_END, () => { $(nextElement) .removeClass(directionalClassName) - .removeClass(direction) + .removeClass(orderClassName) $(nextElement).addClass(ClassName.ACTIVE) $(activeElement) .removeClass(ClassName.ACTIVE) - .removeClass(direction) + .removeClass(orderClassName) .removeClass(directionalClassName) this._isSliding = false -- cgit v1.2.3 From 01f81dd5528c532641789056a14c56d9a4bab0a1 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sun, 4 Dec 2016 20:27:21 -0800 Subject: fix js for previous --- js/src/carousel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index f987fc186..c0d572f0a 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -45,7 +45,7 @@ const Carousel = (($) => { const Direction = { NEXT : 'next', - PREVIOUS : 'prev', + PREV : 'prev', LEFT : 'left', RIGHT : 'right' } @@ -67,7 +67,7 @@ const Carousel = (($) => { RIGHT : 'carousel-item-right', LEFT : 'carousel-item-left', NEXT : 'carousel-item-next', - PREVIOUS : 'carousel-item-prev', + PREV : 'carousel-item-prev', ITEM : 'carousel-item' } -- cgit v1.2.3 From 1afb6959fac4659394c53cba1ebabd3f22714e26 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sun, 4 Dec 2016 21:05:57 -0800 Subject: remove commented out code --- js/src/carousel.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index a8c16283e..304d0160f 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -328,10 +328,6 @@ const Carousel = (($) => { eventDirectionName = Direction.RIGHT } - // const directionalClassName = direction === Direction.NEXT ? - // ClassName.LEFT : - // ClassName.RIGHT - if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) { this._isSliding = false return -- cgit v1.2.3 From bf39bb3ac3d2aef4687b3cd4762015d5f218e2bc Mon Sep 17 00:00:00 2001 From: Starsam80 Date: Thu, 27 Oct 2016 16:13:17 -0600 Subject: Rename `.active` to `.show` --- js/src/alert.js | 8 ++++---- js/src/collapse.js | 16 ++++++++-------- js/src/dropdown.js | 12 ++++++------ js/src/modal.js | 10 +++++----- js/src/popover.js | 6 +++--- js/src/tooltip.js | 28 ++++++++++++++-------------- 6 files changed, 40 insertions(+), 40 deletions(-) (limited to 'js/src') diff --git a/js/src/alert.js b/js/src/alert.js index 8e5524950..884a5dec8 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -36,9 +36,9 @@ const Alert = (($) => { } const ClassName = { - ALERT : 'alert', - FADE : 'fade', - ACTIVE : 'active' + ALERT : 'alert', + FADE : 'fade', + SHOW : 'show' } @@ -108,7 +108,7 @@ const Alert = (($) => { } _removeElement(element) { - $(element).removeClass(ClassName.ACTIVE) + $(element).removeClass(ClassName.SHOW) if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { diff --git a/js/src/collapse.js b/js/src/collapse.js index 1e4730ff7..ad8815993 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -44,7 +44,7 @@ const Collapse = (($) => { } const ClassName = { - ACTIVE : 'active', + SHOW : 'show', COLLAPSE : 'collapse', COLLAPSING : 'collapsing', COLLAPSED : 'collapsed' @@ -56,7 +56,7 @@ const Collapse = (($) => { } const Selector = { - ACTIVES : '.card > .active, .card > .collapsing', + ACTIVES : '.card > .show, .card > .collapsing', DATA_TOGGLE : '[data-toggle="collapse"]' } @@ -104,7 +104,7 @@ const Collapse = (($) => { // public toggle() { - if ($(this._element).hasClass(ClassName.ACTIVE)) { + if ($(this._element).hasClass(ClassName.SHOW)) { this.hide() } else { this.show() @@ -116,7 +116,7 @@ const Collapse = (($) => { throw new Error('Collapse is transitioning') } - if ($(this._element).hasClass(ClassName.ACTIVE)) { + if ($(this._element).hasClass(ClassName.SHOW)) { return } @@ -171,7 +171,7 @@ const Collapse = (($) => { $(this._element) .removeClass(ClassName.COLLAPSING) .addClass(ClassName.COLLAPSE) - .addClass(ClassName.ACTIVE) + .addClass(ClassName.SHOW) this._element.style[dimension] = '' @@ -200,7 +200,7 @@ const Collapse = (($) => { throw new Error('Collapse is transitioning') } - if (!$(this._element).hasClass(ClassName.ACTIVE)) { + if (!$(this._element).hasClass(ClassName.SHOW)) { return } @@ -221,7 +221,7 @@ const Collapse = (($) => { $(this._element) .addClass(ClassName.COLLAPSING) .removeClass(ClassName.COLLAPSE) - .removeClass(ClassName.ACTIVE) + .removeClass(ClassName.SHOW) this._element.setAttribute('aria-expanded', false) @@ -299,7 +299,7 @@ const Collapse = (($) => { _addAriaAndCollapsedClass(element, triggerArray) { if (element) { - const isOpen = $(element).hasClass(ClassName.ACTIVE) + const isOpen = $(element).hasClass(ClassName.SHOW) element.setAttribute('aria-expanded', isOpen) if (triggerArray.length) { diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 8b2164aa9..97bba1c76 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -41,7 +41,7 @@ const Dropdown = (($) => { const ClassName = { BACKDROP : 'dropdown-backdrop', DISABLED : 'disabled', - ACTIVE : 'active' + SHOW : 'show' } const Selector = { @@ -86,7 +86,7 @@ const Dropdown = (($) => { } const parent = Dropdown._getParentFromElement(this) - const isActive = $(parent).hasClass(ClassName.ACTIVE) + const isActive = $(parent).hasClass(ClassName.SHOW) Dropdown._clearMenus() @@ -118,7 +118,7 @@ const Dropdown = (($) => { this.focus() this.setAttribute('aria-expanded', true) - $(parent).toggleClass(ClassName.ACTIVE) + $(parent).toggleClass(ClassName.SHOW) $(parent).trigger($.Event(Event.SHOWN, relatedTarget)) return false @@ -176,7 +176,7 @@ const Dropdown = (($) => { relatedTarget : toggles[i] } - if (!$(parent).hasClass(ClassName.ACTIVE)) { + if (!$(parent).hasClass(ClassName.SHOW)) { continue } @@ -195,7 +195,7 @@ const Dropdown = (($) => { toggles[i].setAttribute('aria-expanded', 'false') $(parent) - .removeClass(ClassName.ACTIVE) + .removeClass(ClassName.SHOW) .trigger($.Event(Event.HIDDEN, relatedTarget)) } } @@ -225,7 +225,7 @@ const Dropdown = (($) => { } const parent = Dropdown._getParentFromElement(this) - const isActive = $(parent).hasClass(ClassName.ACTIVE) + const isActive = $(parent).hasClass(ClassName.SHOW) if (!isActive && event.which !== ESCAPE_KEYCODE || isActive && event.which === ESCAPE_KEYCODE) { diff --git a/js/src/modal.js b/js/src/modal.js index 70bb68e42..94abd19f4 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -60,7 +60,7 @@ const Modal = (($) => { BACKDROP : 'modal-backdrop', OPEN : 'modal-open', FADE : 'fade', - ACTIVE : 'active' + SHOW : 'show' } const Selector = { @@ -185,7 +185,7 @@ const Modal = (($) => { $(document).off(Event.FOCUSIN) - $(this._element).removeClass(ClassName.ACTIVE) + $(this._element).removeClass(ClassName.SHOW) $(this._element).off(Event.CLICK_DISMISS) $(this._dialog).off(Event.MOUSEDOWN_DISMISS) @@ -242,7 +242,7 @@ const Modal = (($) => { Util.reflow(this._element) } - $(this._element).addClass(ClassName.ACTIVE) + $(this._element).addClass(ClassName.SHOW) if (this._config.focus) { this._enforceFocus() @@ -356,7 +356,7 @@ const Modal = (($) => { Util.reflow(this._backdrop) } - $(this._backdrop).addClass(ClassName.ACTIVE) + $(this._backdrop).addClass(ClassName.SHOW) if (!callback) { return @@ -372,7 +372,7 @@ const Modal = (($) => { .emulateTransitionEnd(BACKDROP_TRANSITION_DURATION) } else if (!this._isShown && this._backdrop) { - $(this._backdrop).removeClass(ClassName.ACTIVE) + $(this._backdrop).removeClass(ClassName.SHOW) const callbackRemove = () => { this._removeBackdrop() diff --git a/js/src/popover.js b/js/src/popover.js index a08ed4de9..33bc9e48c 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -37,8 +37,8 @@ const Popover = (($) => { }) const ClassName = { - FADE : 'fade', - ACTIVE : 'active' + FADE : 'fade', + SHOW : 'show' } const Selector = { @@ -117,7 +117,7 @@ const Popover = (($) => { this.setElementContent($tip.find(Selector.TITLE), this.getTitle()) this.setElementContent($tip.find(Selector.CONTENT), this._getContent()) - $tip.removeClass(`${ClassName.FADE} ${ClassName.ACTIVE}`) + $tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`) this.cleanupTether() } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index dc291a72c..3fa5ecab4 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -72,8 +72,8 @@ const Tooltip = (($) => { } const HoverState = { - ACTIVE : 'active', - OUT : 'out' + SHOW : 'show', + OUT : 'out' } const Event = { @@ -90,8 +90,8 @@ const Tooltip = (($) => { } const ClassName = { - FADE : 'fade', - ACTIVE : 'active' + FADE : 'fade', + SHOW : 'show' } const Selector = { @@ -208,7 +208,7 @@ const Tooltip = (($) => { } else { - if ($(this.getTipElement()).hasClass(ClassName.ACTIVE)) { + if ($(this.getTipElement()).hasClass(ClassName.SHOW)) { this._leave(null, this) return } @@ -303,7 +303,7 @@ const Tooltip = (($) => { Util.reflow(tip) this._tether.position() - $(tip).addClass(ClassName.ACTIVE) + $(tip).addClass(ClassName.SHOW) const complete = () => { const prevHoverState = this._hoverState @@ -336,7 +336,7 @@ const Tooltip = (($) => { throw new Error('Tooltip is transitioning') } const complete = () => { - if (this._hoverState !== HoverState.ACTIVE && tip.parentNode) { + if (this._hoverState !== HoverState.SHOW && tip.parentNode) { tip.parentNode.removeChild(tip) } @@ -356,7 +356,7 @@ const Tooltip = (($) => { return } - $(tip).removeClass(ClassName.ACTIVE) + $(tip).removeClass(ClassName.SHOW) if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { @@ -388,7 +388,7 @@ const Tooltip = (($) => { this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle()) - $tip.removeClass(`${ClassName.FADE} ${ClassName.ACTIVE}`) + $tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`) this.cleanupTether() } @@ -513,15 +513,15 @@ const Tooltip = (($) => { ] = true } - if ($(context.getTipElement()).hasClass(ClassName.ACTIVE) || - context._hoverState === HoverState.ACTIVE) { - context._hoverState = HoverState.ACTIVE + if ($(context.getTipElement()).hasClass(ClassName.SHOW) || + context._hoverState === HoverState.SHOW) { + context._hoverState = HoverState.SHOW return } clearTimeout(context._timeout) - context._hoverState = HoverState.ACTIVE + context._hoverState = HoverState.SHOW if (!context.config.delay || !context.config.delay.show) { context.show() @@ -529,7 +529,7 @@ const Tooltip = (($) => { } context._timeout = setTimeout(() => { - if (context._hoverState === HoverState.ACTIVE) { + if (context._hoverState === HoverState.SHOW) { context.show() } }, context.config.delay.show) -- cgit v1.2.3 From d991c868a4b9b598a622f739547f71ee0ea7a352 Mon Sep 17 00:00:00 2001 From: Starsam80 Date: Thu, 27 Oct 2016 16:50:23 -0600 Subject: Fix tabs by using new classes --- js/src/tab.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/src') diff --git a/js/src/tab.js b/js/src/tab.js index e7e8f550f..c7e5fbfbe 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -37,7 +37,7 @@ const Tab = (($) => { DROPDOWN_MENU : 'dropdown-menu', ACTIVE : 'active', FADE : 'fade', - IN : 'in' + SHOW : 'show' } const Selector = { @@ -173,7 +173,7 @@ const Tab = (($) => { } if (active) { - $(active).removeClass(ClassName.IN) + $(active).removeClass(ClassName.SHOW) } } @@ -197,7 +197,7 @@ const Tab = (($) => { if (isTransitioning) { Util.reflow(element) - $(element).addClass(ClassName.IN) + $(element).addClass(ClassName.SHOW) } else { $(element).removeClass(ClassName.FADE) } -- cgit v1.2.3 From 1d6cdb65b32f918fc497953adf02b60e26ea3fec Mon Sep 17 00:00:00 2001 From: mr-july Date: Fri, 23 Dec 2016 07:00:56 +0100 Subject: scrollspy: fix wrong activation of all nested links (#20304) * fix wrong activation of all nested links; just first level item should be activated * use template instead of string concatenation --- js/src/scrollspy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 9cb1438ca..0a4708bf9 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -258,7 +258,7 @@ const ScrollSpy = (($) => { } else { // todo (fat) this is kinda sus... // recursively add actives to tested nav-links - $link.parents(Selector.LI).find(Selector.NAV_LINKS).addClass(ClassName.ACTIVE) + $link.parents(Selector.LI).find(`> ${Selector.NAV_LINKS}`).addClass(ClassName.ACTIVE) } $(this._scrollElement).trigger(Event.ACTIVATE, { -- cgit v1.2.3 From dab6a41e049de64653c8b91c28acf212137b0452 Mon Sep 17 00:00:00 2001 From: Matheus Azzi Date: Sat, 15 Oct 2016 22:55:48 -0300 Subject: Carousel: Only prevents default for ARROW_LEFT and ARROW_RIGHT keys Fixes 2 bugs: 1. All keydowns were being prevented. Because of that the user wasn't able to navigate in the whole page using ARROW_UP/ARROW_DOWN. 2. Even when is an input or textarea the keydowns were being prevented. Because of that the user wasn't able to type any text on these elements. --- js/src/carousel.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index 304d0160f..78f8eb468 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -245,9 +245,11 @@ const Carousel = (($) => { switch (event.which) { case ARROW_LEFT_KEYCODE: + event.preventDefault() this.prev() break case ARROW_RIGHT_KEYCODE: + event.preventDefault() this.next() break default: -- cgit v1.2.3 From b0508a975d711d6b24c01f57dd5445c22699fac4 Mon Sep 17 00:00:00 2001 From: Johann-S Date: Fri, 23 Dec 2016 11:56:09 +0100 Subject: Closes: #21412: Fix unit test for carousel --- js/src/carousel.js | 1 - 1 file changed, 1 deletion(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index 78f8eb468..9a1a668b2 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -241,7 +241,6 @@ const Carousel = (($) => { if (/input|textarea/i.test(event.target.tagName)) { return } - event.preventDefault() switch (event.which) { case ARROW_LEFT_KEYCODE: -- cgit v1.2.3 From 9103bffe37d366f8b2a4092092ddec850917d260 Mon Sep 17 00:00:00 2001 From: Alessandro Rodi Date: Sun, 25 Dec 2016 08:31:34 +0100 Subject: [Fix #19849] Tabs are opened even if disabled. (#20795) * [Fix #19849] Tabs are opened even if disabled. * fix hund code review hints * rollback hound issues because Travis fails --- js/src/tab.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/tab.js b/js/src/tab.js index c7e5fbfbe..2f4e453e0 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -36,6 +36,7 @@ const Tab = (($) => { const ClassName = { DROPDOWN_MENU : 'dropdown-menu', ACTIVE : 'active', + DISABLED : 'disabled', FADE : 'fade', SHOW : 'show' } @@ -79,7 +80,8 @@ const Tab = (($) => { show() { if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && - $(this._element).hasClass(ClassName.ACTIVE)) { + $(this._element).hasClass(ClassName.ACTIVE) || + $(this._element).hasClass(ClassName.DISABLED)) { return } -- cgit v1.2.3 From aa7f95fd777b5a733bc85c158919d206e05a61b5 Mon Sep 17 00:00:00 2001 From: Max Beatty Date: Mon, 26 Dec 2016 16:21:27 -0800 Subject: update click state when hiding so can be shown again by trigger. fixes #16732 --- js/src/tooltip.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 024035fe4..0c1d381b9 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -358,6 +358,10 @@ const Tooltip = (($) => { $(tip).removeClass(ClassName.SHOW) + this._activeTrigger[Trigger.CLICK] = false + this._activeTrigger[Trigger.FOCUS] = false + this._activeTrigger[Trigger.HOVER] = false + if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { this._isTransitioning = true -- cgit v1.2.3