1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-28 06:20:15 +02:00

Comply to the new rules.

This commit is contained in:
XhmikosR
2017-12-16 14:00:38 +02:00
parent 6d336502c7
commit 80d0943b95
32 changed files with 1798 additions and 1760 deletions

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): alert.js
@@ -10,8 +9,6 @@ import Util from './util'
*/
const Alert = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -42,7 +39,6 @@ const Alert = (($) => {
SHOW : 'show'
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -50,20 +46,17 @@ const Alert = (($) => {
*/
class Alert {
constructor(element) {
this._element = element
}
// getters
// Getters
static get VERSION() {
return VERSION
}
// public
// Public
close(element) {
element = element || this._element
@@ -83,8 +76,7 @@ const Alert = (($) => {
this._element = null
}
// private
// Private
_getRootElement(element) {
const selector = Util.getSelectorFromElement(element)
@@ -129,8 +121,7 @@ const Alert = (($) => {
.remove()
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
@@ -157,10 +148,8 @@ const Alert = (($) => {
alertInstance.close(this)
}
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -173,7 +162,6 @@ const Alert = (($) => {
Alert._handleDismiss(new Alert())
)
/**
* ------------------------------------------------------------------------
* jQuery
@@ -188,7 +176,6 @@ const Alert = (($) => {
}
return Alert
})($)
export default Alert

View File

@@ -8,8 +8,6 @@ import $ from 'jquery'
*/
const Button = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -39,11 +37,10 @@ const Button = (($) => {
const Event = {
CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`,
FOCUS_BLUR_DATA_API : `focus${EVENT_KEY}${DATA_API_KEY} `
+ `blur${EVENT_KEY}${DATA_API_KEY}`
FOCUS_BLUR_DATA_API : `focus${EVENT_KEY}${DATA_API_KEY} ` +
`blur${EVENT_KEY}${DATA_API_KEY}`
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -51,25 +48,22 @@ const Button = (($) => {
*/
class Button {
constructor(element) {
this._element = element
}
// getters
// Getters
static get VERSION() {
return VERSION
}
// public
// Public
toggle() {
let triggerChangeEvent = true
let addAriaPressed = true
const rootElement = $(this._element).closest(
const rootElement = $(this._element).closest(
Selector.DATA_TOGGLE
)[0]
@@ -81,7 +75,6 @@ const Button = (($) => {
if (input.checked &&
$(this._element).hasClass(ClassName.ACTIVE)) {
triggerChangeEvent = false
} else {
const activeElement = $(rootElement).find(Selector.ACTIVE)[0]
@@ -105,7 +98,6 @@ const Button = (($) => {
input.focus()
addAriaPressed = false
}
}
if (addAriaPressed) {
@@ -123,8 +115,7 @@ const Button = (($) => {
this._element = null
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
@@ -140,10 +131,8 @@ const Button = (($) => {
}
})
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -167,22 +156,20 @@ const Button = (($) => {
$(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type))
})
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Button._jQueryInterface
$.fn[NAME] = Button._jQueryInterface
$.fn[NAME].Constructor = Button
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Button._jQueryInterface
}
return Button
})($)
export default Button

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): carousel.js
@@ -10,8 +9,6 @@ import Util from './util'
*/
const Carousel = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -84,7 +81,6 @@ const Carousel = (($) => {
DATA_RIDE : '[data-ride="carousel"]'
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -92,7 +88,6 @@ const Carousel = (($) => {
*/
class Carousel {
constructor(element, config) {
this._items = null
this._interval = null
@@ -110,8 +105,7 @@ const Carousel = (($) => {
this._addEventListeners()
}
// getters
// Getters
static get VERSION() {
return VERSION
@@ -121,8 +115,7 @@ const Carousel = (($) => {
return Default
}
// public
// Public
next() {
if (!this._isSliding) {
@@ -198,9 +191,9 @@ const Carousel = (($) => {
return
}
const direction = index > activeIndex ?
Direction.NEXT :
Direction.PREV
const direction = index > activeIndex
? Direction.NEXT
: Direction.PREV
this._slide(direction, this._items[index])
}
@@ -219,8 +212,7 @@ const Carousel = (($) => {
this._indicatorsElement = null
}
// private
// Private
_getConfig(config) {
config = {
@@ -242,7 +234,7 @@ const Carousel = (($) => {
.on(Event.MOUSEENTER, (event) => this.pause(event))
.on(Event.MOUSELEAVE, (event) => this.cycle(event))
if ('ontouchstart' in document.documentElement) {
// if it's a touch-enabled device, mouseenter/leave are fired as
// If it's a touch-enabled device, mouseenter/leave are fired as
// part of the mouse compatibility events on first tap - the carousel
// would stop cycling until user tapped out of it;
// here, we listen for touchend, explicitly pause the carousel
@@ -275,7 +267,6 @@ const Carousel = (($) => {
this.next()
break
default:
return
}
}
@@ -299,11 +290,10 @@ const Carousel = (($) => {
const delta = direction === Direction.PREV ? -1 : 1
const itemIndex = (activeIndex + delta) % this._items.length
return itemIndex === -1 ?
this._items[this._items.length - 1] : this._items[itemIndex]
return itemIndex === -1
? this._items[this._items.length - 1] : this._items[itemIndex]
}
_triggerSlideEvent(relatedTarget, eventDirectionName) {
const targetIndex = this._getItemIndex(relatedTarget)
const fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0])
@@ -368,7 +358,7 @@ const Carousel = (($) => {
}
if (!activeElement || !nextElement) {
// some weirdness is happening, so we bail
// Some weirdness is happening, so we bail
return
}
@@ -389,7 +379,6 @@ const Carousel = (($) => {
if (Util.supportsTransitionEnd() &&
$(this._element).hasClass(ClassName.SLIDE)) {
$(nextElement).addClass(orderClassName)
Util.reflow(nextElement)
@@ -408,10 +397,8 @@ const Carousel = (($) => {
this._isSliding = false
setTimeout(() => $(this._element).trigger(slidEvent), 0)
})
.emulateTransitionEnd(TRANSITION_DURATION)
} else {
$(activeElement).removeClass(ClassName.ACTIVE)
$(nextElement).addClass(ClassName.ACTIVE)
@@ -425,12 +412,11 @@ const Carousel = (($) => {
}
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
let data = $(this).data(DATA_KEY)
let _config = {
...Default,
...$(this).data()
@@ -454,7 +440,7 @@ const Carousel = (($) => {
data.to(config)
} else if (typeof action === 'string') {
if (typeof data[action] === 'undefined') {
throw new Error(`No method named "${action}"`)
throw new TypeError(`No method named "${action}"`)
}
data[action]()
} else if (_config.interval) {
@@ -495,10 +481,8 @@ const Carousel = (($) => {
event.preventDefault()
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -515,22 +499,20 @@ const Carousel = (($) => {
})
})
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Carousel._jQueryInterface
$.fn[NAME] = Carousel._jQueryInterface
$.fn[NAME].Constructor = Carousel
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Carousel._jQueryInterface
}
return Carousel
})($)
export default Carousel

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): collapse.js
@@ -10,8 +9,6 @@ import Util from './util'
*/
const Collapse = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -61,7 +58,6 @@ const Collapse = (($) => {
DATA_TOGGLE : '[data-toggle="collapse"]'
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -69,7 +65,6 @@ const Collapse = (($) => {
*/
class Collapse {
constructor(element, config) {
this._isTransitioning = false
this._element = element
@@ -99,8 +94,7 @@ const Collapse = (($) => {
}
}
// getters
// Getters
static get VERSION() {
return VERSION
@@ -110,8 +104,7 @@ const Collapse = (($) => {
return Default
}
// public
// Public
toggle() {
if ($(this._element).hasClass(ClassName.SHOW)) {
@@ -136,7 +129,7 @@ const Collapse = (($) => {
.find(Selector.ACTIVES)
.filter(`[data-parent="${this._config.parent}"]`)
)
if (!actives.length) {
if (actives.length === 0) {
actives = null
}
}
@@ -169,7 +162,7 @@ const Collapse = (($) => {
this._element.style[dimension] = 0
if (this._triggerArray.length) {
if (this._triggerArray.length > 0) {
$(this._triggerArray)
.removeClass(ClassName.COLLAPSED)
.attr('aria-expanded', true)
@@ -196,7 +189,7 @@ const Collapse = (($) => {
}
const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1)
const scrollSize = `scroll${capitalizedDimension}`
const scrollSize = `scroll${capitalizedDimension}`
$(this._element)
.one(Util.TRANSITION_END, complete)
@@ -217,7 +210,7 @@ const Collapse = (($) => {
return
}
const dimension = this._getDimension()
const dimension = this._getDimension()
this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`
@@ -228,7 +221,7 @@ const Collapse = (($) => {
.removeClass(ClassName.COLLAPSE)
.removeClass(ClassName.SHOW)
if (this._triggerArray.length) {
if (this._triggerArray.length > 0) {
for (let i = 0; i < this._triggerArray.length; i++) {
const trigger = this._triggerArray[i]
const selector = Util.getSelectorFromElement(trigger)
@@ -236,7 +229,7 @@ const Collapse = (($) => {
const $elem = $(selector)
if (!$elem.hasClass(ClassName.SHOW)) {
$(trigger).addClass(ClassName.COLLAPSED)
.attr('aria-expanded', false)
.attr('aria-expanded', false)
}
}
}
@@ -278,15 +271,14 @@ const Collapse = (($) => {
this._isTransitioning = null
}
// private
// Private
_getConfig(config) {
config = {
...Default,
...config
}
config.toggle = Boolean(config.toggle) // coerce string values
config.toggle = Boolean(config.toggle) // Coerce string values
Util.typeCheckConfig(NAME, config, DefaultType)
return config
}
@@ -301,7 +293,7 @@ const Collapse = (($) => {
if (Util.isElement(this._config.parent)) {
parent = this._config.parent
// it's a jQuery object
// It's a jQuery object
if (typeof this._config.parent.jquery !== 'undefined') {
parent = this._config.parent[0]
}
@@ -326,7 +318,7 @@ const Collapse = (($) => {
if (element) {
const isOpen = $(element).hasClass(ClassName.SHOW)
if (triggerArray.length) {
if (triggerArray.length > 0) {
$(triggerArray)
.toggleClass(ClassName.COLLAPSED, !isOpen)
.attr('aria-expanded', isOpen)
@@ -334,8 +326,7 @@ const Collapse = (($) => {
}
}
// static
// Static
static _getTargetFromElement(element) {
const selector = Util.getSelectorFromElement(element)
@@ -363,16 +354,14 @@ const Collapse = (($) => {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error(`No method named "${config}"`)
throw new TypeError(`No method named "${config}"`)
}
data[config]()
}
})
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -395,22 +384,20 @@ const Collapse = (($) => {
})
})
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Collapse._jQueryInterface
$.fn[NAME] = Collapse._jQueryInterface
$.fn[NAME].Constructor = Collapse
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Collapse._jQueryInterface
}
return Collapse
})($)
export default Collapse

View File

@@ -2,7 +2,6 @@ import $ from 'jquery'
import Popper from 'popper.js'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): dropdown.js
@@ -11,7 +10,6 @@ import Util from './util'
*/
const Dropdown = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -85,7 +83,6 @@ const Dropdown = (($) => {
boundary : '(string|element)'
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -93,7 +90,6 @@ const Dropdown = (($) => {
*/
class Dropdown {
constructor(element, config) {
this._element = element
this._popper = null
@@ -104,8 +100,7 @@ const Dropdown = (($) => {
this._addEventListeners()
}
// getters
// Getters
static get VERSION() {
return VERSION
@@ -119,7 +114,7 @@ const Dropdown = (($) => {
return DefaultType
}
// public
// Public
toggle() {
if (this._element.disabled || $(this._element).hasClass(ClassName.DISABLED)) {
@@ -136,7 +131,7 @@ const Dropdown = (($) => {
}
const relatedTarget = {
relatedTarget : this._element
relatedTarget: this._element
}
const showEvent = $.Event(Event.SHOW, relatedTarget)
@@ -153,10 +148,10 @@ const Dropdown = (($) => {
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new Error('Bootstrap dropdown require Popper.js (https://popper.js.org)')
throw new TypeError('Bootstrap dropdown require Popper.js (https://popper.js.org)')
}
let element = this._element
// for dropup with alignment we use the parent as popper container
// For dropup with alignment we use the parent as popper container
if ($(parent).hasClass(ClassName.DROPUP)) {
if ($(this._menu).hasClass(ClassName.MENULEFT) || $(this._menu).hasClass(ClassName.MENURIGHT)) {
element = parent
@@ -171,13 +166,12 @@ const Dropdown = (($) => {
this._popper = new Popper(element, this._menu, this._getPopperConfig())
}
// if this is a touch-enabled device we add extra
// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
if ('ontouchstart' in document.documentElement &&
!$(parent).closest(Selector.NAVBAR_NAV).length) {
$(parent).closest(Selector.NAVBAR_NAV).length === 0) {
$('body').children().on('mouseover', null, $.noop)
}
@@ -208,7 +202,7 @@ const Dropdown = (($) => {
}
}
// private
// Private
_addEventListeners() {
$(this._element).on(Event.CLICK, (event) => {
@@ -244,7 +238,7 @@ const Dropdown = (($) => {
_getPlacement() {
const $parentDropdown = $(this._element).parent()
let placement = AttachmentMap.BOTTOM
let placement = AttachmentMap.BOTTOM
// Handle dropup
if ($parentDropdown.hasClass(ClassName.DROPUP)) {
@@ -280,14 +274,14 @@ const Dropdown = (($) => {
offsetConf.offset = this._config.offset
}
const popperConfig = {
placement : this._getPlacement(),
modifiers : {
offset : offsetConf,
flip : {
enabled : this._config.flip
placement: this._getPlacement(),
modifiers: {
offset: offsetConf,
flip: {
enabled: this._config.flip
},
preventOverflow : {
boundariesElement : this._config.boundary
preventOverflow: {
boundariesElement: this._config.boundary
}
}
}
@@ -295,7 +289,7 @@ const Dropdown = (($) => {
return popperConfig
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
@@ -309,7 +303,7 @@ const Dropdown = (($) => {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error(`No method named "${config}"`)
throw new TypeError(`No method named "${config}"`)
}
data[config]()
}
@@ -324,10 +318,10 @@ const Dropdown = (($) => {
const toggles = $.makeArray($(Selector.DATA_TOGGLE))
for (let i = 0; i < toggles.length; i++) {
const parent = Dropdown._getParentFromElement(toggles[i])
const context = $(toggles[i]).data(DATA_KEY)
const parent = Dropdown._getParentFromElement(toggles[i])
const context = $(toggles[i]).data(DATA_KEY)
const relatedTarget = {
relatedTarget : toggles[i]
relatedTarget: toggles[i]
}
if (!context) {
@@ -340,8 +334,8 @@ const Dropdown = (($) => {
}
if (event && (event.type === 'click' &&
/input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE)
&& $.contains(parent, event.target)) {
/input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) &&
$.contains(parent, event.target)) {
continue
}
@@ -351,7 +345,7 @@ const Dropdown = (($) => {
continue
}
// if this is a touch-enabled device we remove the extra
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
$('body').children().off('mouseover', null, $.noop)
@@ -386,8 +380,8 @@ const Dropdown = (($) => {
// - If key is other than escape
// - If key is not up or down => not a dropdown command
// - If trigger inside the menu => not a dropdown command
if (/input|textarea/i.test(event.target.tagName) ?
event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE &&
if (/input|textarea/i.test(event.target.tagName)
? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE &&
(event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE ||
$(event.target).closest(Selector.MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
return
@@ -405,7 +399,6 @@ const Dropdown = (($) => {
if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) ||
isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) {
const toggle = $(parent).find(Selector.DATA_TOGGLE)[0]
$(toggle).trigger('focus')
@@ -417,17 +410,17 @@ const Dropdown = (($) => {
const items = $(parent).find(Selector.VISIBLE_ITEMS).get()
if (!items.length) {
if (items.length === 0) {
return
}
let index = items.indexOf(event.target)
if (event.which === ARROW_UP_KEYCODE && index > 0) { // up
if (event.which === ARROW_UP_KEYCODE && index > 0) { // Up
index--
}
if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { // down
if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { // Down
index++
}
@@ -437,10 +430,8 @@ const Dropdown = (($) => {
items[index].focus()
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -448,7 +439,7 @@ const Dropdown = (($) => {
*/
$(document)
.on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler)
.on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler)
.on(Event.KEYDOWN_DATA_API, Selector.MENU, Dropdown._dataApiKeydownHandler)
.on(`${Event.CLICK_DATA_API} ${Event.KEYUP_DATA_API}`, Dropdown._clearMenus)
.on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
@@ -460,22 +451,20 @@ const Dropdown = (($) => {
e.stopPropagation()
})
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Dropdown._jQueryInterface
$.fn[NAME] = Dropdown._jQueryInterface
$.fn[NAME].Constructor = Dropdown
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Dropdown._jQueryInterface
}
return Dropdown
})($, Popper)
export default Dropdown

View File

@@ -20,12 +20,12 @@ import Util from './util'
(($) => {
if (typeof $ === 'undefined') {
throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.')
throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.')
}
const version = $.fn.jquery.split(' ')[0].split('.')
const minMajor = 1
const ltMajor = 2
const ltMajor = 2
const minMinor = 9
const minPatch = 1
const maxMajor = 4

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): modal.js
@@ -10,8 +9,6 @@ import Util from './util'
*/
const Modal = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -73,7 +70,6 @@ const Modal = (($) => {
NAVBAR_TOGGLER : '.navbar-toggler'
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -81,7 +77,6 @@ const Modal = (($) => {
*/
class Modal {
constructor(element, config) {
this._config = this._getConfig(config)
this._element = element
@@ -94,8 +89,7 @@ const Modal = (($) => {
this._scrollbarWidth = 0
}
// getters
// Getters
static get VERSION() {
return VERSION
@@ -105,8 +99,7 @@ const Modal = (($) => {
return Default
}
// public
// Public
toggle(relatedTarget) {
return this._isShown ? this.hide() : this.show(relatedTarget)
@@ -196,7 +189,6 @@ const Modal = (($) => {
$(this._dialog).off(Event.MOUSEDOWN_DISMISS)
if (transition) {
$(this._element)
.one(Util.TRANSITION_END, (event) => this._hideModal(event))
.emulateTransitionEnd(TRANSITION_DURATION)
@@ -224,7 +216,7 @@ const Modal = (($) => {
this._adjustDialog()
}
// private
// Private
_getConfig(config) {
config = {
@@ -241,7 +233,7 @@ const Modal = (($) => {
if (!this._element.parentNode ||
this._element.parentNode.nodeType !== Node.ELEMENT_NODE) {
// don't move modals dom position
// Don't move modal's DOM position
document.body.appendChild(this._element)
}
@@ -282,11 +274,11 @@ const Modal = (($) => {
_enforceFocus() {
$(document)
.off(Event.FOCUSIN) // guard against infinite focus loop
.off(Event.FOCUSIN) // Guard against infinite focus loop
.on(Event.FOCUSIN, (event) => {
if (document !== event.target &&
this._element !== event.target &&
!$(this._element).has(event.target).length) {
$(this._element).has(event.target).length === 0) {
this._element.focus()
}
})
@@ -300,7 +292,6 @@ const Modal = (($) => {
this.hide()
}
})
} else if (!this._isShown) {
$(this._element).off(Event.KEYDOWN_DISMISS)
}
@@ -334,8 +325,8 @@ const Modal = (($) => {
}
_showBackdrop(callback) {
const animate = $(this._element).hasClass(ClassName.FADE) ?
ClassName.FADE : ''
const animate = $(this._element).hasClass(ClassName.FADE)
? ClassName.FADE : ''
if (this._isShown && this._config.backdrop) {
const doAnimate = Util.supportsTransitionEnd() && animate
@@ -382,7 +373,6 @@ const Modal = (($) => {
$(this._backdrop)
.one(Util.TRANSITION_END, callback)
.emulateTransitionEnd(BACKDROP_TRANSITION_DURATION)
} else if (!this._isShown && this._backdrop) {
$(this._backdrop).removeClass(ClassName.SHOW)
@@ -401,13 +391,11 @@ const Modal = (($) => {
} else {
callbackRemove()
}
} else if (callback) {
callback()
}
}
// ----------------------------------------------------------------------
// the following methods are used to handle overflowing modals
// todo (fat): these should probably be refactored out of modal.js
@@ -503,12 +491,11 @@ const Modal = (($) => {
return scrollbarWidth
}
// static
// Static
static _jQueryInterface(config, relatedTarget) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
let data = $(this).data(DATA_KEY)
const _config = {
...Modal.Default,
...$(this).data(),
@@ -522,7 +509,7 @@ const Modal = (($) => {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error(`No method named "${config}"`)
throw new TypeError(`No method named "${config}"`)
}
data[config](relatedTarget)
} else if (_config.show) {
@@ -530,10 +517,8 @@ const Modal = (($) => {
}
})
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -548,8 +533,8 @@ const Modal = (($) => {
target = $(selector)[0]
}
const config = $(target).data(DATA_KEY) ?
'toggle' : {
const config = $(target).data(DATA_KEY)
? 'toggle' : {
...$(target).data(),
...$(this).data()
}
@@ -560,7 +545,7 @@ const Modal = (($) => {
const $target = $(target).one(Event.SHOW, (showEvent) => {
if (showEvent.isDefaultPrevented()) {
// only register focus restorer if modal will actually get shown
// Only register focus restorer if modal will actually get shown
return
}
@@ -574,22 +559,20 @@ const Modal = (($) => {
Modal._jQueryInterface.call($(target), config, this)
})
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Modal._jQueryInterface
$.fn[NAME] = Modal._jQueryInterface
$.fn[NAME].Constructor = Modal
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Modal._jQueryInterface
}
return Modal
})($)
export default Modal

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Tooltip from './tooltip'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): popover.js
@@ -10,8 +9,6 @@ import Tooltip from './tooltip'
*/
const Popover = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -31,10 +28,10 @@ const Popover = (($) => {
placement : 'right',
trigger : 'click',
content : '',
template : '<div class="popover" role="tooltip">'
+ '<div class="arrow"></div>'
+ '<h3 class="popover-header"></h3>'
+ '<div class="popover-body"></div></div>'
template : '<div class="popover" role="tooltip">' +
'<div class="arrow"></div>' +
'<h3 class="popover-header"></h3>' +
'<div class="popover-body"></div></div>'
}
const DefaultType = {
@@ -65,7 +62,6 @@ const Popover = (($) => {
MOUSELEAVE : `mouseleave${EVENT_KEY}`
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -73,9 +69,7 @@ const Popover = (($) => {
*/
class Popover extends Tooltip {
// getters
// Getters
static get VERSION() {
return VERSION
@@ -105,8 +99,7 @@ const Popover = (($) => {
return DefaultType
}
// overrides
// Overrides
isWithContent() {
return this.getTitle() || this._getContent()
@@ -124,7 +117,7 @@ const Popover = (($) => {
setContent() {
const $tip = $(this.getTipElement())
// we use append for html objects to maintain js events
// We use append for html objects to maintain js events
this.setElementContent($tip.find(Selector.TITLE), this.getTitle())
let content = this._getContent()
if (typeof content === 'function') {
@@ -135,11 +128,11 @@ const Popover = (($) => {
$tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`)
}
// private
// Private
_getContent() {
return this.element.getAttribute('data-content')
|| this.config.content
return this.element.getAttribute('data-content') ||
this.config.content
}
_cleanTipClass() {
@@ -150,12 +143,11 @@ const Popover = (($) => {
}
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
let data = $(this).data(DATA_KEY)
const _config = typeof config === 'object' ? config : null
if (!data && /destroy|hide/.test(config)) {
@@ -169,7 +161,7 @@ const Popover = (($) => {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error(`No method named "${config}"`)
throw new TypeError(`No method named "${config}"`)
}
data[config]()
}
@@ -177,22 +169,20 @@ const Popover = (($) => {
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Popover._jQueryInterface
$.fn[NAME] = Popover._jQueryInterface
$.fn[NAME].Constructor = Popover
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Popover._jQueryInterface
}
return Popover
})($)
export default Popover

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): scrollspy.js
@@ -10,8 +9,6 @@ import Util from './util'
*/
const ScrollSpy = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -66,7 +63,6 @@ const ScrollSpy = (($) => {
POSITION : 'position'
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -74,14 +70,13 @@ const ScrollSpy = (($) => {
*/
class ScrollSpy {
constructor(element, config) {
this._element = element
this._scrollElement = element.tagName === 'BODY' ? window : element
this._config = this._getConfig(config)
this._selector = `${this._config.target} ${Selector.NAV_LINKS},`
+ `${this._config.target} ${Selector.LIST_ITEMS},`
+ `${this._config.target} ${Selector.DROPDOWN_ITEMS}`
this._selector = `${this._config.target} ${Selector.NAV_LINKS},` +
`${this._config.target} ${Selector.LIST_ITEMS},` +
`${this._config.target} ${Selector.DROPDOWN_ITEMS}`
this._offsets = []
this._targets = []
this._activeTarget = null
@@ -93,8 +88,7 @@ const ScrollSpy = (($) => {
this._process()
}
// getters
// Getters
static get VERSION() {
return VERSION
@@ -104,18 +98,17 @@ const ScrollSpy = (($) => {
return Default
}
// public
// Public
refresh() {
const autoMethod = this._scrollElement !== this._scrollElement.window ?
OffsetMethod.POSITION : OffsetMethod.OFFSET
const autoMethod = this._scrollElement === this._scrollElement.window
? OffsetMethod.OFFSET : OffsetMethod.POSITION
const offsetMethod = this._config.method === 'auto' ?
autoMethod : this._config.method
const offsetMethod = this._config.method === 'auto'
? autoMethod : this._config.method
const offsetBase = offsetMethod === OffsetMethod.POSITION ?
this._getScrollTop() : 0
const offsetBase = offsetMethod === OffsetMethod.POSITION
? this._getScrollTop() : 0
this._offsets = []
this._targets = []
@@ -136,7 +129,7 @@ const ScrollSpy = (($) => {
if (target) {
const targetBCR = target.getBoundingClientRect()
if (targetBCR.width || targetBCR.height) {
// todo (fat): remove sketch reliance on jQuery position/offset
// TODO (fat): remove sketch reliance on jQuery position/offset
return [
$(target)[offsetMethod]().top + offsetBase,
targetSelector
@@ -145,8 +138,8 @@ const ScrollSpy = (($) => {
}
return null
})
.filter((item) => item)
.sort((a, b) => a[0] - b[0])
.filter((item) => item)
.sort((a, b) => a[0] - b[0])
.forEach((item) => {
this._offsets.push(item[0])
this._targets.push(item[1])
@@ -167,8 +160,7 @@ const ScrollSpy = (($) => {
this._scrollHeight = null
}
// private
// Private
_getConfig(config) {
config = {
@@ -191,8 +183,8 @@ const ScrollSpy = (($) => {
}
_getScrollTop() {
return this._scrollElement === window ?
this._scrollElement.pageYOffset : this._scrollElement.scrollTop
return this._scrollElement === window
? this._scrollElement.pageYOffset : this._scrollElement.scrollTop
}
_getScrollHeight() {
@@ -203,16 +195,16 @@ const ScrollSpy = (($) => {
}
_getOffsetHeight() {
return this._scrollElement === window ?
window.innerHeight : this._scrollElement.getBoundingClientRect().height
return this._scrollElement === window
? window.innerHeight : this._scrollElement.getBoundingClientRect().height
}
_process() {
const scrollTop = this._getScrollTop() + this._config.offset
const scrollHeight = this._getScrollHeight()
const maxScroll = this._config.offset
+ scrollHeight
- this._getOffsetHeight()
const maxScroll = this._config.offset +
scrollHeight -
this._getOffsetHeight()
if (this._scrollHeight !== scrollHeight) {
this.refresh()
@@ -234,9 +226,9 @@ const ScrollSpy = (($) => {
}
for (let i = this._offsets.length; i--;) {
const isActiveTarget = this._activeTarget !== this._targets[i]
&& scrollTop >= this._offsets[i]
&& (typeof this._offsets[i + 1] === 'undefined' ||
const isActiveTarget = this._activeTarget !== this._targets[i] &&
scrollTop >= this._offsets[i] &&
(typeof this._offsets[i + 1] === 'undefined' ||
scrollTop < this._offsets[i + 1])
if (isActiveTarget) {
@@ -252,7 +244,7 @@ const ScrollSpy = (($) => {
let queries = this._selector.split(',')
// eslint-disable-next-line arrow-body-style
queries = queries.map((selector) => {
queries = queries.map((selector) => {
return `${selector}[data-target="${target}"],` +
`${selector}[href="${target}"]`
})
@@ -281,12 +273,11 @@ const ScrollSpy = (($) => {
$(this._selector).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE)
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
let data = $(this).data(DATA_KEY)
const _config = typeof config === 'object' && config
if (!data) {
@@ -296,17 +287,14 @@ const ScrollSpy = (($) => {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error(`No method named "${config}"`)
throw new TypeError(`No method named "${config}"`)
}
data[config]()
}
})
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -322,22 +310,20 @@ const ScrollSpy = (($) => {
}
})
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = ScrollSpy._jQueryInterface
$.fn[NAME] = ScrollSpy._jQueryInterface
$.fn[NAME].Constructor = ScrollSpy
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return ScrollSpy._jQueryInterface
}
return ScrollSpy
})($)
export default ScrollSpy

View File

@@ -1,7 +1,6 @@
import $ from 'jquery'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): tab.js
@@ -10,8 +9,6 @@ import Util from './util'
*/
const Tab = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -52,7 +49,6 @@ const Tab = (($) => {
DROPDOWN_ACTIVE_CHILD : '> .dropdown-menu .active'
}
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -60,20 +56,17 @@ const Tab = (($) => {
*/
class Tab {
constructor(element) {
this._element = element
}
// getters
// Getters
static get VERSION() {
return VERSION
}
// public
// Public
show() {
if (this._element.parentNode &&
@@ -86,7 +79,7 @@ const Tab = (($) => {
let target
let previous
const listElement = $(this._element).closest(Selector.NAV_LIST_GROUP)[0]
const selector = Util.getSelectorFromElement(this._element)
const selector = Util.getSelectorFromElement(this._element)
if (listElement) {
const itemSelector = listElement.nodeName === 'UL' ? Selector.ACTIVE_UL : Selector.ACTIVE
@@ -147,8 +140,7 @@ const Tab = (($) => {
this._element = null
}
// private
// Private
_activate(element, container, callback) {
let activeElements
@@ -158,10 +150,10 @@ const Tab = (($) => {
activeElements = $(container).children(Selector.ACTIVE)
}
const active = activeElements[0]
const isTransitioning = callback
&& Util.supportsTransitionEnd()
&& (active && $(active).hasClass(ClassName.FADE))
const active = activeElements[0]
const isTransitioning = callback &&
Util.supportsTransitionEnd() &&
(active && $(active).hasClass(ClassName.FADE))
const complete = () => this._transitionComplete(
element,
@@ -205,7 +197,6 @@ const Tab = (($) => {
if (element.parentNode &&
$(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {
const dropdownElement = $(element).closest(Selector.DROPDOWN)[0]
if (dropdownElement) {
$(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE)
@@ -219,13 +210,12 @@ const Tab = (($) => {
}
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
const $this = $(this)
let data = $this.data(DATA_KEY)
let data = $this.data(DATA_KEY)
if (!data) {
data = new Tab(this)
@@ -234,16 +224,14 @@ const Tab = (($) => {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error(`No method named "${config}"`)
throw new TypeError(`No method named "${config}"`)
}
data[config]()
}
})
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
@@ -256,22 +244,20 @@ const Tab = (($) => {
Tab._jQueryInterface.call($(this), 'show')
})
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Tab._jQueryInterface
$.fn[NAME] = Tab._jQueryInterface
$.fn[NAME].Constructor = Tab
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Tab._jQueryInterface
}
return Tab
})($)
export default Tab

View File

@@ -2,7 +2,6 @@ import $ from 'jquery'
import Popper from 'popper.js'
import Util from './util'
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.0.0-beta.3): tooltip.js
@@ -11,7 +10,6 @@ import Util from './util'
*/
const Tooltip = (($) => {
/**
* ------------------------------------------------------------------------
* Constants
@@ -52,9 +50,9 @@ const Tooltip = (($) => {
const Default = {
animation : true,
template : '<div class="tooltip" role="tooltip">'
+ '<div class="arrow"></div>'
+ '<div class="tooltip-inner"></div></div>',
template : '<div class="tooltip" role="tooltip">' +
'<div class="arrow"></div>' +
'<div class="tooltip-inner"></div></div>',
trigger : 'hover focus',
title : '',
delay : 0,
@@ -111,14 +109,13 @@ const Tooltip = (($) => {
*/
class Tooltip {
constructor(element, config) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new Error('Bootstrap tooltips require Popper.js (https://popper.js.org)')
throw new TypeError('Bootstrap tooltips require Popper.js (https://popper.js.org)')
}
// private
@@ -128,17 +125,15 @@ const Tooltip = (($) => {
this._activeTrigger = {}
this._popper = null
// protected
// Protected
this.element = element
this.config = this._getConfig(config)
this.tip = null
this._setListeners()
}
// getters
// Getters
static get VERSION() {
return VERSION
@@ -168,8 +163,7 @@ const Tooltip = (($) => {
return DefaultType
}
// public
// Public
enable() {
this._isEnabled = true
@@ -207,9 +201,7 @@ const Tooltip = (($) => {
} else {
context._leave(null, context)
}
} else {
if ($(this.getTipElement()).hasClass(ClassName.SHOW)) {
this._leave(null, this)
return
@@ -275,9 +267,9 @@ const Tooltip = (($) => {
$(tip).addClass(ClassName.FADE)
}
const placement = typeof this.config.placement === 'function' ?
this.config.placement.call(this, tip, this.element) :
this.config.placement
const placement = typeof this.config.placement === 'function'
? this.config.placement.call(this, tip, this.element)
: this.config.placement
const attachment = this._getAttachment(placement)
this.addAttachmentClass(attachment)
@@ -313,14 +305,14 @@ const Tooltip = (($) => {
this._handlePopperPlacementChange(data)
}
},
onUpdate : (data) => {
onUpdate: (data) => {
this._handlePopperPlacementChange(data)
}
})
$(tip).addClass(ClassName.SHOW)
// if this is a touch-enabled device we add extra
// If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
@@ -355,7 +347,7 @@ const Tooltip = (($) => {
hide(callback) {
const tip = this.getTipElement()
const hideEvent = $.Event(this.constructor.Event.HIDE)
const complete = () => {
const complete = () => {
if (this._hoverState !== HoverState.SHOW && tip.parentNode) {
tip.parentNode.removeChild(tip)
}
@@ -380,7 +372,7 @@ const Tooltip = (($) => {
$(tip).removeClass(ClassName.SHOW)
// if this is a touch-enabled device we remove the extra
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
$('body').children().off('mouseover', null, $.noop)
@@ -392,17 +384,14 @@ const Tooltip = (($) => {
if (Util.supportsTransitionEnd() &&
$(this.tip).hasClass(ClassName.FADE)) {
$(tip)
.one(Util.TRANSITION_END, complete)
.emulateTransitionEnd(TRANSITION_DURATION)
} else {
complete()
}
this._hoverState = ''
}
update() {
@@ -411,7 +400,7 @@ const Tooltip = (($) => {
}
}
// protected
// Protected
isWithContent() {
return Boolean(this.getTitle())
@@ -435,7 +424,7 @@ const Tooltip = (($) => {
setElementContent($element, content) {
const html = this.config.html
if (typeof content === 'object' && (content.nodeType || content.jquery)) {
// content is a DOM node or a jQuery
// Content is a DOM node or a jQuery
if (html) {
if (!$(content).parent().is($element)) {
$element.empty().append(content)
@@ -452,16 +441,15 @@ const Tooltip = (($) => {
let title = this.element.getAttribute('data-original-title')
if (!title) {
title = typeof this.config.title === 'function' ?
this.config.title.call(this.element) :
this.config.title
title = typeof this.config.title === 'function'
? this.config.title.call(this.element)
: this.config.title
}
return title
}
// private
// Private
_getAttachment(placement) {
return AttachmentMap[placement.toUpperCase()]
@@ -477,14 +465,13 @@ const Tooltip = (($) => {
this.config.selector,
(event) => this.toggle(event)
)
} else if (trigger !== Trigger.MANUAL) {
const eventIn = trigger === Trigger.HOVER ?
this.constructor.Event.MOUSEENTER :
this.constructor.Event.FOCUSIN
const eventOut = trigger === Trigger.HOVER ?
this.constructor.Event.MOUSELEAVE :
this.constructor.Event.FOCUSOUT
const eventIn = trigger === Trigger.HOVER
? this.constructor.Event.MOUSEENTER
: this.constructor.Event.FOCUSIN
const eventOut = trigger === Trigger.HOVER
? this.constructor.Event.MOUSELEAVE
: this.constructor.Event.FOCUSOUT
$(this.element)
.on(
@@ -508,8 +495,8 @@ const Tooltip = (($) => {
if (this.config.selector) {
this.config = {
...this.config,
trigger : 'manual',
selector : ''
trigger: 'manual',
selector: ''
}
} else {
this._fixTitle()
@@ -627,8 +614,8 @@ const Tooltip = (($) => {
if (typeof config.delay === 'number') {
config.delay = {
show : config.delay,
hide : config.delay
show: config.delay,
hide: config.delay
}
}
@@ -677,7 +664,7 @@ const Tooltip = (($) => {
}
_fixTransition() {
const tip = this.getTipElement()
const tip = this.getTipElement()
const initConfigAnimation = this.config.animation
if (tip.getAttribute('x-placement') !== null) {
return
@@ -689,11 +676,11 @@ const Tooltip = (($) => {
this.config.animation = initConfigAnimation
}
// static
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
let data = $(this).data(DATA_KEY)
const _config = typeof config === 'object' && config
if (!data && /dispose|hide/.test(config)) {
@@ -707,7 +694,7 @@ const Tooltip = (($) => {
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new Error(`No method named "${config}"`)
throw new TypeError(`No method named "${config}"`)
}
data[config]()
}
@@ -715,22 +702,20 @@ const Tooltip = (($) => {
}
}
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Tooltip._jQueryInterface
$.fn[NAME] = Tooltip._jQueryInterface
$.fn[NAME].Constructor = Tooltip
$.fn[NAME].noConflict = function () {
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Tooltip._jQueryInterface
}
return Tooltip
})($, Popper)
export default Tooltip

View File

@@ -8,8 +8,6 @@ import $ from 'jquery'
*/
const Util = (($) => {
/**
* ------------------------------------------------------------------------
* Private TransitionEnd Helpers
@@ -20,7 +18,7 @@ const Util = (($) => {
const MAX_UID = 1000000
// shoutout AngusCroll (https://goo.gl/pxwQGp)
// Shoutout AngusCroll (https://goo.gl/pxwQGp)
function toType(obj) {
return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}
@@ -75,10 +73,10 @@ const Util = (($) => {
}
function escapeId(selector) {
// we escape IDs in case of special selectors (selector = '#myId:something')
// We escape IDs in case of special selectors (selector = '#myId:something')
// $.escapeSelector does not exist in jQuery < 3
selector = typeof $.escapeSelector === 'function' ? $.escapeSelector(selector).substr(1) :
selector.replace(/(:|\.|\[|\]|,|=|@)/g, '\\$1')
selector = typeof $.escapeSelector === 'function' ? $.escapeSelector(selector).substr(1)
: selector.replace(/(:|\.|\[|\]|,|=|@)/g, '\\$1')
return selector
}
@@ -107,7 +105,7 @@ const Util = (($) => {
selector = element.getAttribute('href') || ''
}
// if it's an ID
// If it's an ID
if (selector.charAt(0) === '#') {
selector = escapeId(selector)
}
@@ -115,7 +113,7 @@ const Util = (($) => {
try {
const $selector = $(document).find(selector)
return $selector.length > 0 ? selector : null
} catch (error) {
} catch (err) {
return null
}
},
@@ -141,8 +139,8 @@ const Util = (($) => {
if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
const expectedTypes = configTypes[property]
const value = config[property]
const valueType = value && Util.isElement(value) ?
'element' : toType(value)
const valueType = value && Util.isElement(value)
? 'element' : toType(value)
if (!new RegExp(expectedTypes).test(valueType)) {
throw new Error(
@@ -158,7 +156,6 @@ const Util = (($) => {
setTransitionEndSupport()
return Util
})($)
export default Util