aboutsummaryrefslogtreecommitdiff
path: root/js/src
diff options
context:
space:
mode:
authorPierre-Denis Vanduynslager <[email protected]>2016-08-02 01:35:38 -0400
committerPierre-Denis Vanduynslager <[email protected]>2016-08-02 01:35:38 -0400
commit27cf3d675c80029ff2cea1e14903886c00119e37 (patch)
treea84ac3a7f6759fe0be4f099c41e6c92b58999437 /js/src
parentf0c0a7533c854613eba42394631567a44d790053 (diff)
parent8e4f3fe7b95f6bb7c9939288229ec5683364743d (diff)
downloadbootstrap-27cf3d675c80029ff2cea1e14903886c00119e37.tar.xz
bootstrap-27cf3d675c80029ff2cea1e14903886c00119e37.zip
Merge remote-tracking branch 'twbs/v4-dev' into v4-dev
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.js17
-rw-r--r--js/src/collapse.js4
-rw-r--r--js/src/dropdown.js30
-rw-r--r--js/src/modal.js7
-rw-r--r--js/src/popover.js4
-rw-r--r--js/src/scrollspy.js5
-rw-r--r--js/src/tab.js4
-rw-r--r--js/src/tooltip.js4
-rw-r--r--js/src/util.js9
11 files changed, 54 insertions, 38 deletions
diff --git a/js/src/alert.js b/js/src/alert.js
index 4cb006ea3..a4e7f56a5 100644
--- a/js/src/alert.js
+++ b/js/src/alert.js
@@ -3,7 +3,7 @@ import Util from './util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): alert.js
+ * Bootstrap (v4.0.0-alpha.3): 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.2'
+ const VERSION = '4.0.0-alpha.3'
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 39e2b3974..14f3c569f 100644
--- a/js/src/button.js
+++ b/js/src/button.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): button.js
+ * Bootstrap (v4.0.0-alpha.3): 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.2'
+ const VERSION = '4.0.0-alpha.3'
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 34cab4391..e2a6537bf 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -3,7 +3,7 @@ import Util from './util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): carousel.js
+ * Bootstrap (v4.0.0-alpha.3): carousel.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -18,12 +18,14 @@ const Carousel = (($) => {
*/
const NAME = 'carousel'
- const VERSION = '4.0.0-alpha.2'
+ const VERSION = '4.0.0-alpha.3'
const DATA_KEY = 'bs.carousel'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]
const TRANSITION_DURATION = 600
+ const ARROW_LEFT_KEYCODE = 37 // KeyboardEvent.which value for left arrow key
+ const ARROW_RIGHT_KEYCODE = 39 // KeyboardEvent.which value for right arrow key
const Default = {
interval : 5000,
@@ -236,9 +238,14 @@ const Carousel = (($) => {
}
switch (event.which) {
- case 37: this.prev(); break
- case 39: this.next(); break
- default: return
+ case ARROW_LEFT_KEYCODE:
+ this.prev()
+ break
+ case ARROW_RIGHT_KEYCODE:
+ this.next()
+ break
+ default:
+ return
}
}
diff --git a/js/src/collapse.js b/js/src/collapse.js
index 3dd07cadf..d99b384d1 100644
--- a/js/src/collapse.js
+++ b/js/src/collapse.js
@@ -3,7 +3,7 @@ import Util from './util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): collapse.js
+ * Bootstrap (v4.0.0-alpha.3): 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.2'
+ const VERSION = '4.0.0-alpha.3'
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 92f841bc4..e0f4a1822 100644
--- a/js/src/dropdown.js
+++ b/js/src/dropdown.js
@@ -3,7 +3,7 @@ import Util from './util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): dropdown.js
+ * Bootstrap (v4.0.0-alpha.3): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -17,12 +17,16 @@ const Dropdown = (($) => {
* ------------------------------------------------------------------------
*/
- const NAME = 'dropdown'
- const VERSION = '4.0.0-alpha.2'
- const DATA_KEY = 'bs.dropdown'
- const EVENT_KEY = `.${DATA_KEY}`
- const DATA_API_KEY = '.data-api'
- const JQUERY_NO_CONFLICT = $.fn[NAME]
+ const NAME = 'dropdown'
+ const VERSION = '4.0.0-alpha.3'
+ const DATA_KEY = 'bs.dropdown'
+ const EVENT_KEY = `.${DATA_KEY}`
+ const DATA_API_KEY = '.data-api'
+ const JQUERY_NO_CONFLICT = $.fn[NAME]
+ const ESCAPE_KEYCODE = 27 // KeyboardEvent.which value for Escape (Esc) key
+ const ARROW_UP_KEYCODE = 38 // KeyboardEvent.which value for up arrow key
+ const ARROW_DOWN_KEYCODE = 40 // KeyboardEvent.which value for down arrow key
+ const RIGHT_MOUSE_BUTTON_WHICH = 3 // MouseEvent.which value for the right button (assuming a right-handed mouse)
const Event = {
HIDE : `hide${EVENT_KEY}`,
@@ -152,7 +156,7 @@ const Dropdown = (($) => {
}
static _clearMenus(event) {
- if (event && event.which === 3) {
+ if (event && event.which === RIGHT_MOUSE_BUTTON_WHICH) {
return
}
@@ -218,10 +222,10 @@ const Dropdown = (($) => {
let parent = Dropdown._getParentFromElement(this)
let isActive = $(parent).hasClass(ClassName.OPEN)
- if ((!isActive && event.which !== 27) ||
- (isActive && event.which === 27)) {
+ if ((!isActive && event.which !== ESCAPE_KEYCODE) ||
+ (isActive && event.which === ESCAPE_KEYCODE)) {
- if (event.which === 27) {
+ if (event.which === ESCAPE_KEYCODE) {
let toggle = $(parent).find(Selector.DATA_TOGGLE)[0]
$(toggle).trigger('focus')
}
@@ -242,11 +246,11 @@ const Dropdown = (($) => {
let index = items.indexOf(event.target)
- if (event.which === 38 && index > 0) { // up
+ if (event.which === ARROW_UP_KEYCODE && index > 0) { // up
index--
}
- if (event.which === 40 && index < items.length - 1) { // down
+ if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { // down
index++
}
diff --git a/js/src/modal.js b/js/src/modal.js
index f52af09a2..9b3a99ddd 100644
--- a/js/src/modal.js
+++ b/js/src/modal.js
@@ -3,7 +3,7 @@ import Util from './util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): modal.js
+ * Bootstrap (v4.0.0-alpha.3): modal.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -18,13 +18,14 @@ const Modal = (($) => {
*/
const NAME = 'modal'
- const VERSION = '4.0.0-alpha.2'
+ const VERSION = '4.0.0-alpha.3'
const DATA_KEY = 'bs.modal'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
const JQUERY_NO_CONFLICT = $.fn[NAME]
const TRANSITION_DURATION = 300
const BACKDROP_TRANSITION_DURATION = 150
+ const ESCAPE_KEYCODE = 27 // KeyboardEvent.which value for Escape (Esc) key
const Default = {
backdrop : true,
@@ -271,7 +272,7 @@ const Modal = (($) => {
_setEscapeEvent() {
if (this._isShown && this._config.keyboard) {
$(this._element).on(Event.KEYDOWN_DISMISS, (event) => {
- if (event.which === 27) {
+ if (event.which === ESCAPE_KEYCODE) {
this.hide()
}
})
diff --git a/js/src/popover.js b/js/src/popover.js
index 7e8ec4297..e4c32637b 100644
--- a/js/src/popover.js
+++ b/js/src/popover.js
@@ -3,7 +3,7 @@ import Tooltip from './tooltip'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): popover.js
+ * Bootstrap (v4.0.0-alpha.3): 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.2'
+ const VERSION = '4.0.0-alpha.3'
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 b9186db00..52b8b6d20 100644
--- a/js/src/scrollspy.js
+++ b/js/src/scrollspy.js
@@ -3,7 +3,7 @@ import Util from './util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): scrollspy.js
+ * Bootstrap (v4.0.0-alpha.3): 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.2'
+ const VERSION = '4.0.0-alpha.3'
const DATA_KEY = 'bs.scrollspy'
const EVENT_KEY = `.${DATA_KEY}`
const DATA_API_KEY = '.data-api'
@@ -140,6 +140,7 @@ const ScrollSpy = (($) => {
targetSelector
]
}
+ return null
})
.filter((item) => item)
.sort((a, b) => a[0] - b[0])
diff --git a/js/src/tab.js b/js/src/tab.js
index 33f56faae..7bd8f2f9c 100644
--- a/js/src/tab.js
+++ b/js/src/tab.js
@@ -3,7 +3,7 @@ import Util from './util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): tab.js
+ * Bootstrap (v4.0.0-alpha.3): 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.2'
+ const VERSION = '4.0.0-alpha.3'
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 77803dc40..0b3ba3669 100644
--- a/js/src/tooltip.js
+++ b/js/src/tooltip.js
@@ -5,7 +5,7 @@ import Util from './util'
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): tooltip.js
+ * Bootstrap (v4.0.0-alpha.3): 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.2'
+ const VERSION = '4.0.0-alpha.3'
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 dba6e9bd6..051555268 100644
--- a/js/src/util.js
+++ b/js/src/util.js
@@ -1,6 +1,6 @@
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.0.0-alpha.2): util.js
+ * Bootstrap (v4.0.0-alpha.3): util.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
@@ -16,6 +16,8 @@ const Util = (($) => {
let transition = false
+ const MAX_UID = 1000000
+
const TransitionEndEvent = {
WebkitTransition : 'webkitTransitionEnd',
MozTransition : 'transitionend',
@@ -38,8 +40,9 @@ const Util = (($) => {
delegateType: transition.end,
handle(event) {
if ($(event.target).is(this)) {
- return event.handleObj.handler.apply(this, arguments)
+ return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params
}
+ return undefined
}
}
}
@@ -100,7 +103,7 @@ const Util = (($) => {
getUID(prefix) {
do {
/* eslint-disable no-bitwise */
- prefix += ~~(Math.random() * 1000000) // "~~" acts like a faster Math.floor() here
+ prefix += ~~(Math.random() * MAX_UID) // "~~" acts like a faster Math.floor() here
/* eslint-enable no-bitwise */
} while (document.getElementById(prefix))
return prefix