aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
Diffstat (limited to 'js/src')
-rw-r--r--js/src/alert.js4
-rw-r--r--js/src/button.js4
-rw-r--r--js/src/carousel.js20
-rw-r--r--js/src/collapse.js7
-rw-r--r--js/src/dropdown.js17
-rw-r--r--js/src/modal.js18
-rw-r--r--js/src/popover.js7
-rw-r--r--js/src/scrollspy.js7
-rw-r--r--js/src/tab.js13
-rw-r--r--js/src/tooltip.js42
-rw-r--r--js/src/util.js4
11 files changed, 85 insertions, 58 deletions
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 efacd9494..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'
@@ -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
)
}
}
@@ -390,10 +397,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..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'
@@ -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..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,18 +18,18 @@ 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'
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}`
}
@@ -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..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'
@@ -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}`,
@@ -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
}
})
})
@@ -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..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]
@@ -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..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'
@@ -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..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'
@@ -234,6 +234,9 @@ const Tab = (($) => {
}
if (typeof config === 'string') {
+ if (data[config] === undefined) {
+ throw new Error(`No method named "${config}"`)
+ }
data[config]()
}
})
@@ -250,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')
+ })
/**
diff --git a/js/src/tooltip.js b/js/src/tooltip.js
index 151cd6f51..b0eec1abc 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -1,15 +1,25 @@
+/* global Tether */
+
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)
* --------------------------------------------------------------------------
*/
const Tooltip = (($) => {
+ /**
+ * Check for Tether dependency
+ * Tether - http://github.hubspot.com/tether/
+ */
+ if (window.Tether === undefined) {
+ throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)')
+ }
+
/**
* ------------------------------------------------------------------------
@@ -18,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]
@@ -270,12 +280,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)
@@ -398,12 +409,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)
}
}
@@ -457,12 +462,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') ||
@@ -622,6 +621,9 @@ const Tooltip = (($) => {
}
if (typeof config === 'string') {
+ if (data[config] === undefined) {
+ throw new Error(`No method named "${config}"`)
+ }
data[config]()
}
})
diff --git a/js/src/util.js b/js/src/util.js
index f4a584125..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)
* --------------------------------------------------------------------------
*/
@@ -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
},