mirror of https://github.com/twbs/bootstrap.git
Comply to the new rules.
This commit is contained in:
parent
44e6abcba5
commit
46c037410b
|
@ -15,8 +15,10 @@ const banner = require('./banner.js')
|
||||||
const TEST = process.env.NODE_ENV === 'test'
|
const TEST = process.env.NODE_ENV === 'test'
|
||||||
const plugins = [
|
const plugins = [
|
||||||
babel({
|
babel({
|
||||||
exclude: 'node_modules/**', // Only transpile our source code
|
// Only transpile our source code
|
||||||
externalHelpersWhitelist: [ // Include only required helpers
|
exclude: 'node_modules/**',
|
||||||
|
// Include only required helpers
|
||||||
|
externalHelpersWhitelist: [
|
||||||
'defineProperties',
|
'defineProperties',
|
||||||
'createClass',
|
'createClass',
|
||||||
'inheritsLoose',
|
'inheritsLoose',
|
||||||
|
@ -147,9 +149,7 @@ function getConfigByPluginKey(pluginKey) {
|
||||||
function build(plugin) {
|
function build(plugin) {
|
||||||
console.log(`Building ${plugin} plugin...`)
|
console.log(`Building ${plugin} plugin...`)
|
||||||
|
|
||||||
const config = getConfigByPluginKey(plugin)
|
const { external, globals } = getConfigByPluginKey(plugin)
|
||||||
const external = config.external
|
|
||||||
const globals = config.globals
|
|
||||||
let pluginPath = rootPath
|
let pluginPath = rootPath
|
||||||
|
|
||||||
const utilObjects = [
|
const utilObjects = [
|
||||||
|
@ -179,7 +179,7 @@ function build(plugin) {
|
||||||
input: bsPlugins[plugin],
|
input: bsPlugins[plugin],
|
||||||
plugins,
|
plugins,
|
||||||
external
|
external
|
||||||
}).then((bundle) => {
|
}).then(bundle => {
|
||||||
bundle.write({
|
bundle.write({
|
||||||
banner: banner(pluginFilename),
|
banner: banner(pluginFilename),
|
||||||
format: 'umd',
|
format: 'umd',
|
||||||
|
@ -189,8 +189,8 @@ function build(plugin) {
|
||||||
file: path.resolve(__dirname, `${pluginPath}${pluginFilename}`)
|
file: path.resolve(__dirname, `${pluginPath}${pluginFilename}`)
|
||||||
})
|
})
|
||||||
.then(() => console.log(`Building ${plugin} plugin... Done!`))
|
.then(() => console.log(`Building ${plugin} plugin... Done!`))
|
||||||
.catch((err) => console.error(`${plugin}: ${err}`))
|
.catch(error => console.error(`${plugin}: ${error}`))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(bsPlugins).forEach((plugin) => build(plugin))
|
Object.keys(bsPlugins).forEach(plugin => build(plugin))
|
||||||
|
|
|
@ -30,18 +30,21 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) {
|
||||||
if (excludedDirectories.has(path.parse(directory).base)) {
|
if (excludedDirectories.has(path.parse(directory).base)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readdir(directory, (err, names) => {
|
fs.readdir(directory, (err, names) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
errback(err)
|
errback(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
names.forEach((name) => {
|
|
||||||
|
names.forEach(name => {
|
||||||
const filepath = path.join(directory, name)
|
const filepath = path.join(directory, name)
|
||||||
fs.lstat(filepath, (err, stats) => {
|
fs.lstat(filepath, (err, stats) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
process.nextTick(errback, err)
|
process.nextTick(errback, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stats.isDirectory()) {
|
if (stats.isDirectory()) {
|
||||||
process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback)
|
process.nextTick(walkAsync, filepath, excludedDirectories, fileCallback, errback)
|
||||||
} else if (stats.isFile()) {
|
} else if (stats.isFile()) {
|
||||||
|
@ -55,18 +58,21 @@ function walkAsync(directory, excludedDirectories, fileCallback, errback) {
|
||||||
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) {
|
function replaceRecursively(directory, excludedDirectories, allowedExtensions, original, replacement) {
|
||||||
original = new RegExp(regExpQuote(original), 'g')
|
original = new RegExp(regExpQuote(original), 'g')
|
||||||
replacement = regExpQuoteReplacement(replacement)
|
replacement = regExpQuoteReplacement(replacement)
|
||||||
const updateFile = DRY_RUN ? (filepath) => {
|
const updateFile = DRY_RUN ?
|
||||||
|
filepath => {
|
||||||
if (allowedExtensions.has(path.parse(filepath).ext)) {
|
if (allowedExtensions.has(path.parse(filepath).ext)) {
|
||||||
console.log(`FILE: ${filepath}`)
|
console.log(`FILE: ${filepath}`)
|
||||||
} else {
|
} else {
|
||||||
console.log(`EXCLUDED:${filepath}`)
|
console.log(`EXCLUDED:${filepath}`)
|
||||||
}
|
}
|
||||||
} : (filepath) => {
|
} :
|
||||||
|
filepath => {
|
||||||
if (allowedExtensions.has(path.parse(filepath).ext)) {
|
if (allowedExtensions.has(path.parse(filepath).ext)) {
|
||||||
sh.sed('-i', original, replacement, filepath)
|
sh.sed('-i', original, replacement, filepath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
walkAsync(directory, excludedDirectories, updateFile, (err) => {
|
|
||||||
|
walkAsync(directory, excludedDirectories, updateFile, err => {
|
||||||
console.error('ERROR while traversing directory!:')
|
console.error('ERROR while traversing directory!:')
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
|
@ -79,6 +85,7 @@ function main(args) {
|
||||||
console.error('Got arguments:', args)
|
console.error('Got arguments:', args)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldVersion = args[0]
|
const oldVersion = args[0]
|
||||||
const newVersion = args[1]
|
const newVersion = args[1]
|
||||||
const EXCLUDED_DIRS = new Set([
|
const EXCLUDED_DIRS = new Set([
|
||||||
|
|
|
@ -43,7 +43,7 @@ const files = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
files.forEach((file) => {
|
files.forEach(file => {
|
||||||
fs.readFile(file.file, 'utf8', (err, data) => {
|
fs.readFile(file.file, 'utf8', (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err
|
throw err
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
module.exports = (ctx) => ({
|
module.exports = ctx => ({
|
||||||
map: ctx.file.dirname.includes('examples') ? false : {
|
map: ctx.file.dirname.includes('examples') ?
|
||||||
|
false :
|
||||||
|
{
|
||||||
inline: false,
|
inline: false,
|
||||||
annotation: true,
|
annotation: true,
|
||||||
sourcesContent: true
|
sourcesContent: true
|
||||||
|
|
|
@ -11,8 +11,10 @@ let fileDest = 'bootstrap.js'
|
||||||
const external = ['popper.js']
|
const external = ['popper.js']
|
||||||
const plugins = [
|
const plugins = [
|
||||||
babel({
|
babel({
|
||||||
exclude: 'node_modules/**', // Only transpile our source code
|
// Only transpile our source code
|
||||||
externalHelpersWhitelist: [ // Include only required helpers
|
exclude: 'node_modules/**',
|
||||||
|
// Include only required helpers
|
||||||
|
externalHelpersWhitelist: [
|
||||||
'defineProperties',
|
'defineProperties',
|
||||||
'createClass',
|
'createClass',
|
||||||
'inheritsLoose',
|
'inheritsLoose',
|
||||||
|
|
|
@ -118,7 +118,7 @@ class Alert {
|
||||||
const transitionDuration = getTransitionDurationFromElement(element)
|
const transitionDuration = getTransitionDurationFromElement(element)
|
||||||
|
|
||||||
EventHandler
|
EventHandler
|
||||||
.one(element, TRANSITION_END, (event) => this._destroyElement(element, event))
|
.one(element, TRANSITION_END, event => this._destroyElement(element, event))
|
||||||
emulateTransitionEnd(element, transitionDuration)
|
emulateTransitionEnd(element, transitionDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ class Button {
|
||||||
* ------------------------------------------------------------------------
|
* ------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, (event) => {
|
EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
let button = event.target
|
let button = event.target
|
||||||
|
@ -162,15 +162,16 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, (ev
|
||||||
data = new Button(button)
|
data = new Button(button)
|
||||||
Data.setData(button, DATA_KEY, data)
|
Data.setData(button, DATA_KEY, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
data.toggle()
|
data.toggle()
|
||||||
})
|
})
|
||||||
|
|
||||||
EventHandler.on(document, Event.FOCUS_DATA_API, Selector.DATA_TOGGLE_CARROT, (event) => {
|
EventHandler.on(document, Event.FOCUS_DATA_API, Selector.DATA_TOGGLE_CARROT, event => {
|
||||||
const button = SelectorEngine.closest(event.target, Selector.BUTTON)
|
const button = SelectorEngine.closest(event.target, Selector.BUTTON)
|
||||||
button.classList.add(ClassName.FOCUS)
|
button.classList.add(ClassName.FOCUS)
|
||||||
})
|
})
|
||||||
|
|
||||||
EventHandler.on(document, Event.BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, (event) => {
|
EventHandler.on(document, Event.BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, event => {
|
||||||
const button = SelectorEngine.closest(event.target, Selector.BUTTON)
|
const button = SelectorEngine.closest(event.target, Selector.BUTTON)
|
||||||
button.classList.remove(ClassName.FOCUS)
|
button.classList.remove(ClassName.FOCUS)
|
||||||
})
|
})
|
||||||
|
|
|
@ -216,9 +216,9 @@ class Carousel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction = index > activeIndex
|
const direction = index > activeIndex ?
|
||||||
? Direction.NEXT
|
Direction.NEXT :
|
||||||
: Direction.PREV
|
Direction.PREV
|
||||||
|
|
||||||
this._slide(direction, this._items[index])
|
this._slide(direction, this._items[index])
|
||||||
}
|
}
|
||||||
|
@ -271,14 +271,14 @@ class Carousel {
|
||||||
_addEventListeners() {
|
_addEventListeners() {
|
||||||
if (this._config.keyboard) {
|
if (this._config.keyboard) {
|
||||||
EventHandler
|
EventHandler
|
||||||
.on(this._element, Event.KEYDOWN, (event) => this._keydown(event))
|
.on(this._element, Event.KEYDOWN, event => this._keydown(event))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._config.pause === 'hover') {
|
if (this._config.pause === 'hover') {
|
||||||
EventHandler
|
EventHandler
|
||||||
.on(this._element, Event.MOUSEENTER, (event) => this.pause(event))
|
.on(this._element, Event.MOUSEENTER, event => this.pause(event))
|
||||||
EventHandler
|
EventHandler
|
||||||
.on(this._element, Event.MOUSELEAVE, (event) => this.cycle(event))
|
.on(this._element, Event.MOUSELEAVE, event => this.cycle(event))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._config.touch) {
|
if (this._config.touch) {
|
||||||
|
@ -291,7 +291,7 @@ class Carousel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const start = (event) => {
|
const start = event => {
|
||||||
if (this._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
|
if (this._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
|
||||||
this.touchStartX = event.clientX
|
this.touchStartX = event.clientX
|
||||||
} else if (!this._pointerEvent) {
|
} else if (!this._pointerEvent) {
|
||||||
|
@ -299,7 +299,7 @@ class Carousel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const move = (event) => {
|
const move = event => {
|
||||||
// ensure swiping with one touch and not pinching
|
// ensure swiping with one touch and not pinching
|
||||||
if (event.touches && event.touches.length > 1) {
|
if (event.touches && event.touches.length > 1) {
|
||||||
this.touchDeltaX = 0
|
this.touchDeltaX = 0
|
||||||
|
@ -308,7 +308,7 @@ class Carousel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const end = (event) => {
|
const end = event => {
|
||||||
if (this._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
|
if (this._pointerEvent && PointerType[event.pointerType.toUpperCase()]) {
|
||||||
this.touchDeltaX = event.clientX - this.touchStartX
|
this.touchDeltaX = event.clientX - this.touchStartX
|
||||||
}
|
}
|
||||||
|
@ -327,23 +327,24 @@ class Carousel {
|
||||||
if (this.touchTimeout) {
|
if (this.touchTimeout) {
|
||||||
clearTimeout(this.touchTimeout)
|
clearTimeout(this.touchTimeout)
|
||||||
}
|
}
|
||||||
this.touchTimeout = setTimeout((event) => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
|
|
||||||
|
this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
makeArray(SelectorEngine.find(Selector.ITEM_IMG, this._element)).forEach((itemImg) => {
|
makeArray(SelectorEngine.find(Selector.ITEM_IMG, this._element)).forEach(itemImg => {
|
||||||
EventHandler.on(itemImg, Event.DRAG_START, (e) => e.preventDefault())
|
EventHandler.on(itemImg, Event.DRAG_START, e => e.preventDefault())
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this._pointerEvent) {
|
if (this._pointerEvent) {
|
||||||
EventHandler.on(this._element, Event.POINTERDOWN, (event) => start(event))
|
EventHandler.on(this._element, Event.POINTERDOWN, event => start(event))
|
||||||
EventHandler.on(this._element, Event.POINTERUP, (event) => end(event))
|
EventHandler.on(this._element, Event.POINTERUP, event => end(event))
|
||||||
|
|
||||||
this._element.classList.add(ClassName.POINTER_EVENT)
|
this._element.classList.add(ClassName.POINTER_EVENT)
|
||||||
} else {
|
} else {
|
||||||
EventHandler.on(this._element, Event.TOUCHSTART, (event) => start(event))
|
EventHandler.on(this._element, Event.TOUCHSTART, event => start(event))
|
||||||
EventHandler.on(this._element, Event.TOUCHMOVE, (event) => move(event))
|
EventHandler.on(this._element, Event.TOUCHMOVE, event => move(event))
|
||||||
EventHandler.on(this._element, Event.TOUCHEND, (event) => end(event))
|
EventHandler.on(this._element, Event.TOUCHEND, event => end(event))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,9 +367,9 @@ class Carousel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getItemIndex(element) {
|
_getItemIndex(element) {
|
||||||
this._items = element && element.parentNode
|
this._items = element && element.parentNode ?
|
||||||
? makeArray(SelectorEngine.find(Selector.ITEM, element.parentNode))
|
makeArray(SelectorEngine.find(Selector.ITEM, element.parentNode)) :
|
||||||
: []
|
[]
|
||||||
|
|
||||||
return this._items.indexOf(element)
|
return this._items.indexOf(element)
|
||||||
}
|
}
|
||||||
|
@ -388,8 +389,9 @@ class Carousel {
|
||||||
const delta = direction === Direction.PREV ? -1 : 1
|
const delta = direction === Direction.PREV ? -1 : 1
|
||||||
const itemIndex = (activeIndex + delta) % this._items.length
|
const itemIndex = (activeIndex + delta) % this._items.length
|
||||||
|
|
||||||
return itemIndex === -1
|
return itemIndex === -1 ?
|
||||||
? this._items[this._items.length - 1] : this._items[itemIndex]
|
this._items[this._items.length - 1] :
|
||||||
|
this._items[itemIndex]
|
||||||
}
|
}
|
||||||
|
|
||||||
_triggerSlideEvent(relatedTarget, eventDirectionName) {
|
_triggerSlideEvent(relatedTarget, eventDirectionName) {
|
||||||
|
@ -552,8 +554,9 @@ class Carousel {
|
||||||
data.to(config)
|
data.to(config)
|
||||||
} else if (typeof action === 'string') {
|
} else if (typeof action === 'string') {
|
||||||
if (typeof data[action] === 'undefined') {
|
if (typeof data[action] === 'undefined') {
|
||||||
throw new Error(`No method named "${action}"`)
|
throw new TypeError(`No method named "${action}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[action]()
|
data[action]()
|
||||||
} else if (_config.interval && _config.ride) {
|
} else if (_config.interval && _config.ride) {
|
||||||
data.pause()
|
data.pause()
|
||||||
|
|
|
@ -89,7 +89,7 @@ class Collapse {
|
||||||
const elem = toggleList[i]
|
const elem = toggleList[i]
|
||||||
const selector = getSelectorFromElement(elem)
|
const selector = getSelectorFromElement(elem)
|
||||||
const filterElement = makeArray(SelectorEngine.find(selector))
|
const filterElement = makeArray(SelectorEngine.find(selector))
|
||||||
.filter((foundElem) => foundElem === element)
|
.filter(foundElem => foundElem === element)
|
||||||
|
|
||||||
if (selector !== null && filterElement.length) {
|
if (selector !== null && filterElement.length) {
|
||||||
this._selector = selector
|
this._selector = selector
|
||||||
|
@ -141,7 +141,7 @@ class Collapse {
|
||||||
|
|
||||||
if (this._parent) {
|
if (this._parent) {
|
||||||
actives = makeArray(SelectorEngine.find(Selector.ACTIVES, this._parent))
|
actives = makeArray(SelectorEngine.find(Selector.ACTIVES, this._parent))
|
||||||
.filter((elem) => {
|
.filter(elem => {
|
||||||
if (typeof this._config.parent === 'string') {
|
if (typeof this._config.parent === 'string') {
|
||||||
return elem.getAttribute('data-parent') === this._config.parent
|
return elem.getAttribute('data-parent') === this._config.parent
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ class Collapse {
|
||||||
|
|
||||||
const container = SelectorEngine.findOne(this._selector)
|
const container = SelectorEngine.findOne(this._selector)
|
||||||
if (actives) {
|
if (actives) {
|
||||||
const tempActiveData = actives.filter((elem) => container !== elem)
|
const tempActiveData = actives.filter(elem => container !== elem)
|
||||||
activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY) : null
|
activesData = tempActiveData[0] ? Data.getData(tempActiveData[0], DATA_KEY) : null
|
||||||
|
|
||||||
if (activesData && activesData._isTransitioning) {
|
if (activesData && activesData._isTransitioning) {
|
||||||
|
@ -170,7 +170,7 @@ class Collapse {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actives) {
|
if (actives) {
|
||||||
actives.forEach((elemActive) => {
|
actives.forEach(elemActive => {
|
||||||
if (container !== elemActive) {
|
if (container !== elemActive) {
|
||||||
Collapse._collapseInterface(elemActive, 'hide')
|
Collapse._collapseInterface(elemActive, 'hide')
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ class Collapse {
|
||||||
this._element.style[dimension] = 0
|
this._element.style[dimension] = 0
|
||||||
|
|
||||||
if (this._triggerArray.length) {
|
if (this._triggerArray.length) {
|
||||||
this._triggerArray.forEach((element) => {
|
this._triggerArray.forEach(element => {
|
||||||
element.classList.remove(ClassName.COLLAPSED)
|
element.classList.remove(ClassName.COLLAPSED)
|
||||||
element.setAttribute('aria-expanded', true)
|
element.setAttribute('aria-expanded', true)
|
||||||
})
|
})
|
||||||
|
@ -308,7 +308,7 @@ class Collapse {
|
||||||
let parent
|
let parent
|
||||||
|
|
||||||
if (isElement(this._config.parent)) {
|
if (isElement(this._config.parent)) {
|
||||||
parent = this._config.parent
|
{ parent } = this._config
|
||||||
|
|
||||||
// it's a jQuery object
|
// it's a jQuery object
|
||||||
if (typeof this._config.parent.jquery !== 'undefined' || typeof this._config.parent[0] !== 'undefined') {
|
if (typeof this._config.parent.jquery !== 'undefined' || typeof this._config.parent[0] !== 'undefined') {
|
||||||
|
@ -318,11 +318,10 @@ class Collapse {
|
||||||
parent = SelectorEngine.findOne(this._config.parent)
|
parent = SelectorEngine.findOne(this._config.parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
const selector =
|
const selector = `[data-toggle="collapse"][data-parent="${parent}"]`
|
||||||
`[data-toggle="collapse"][data-parent="${this._config.parent}"]`
|
|
||||||
|
|
||||||
makeArray(SelectorEngine.find(selector, parent))
|
makeArray(SelectorEngine.find(selector, parent))
|
||||||
.forEach((element) => {
|
.forEach(element => {
|
||||||
this._addAriaAndCollapsedClass(
|
this._addAriaAndCollapsedClass(
|
||||||
Collapse._getTargetFromElement(element),
|
Collapse._getTargetFromElement(element),
|
||||||
[element]
|
[element]
|
||||||
|
@ -337,12 +336,13 @@ class Collapse {
|
||||||
const isOpen = element.classList.contains(ClassName.SHOW)
|
const isOpen = element.classList.contains(ClassName.SHOW)
|
||||||
|
|
||||||
if (triggerArray.length) {
|
if (triggerArray.length) {
|
||||||
triggerArray.forEach((elem) => {
|
triggerArray.forEach(elem => {
|
||||||
if (!isOpen) {
|
if (isOpen) {
|
||||||
elem.classList.add(ClassName.COLLAPSED)
|
|
||||||
} else {
|
|
||||||
elem.classList.remove(ClassName.COLLAPSED)
|
elem.classList.remove(ClassName.COLLAPSED)
|
||||||
|
} else {
|
||||||
|
elem.classList.add(ClassName.COLLAPSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
elem.setAttribute('aria-expanded', isOpen)
|
elem.setAttribute('aria-expanded', isOpen)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -374,8 +374,9 @@ class Collapse {
|
||||||
|
|
||||||
if (typeof config === 'string') {
|
if (typeof config === 'string') {
|
||||||
if (typeof data[config] === 'undefined') {
|
if (typeof data[config] === 'undefined') {
|
||||||
throw new Error(`No method named "${config}"`)
|
throw new TypeError(`No method named "${config}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,7 +408,7 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
|
||||||
const selector = getSelectorFromElement(this)
|
const selector = getSelectorFromElement(this)
|
||||||
const selectorElements = makeArray(SelectorEngine.find(selector))
|
const selectorElements = makeArray(SelectorEngine.find(selector))
|
||||||
|
|
||||||
selectorElements.forEach((element) => {
|
selectorElements.forEach(element => {
|
||||||
const data = Data.getData(element, DATA_KEY)
|
const data = Data.getData(element, DATA_KEY)
|
||||||
let config
|
let config
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -416,6 +417,7 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
|
||||||
data._config.parent = triggerData.parent
|
data._config.parent = triggerData.parent
|
||||||
data._parent = data._getParent()
|
data._parent = data._getParent()
|
||||||
}
|
}
|
||||||
|
|
||||||
config = 'toggle'
|
config = 'toggle'
|
||||||
} else {
|
} else {
|
||||||
config = triggerData
|
config = triggerData
|
||||||
|
|
|
@ -35,6 +35,7 @@ const mapData = (() => {
|
||||||
if (keyProperties.key === key) {
|
if (keyProperties.key === key) {
|
||||||
return storeData[keyProperties.id]
|
return storeData[keyProperties.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
delete(element, key) {
|
delete(element, key) {
|
||||||
|
|
|
@ -27,17 +27,52 @@ const customEvents = {
|
||||||
mouseleave: 'mouseout'
|
mouseleave: 'mouseout'
|
||||||
}
|
}
|
||||||
const nativeEvents = [
|
const nativeEvents = [
|
||||||
'click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu',
|
'click',
|
||||||
'mousewheel', 'DOMMouseScroll',
|
'dblclick',
|
||||||
'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend',
|
'mouseup',
|
||||||
'keydown', 'keypress', 'keyup',
|
'mousedown',
|
||||||
|
'contextmenu',
|
||||||
|
'mousewheel',
|
||||||
|
'DOMMouseScroll',
|
||||||
|
'mouseover',
|
||||||
|
'mouseout',
|
||||||
|
'mousemove',
|
||||||
|
'selectstart',
|
||||||
|
'selectend',
|
||||||
|
'keydown',
|
||||||
|
'keypress',
|
||||||
|
'keyup',
|
||||||
'orientationchange',
|
'orientationchange',
|
||||||
'touchstart', 'touchmove', 'touchend', 'touchcancel',
|
'touchstart',
|
||||||
'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel',
|
'touchmove',
|
||||||
'gesturestart', 'gesturechange', 'gestureend',
|
'touchend',
|
||||||
'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout',
|
'touchcancel',
|
||||||
'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange',
|
'pointerdown',
|
||||||
'error', 'abort', 'scroll'
|
'pointermove',
|
||||||
|
'pointerup',
|
||||||
|
'pointerleave',
|
||||||
|
'pointercancel',
|
||||||
|
'gesturestart',
|
||||||
|
'gesturechange',
|
||||||
|
'gestureend',
|
||||||
|
'focus',
|
||||||
|
'blur',
|
||||||
|
'change',
|
||||||
|
'reset',
|
||||||
|
'select',
|
||||||
|
'submit',
|
||||||
|
'focusin',
|
||||||
|
'focusout',
|
||||||
|
'load',
|
||||||
|
'unload',
|
||||||
|
'beforeunload',
|
||||||
|
'resize',
|
||||||
|
'move',
|
||||||
|
'DOMContentLoaded',
|
||||||
|
'readystatechange',
|
||||||
|
'error',
|
||||||
|
'abort',
|
||||||
|
'scroll'
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +95,7 @@ function getEvent(element) {
|
||||||
function fixEvent(event, element) {
|
function fixEvent(event, element) {
|
||||||
// Add which for key events
|
// Add which for key events
|
||||||
if (event.which === null && keyEventRegex.test(event.type)) {
|
if (event.which === null && keyEventRegex.test(event.type)) {
|
||||||
event.which = event.charCode !== null ? event.charCode : event.keyCode
|
event.which = event.charCode === null ? event.keyCode : event.charCode
|
||||||
}
|
}
|
||||||
|
|
||||||
event.delegateTarget = element
|
event.delegateTarget = element
|
||||||
|
@ -81,7 +116,7 @@ function bootstrapDelegationHandler(element, selector, fn) {
|
||||||
return function handler(event) {
|
return function handler(event) {
|
||||||
const domElements = element.querySelectorAll(selector)
|
const domElements = element.querySelectorAll(selector)
|
||||||
|
|
||||||
for (let target = event.target; target && target !== this; target = target.parentNode) {
|
for (let { target } = event; target && target !== this; target = target.parentNode) {
|
||||||
for (let i = domElements.length; i--;) {
|
for (let i = domElements.length; i--;) {
|
||||||
if (domElements[i] === target) {
|
if (domElements[i] === target) {
|
||||||
fixEvent(event, target)
|
fixEvent(event, target)
|
||||||
|
@ -158,7 +193,7 @@ function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''))
|
const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''))
|
||||||
const fn = !delegation ? bootstrapHandler(element, handler) : bootstrapDelegationHandler(element, handler, delegationFn)
|
const fn = delegation ? bootstrapDelegationHandler(element, handler, delegationFn) : bootstrapHandler(element, handler)
|
||||||
|
|
||||||
fn.delegationSelector = delegation ? handler : null
|
fn.delegationSelector = delegation ? handler : null
|
||||||
fn.originalHandler = originalHandler
|
fn.originalHandler = originalHandler
|
||||||
|
@ -184,7 +219,7 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) {
|
||||||
const storeElementEvent = events[typeEvent] || {}
|
const storeElementEvent = events[typeEvent] || {}
|
||||||
|
|
||||||
Object.keys(storeElementEvent)
|
Object.keys(storeElementEvent)
|
||||||
.forEach((handlerKey) => {
|
.forEach(handlerKey => {
|
||||||
if (handlerKey.indexOf(namespace) > -1) {
|
if (handlerKey.indexOf(namespace) > -1) {
|
||||||
const event = storeElementEvent[handlerKey]
|
const event = storeElementEvent[handlerKey]
|
||||||
|
|
||||||
|
@ -224,14 +259,14 @@ const EventHandler = {
|
||||||
|
|
||||||
if (isNamespace) {
|
if (isNamespace) {
|
||||||
Object.keys(events)
|
Object.keys(events)
|
||||||
.forEach((elementEvent) => {
|
.forEach(elementEvent => {
|
||||||
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.substr(1))
|
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.substr(1))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const storeElementEvent = events[typeEvent] || {}
|
const storeElementEvent = events[typeEvent] || {}
|
||||||
Object.keys(storeElementEvent)
|
Object.keys(storeElementEvent)
|
||||||
.forEach((keyHandlers) => {
|
.forEach(keyHandlers => {
|
||||||
const handlerKey = keyHandlers.replace(stripUidRegex, '')
|
const handlerKey = keyHandlers.replace(stripUidRegex, '')
|
||||||
|
|
||||||
if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) {
|
if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) {
|
||||||
|
@ -279,7 +314,7 @@ const EventHandler = {
|
||||||
// merge custom informations in our event
|
// merge custom informations in our event
|
||||||
if (typeof args !== 'undefined') {
|
if (typeof args !== 'undefined') {
|
||||||
Object.keys(args)
|
Object.keys(args)
|
||||||
.forEach((key) => {
|
.forEach(key => {
|
||||||
Object.defineProperty(evt, key, {
|
Object.defineProperty(evt, key, {
|
||||||
get() {
|
get() {
|
||||||
return args[key]
|
return args[key]
|
||||||
|
|
|
@ -26,7 +26,7 @@ function normalizeData(val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeDataKey(key) {
|
function normalizeDataKey(key) {
|
||||||
return key.replace(/[A-Z]/g, (chr) => chr.toLowerCase())
|
return key.replace(/[A-Z]/g, chr => chr.toLowerCase())
|
||||||
}
|
}
|
||||||
|
|
||||||
const Manipulator = {
|
const Manipulator = {
|
||||||
|
@ -47,7 +47,7 @@ const Manipulator = {
|
||||||
...element.dataset
|
...element.dataset
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(attributes).forEach((key) => {
|
Object.keys(attributes).forEach(key => {
|
||||||
attributes[key] = normalizeData(attributes[key])
|
attributes[key] = normalizeData(attributes[key])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ const Polyfill = (() => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
element.querySelectorAll(':scope *')
|
element.querySelectorAll(':scope *')
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@ import {
|
||||||
* ------------------------------------------------------------------------
|
* ------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const findFn = Polyfill.find
|
const { find: findFn, findOne } = Polyfill
|
||||||
const findOne = Polyfill.findOne
|
|
||||||
const NODE_TEXT = 3
|
const NODE_TEXT = 3
|
||||||
|
|
||||||
const SelectorEngine = {
|
const SelectorEngine = {
|
||||||
|
@ -48,7 +47,7 @@ const SelectorEngine = {
|
||||||
|
|
||||||
const children = makeArray(element.children)
|
const children = makeArray(element.children)
|
||||||
|
|
||||||
return children.filter((child) => this.matches(child, selector))
|
return children.filter(child => this.matches(child, selector))
|
||||||
},
|
},
|
||||||
|
|
||||||
parents(element, selector) {
|
parents(element, selector) {
|
||||||
|
|
|
@ -181,6 +181,7 @@ class Dropdown {
|
||||||
if (this._config.boundary !== 'scrollParent') {
|
if (this._config.boundary !== 'scrollParent') {
|
||||||
parent.classList.add(ClassName.POSITION_STATIC)
|
parent.classList.add(ClassName.POSITION_STATIC)
|
||||||
}
|
}
|
||||||
|
|
||||||
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig())
|
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +192,7 @@ class Dropdown {
|
||||||
if ('ontouchstart' in document.documentElement &&
|
if ('ontouchstart' in document.documentElement &&
|
||||||
!makeArray(SelectorEngine.closest(parent, Selector.NAVBAR_NAV)).length) {
|
!makeArray(SelectorEngine.closest(parent, Selector.NAVBAR_NAV)).length) {
|
||||||
makeArray(document.body.children)
|
makeArray(document.body.children)
|
||||||
.forEach((elem) => EventHandler.on(elem, 'mouseover', null, noop()))
|
.forEach(elem => EventHandler.on(elem, 'mouseover', null, noop()))
|
||||||
}
|
}
|
||||||
|
|
||||||
this._element.focus()
|
this._element.focus()
|
||||||
|
@ -265,7 +266,7 @@ class Dropdown {
|
||||||
// Private
|
// Private
|
||||||
|
|
||||||
_addEventListeners() {
|
_addEventListeners() {
|
||||||
EventHandler.on(this._element, Event.CLICK, (event) => {
|
EventHandler.on(this._element, Event.CLICK, event => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
this.toggle()
|
this.toggle()
|
||||||
|
@ -296,6 +297,7 @@ class Dropdown {
|
||||||
this._menu = SelectorEngine.findOne(Selector.MENU, parent)
|
this._menu = SelectorEngine.findOne(Selector.MENU, parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._menu
|
return this._menu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +318,7 @@ class Dropdown {
|
||||||
} else if (this._menu.classList.contains(ClassName.MENURIGHT)) {
|
} else if (this._menu.classList.contains(ClassName.MENURIGHT)) {
|
||||||
placement = AttachmentMap.BOTTOMEND
|
placement = AttachmentMap.BOTTOMEND
|
||||||
}
|
}
|
||||||
|
|
||||||
return placement
|
return placement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +330,7 @@ class Dropdown {
|
||||||
const offset = {}
|
const offset = {}
|
||||||
|
|
||||||
if (typeof this._config.offset === 'function') {
|
if (typeof this._config.offset === 'function') {
|
||||||
offset.fn = (data) => {
|
offset.fn = data => {
|
||||||
data.offsets = {
|
data.offsets = {
|
||||||
...data.offsets,
|
...data.offsets,
|
||||||
...this._config.offset(data.offsets, this._element) || {}
|
...this._config.offset(data.offsets, this._element) || {}
|
||||||
|
@ -378,8 +381,9 @@ class Dropdown {
|
||||||
|
|
||||||
if (typeof config === 'string') {
|
if (typeof config === 'string') {
|
||||||
if (typeof data[config] === 'undefined') {
|
if (typeof data[config] === 'undefined') {
|
||||||
throw new Error(`No method named "${config}"`)
|
throw new TypeError(`No method named "${config}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -433,7 +437,7 @@ class Dropdown {
|
||||||
// empty mouseover listeners we added for iOS support
|
// empty mouseover listeners we added for iOS support
|
||||||
if ('ontouchstart' in document.documentElement) {
|
if ('ontouchstart' in document.documentElement) {
|
||||||
makeArray(document.body.children)
|
makeArray(document.body.children)
|
||||||
.forEach((elem) => EventHandler.off(elem, 'mouseover', null, noop()))
|
.forEach(elem => EventHandler.off(elem, 'mouseover', null, noop()))
|
||||||
}
|
}
|
||||||
|
|
||||||
toggles[i].setAttribute('aria-expanded', 'false')
|
toggles[i].setAttribute('aria-expanded', 'false')
|
||||||
|
@ -463,10 +467,11 @@ class Dropdown {
|
||||||
// - If key is other than escape
|
// - If key is other than escape
|
||||||
// - If key is not up or down => not a dropdown command
|
// - If key is not up or down => not a dropdown command
|
||||||
// - If trigger inside the menu => not a dropdown command
|
// - If trigger inside the menu => not a dropdown command
|
||||||
if (/input|textarea/i.test(event.target.tagName)
|
if (/input|textarea/i.test(event.target.tagName) ?
|
||||||
? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE &&
|
event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE &&
|
||||||
(event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE ||
|
(event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE ||
|
||||||
SelectorEngine.closest(event.target, Selector.MENU)) : !REGEXP_KEYDOWN.test(event.which)) {
|
SelectorEngine.closest(event.target, Selector.MENU)) :
|
||||||
|
!REGEXP_KEYDOWN.test(event.which)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,7 +538,7 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
|
||||||
Dropdown._dropdownInterface(this, 'toggle')
|
Dropdown._dropdownInterface(this, 'toggle')
|
||||||
})
|
})
|
||||||
EventHandler
|
EventHandler
|
||||||
.on(document, Event.CLICK_DATA_API, Selector.FORM_CHILD, (e) => e.stopPropagation())
|
.on(document, Event.CLICK_DATA_API, Selector.FORM_CHILD, e => e.stopPropagation())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ------------------------------------------------------------------------
|
* ------------------------------------------------------------------------
|
||||||
|
|
|
@ -146,11 +146,11 @@ class Modal {
|
||||||
EventHandler.on(this._element,
|
EventHandler.on(this._element,
|
||||||
Event.CLICK_DISMISS,
|
Event.CLICK_DISMISS,
|
||||||
Selector.DATA_DISMISS,
|
Selector.DATA_DISMISS,
|
||||||
(event) => this.hide(event)
|
event => this.hide(event)
|
||||||
)
|
)
|
||||||
|
|
||||||
EventHandler.on(this._dialog, Event.MOUSEDOWN_DISMISS, () => {
|
EventHandler.on(this._dialog, Event.MOUSEDOWN_DISMISS, () => {
|
||||||
EventHandler.one(this._element, Event.MOUSEUP_DISMISS, (event) => {
|
EventHandler.one(this._element, Event.MOUSEUP_DISMISS, event => {
|
||||||
if (event.target === this._element) {
|
if (event.target === this._element) {
|
||||||
this._ignoreBackdropClick = true
|
this._ignoreBackdropClick = true
|
||||||
}
|
}
|
||||||
|
@ -192,11 +192,10 @@ class Modal {
|
||||||
EventHandler.off(this._element, Event.CLICK_DISMISS)
|
EventHandler.off(this._element, Event.CLICK_DISMISS)
|
||||||
EventHandler.off(this._dialog, Event.MOUSEDOWN_DISMISS)
|
EventHandler.off(this._dialog, Event.MOUSEDOWN_DISMISS)
|
||||||
|
|
||||||
|
|
||||||
if (transition) {
|
if (transition) {
|
||||||
const transitionDuration = getTransitionDurationFromElement(this._element)
|
const transitionDuration = getTransitionDurationFromElement(this._element)
|
||||||
|
|
||||||
EventHandler.one(this._element, TRANSITION_END, (event) => this._hideModal(event))
|
EventHandler.one(this._element, TRANSITION_END, event => this._hideModal(event))
|
||||||
emulateTransitionEnd(this._element, transitionDuration)
|
emulateTransitionEnd(this._element, transitionDuration)
|
||||||
} else {
|
} else {
|
||||||
this._hideModal()
|
this._hideModal()
|
||||||
|
@ -205,7 +204,7 @@ class Modal {
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
[window, this._element, this._dialog]
|
[window, this._element, this._dialog]
|
||||||
.forEach((htmlElement) => EventHandler.off(htmlElement, EVENT_KEY))
|
.forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
|
* `document` has 2 events `Event.FOCUSIN` and `Event.CLICK_DATA_API`
|
||||||
|
@ -275,6 +274,7 @@ class Modal {
|
||||||
if (this._config.focus) {
|
if (this._config.focus) {
|
||||||
this._element.focus()
|
this._element.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
this._isTransitioning = false
|
this._isTransitioning = false
|
||||||
EventHandler.trigger(this._element, Event.SHOWN, {
|
EventHandler.trigger(this._element, Event.SHOWN, {
|
||||||
relatedTarget
|
relatedTarget
|
||||||
|
@ -293,7 +293,7 @@ class Modal {
|
||||||
|
|
||||||
_enforceFocus() {
|
_enforceFocus() {
|
||||||
EventHandler.off(document, Event.FOCUSIN) // guard against infinite focus loop
|
EventHandler.off(document, Event.FOCUSIN) // guard against infinite focus loop
|
||||||
EventHandler.on(document, Event.FOCUSIN, (event) => {
|
EventHandler.on(document, Event.FOCUSIN, event => {
|
||||||
if (document !== event.target &&
|
if (document !== event.target &&
|
||||||
this._element !== event.target &&
|
this._element !== event.target &&
|
||||||
!this._element.contains(event.target)) {
|
!this._element.contains(event.target)) {
|
||||||
|
@ -304,7 +304,7 @@ class Modal {
|
||||||
|
|
||||||
_setEscapeEvent() {
|
_setEscapeEvent() {
|
||||||
if (this._isShown && this._config.keyboard) {
|
if (this._isShown && this._config.keyboard) {
|
||||||
EventHandler.on(this._element, Event.KEYDOWN_DISMISS, (event) => {
|
EventHandler.on(this._element, Event.KEYDOWN_DISMISS, event => {
|
||||||
if (event.which === ESCAPE_KEYCODE) {
|
if (event.which === ESCAPE_KEYCODE) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
this.hide()
|
this.hide()
|
||||||
|
@ -317,7 +317,7 @@ class Modal {
|
||||||
|
|
||||||
_setResizeEvent() {
|
_setResizeEvent() {
|
||||||
if (this._isShown) {
|
if (this._isShown) {
|
||||||
EventHandler.on(window, Event.RESIZE, (event) => this.handleUpdate(event))
|
EventHandler.on(window, Event.RESIZE, event => this.handleUpdate(event))
|
||||||
} else {
|
} else {
|
||||||
EventHandler.off(window, Event.RESIZE)
|
EventHandler.off(window, Event.RESIZE)
|
||||||
}
|
}
|
||||||
|
@ -344,9 +344,9 @@ class Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
_showBackdrop(callback) {
|
_showBackdrop(callback) {
|
||||||
const animate = this._element.classList.contains(ClassName.FADE)
|
const animate = this._element.classList.contains(ClassName.FADE) ?
|
||||||
? ClassName.FADE
|
ClassName.FADE :
|
||||||
: ''
|
''
|
||||||
|
|
||||||
if (this._isShown && this._config.backdrop) {
|
if (this._isShown && this._config.backdrop) {
|
||||||
this._backdrop = document.createElement('div')
|
this._backdrop = document.createElement('div')
|
||||||
|
@ -358,14 +358,16 @@ class Modal {
|
||||||
|
|
||||||
document.body.appendChild(this._backdrop)
|
document.body.appendChild(this._backdrop)
|
||||||
|
|
||||||
EventHandler.on(this._element, Event.CLICK_DISMISS, (event) => {
|
EventHandler.on(this._element, Event.CLICK_DISMISS, event => {
|
||||||
if (this._ignoreBackdropClick) {
|
if (this._ignoreBackdropClick) {
|
||||||
this._ignoreBackdropClick = false
|
this._ignoreBackdropClick = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.target !== event.currentTarget) {
|
if (event.target !== event.currentTarget) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._config.backdrop === 'static') {
|
if (this._config.backdrop === 'static') {
|
||||||
this._element.focus()
|
this._element.focus()
|
||||||
} else {
|
} else {
|
||||||
|
@ -450,7 +452,7 @@ class Modal {
|
||||||
|
|
||||||
// Adjust fixed content padding
|
// Adjust fixed content padding
|
||||||
makeArray(SelectorEngine.find(Selector.FIXED_CONTENT))
|
makeArray(SelectorEngine.find(Selector.FIXED_CONTENT))
|
||||||
.forEach((element) => {
|
.forEach(element => {
|
||||||
const actualPadding = element.style.paddingRight
|
const actualPadding = element.style.paddingRight
|
||||||
const calculatedPadding = window.getComputedStyle(element)['padding-right']
|
const calculatedPadding = window.getComputedStyle(element)['padding-right']
|
||||||
Manipulator.setDataAttribute(element, 'padding-right', actualPadding)
|
Manipulator.setDataAttribute(element, 'padding-right', actualPadding)
|
||||||
|
@ -459,7 +461,7 @@ class Modal {
|
||||||
|
|
||||||
// Adjust sticky content margin
|
// Adjust sticky content margin
|
||||||
makeArray(SelectorEngine.find(Selector.STICKY_CONTENT))
|
makeArray(SelectorEngine.find(Selector.STICKY_CONTENT))
|
||||||
.forEach((element) => {
|
.forEach(element => {
|
||||||
const actualMargin = element.style.marginRight
|
const actualMargin = element.style.marginRight
|
||||||
const calculatedMargin = window.getComputedStyle(element)['margin-right']
|
const calculatedMargin = window.getComputedStyle(element)['margin-right']
|
||||||
Manipulator.setDataAttribute(element, 'margin-right', actualMargin)
|
Manipulator.setDataAttribute(element, 'margin-right', actualMargin)
|
||||||
|
@ -480,7 +482,7 @@ class Modal {
|
||||||
_resetScrollbar() {
|
_resetScrollbar() {
|
||||||
// Restore fixed content padding
|
// Restore fixed content padding
|
||||||
makeArray(SelectorEngine.find(Selector.FIXED_CONTENT))
|
makeArray(SelectorEngine.find(Selector.FIXED_CONTENT))
|
||||||
.forEach((element) => {
|
.forEach(element => {
|
||||||
const padding = Manipulator.getDataAttribute(element, 'padding-right')
|
const padding = Manipulator.getDataAttribute(element, 'padding-right')
|
||||||
if (typeof padding !== 'undefined') {
|
if (typeof padding !== 'undefined') {
|
||||||
Manipulator.removeDataAttribute(element, 'padding-right')
|
Manipulator.removeDataAttribute(element, 'padding-right')
|
||||||
|
@ -490,7 +492,7 @@ class Modal {
|
||||||
|
|
||||||
// Restore sticky content and navbar-toggler margin
|
// Restore sticky content and navbar-toggler margin
|
||||||
makeArray(SelectorEngine.find(`${Selector.STICKY_CONTENT}`))
|
makeArray(SelectorEngine.find(`${Selector.STICKY_CONTENT}`))
|
||||||
.forEach((element) => {
|
.forEach(element => {
|
||||||
const margin = Manipulator.getDataAttribute(element, 'margin-right')
|
const margin = Manipulator.getDataAttribute(element, 'margin-right')
|
||||||
if (typeof margin !== 'undefined') {
|
if (typeof margin !== 'undefined') {
|
||||||
Manipulator.removeDataAttribute(element, 'margin-right')
|
Manipulator.removeDataAttribute(element, 'margin-right')
|
||||||
|
@ -500,11 +502,11 @@ class Modal {
|
||||||
|
|
||||||
// Restore body padding
|
// Restore body padding
|
||||||
const padding = Manipulator.getDataAttribute(document.body, 'padding-right')
|
const padding = Manipulator.getDataAttribute(document.body, 'padding-right')
|
||||||
if (typeof padding !== 'undefined') {
|
if (typeof padding === 'undefined') {
|
||||||
|
document.body.style.paddingRight = ''
|
||||||
|
} else {
|
||||||
Manipulator.removeDataAttribute(document.body, 'padding-right')
|
Manipulator.removeDataAttribute(document.body, 'padding-right')
|
||||||
document.body.style.paddingRight = padding
|
document.body.style.paddingRight = padding
|
||||||
} else {
|
|
||||||
document.body.style.paddingRight = ''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,6 +538,7 @@ class Modal {
|
||||||
if (typeof data[config] === 'undefined') {
|
if (typeof data[config] === 'undefined') {
|
||||||
throw new TypeError(`No method named "${config}"`)
|
throw new TypeError(`No method named "${config}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[config](relatedTarget)
|
data[config](relatedTarget)
|
||||||
} else if (_config.show) {
|
} else if (_config.show) {
|
||||||
data.show(relatedTarget)
|
data.show(relatedTarget)
|
||||||
|
@ -562,8 +565,9 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
|
||||||
target = SelectorEngine.findOne(selector)
|
target = SelectorEngine.findOne(selector)
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = Data.getData(target, DATA_KEY)
|
const config = Data.getData(target, DATA_KEY) ?
|
||||||
? 'toggle' : {
|
'toggle' :
|
||||||
|
{
|
||||||
...Manipulator.getDataAttributes(target),
|
...Manipulator.getDataAttributes(target),
|
||||||
...Manipulator.getDataAttributes(this)
|
...Manipulator.getDataAttributes(this)
|
||||||
}
|
}
|
||||||
|
@ -572,7 +576,7 @@ EventHandler.on(document, Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler.one(target, Event.SHOW, (showEvent) => {
|
EventHandler.one(target, Event.SHOW, showEvent => {
|
||||||
if (showEvent.defaultPrevented) {
|
if (showEvent.defaultPrevented) {
|
||||||
// only register focus restorer if modal will actually get shown
|
// only register focus restorer if modal will actually get shown
|
||||||
return
|
return
|
||||||
|
|
|
@ -120,6 +120,7 @@ class Popover extends Tooltip {
|
||||||
if (typeof content === 'function') {
|
if (typeof content === 'function') {
|
||||||
content = content.call(this.element)
|
content = content.call(this.element)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setElementContent(SelectorEngine.findOne(Selector.CONTENT, tip), content)
|
this.setElementContent(SelectorEngine.findOne(Selector.CONTENT, tip), content)
|
||||||
|
|
||||||
tip.classList.remove(ClassName.FADE)
|
tip.classList.remove(ClassName.FADE)
|
||||||
|
@ -138,8 +139,8 @@ class Popover extends Tooltip {
|
||||||
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
|
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
|
||||||
|
|
||||||
if (tabClass !== null && tabClass.length > 0) {
|
if (tabClass !== null && tabClass.length > 0) {
|
||||||
tabClass.map((token) => token.trim())
|
tabClass.map(token => token.trim())
|
||||||
.forEach((tClass) => tip.classList.remove(tClass))
|
.forEach(tClass => tip.classList.remove(tClass))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +164,7 @@ class Popover extends Tooltip {
|
||||||
if (typeof data[config] === 'undefined') {
|
if (typeof data[config] === 'undefined') {
|
||||||
throw new TypeError(`No method named "${config}"`)
|
throw new TypeError(`No method named "${config}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ScrollSpy {
|
||||||
this._activeTarget = null
|
this._activeTarget = null
|
||||||
this._scrollHeight = 0
|
this._scrollHeight = 0
|
||||||
|
|
||||||
EventHandler.on(this._scrollElement, Event.SCROLL, (event) => this._process(event))
|
EventHandler.on(this._scrollElement, Event.SCROLL, event => this._process(event))
|
||||||
|
|
||||||
this.refresh()
|
this.refresh()
|
||||||
this._process()
|
this._process()
|
||||||
|
@ -110,14 +110,17 @@ class ScrollSpy {
|
||||||
// Public
|
// Public
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
const autoMethod = this._scrollElement === this._scrollElement.window
|
const autoMethod = this._scrollElement === this._scrollElement.window ?
|
||||||
? OffsetMethod.OFFSET : OffsetMethod.POSITION
|
OffsetMethod.OFFSET :
|
||||||
|
OffsetMethod.POSITION
|
||||||
|
|
||||||
const offsetMethod = this._config.method === 'auto'
|
const offsetMethod = this._config.method === 'auto' ?
|
||||||
? autoMethod : this._config.method
|
autoMethod :
|
||||||
|
this._config.method
|
||||||
|
|
||||||
const offsetBase = offsetMethod === OffsetMethod.POSITION
|
const offsetBase = offsetMethod === OffsetMethod.POSITION ?
|
||||||
? this._getScrollTop() : 0
|
this._getScrollTop() :
|
||||||
|
0
|
||||||
|
|
||||||
this._offsets = []
|
this._offsets = []
|
||||||
this._targets = []
|
this._targets = []
|
||||||
|
@ -127,7 +130,7 @@ class ScrollSpy {
|
||||||
const targets = makeArray(SelectorEngine.find(this._selector))
|
const targets = makeArray(SelectorEngine.find(this._selector))
|
||||||
|
|
||||||
targets
|
targets
|
||||||
.map((element) => {
|
.map(element => {
|
||||||
let target
|
let target
|
||||||
const targetSelector = getSelectorFromElement(element)
|
const targetSelector = getSelectorFromElement(element)
|
||||||
|
|
||||||
|
@ -145,11 +148,12 @@ class ScrollSpy {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
.filter((item) => item)
|
.filter(item => item)
|
||||||
.sort((a, b) => a[0] - b[0])
|
.sort((a, b) => a[0] - b[0])
|
||||||
.forEach((item) => {
|
.forEach(item => {
|
||||||
this._offsets.push(item[0])
|
this._offsets.push(item[0])
|
||||||
this._targets.push(item[1])
|
this._targets.push(item[1])
|
||||||
})
|
})
|
||||||
|
@ -178,11 +182,12 @@ class ScrollSpy {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof config.target !== 'string') {
|
if (typeof config.target !== 'string') {
|
||||||
let id = config.target.id
|
let { id } = config.target
|
||||||
if (!id) {
|
if (!id) {
|
||||||
id = getUID(NAME)
|
id = getUID(NAME)
|
||||||
config.target.id = id
|
config.target.id = id
|
||||||
}
|
}
|
||||||
|
|
||||||
config.target = `#${id}`
|
config.target = `#${id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,8 +197,9 @@ class ScrollSpy {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getScrollTop() {
|
_getScrollTop() {
|
||||||
return this._scrollElement === window
|
return this._scrollElement === window ?
|
||||||
? this._scrollElement.pageYOffset : this._scrollElement.scrollTop
|
this._scrollElement.pageYOffset :
|
||||||
|
this._scrollElement.scrollTop
|
||||||
}
|
}
|
||||||
|
|
||||||
_getScrollHeight() {
|
_getScrollHeight() {
|
||||||
|
@ -204,8 +210,9 @@ class ScrollSpy {
|
||||||
}
|
}
|
||||||
|
|
||||||
_getOffsetHeight() {
|
_getOffsetHeight() {
|
||||||
return this._scrollElement === window
|
return this._scrollElement === window ?
|
||||||
? window.innerHeight : this._scrollElement.getBoundingClientRect().height
|
window.innerHeight :
|
||||||
|
this._scrollElement.getBoundingClientRect().height
|
||||||
}
|
}
|
||||||
|
|
||||||
_process() {
|
_process() {
|
||||||
|
@ -225,6 +232,7 @@ class ScrollSpy {
|
||||||
if (this._activeTarget !== target) {
|
if (this._activeTarget !== target) {
|
||||||
this._activate(target)
|
this._activate(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +261,7 @@ class ScrollSpy {
|
||||||
this._clear()
|
this._clear()
|
||||||
|
|
||||||
const queries = this._selector.split(',')
|
const queries = this._selector.split(',')
|
||||||
.map((selector) => `${selector}[data-target="${target}"],${selector}[href="${target}"]`)
|
.map(selector => `${selector}[data-target="${target}"],${selector}[href="${target}"]`)
|
||||||
|
|
||||||
const link = SelectorEngine.findOne(queries.join(','))
|
const link = SelectorEngine.findOne(queries.join(','))
|
||||||
|
|
||||||
|
@ -269,17 +277,17 @@ class ScrollSpy {
|
||||||
|
|
||||||
SelectorEngine
|
SelectorEngine
|
||||||
.parents(link, Selector.NAV_LIST_GROUP)
|
.parents(link, Selector.NAV_LIST_GROUP)
|
||||||
.forEach((listGroup) => {
|
.forEach(listGroup => {
|
||||||
// Set triggered links parents as active
|
// Set triggered links parents as active
|
||||||
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
|
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor
|
||||||
SelectorEngine.prev(listGroup, `${Selector.NAV_LINKS}, ${Selector.LIST_ITEMS}`)
|
SelectorEngine.prev(listGroup, `${Selector.NAV_LINKS}, ${Selector.LIST_ITEMS}`)
|
||||||
.forEach((item) => item.classList.add(ClassName.ACTIVE))
|
.forEach(item => item.classList.add(ClassName.ACTIVE))
|
||||||
|
|
||||||
// Handle special case when .nav-link is inside .nav-item
|
// Handle special case when .nav-link is inside .nav-item
|
||||||
SelectorEngine.prev(listGroup, Selector.NAV_ITEMS)
|
SelectorEngine.prev(listGroup, Selector.NAV_ITEMS)
|
||||||
.forEach((navItem) => {
|
.forEach(navItem => {
|
||||||
SelectorEngine.children(navItem, Selector.NAV_LINKS)
|
SelectorEngine.children(navItem, Selector.NAV_LINKS)
|
||||||
.forEach((item) => item.classList.add(ClassName.ACTIVE))
|
.forEach(item => item.classList.add(ClassName.ACTIVE))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -291,8 +299,8 @@ class ScrollSpy {
|
||||||
|
|
||||||
_clear() {
|
_clear() {
|
||||||
makeArray(SelectorEngine.find(this._selector))
|
makeArray(SelectorEngine.find(this._selector))
|
||||||
.filter((node) => node.classList.contains(ClassName.ACTIVE))
|
.filter(node => node.classList.contains(ClassName.ACTIVE))
|
||||||
.forEach((node) => node.classList.remove(ClassName.ACTIVE))
|
.forEach(node => node.classList.remove(ClassName.ACTIVE))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
@ -310,6 +318,7 @@ class ScrollSpy {
|
||||||
if (typeof data[config] === 'undefined') {
|
if (typeof data[config] === 'undefined') {
|
||||||
throw new TypeError(`No method named "${config}"`)
|
throw new TypeError(`No method named "${config}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -328,7 +337,7 @@ class ScrollSpy {
|
||||||
|
|
||||||
EventHandler.on(window, Event.LOAD_DATA_API, () => {
|
EventHandler.on(window, Event.LOAD_DATA_API, () => {
|
||||||
makeArray(SelectorEngine.find(Selector.DATA_SPY))
|
makeArray(SelectorEngine.find(Selector.DATA_SPY))
|
||||||
.forEach((spy) => new ScrollSpy(spy, Manipulator.getDataAttributes(spy)))
|
.forEach(spy => new ScrollSpy(spy, Manipulator.getDataAttributes(spy)))
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -146,9 +146,9 @@ class Tab {
|
||||||
// Private
|
// Private
|
||||||
|
|
||||||
_activate(element, container, callback) {
|
_activate(element, container, callback) {
|
||||||
const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL')
|
const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ?
|
||||||
? SelectorEngine.find(Selector.ACTIVE_UL, container)
|
SelectorEngine.find(Selector.ACTIVE_UL, container) :
|
||||||
: SelectorEngine.children(container, Selector.ACTIVE)
|
SelectorEngine.children(container, Selector.ACTIVE)
|
||||||
|
|
||||||
const active = activeElements[0]
|
const active = activeElements[0]
|
||||||
const isTransitioning = callback &&
|
const isTransitioning = callback &&
|
||||||
|
@ -202,7 +202,7 @@ class Tab {
|
||||||
|
|
||||||
if (dropdownElement) {
|
if (dropdownElement) {
|
||||||
makeArray(SelectorEngine.find(Selector.DROPDOWN_TOGGLE))
|
makeArray(SelectorEngine.find(Selector.DROPDOWN_TOGGLE))
|
||||||
.forEach((dropdown) => dropdown.classList.add(ClassName.ACTIVE))
|
.forEach(dropdown => dropdown.classList.add(ClassName.ACTIVE))
|
||||||
}
|
}
|
||||||
|
|
||||||
element.setAttribute('aria-expanded', true)
|
element.setAttribute('aria-expanded', true)
|
||||||
|
@ -223,6 +223,7 @@ class Tab {
|
||||||
if (typeof data[config] === 'undefined') {
|
if (typeof data[config] === 'undefined') {
|
||||||
throw new TypeError(`No method named "${config}"`)
|
throw new TypeError(`No method named "${config}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -41,7 +41,6 @@ const CLASS_PREFIX = 'bs-tooltip'
|
||||||
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
|
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
|
||||||
const DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']
|
const DISALLOWED_ATTRIBUTES = ['sanitize', 'whiteList', 'sanitizeFn']
|
||||||
|
|
||||||
|
|
||||||
const DefaultType = {
|
const DefaultType = {
|
||||||
animation: 'boolean',
|
animation: 'boolean',
|
||||||
template: 'string',
|
template: 'string',
|
||||||
|
@ -124,7 +123,6 @@ const Trigger = {
|
||||||
MANUAL: 'manual'
|
MANUAL: 'manual'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ------------------------------------------------------------------------
|
* ------------------------------------------------------------------------
|
||||||
* Class Definition
|
* Class Definition
|
||||||
|
@ -269,9 +267,9 @@ class Tooltip {
|
||||||
if (this.isWithContent() && this._isEnabled) {
|
if (this.isWithContent() && this._isEnabled) {
|
||||||
const showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW)
|
const showEvent = EventHandler.trigger(this.element, this.constructor.Event.SHOW)
|
||||||
const shadowRoot = findShadowRoot(this.element)
|
const shadowRoot = findShadowRoot(this.element)
|
||||||
const isInTheDom = shadowRoot !== null
|
const isInTheDom = shadowRoot === null ?
|
||||||
? shadowRoot.contains(this.element)
|
this.element.ownerDocument.documentElement.contains(this.element) :
|
||||||
: this.element.ownerDocument.documentElement.contains(this.element)
|
shadowRoot.contains(this.element)
|
||||||
|
|
||||||
if (showEvent.defaultPrevented || !isInTheDom) {
|
if (showEvent.defaultPrevented || !isInTheDom) {
|
||||||
return
|
return
|
||||||
|
@ -289,9 +287,9 @@ class Tooltip {
|
||||||
tip.classList.add(ClassName.FADE)
|
tip.classList.add(ClassName.FADE)
|
||||||
}
|
}
|
||||||
|
|
||||||
const placement = typeof this.config.placement === 'function'
|
const placement = typeof this.config.placement === 'function' ?
|
||||||
? this.config.placement.call(this, tip, this.element)
|
this.config.placement.call(this, tip, this.element) :
|
||||||
: this.config.placement
|
this.config.placement
|
||||||
|
|
||||||
const attachment = this._getAttachment(placement)
|
const attachment = this._getAttachment(placement)
|
||||||
this.addAttachmentClass(attachment)
|
this.addAttachmentClass(attachment)
|
||||||
|
@ -319,12 +317,12 @@ class Tooltip {
|
||||||
boundariesElement: this.config.boundary
|
boundariesElement: this.config.boundary
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCreate: (data) => {
|
onCreate: data => {
|
||||||
if (data.originalPlacement !== data.placement) {
|
if (data.originalPlacement !== data.placement) {
|
||||||
this._handlePopperPlacementChange(data)
|
this._handlePopperPlacementChange(data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onUpdate: (data) => this._handlePopperPlacementChange(data)
|
onUpdate: data => this._handlePopperPlacementChange(data)
|
||||||
})
|
})
|
||||||
|
|
||||||
tip.classList.add(ClassName.SHOW)
|
tip.classList.add(ClassName.SHOW)
|
||||||
|
@ -334,7 +332,7 @@ class Tooltip {
|
||||||
// only needed because of broken event delegation on iOS
|
// only needed because of broken event delegation on iOS
|
||||||
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
||||||
if ('ontouchstart' in document.documentElement) {
|
if ('ontouchstart' in document.documentElement) {
|
||||||
makeArray(document.body.children).forEach((element) => {
|
makeArray(document.body.children).forEach(element => {
|
||||||
EventHandler.on(element, 'mouseover', noop())
|
EventHandler.on(element, 'mouseover', noop())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -343,6 +341,7 @@ class Tooltip {
|
||||||
if (this.config.animation) {
|
if (this.config.animation) {
|
||||||
this._fixTransition()
|
this._fixTransition()
|
||||||
}
|
}
|
||||||
|
|
||||||
const prevHoverState = this._hoverState
|
const prevHoverState = this._hoverState
|
||||||
this._hoverState = null
|
this._hoverState = null
|
||||||
|
|
||||||
|
@ -393,7 +392,7 @@ class Tooltip {
|
||||||
// empty mouseover listeners we added for iOS support
|
// empty mouseover listeners we added for iOS support
|
||||||
if ('ontouchstart' in document.documentElement) {
|
if ('ontouchstart' in document.documentElement) {
|
||||||
makeArray(document.body.children)
|
makeArray(document.body.children)
|
||||||
.forEach((element) => EventHandler.off(element, 'mouseover', noop))
|
.forEach(element => EventHandler.off(element, 'mouseover', noop))
|
||||||
}
|
}
|
||||||
|
|
||||||
this._activeTrigger[Trigger.CLICK] = false
|
this._activeTrigger[Trigger.CLICK] = false
|
||||||
|
@ -485,9 +484,9 @@ class Tooltip {
|
||||||
let title = this.element.getAttribute('data-original-title')
|
let title = this.element.getAttribute('data-original-title')
|
||||||
|
|
||||||
if (!title) {
|
if (!title) {
|
||||||
title = typeof this.config.title === 'function'
|
title = typeof this.config.title === 'function' ?
|
||||||
? this.config.title.call(this.element)
|
this.config.title.call(this.element) :
|
||||||
: this.config.title
|
this.config.title
|
||||||
}
|
}
|
||||||
|
|
||||||
return title
|
return title
|
||||||
|
@ -499,7 +498,7 @@ class Tooltip {
|
||||||
const offset = {}
|
const offset = {}
|
||||||
|
|
||||||
if (typeof this.config.offset === 'function') {
|
if (typeof this.config.offset === 'function') {
|
||||||
offset.fn = (data) => {
|
offset.fn = data => {
|
||||||
data.offsets = {
|
data.offsets = {
|
||||||
...data.offsets,
|
...data.offsets,
|
||||||
...this.config.offset(data.offsets, this.element) || {}
|
...this.config.offset(data.offsets, this.element) || {}
|
||||||
|
@ -533,30 +532,30 @@ class Tooltip {
|
||||||
_setListeners() {
|
_setListeners() {
|
||||||
const triggers = this.config.trigger.split(' ')
|
const triggers = this.config.trigger.split(' ')
|
||||||
|
|
||||||
triggers.forEach((trigger) => {
|
triggers.forEach(trigger => {
|
||||||
if (trigger === 'click') {
|
if (trigger === 'click') {
|
||||||
EventHandler.on(this.element,
|
EventHandler.on(this.element,
|
||||||
this.constructor.Event.CLICK,
|
this.constructor.Event.CLICK,
|
||||||
this.config.selector,
|
this.config.selector,
|
||||||
(event) => this.toggle(event)
|
event => this.toggle(event)
|
||||||
)
|
)
|
||||||
} else if (trigger !== Trigger.MANUAL) {
|
} else if (trigger !== Trigger.MANUAL) {
|
||||||
const eventIn = trigger === Trigger.HOVER
|
const eventIn = trigger === Trigger.HOVER ?
|
||||||
? this.constructor.Event.MOUSEENTER
|
this.constructor.Event.MOUSEENTER :
|
||||||
: this.constructor.Event.FOCUSIN
|
this.constructor.Event.FOCUSIN
|
||||||
const eventOut = trigger === Trigger.HOVER
|
const eventOut = trigger === Trigger.HOVER ?
|
||||||
? this.constructor.Event.MOUSELEAVE
|
this.constructor.Event.MOUSELEAVE :
|
||||||
: this.constructor.Event.FOCUSOUT
|
this.constructor.Event.FOCUSOUT
|
||||||
|
|
||||||
EventHandler.on(this.element,
|
EventHandler.on(this.element,
|
||||||
eventIn,
|
eventIn,
|
||||||
this.config.selector,
|
this.config.selector,
|
||||||
(event) => this._enter(event)
|
event => this._enter(event)
|
||||||
)
|
)
|
||||||
EventHandler.on(this.element,
|
EventHandler.on(this.element,
|
||||||
eventOut,
|
eventOut,
|
||||||
this.config.selector,
|
this.config.selector,
|
||||||
(event) => this._leave(event)
|
event => this._leave(event)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -686,7 +685,7 @@ class Tooltip {
|
||||||
const dataAttributes = Manipulator.getDataAttributes(this.element)
|
const dataAttributes = Manipulator.getDataAttributes(this.element)
|
||||||
|
|
||||||
Object.keys(dataAttributes)
|
Object.keys(dataAttributes)
|
||||||
.forEach((dataAttr) => {
|
.forEach(dataAttr => {
|
||||||
if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
|
if (DISALLOWED_ATTRIBUTES.indexOf(dataAttr) !== -1) {
|
||||||
delete dataAttributes[dataAttr]
|
delete dataAttributes[dataAttr]
|
||||||
}
|
}
|
||||||
|
@ -749,8 +748,8 @@ class Tooltip {
|
||||||
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
|
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX)
|
||||||
if (tabClass !== null && tabClass.length) {
|
if (tabClass !== null && tabClass.length) {
|
||||||
tabClass
|
tabClass
|
||||||
.map((token) => token.trim())
|
.map(token => token.trim())
|
||||||
.forEach((tClass) => tip.classList.remove(tClass))
|
.forEach(tClass => tip.classList.remove(tClass))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -767,6 +766,7 @@ class Tooltip {
|
||||||
if (tip.getAttribute('x-placement') !== null) {
|
if (tip.getAttribute('x-placement') !== null) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tip.classList.remove(ClassName.FADE)
|
tip.classList.remove(ClassName.FADE)
|
||||||
this.config.animation = false
|
this.config.animation = false
|
||||||
this.hide()
|
this.hide()
|
||||||
|
@ -793,6 +793,7 @@ class Tooltip {
|
||||||
if (typeof data[config] === 'undefined') {
|
if (typeof data[config] === 'undefined') {
|
||||||
throw new TypeError(`No method named "${config}"`)
|
throw new TypeError(`No method named "${config}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
const MAX_UID = 1000000
|
const MAX_UID = 1000000
|
||||||
const MILLISECONDS_MULTIPLIER = 1000
|
const MILLISECONDS_MULTIPLIER = 1000
|
||||||
const TRANSITION_END = 'transitionend'
|
const TRANSITION_END = 'transitionend'
|
||||||
const jQuery = window.jQuery
|
const { jQuery } = window
|
||||||
|
|
||||||
// Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
// Shoutout AngusCroll (https://goo.gl/pxwQGp)
|
||||||
const toType = (obj) => ({}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase())
|
const toType = obj => ({}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
|
@ -19,15 +19,16 @@ const toType = (obj) => ({}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCa
|
||||||
* --------------------------------------------------------------------------
|
* --------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const getUID = (prefix) => {
|
const getUID = prefix => {
|
||||||
do {
|
do {
|
||||||
// eslint-disable-next-line no-bitwise
|
// eslint-disable-next-line no-bitwise
|
||||||
prefix += ~~(Math.random() * MAX_UID) // "~~" acts like a faster Math.floor() here
|
prefix += ~~(Math.random() * MAX_UID) // "~~" acts like a faster Math.floor() here
|
||||||
} while (document.getElementById(prefix))
|
} while (document.getElementById(prefix))
|
||||||
|
|
||||||
return prefix
|
return prefix
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSelectorFromElement = (element) => {
|
const getSelectorFromElement = element => {
|
||||||
let selector = element.getAttribute('data-target')
|
let selector = element.getAttribute('data-target')
|
||||||
|
|
||||||
if (!selector || selector === '#') {
|
if (!selector || selector === '#') {
|
||||||
|
@ -38,12 +39,12 @@ const getSelectorFromElement = (element) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return document.querySelector(selector) ? selector : null
|
return document.querySelector(selector) ? selector : null
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTransitionDurationFromElement = (element) => {
|
const getTransitionDurationFromElement = element => {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -69,11 +70,11 @@ const getTransitionDurationFromElement = (element) => {
|
||||||
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER
|
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER
|
||||||
}
|
}
|
||||||
|
|
||||||
const triggerTransitionEnd = (element) => {
|
const triggerTransitionEnd = element => {
|
||||||
element.dispatchEvent(new Event(TRANSITION_END))
|
element.dispatchEvent(new Event(TRANSITION_END))
|
||||||
}
|
}
|
||||||
|
|
||||||
const isElement = (obj) => (obj[0] || obj).nodeType
|
const isElement = obj => (obj[0] || obj).nodeType
|
||||||
|
|
||||||
const emulateTransitionEnd = (element, duration) => {
|
const emulateTransitionEnd = (element, duration) => {
|
||||||
let called = false
|
let called = false
|
||||||
|
@ -94,11 +95,12 @@ const emulateTransitionEnd = (element, duration) => {
|
||||||
|
|
||||||
const typeCheckConfig = (componentName, config, configTypes) => {
|
const typeCheckConfig = (componentName, config, configTypes) => {
|
||||||
Object.keys(configTypes)
|
Object.keys(configTypes)
|
||||||
.forEach((property) => {
|
.forEach(property => {
|
||||||
const expectedTypes = configTypes[property]
|
const expectedTypes = configTypes[property]
|
||||||
const value = config[property]
|
const value = config[property]
|
||||||
const valueType = value && isElement(value)
|
const valueType = value && isElement(value) ?
|
||||||
? 'element' : toType(value)
|
'element' :
|
||||||
|
toType(value)
|
||||||
|
|
||||||
if (!new RegExp(expectedTypes).test(valueType)) {
|
if (!new RegExp(expectedTypes).test(valueType)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@ -109,7 +111,7 @@ const typeCheckConfig = (componentName, config, configTypes) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const makeArray = (nodeList) => {
|
const makeArray = nodeList => {
|
||||||
if (!nodeList) {
|
if (!nodeList) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
@ -117,7 +119,7 @@ const makeArray = (nodeList) => {
|
||||||
return [].slice.call(nodeList)
|
return [].slice.call(nodeList)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isVisible = (element) => {
|
const isVisible = element => {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -131,7 +133,7 @@ const isVisible = (element) => {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const findShadowRoot = (element) => {
|
const findShadowRoot = element => {
|
||||||
if (!document.documentElement.attachShadow) {
|
if (!document.documentElement.attachShadow) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -157,7 +159,7 @@ const findShadowRoot = (element) => {
|
||||||
// eslint-disable-next-line no-empty-function
|
// eslint-disable-next-line no-empty-function
|
||||||
const noop = () => function () {}
|
const noop = () => function () {}
|
||||||
|
|
||||||
const reflow = (element) => element.offsetHeight
|
const reflow = element => element.offsetHeight
|
||||||
|
|
||||||
export {
|
export {
|
||||||
jQuery,
|
jQuery,
|
||||||
|
|
|
@ -47,7 +47,7 @@ const allowedAttribute = (attr, allowedAttributeList) => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const regExp = allowedAttributeList.filter((attrRegex) => attrRegex instanceof RegExp)
|
const regExp = allowedAttributeList.filter(attrRegex => attrRegex instanceof RegExp)
|
||||||
|
|
||||||
// Check if a regular expression validates the attribute.
|
// Check if a regular expression validates the attribute.
|
||||||
for (let i = 0, l = regExp.length; i < l; i++) {
|
for (let i = 0, l = regExp.length; i < l; i++) {
|
||||||
|
@ -120,7 +120,7 @@ export function sanitizeHtml(unsafeHtml, whiteList, sanitizeFn) {
|
||||||
const attributeList = makeArray(el.attributes)
|
const attributeList = makeArray(el.attributes)
|
||||||
const whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || [])
|
const whitelistedAttributes = [].concat(whiteList['*'] || [], whiteList[elName] || [])
|
||||||
|
|
||||||
attributeList.forEach((attr) => {
|
attributeList.forEach(attr => {
|
||||||
if (!allowedAttribute(attr, whitelistedAttributes)) {
|
if (!allowedAttribute(attr, whitelistedAttributes)) {
|
||||||
el.removeAttribute(attr.nodeName)
|
el.removeAttribute(attr.nodeName)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,6 @@ import 'popper.js'
|
||||||
import bootstrap from '../../../dist/js/bootstrap'
|
import bootstrap from '../../../dist/js/bootstrap'
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
Array.from(document.querySelectorAll('[data-toggle="tooltip"]'))
|
[...document.querySelectorAll('[data-toggle="tooltip"]')]
|
||||||
.map((tooltipNode) => new bootstrap.Tooltip(tooltipNode))
|
.map(tooltipNode => new bootstrap.Tooltip(tooltipNode))
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ const {
|
||||||
browsersKeys
|
browsersKeys
|
||||||
} = require('./browsers')
|
} = require('./browsers')
|
||||||
|
|
||||||
const env = process.env
|
const { env } = process
|
||||||
const bundle = env.BUNDLE === 'true'
|
const bundle = env.BUNDLE === 'true'
|
||||||
const browserStack = env.BROWSER === 'true'
|
const browserStack = env.BROWSER === 'true'
|
||||||
const debug = env.DEBUG === 'true'
|
const debug = env.DEBUG === 'true'
|
||||||
|
@ -173,7 +173,7 @@ conf.plugins = plugins
|
||||||
conf.reporters = reporters
|
conf.reporters = reporters
|
||||||
conf.files = files
|
conf.files = files
|
||||||
|
|
||||||
module.exports = (karmaConfig) => {
|
module.exports = karmaConfig => {
|
||||||
// possible values: karmaConfig.LOG_DISABLE || karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN || karmaConfig.LOG_INFO || karmaConfig.LOG_DEBUG
|
// possible values: karmaConfig.LOG_DISABLE || karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN || karmaConfig.LOG_INFO || karmaConfig.LOG_DEBUG
|
||||||
conf.logLevel = karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN
|
conf.logLevel = karmaConfig.LOG_ERROR || karmaConfig.LOG_WARN
|
||||||
karmaConfig.set(conf)
|
karmaConfig.set(conf)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var Alert = typeof window.bootstrap !== 'undefined' ? window.bootstrap.Alert : window.Alert
|
var Alert = typeof window.bootstrap === 'undefined' ? window.Alert : window.bootstrap.Alert
|
||||||
|
|
||||||
QUnit.module('alert plugin')
|
QUnit.module('alert plugin')
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var Button = typeof window.bootstrap !== 'undefined' ? window.bootstrap.Button : window.Button
|
var Button = typeof window.bootstrap === 'undefined' ? window.Button : window.bootstrap.Button
|
||||||
|
|
||||||
QUnit.module('button plugin')
|
QUnit.module('button plugin')
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
window.Carousel = typeof bootstrap !== 'undefined' ? bootstrap.Carousel : Carousel
|
window.Carousel = typeof bootstrap === 'undefined' ? Carousel : bootstrap.Carousel
|
||||||
|
|
||||||
var originWinPointerEvent = window.PointerEvent
|
var originWinPointerEvent = window.PointerEvent
|
||||||
window.MSPointerEvent = null
|
window.MSPointerEvent = null
|
||||||
|
@ -65,8 +65,8 @@ $(function () {
|
||||||
$el.bootstrapCarousel()
|
$el.bootstrapCarousel()
|
||||||
try {
|
try {
|
||||||
$el.bootstrapCarousel('noMethod')
|
$el.bootstrapCarousel('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ $(function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$('<div/>').bootstrapCarousel(config)
|
$('<div/>').bootstrapCarousel(config)
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
message = err.message
|
message = error.message
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.ok(message === expectedMessage, 'correct error message')
|
assert.ok(message === expectedMessage, 'correct error message')
|
||||||
|
@ -102,8 +102,8 @@ $(function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$('<div/>').bootstrapCarousel(config)
|
$('<div/>').bootstrapCarousel(config)
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
message = err.message
|
message = error.message
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.ok(message === expectedMessage, 'correct error message')
|
assert.ok(message === expectedMessage, 'correct error message')
|
||||||
|
@ -161,6 +161,7 @@ $(function () {
|
||||||
}, 0)
|
}, 0)
|
||||||
$carousel[0].removeEventListener('slide.bs.carousel', onSlide)
|
$carousel[0].removeEventListener('slide.bs.carousel', onSlide)
|
||||||
}
|
}
|
||||||
|
|
||||||
$carousel[0].addEventListener('slide.bs.carousel', onSlide)
|
$carousel[0].addEventListener('slide.bs.carousel', onSlide)
|
||||||
|
|
||||||
function onSlid() {
|
function onSlid() {
|
||||||
|
@ -173,6 +174,7 @@ $(function () {
|
||||||
}, 0)
|
}, 0)
|
||||||
$carousel[0].removeEventListener('slid.bs.carousel', onSlid)
|
$carousel[0].removeEventListener('slid.bs.carousel', onSlid)
|
||||||
}
|
}
|
||||||
|
|
||||||
$carousel[0].addEventListener('slid.bs.carousel', onSlid)
|
$carousel[0].addEventListener('slid.bs.carousel', onSlid)
|
||||||
|
|
||||||
$carousel.bootstrapCarousel('next')
|
$carousel.bootstrapCarousel('next')
|
||||||
|
@ -682,6 +684,7 @@ $(function () {
|
||||||
assert.strictEqual(event.defaultPrevented, false)
|
assert.strictEqual(event.defaultPrevented, false)
|
||||||
$template[0].removeEventListener('keydown', handlerKeydown)
|
$template[0].removeEventListener('keydown', handlerKeydown)
|
||||||
}
|
}
|
||||||
|
|
||||||
$template[0].addEventListener('keydown', handlerKeydown)
|
$template[0].addEventListener('keydown', handlerKeydown)
|
||||||
|
|
||||||
// arrow down
|
// arrow down
|
||||||
|
@ -694,6 +697,7 @@ $(function () {
|
||||||
$template[0].addEventListener('keydown', handlerKeydown2)
|
$template[0].addEventListener('keydown', handlerKeydown2)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
|
||||||
$template[0].addEventListener('keydown', handlerKeydown2)
|
$template[0].addEventListener('keydown', handlerKeydown2)
|
||||||
|
|
||||||
// arrow up
|
// arrow up
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var Collapse = typeof window.bootstrap !== 'undefined' ? window.bootstrap.Collapse : window.Collapse
|
var Collapse = typeof window.bootstrap === 'undefined' ? window.Collapse : window.bootstrap.Collapse
|
||||||
|
|
||||||
QUnit.module('collapse plugin')
|
QUnit.module('collapse plugin')
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ $(function () {
|
||||||
$el.bootstrapCollapse()
|
$el.bootstrapCollapse()
|
||||||
try {
|
try {
|
||||||
$el.bootstrapCollapse('noMethod')
|
$el.bootstrapCollapse('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -838,7 +838,7 @@ $(function () {
|
||||||
parent: $('.my-collapse')
|
parent: $('.my-collapse')
|
||||||
})
|
})
|
||||||
assert.ok(true, 'collapse correctly created')
|
assert.ok(true, 'collapse correctly created')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.ok(false, 'collapse not created')
|
assert.ok(false, 'collapse not created')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -859,7 +859,7 @@ $(function () {
|
||||||
parent: $('.my-collapse')[0]
|
parent: $('.my-collapse')[0]
|
||||||
})
|
})
|
||||||
assert.ok(true, 'collapse correctly created')
|
assert.ok(true, 'collapse correctly created')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.ok(false, 'collapse not created')
|
assert.ok(false, 'collapse not created')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var Dropdown = typeof window.bootstrap !== 'undefined' ? window.bootstrap.Dropdown : window.Dropdown
|
var Dropdown = typeof window.bootstrap === 'undefined' ? window.Dropdown : window.bootstrap.Dropdown
|
||||||
|
|
||||||
QUnit.module('dropdowns plugin')
|
QUnit.module('dropdowns plugin')
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ $(function () {
|
||||||
$el.bootstrapDropdown()
|
$el.bootstrapDropdown()
|
||||||
try {
|
try {
|
||||||
$el.bootstrapDropdown('noMethod')
|
$el.bootstrapDropdown('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
window.Util = typeof bootstrap !== 'undefined' ? bootstrap.Util : Util
|
window.Util = typeof bootstrap === 'undefined' ? Util : bootstrap.Util
|
||||||
var Modal = typeof window.bootstrap !== 'undefined' ? window.bootstrap.Modal : window.Modal
|
var Modal = typeof window.bootstrap === 'undefined' ? window.Modal : window.bootstrap.Modal
|
||||||
|
|
||||||
QUnit.module('modal plugin')
|
QUnit.module('modal plugin')
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ $(function () {
|
||||||
$el.bootstrapModal()
|
$el.bootstrapModal()
|
||||||
try {
|
try {
|
||||||
$el.bootstrapModal('noMethod')
|
$el.bootstrapModal('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -758,6 +758,7 @@ $(function () {
|
||||||
document.removeEventListener('focusin', focusInListener)
|
document.removeEventListener('focusin', focusInListener)
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('focusin', focusInListener)
|
document.addEventListener('focusin', focusInListener)
|
||||||
|
|
||||||
var focusInEvent = new Event('focusin')
|
var focusInEvent = new Event('focusin')
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var Popover = typeof window.bootstrap !== 'undefined' ? window.bootstrap.Popover : window.Popover
|
var Popover = typeof window.bootstrap === 'undefined' ? window.Popover : window.bootstrap.Popover
|
||||||
|
|
||||||
QUnit.module('popover plugin')
|
QUnit.module('popover plugin')
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ $(function () {
|
||||||
$el.bootstrapPopover()
|
$el.bootstrapPopover()
|
||||||
try {
|
try {
|
||||||
$el.bootstrapPopover('noMethod')
|
$el.bootstrapPopover('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -367,8 +367,8 @@ $(function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$('<div data-toggle="popover" data-title="some title" data-content="@Johann-S" style="display: none"/>').bootstrapPopover('show')
|
$('<div data-toggle="popover" data-title="some title" data-content="@Johann-S" style="display: none"/>').bootstrapPopover('show')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'Please use show on visible elements')
|
assert.strictEqual(error.message, 'Please use show on visible elements')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var ScrollSpy = typeof window.bootstrap !== 'undefined' ? window.bootstrap.ScrollSpy : window.ScrollSpy
|
var ScrollSpy = typeof window.bootstrap === 'undefined' ? window.ScrollSpy : window.bootstrap.ScrollSpy
|
||||||
|
|
||||||
QUnit.module('scrollspy plugin')
|
QUnit.module('scrollspy plugin')
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ $(function () {
|
||||||
$el.bootstrapScrollspy()
|
$el.bootstrapScrollspy()
|
||||||
try {
|
try {
|
||||||
$el.bootstrapScrollspy('noMethod')
|
$el.bootstrapScrollspy('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,8 @@ $(function () {
|
||||||
$el.bootstrapTab()
|
$el.bootstrapTab()
|
||||||
try {
|
try {
|
||||||
$el.bootstrapTab('noMethod')
|
$el.bootstrapTab('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ $(function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$el.bootstrapToast('noMethod')
|
$el.bootstrapToast('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -208,7 +208,6 @@ $(function () {
|
||||||
.bootstrapToast('show')
|
.bootstrapToast('show')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
QUnit.test('should close toast when close element with data-dismiss attribute is set', function (assert) {
|
QUnit.test('should close toast when close element with data-dismiss attribute is set', function (assert) {
|
||||||
assert.expect(2)
|
assert.expect(2)
|
||||||
var done = assert.async()
|
var done = assert.async()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var Tooltip = typeof window.bootstrap !== 'undefined' ? window.bootstrap.Tooltip : window.Tooltip
|
var Tooltip = typeof window.bootstrap === 'undefined' ? window.Tooltip : window.bootstrap.Tooltip
|
||||||
|
|
||||||
QUnit.module('tooltip plugin')
|
QUnit.module('tooltip plugin')
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ $(function () {
|
||||||
$el.bootstrapTooltip()
|
$el.bootstrapTooltip()
|
||||||
try {
|
try {
|
||||||
$el.bootstrapTooltip('noMethod')
|
$el.bootstrapTooltip('noMethod')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'No method named "noMethod"')
|
assert.strictEqual(error.message, 'No method named "noMethod"')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -231,8 +231,8 @@ $(function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$('<div title="tooltip title" style="display: none"/>').bootstrapTooltip('show')
|
$('<div title="tooltip title" style="display: none"/>').bootstrapTooltip('show')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'Please use show on visible elements')
|
assert.strictEqual(error.message, 'Please use show on visible elements')
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -557,7 +557,7 @@ $(function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$tooltip.bootstrapTooltip('show')
|
$tooltip.bootstrapTooltip('show')
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
passed = false
|
passed = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ $(function () {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Util.typeCheckConfig(namePlugin, config, defaultType)
|
Util.typeCheckConfig(namePlugin, config, defaultType)
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
assert.strictEqual(err.message, 'COLLAPSE: Option "parent" provided type "number" but expected type "(string|element)".')
|
assert.strictEqual(error.message, 'COLLAPSE: Option "parent" provided type "number" but expected type "(string|element)".')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -139,9 +139,7 @@ $(function () {
|
||||||
assert.expect(1)
|
assert.expect(1)
|
||||||
|
|
||||||
var $div = $('<div id="test"></div>').appendTo($('#qunit-fixture'))
|
var $div = $('<div id="test"></div>').appendTo($('#qunit-fixture'))
|
||||||
if (!document.documentElement.attachShadow) {
|
if (document.documentElement.attachShadow) {
|
||||||
assert.equal(null, Util.findShadowRoot($div[0]))
|
|
||||||
} else {
|
|
||||||
var sandbox = sinon.createSandbox()
|
var sandbox = sinon.createSandbox()
|
||||||
|
|
||||||
sandbox.replace(document.documentElement, 'attachShadow', function () {
|
sandbox.replace(document.documentElement, 'attachShadow', function () {
|
||||||
|
@ -151,6 +149,8 @@ $(function () {
|
||||||
|
|
||||||
assert.equal(null, Util.findShadowRoot($div[0]))
|
assert.equal(null, Util.findShadowRoot($div[0]))
|
||||||
sandbox.restore()
|
sandbox.restore()
|
||||||
|
} else {
|
||||||
|
assert.equal(null, Util.findShadowRoot($div[0]))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -156,4 +156,4 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
bsCustomFileInput.init()
|
bsCustomFileInput.init()
|
||||||
}())
|
})()
|
||||||
|
|
|
@ -52,4 +52,4 @@
|
||||||
},
|
},
|
||||||
debug: false // Set debug to true if you want to inspect the dropdown
|
debug: false // Set debug to true if you want to inspect the dropdown
|
||||||
})
|
})
|
||||||
}())
|
})()
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
}
|
}
|
||||||
|
|
||||||
form.classList.add('was-validated')
|
form.classList.add('was-validated')
|
||||||
}, false)
|
}, false)
|
||||||
})
|
})
|
||||||
}, false)
|
}, false)
|
||||||
}())
|
})()
|
||||||
|
|
|
@ -50,4 +50,4 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}())
|
})()
|
||||||
|
|
|
@ -4,4 +4,4 @@
|
||||||
document.querySelector('[data-toggle="offcanvas"]').addEventListener('click', function () {
|
document.querySelector('[data-toggle="offcanvas"]').addEventListener('click', function () {
|
||||||
document.querySelector('.offcanvas-collapse').classList.toggle('open')
|
document.querySelector('.offcanvas-collapse').classList.toggle('open')
|
||||||
})
|
})
|
||||||
}())
|
})()
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// IT'S ALL JUST JUNK FOR OUR DOCS!
|
// IT'S ALL JUST JUNK FOR OUR DOCS!
|
||||||
// ++++++++++++++++++++++++++++++++++++++++++
|
// ++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
|
/* eslint-disable max-nested-callbacks */
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
|
@ -24,4 +26,4 @@
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}())
|
})()
|
||||||
|
|
Loading…
Reference in New Issue