From 926fb111581e9854d4c50b5f5e0f6876d7cbf176 Mon Sep 17 00:00:00 2001 From: lbryant Date: Thu, 20 Aug 2015 01:03:29 -0400 Subject: use Tether addTargetClasses: false option instead of manually removing them --- js/src/tooltip.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index a65caf26e..0af63c981 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -270,12 +270,13 @@ const Tooltip = (($) => { this._tether = new Tether({ attachment, - element : tip, - target : this.element, - classes : TetherClass, - classPrefix : CLASS_PREFIX, - offset : this.config.offset, - constraints : this.config.constraints + element : tip, + target : this.element, + classes : TetherClass, + classPrefix : CLASS_PREFIX, + offset : this.config.offset, + constraints : this.config.constraints, + addTargetClasses: false }) Util.reflow(tip) @@ -384,12 +385,6 @@ const Tooltip = (($) => { cleanupTether() { if (this._tether) { this._tether.destroy() - - // clean up after tether's junk classes - // remove after they fix issue - // (https://github.com/HubSpot/tether/issues/36) - $(this.element).removeClass(this._removeTetherClasses) - $(this.tip).removeClass(this._removeTetherClasses) } } -- cgit v1.2.3 From 8b15b5a2622043a57138ff38cd99ee7c9a418bf0 Mon Sep 17 00:00:00 2001 From: lbryant Date: Thu, 20 Aug 2015 01:22:16 -0400 Subject: _removeTetherClasses is no longer referenced --- js/src/tooltip.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 0af63c981..f54a1dca9 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -438,12 +438,6 @@ const Tooltip = (($) => { } } - _removeTetherClasses(i, css) { - return ((css.baseVal || css).match( - new RegExp(`(^|\\s)${CLASS_PREFIX}-\\S+`, 'g')) || [] - ).join(' ') - } - _fixTitle() { let titleType = typeof this.element.getAttribute('data-original-title') if (this.element.getAttribute('title') || -- cgit v1.2.3 From 21a65f181eebc3f2c0cd43fb3383ee3de673745b Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 16 Sep 2015 10:35:29 +0200 Subject: Add throw error for undefined method on plugins --- js/src/carousel.js | 7 ++++--- js/src/collapse.js | 3 +++ js/src/dropdown.js | 3 +++ js/src/modal.js | 4 +++- js/src/popover.js | 3 +++ js/src/scrollspy.js | 3 +++ js/src/tab.js | 3 +++ js/src/tooltip.js | 3 +++ 8 files changed, 25 insertions(+), 4 deletions(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index efacd9494..d8da854a2 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -390,10 +390,11 @@ const Carousel = (($) => { if (typeof config === 'number') { data.to(config) - - } else if (action) { + } else if (typeof action === 'string') { + if (data[action] === undefined) { + throw new Error(`No method named "${action}"`) + } data[action]() - } else if (_config.interval) { data.pause() data.cycle() diff --git a/js/src/collapse.js b/js/src/collapse.js index e46d3ec60..a9980926e 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -333,6 +333,9 @@ const Collapse = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 734e64312..f947d2aa1 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -143,6 +143,9 @@ const Dropdown = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config].call(this) } }) diff --git a/js/src/modal.js b/js/src/modal.js index f57131e7e..99a49f148 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -463,8 +463,10 @@ const Modal = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config](relatedTarget) - } else if (_config.show) { data.show(relatedTarget) } diff --git a/js/src/popover.js b/js/src/popover.js index b8b24a1c4..11ee86e70 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -153,6 +153,9 @@ const Popover = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) diff --git a/js/src/scrollspy.js b/js/src/scrollspy.js index 27a91958e..bdbd6439c 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -277,6 +277,9 @@ const ScrollSpy = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) diff --git a/js/src/tab.js b/js/src/tab.js index 4b311c24e..1283881e4 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -234,6 +234,9 @@ const Tab = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 151cd6f51..b80bd8e8c 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -622,6 +622,9 @@ const Tooltip = (($) => { } if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error(`No method named "${config}"`) + } data[config]() } }) -- cgit v1.2.3 From 817d997b75d970cc22000f345f68092ed3f0525b Mon Sep 17 00:00:00 2001 From: Johann-S Date: Sun, 27 Sep 2015 01:30:11 +0200 Subject: Use Page Visibility API in Carousel; fixes #17706 Avoids cycling carousels when the page isn't visible. Closes #17710 Refs #15566 --- js/src/carousel.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/carousel.js b/js/src/carousel.js index d8da854a2..8d47fbf9b 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -119,6 +119,13 @@ const Carousel = (($) => { } } + nextWhenVisible() { + // Don't call next when the page isn't visible + if (!document.hidden) { + this.next() + } + } + prev() { if (!this._isSliding) { this._slide(Direction.PREVIOUS) @@ -152,7 +159,7 @@ const Carousel = (($) => { if (this._config.interval && !this._isPaused) { this._interval = setInterval( - $.proxy(this.next, this), this._config.interval + $.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval ) } } -- cgit v1.2.3 From 2d87ec9a64b521807786f476dfe1b7a555b43e4b Mon Sep 17 00:00:00 2001 From: Jon Tewksbury Date: Tue, 3 Nov 2015 15:04:26 -0800 Subject: Add eslint no-undef rule and resolve errors --- js/src/modal.js | 2 +- js/src/tooltip.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'js/src') diff --git a/js/src/modal.js b/js/src/modal.js index 99a49f148..a5f0160c9 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -138,7 +138,7 @@ const Modal = (($) => { $(this._dialog).on(Event.MOUSEDOWN_DISMISS, () => { $(this._element).one(Event.MOUSEUP_DISMISS, (event) => { if ($(event.target).is(this._element)) { - that._ignoreBackdropClick = true + this._ignoreBackdropClick = true } }) }) diff --git a/js/src/tooltip.js b/js/src/tooltip.js index b80bd8e8c..749e42379 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -1,3 +1,5 @@ +/* global Tether */ + import Util from './util' -- cgit v1.2.3 From d600831a153c9930c3fe4e618b187951abc7b43b Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 14 Nov 2015 20:35:10 -0800 Subject: add explicit error for lack of tether in tooltips - fixes #17273 --- js/src/tooltip.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/src') diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 30c2f7165..173ee592e 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -12,6 +12,14 @@ import Util from './util' const Tooltip = (($) => { + /** + * Check for Tether dependency + * Tether - http://github.hubspot.com/tether/ + */ + if (!window.Tether) { + throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)') + } + /** * ------------------------------------------------------------------------ -- cgit v1.2.3 From ece98f980cc9dedbab099bd8d4fc1540a218bb9d Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 14 Nov 2015 20:43:45 -0800 Subject: add undefined for now --- 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 173ee592e..6bd17353d 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) { + if (window.Tether === undefined) { throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)') } -- cgit v1.2.3 From a887a1207c3193a7389a4b84c22991e9a91d82a6 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Mon, 30 Nov 2015 23:47:56 -0800 Subject: util.js: Add comment explaining ~~ trick [skip sauce] [skip validator] --- 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 f4a584125..fccf6178c 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -99,7 +99,7 @@ const Util = (($) => { getUID(prefix) { do { - prefix += ~~(Math.random() * 1000000) + prefix += ~~(Math.random() * 1000000) // "~~" acts like a faster Math.floor() here } while (document.getElementById(prefix)) return prefix }, -- cgit v1.2.3 From 79a4273891cf7929760abc1954037e6b2e31af9a Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Thu, 12 Nov 2015 21:21:32 +0200 Subject: Tweak ESLint rules. --- js/src/dropdown.js | 10 +++++----- js/src/modal.js | 8 ++++---- js/src/tab.js | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'js/src') diff --git a/js/src/dropdown.js b/js/src/dropdown.js index f947d2aa1..286471a73 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -25,11 +25,11 @@ const Dropdown = (($) => { const JQUERY_NO_CONFLICT = $.fn[NAME] const Event = { - HIDE   : `hide${EVENT_KEY}`, - HIDDEN   : `hidden${EVENT_KEY}`, - SHOW   : `show${EVENT_KEY}`, - SHOWN   : `shown${EVENT_KEY}`, - CLICK   : `click${EVENT_KEY}`, + HIDE : `hide${EVENT_KEY}`, + HIDDEN : `hidden${EVENT_KEY}`, + SHOW : `show${EVENT_KEY}`, + SHOWN : `shown${EVENT_KEY}`, + CLICK : `click${EVENT_KEY}`, CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`, KEYDOWN_DATA_API : `keydown${EVENT_KEY}${DATA_API_KEY}` } diff --git a/js/src/modal.js b/js/src/modal.js index a5f0160c9..6fab292f7 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -41,10 +41,10 @@ const Modal = (($) => { } const Event = { - HIDE   : `hide${EVENT_KEY}`, - HIDDEN   : `hidden${EVENT_KEY}`, - SHOW   : `show${EVENT_KEY}`, - SHOWN   : `shown${EVENT_KEY}`, + HIDE : `hide${EVENT_KEY}`, + HIDDEN : `hidden${EVENT_KEY}`, + SHOW : `show${EVENT_KEY}`, + SHOWN : `shown${EVENT_KEY}`, FOCUSIN : `focusin${EVENT_KEY}`, RESIZE : `resize${EVENT_KEY}`, CLICK_DISMISS : `click.dismiss${EVENT_KEY}`, diff --git a/js/src/tab.js b/js/src/tab.js index 1283881e4..6bfe38739 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -253,9 +253,9 @@ const Tab = (($) => { $(document) .on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { - event.preventDefault() - Tab._jQueryInterface.call($(this), 'show') - }) + event.preventDefault() + Tab._jQueryInterface.call($(this), 'show') + }) /** -- cgit v1.2.3 From 75c39f9138ea95e8d472812117b13f1ed7978157 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sat, 5 Dec 2015 02:19:21 -0800 Subject: Fix version numbers is JS files; fixes #18435 [skip sauce] [skip validator] --- 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 da4e5b6a5..9e05dc846 100644 --- a/js/src/alert.js +++ b/js/src/alert.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): alert.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 58ef66b8b..69d63a1ec 100644 --- a/js/src/button.js +++ b/js/src/button.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): button.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 8d47fbf9b..3abb06466 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): carousel.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 a9980926e..17d7396fb 100644 --- a/js/src/collapse.js +++ b/js/src/collapse.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): collapse.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 286471a73..d09b68321 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): dropdown.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 6fab292f7..5a90b2238 100644 --- a/js/src/modal.js +++ b/js/src/modal.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): modal.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 11ee86e70..523dd9ab6 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -3,7 +3,7 @@ import Tooltip from './tooltip' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): popover.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 bdbd6439c..af822e38e 100644 --- a/js/src/scrollspy.js +++ b/js/src/scrollspy.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): scrollspy.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 6bfe38739..393a92b44 100644 --- a/js/src/tab.js +++ b/js/src/tab.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): tab.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 6bd17353d..b0eec1abc 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -5,7 +5,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): tooltip.js + * Bootstrap (v4.0.0-alpha): 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' + const VERSION = '4.0.0-alpha' 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 fccf6178c..64ad84b7c 100644 --- a/js/src/util.js +++ b/js/src/util.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): util.js + * Bootstrap (v4.0.0-alpha): util.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ -- cgit v1.2.3