Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorBardi Harborow <bardi@bardiharborow.com>2016-11-21 17:36:00 +0300
committerBardi Harborow <bardi@bardiharborow.com>2016-11-24 03:59:55 +0300
commitc2616fb74e6bdc0cd46a5678a2c5cffcbe422106 (patch)
treec9f2db3c292861301816f255bbe25b9b45fdd8b2 /js
parent26c16743fce73db5f85c9f16fe59242f876c5360 (diff)
Make JS compliant with the new ESLint rules.
Diffstat (limited to 'js')
-rw-r--r--js/src/alert.js14
-rw-r--r--js/src/button.js8
-rw-r--r--js/src/carousel.js55
-rw-r--r--js/src/collapse.js40
-rw-r--r--js/src/dropdown.js49
-rw-r--r--js/src/modal.js44
-rw-r--r--js/src/popover.js8
-rw-r--r--js/src/scrollspy.js30
-rw-r--r--js/src/tab.js40
-rw-r--r--js/src/tooltip.js81
-rw-r--r--js/src/util.js30
-rw-r--r--js/tests/unit/alert.js2
-rw-r--r--js/tests/unit/button.js2
-rw-r--r--js/tests/unit/carousel.js2
-rw-r--r--js/tests/unit/collapse.js14
-rw-r--r--js/tests/unit/dropdown.js2
-rw-r--r--js/tests/unit/modal.js4
-rw-r--r--js/tests/unit/phantom.js31
-rw-r--r--js/tests/unit/popover.js2
-rw-r--r--js/tests/unit/scrollspy.js14
-rw-r--r--js/tests/unit/tab.js2
-rw-r--r--js/tests/unit/tooltip.js20
22 files changed, 234 insertions, 260 deletions
diff --git a/js/src/alert.js b/js/src/alert.js
index 27411e276c..8e55249501 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 a7eed18262..8b95117657 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 17bfebc688..b7f3b3a7a9 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 f700979e07..ebc3e24cfe 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 3246e6bef0..644659266f 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 a52dcb07fa..5c2c0208aa 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 289853b32a..01804eda6c 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 648173b33b..98582f9182 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 012d2f76fc..c5d205bcfa 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 c4fdbff59c..822ae36525 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 5ddbbbf133..06424fbfe3 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(
diff --git a/js/tests/unit/alert.js b/js/tests/unit/alert.js
index 3128e20be3..9548c3318c 100644
--- a/js/tests/unit/alert.js
+++ b/js/tests/unit/alert.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('alert plugin')
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js
index 5648506cf5..7fd86e13a5 100644
--- a/js/tests/unit/button.js
+++ b/js/tests/unit/button.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('button plugin')
diff --git a/js/tests/unit/carousel.js b/js/tests/unit/carousel.js
index d6d0186e15..033ccfd6c5 100644
--- a/js/tests/unit/carousel.js
+++ b/js/tests/unit/carousel.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('carousel plugin')
diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js
index 25bb7772e2..7db69e2cf8 100644
--- a/js/tests/unit/collapse.js
+++ b/js/tests/unit/collapse.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('collapse plugin')
@@ -56,14 +56,14 @@ $(function () {
assert.expect(2)
var html = [
'<div class="panel-group" id="accordion1">',
- '<div class="panel">',
- '<div id="collapse1" class="collapse"/>',
- '</div>',
+ '<div class="panel">',
+ '<div id="collapse1" class="collapse"/>',
+ '</div>',
'</div>',
'<div class="panel-group" id="accordion2">',
- '<div class="panel">',
- '<div id="collapse2" class="collapse active"/>',
- '</div>',
+ '<div class="panel">',
+ '<div id="collapse2" class="collapse active"/>',
+ '</div>',
'</div>'
].join('')
$(html).appendTo('#qunit-fixture')
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index becd1d0898..7e8ecae4ea 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('dropdowns plugin')
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index f5157d4544..2d5911af3b 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('modal plugin')
@@ -374,7 +374,7 @@ $(function () {
var paddingRight = parseInt($(document.body).css('padding-right'), 10)
assert.strictEqual(isNaN(paddingRight), false)
assert.strictEqual(paddingRight !== 0, true)
- $(document.body).css('padding-right', ''); // Because test case "should ignore other inline styles when trying to restore body padding after closing" fail if not
+ $(document.body).css('padding-right', '') // Because test case "should ignore other inline styles when trying to restore body padding after closing" fail if not
done()
})
.bootstrapModal('show')
diff --git a/js/tests/unit/phantom.js b/js/tests/unit/phantom.js
index 525aea0024..eea7486a43 100644
--- a/js/tests/unit/phantom.js
+++ b/js/tests/unit/phantom.js
@@ -7,7 +7,7 @@
*/
(function () {
- 'use strict';
+ 'use strict'
// Don't re-order tests.
QUnit.config.reorder = false
@@ -70,32 +70,3 @@
})
}())
-
-
-// bind polyfill
-// shoutout mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Polyfill
-
-if (!Function.prototype.bind) {
- Function.prototype.bind = function (oThis) {
- if (typeof this !== 'function') {
- // closest thing possible to the ECMAScript 5
- // internal IsCallable function
- throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
- }
-
- var aArgs = Array.prototype.slice.call(arguments, 1)
- var fToBind = this
- var FNOP = function () {}
- var fBound = function () {
- return fToBind.apply(this instanceof FNOP ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)))
- }
-
- if (this.prototype) {
- // native functions don't have a prototype
- FNOP.prototype = this.prototype
- }
- fBound.prototype = new FNOP()
-
- return fBound
- }
-}
diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js
index 6e47222f14..4667d9e9a7 100644
--- a/js/tests/unit/popover.js
+++ b/js/tests/unit/popover.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('popover plugin')
diff --git a/js/tests/unit/scrollspy.js b/js/tests/unit/scrollspy.js
index 97ddd16ece..a349b5337e 100644
--- a/js/tests/unit/scrollspy.js
+++ b/js/tests/unit/scrollspy.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('scrollspy plugin')
@@ -231,8 +231,8 @@ $(function () {
.appendTo('#qunit-fixture')
.bootstrapScrollspy({ offset: 0, target: '#navigation' })
- !function testActiveElements() {
- if (++times > 3) return done()
+ function testActiveElements() {
+ if (++times > 3) { return done() }
$content.one('scroll', function () {
assert.ok($('#a-1').hasClass('active'), 'nav item for outer element has "active" class')
@@ -241,7 +241,9 @@ $(function () {
})
$content.scrollTop($content.scrollTop() + 10)
- }()
+ }
+
+ testActiveElements()
})
QUnit.test('should clear selection if above the first section', function (assert) {
@@ -399,8 +401,8 @@ $(function () {
$navbar.appendTo('#qunit-fixture')
$content.appendTo('#qunit-fixture')
- if (type === 'js') $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' })
- else if (type === 'data') $(window).trigger('load')
+ if (type === 'js') { $content.bootstrapScrollspy({ target: '.navbar', offset: 0, method: 'position' }) }
+ else if (type === 'data') { $(window).trigger('load') }
var $target = $('#div-' + type + 'm-2')
var scrollspy = $content.data('bs.scrollspy')
diff --git a/js/tests/unit/tab.js b/js/tests/unit/tab.js
index 522ed0b3e4..9835002fae 100644
--- a/js/tests/unit/tab.js
+++ b/js/tests/unit/tab.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('tabs plugin')
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index 97c5855cb0..ea95118a44 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -1,5 +1,5 @@
$(function () {
- 'use strict';
+ 'use strict'
QUnit.module('tooltip plugin')
@@ -382,7 +382,7 @@ $(function () {
var $tooltip = $($target.data('bs.tooltip').tip)
// this is some dumb hack stuff because sub pixels in firefox
- var top = Math.round($target.offset().top + ($target[0].offsetHeight / 2) - ($tooltip[0].offsetHeight / 2))
+ var top = Math.round($target.offset().top + $target[0].offsetHeight / 2 - $tooltip[0].offsetHeight / 2)
var top2 = Math.round($tooltip.offset().top)
var topDiff = top - top2
assert.ok(topDiff <= 1 && topDiff >= -1)
@@ -540,7 +540,7 @@ $(function () {
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
- .bootstrapTooltip({ delay: { show: 0, hide: 150 }})
+ .bootstrapTooltip({ delay: { show: 0, hide: 150 } })
setTimeout(function () {
assert.ok($('.tooltip').is('.fade.active'), '1ms: tooltip faded active')
@@ -587,7 +587,7 @@ $(function () {
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
- .bootstrapTooltip({ delay: { show: 150, hide: 0 }})
+ .bootstrapTooltip({ delay: { show: 150, hide: 0 } })
setTimeout(function () {
assert.ok(!$('.tooltip').is('.fade.active'), '100ms: tooltip not faded active')
@@ -608,7 +608,7 @@ $(function () {
var $tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"/>')
.appendTo('#qunit-fixture')
- .bootstrapTooltip({ delay: { show: 0, hide: 150 }})
+ .bootstrapTooltip({ delay: { show: 0, hide: 150 } })
setTimeout(function () {
assert.ok($($tooltip.data('bs.tooltip').tip).is('.fade.active'), '1ms: tooltip faded active')
@@ -723,10 +723,10 @@ $(function () {
$('#tt-outer').trigger('mouseleave')
assert.strictEqual(currentUid, $('#tt-content').text())
- assert.ok(obj._hoverState == 'out', 'the tooltip hoverState should be set to "out"')
+ assert.ok(obj._hoverState === 'out', 'the tooltip hoverState should be set to "out"')
$('#tt-outer').trigger('mouseenter')
- assert.ok(obj._hoverState == 'active', 'the tooltip hoverState should be set to "active"')
+ assert.ok(obj._hoverState === 'active', 'the tooltip hoverState should be set to "active"')
assert.strictEqual(currentUid, $('#tt-content').text())
})
@@ -788,7 +788,7 @@ $(function () {
var tooltip = $el.data('bs.tooltip')
var $tooltip = $(tooltip.getTipElement())
- function showingTooltip() { return $tooltip.hasClass('active') || tooltip._hoverState == 'active' }
+ function showingTooltip() { return $tooltip.hasClass('active') || tooltip._hoverState === 'active' }
var tests = [
['mouseenter', 'mouseleave'],
@@ -812,8 +812,8 @@ $(function () {
$.each(tests, function (idx, triggers) {
for (var i = 0, len = triggers.length; i < len; i++) {
- $el.trigger(triggers[i]);
- assert.equal(i < (len - 1), showingTooltip())
+ $el.trigger(triggers[i])
+ assert.equal(i < len - 1, showingTooltip())
}
})
})