aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/twbs/bootstrap/js/src/tab.js
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-05-10 14:21:36 +0200
committerMario Vavti <mario@mariovavti.com>2019-05-10 14:21:36 +0200
commit9866053f0ce44721c11990c9f9407e7428757c99 (patch)
tree6e414efa36c3bda00205918cecb9122f951427e3 /vendor/twbs/bootstrap/js/src/tab.js
parent89a2c1a09c896ac3a23df26a1783f5c682188a56 (diff)
downloadvolse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.tar.gz
volse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.tar.bz2
volse-hubzilla-9866053f0ce44721c11990c9f9407e7428757c99.zip
update bootstrap to version 4.3.1
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/tab.js')
-rw-r--r--vendor/twbs/bootstrap/js/src/tab.js402
1 files changed, 199 insertions, 203 deletions
diff --git a/vendor/twbs/bootstrap/js/src/tab.js b/vendor/twbs/bootstrap/js/src/tab.js
index a91b088de..8421e0a43 100644
--- a/vendor/twbs/bootstrap/js/src/tab.js
+++ b/vendor/twbs/bootstrap/js/src/tab.js
@@ -1,264 +1,260 @@
-import $ from 'jquery'
-import Util from './util'
-
/**
* --------------------------------------------------------------------------
- * Bootstrap (v4.1.3): tab.js
+ * Bootstrap (v4.3.1): tab.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
-const Tab = (($) => {
- /**
- * ------------------------------------------------------------------------
- * Constants
- * ------------------------------------------------------------------------
- */
-
- const NAME = 'tab'
- const VERSION = '4.1.3'
- const DATA_KEY = 'bs.tab'
- const EVENT_KEY = `.${DATA_KEY}`
- const DATA_API_KEY = '.data-api'
- const JQUERY_NO_CONFLICT = $.fn[NAME]
-
- const Event = {
- HIDE : `hide${EVENT_KEY}`,
- HIDDEN : `hidden${EVENT_KEY}`,
- SHOW : `show${EVENT_KEY}`,
- SHOWN : `shown${EVENT_KEY}`,
- CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`
- }
+import $ from 'jquery'
+import Util from './util'
+
+/**
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
+ */
+
+const NAME = 'tab'
+const VERSION = '4.3.1'
+const DATA_KEY = 'bs.tab'
+const EVENT_KEY = `.${DATA_KEY}`
+const DATA_API_KEY = '.data-api'
+const JQUERY_NO_CONFLICT = $.fn[NAME]
+
+const Event = {
+ HIDE : `hide${EVENT_KEY}`,
+ HIDDEN : `hidden${EVENT_KEY}`,
+ SHOW : `show${EVENT_KEY}`,
+ SHOWN : `shown${EVENT_KEY}`,
+ CLICK_DATA_API : `click${EVENT_KEY}${DATA_API_KEY}`
+}
+
+const ClassName = {
+ DROPDOWN_MENU : 'dropdown-menu',
+ ACTIVE : 'active',
+ DISABLED : 'disabled',
+ FADE : 'fade',
+ SHOW : 'show'
+}
+
+const Selector = {
+ DROPDOWN : '.dropdown',
+ NAV_LIST_GROUP : '.nav, .list-group',
+ ACTIVE : '.active',
+ ACTIVE_UL : '> li > .active',
+ DATA_TOGGLE : '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
+ DROPDOWN_TOGGLE : '.dropdown-toggle',
+ DROPDOWN_ACTIVE_CHILD : '> .dropdown-menu .active'
+}
+
+/**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
- const ClassName = {
- DROPDOWN_MENU : 'dropdown-menu',
- ACTIVE : 'active',
- DISABLED : 'disabled',
- FADE : 'fade',
- SHOW : 'show'
+class Tab {
+ constructor(element) {
+ this._element = element
}
- const Selector = {
- DROPDOWN : '.dropdown',
- NAV_LIST_GROUP : '.nav, .list-group',
- ACTIVE : '.active',
- ACTIVE_UL : '> li > .active',
- DATA_TOGGLE : '[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',
- DROPDOWN_TOGGLE : '.dropdown-toggle',
- DROPDOWN_ACTIVE_CHILD : '> .dropdown-menu .active'
+ // Getters
+
+ static get VERSION() {
+ return VERSION
}
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ // Public
- class Tab {
- constructor(element) {
- this._element = element
+ show() {
+ if (this._element.parentNode &&
+ this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
+ $(this._element).hasClass(ClassName.ACTIVE) ||
+ $(this._element).hasClass(ClassName.DISABLED)) {
+ return
}
- // Getters
+ let target
+ let previous
+ const listElement = $(this._element).closest(Selector.NAV_LIST_GROUP)[0]
+ const selector = Util.getSelectorFromElement(this._element)
- static get VERSION() {
- return VERSION
+ if (listElement) {
+ const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? Selector.ACTIVE_UL : Selector.ACTIVE
+ previous = $.makeArray($(listElement).find(itemSelector))
+ previous = previous[previous.length - 1]
}
- // Public
+ const hideEvent = $.Event(Event.HIDE, {
+ relatedTarget: this._element
+ })
- show() {
- if (this._element.parentNode &&
- this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
- $(this._element).hasClass(ClassName.ACTIVE) ||
- $(this._element).hasClass(ClassName.DISABLED)) {
- return
- }
+ const showEvent = $.Event(Event.SHOW, {
+ relatedTarget: previous
+ })
+
+ if (previous) {
+ $(previous).trigger(hideEvent)
+ }
- let target
- let previous
- const listElement = $(this._element).closest(Selector.NAV_LIST_GROUP)[0]
- const selector = Util.getSelectorFromElement(this._element)
+ $(this._element).trigger(showEvent)
- if (listElement) {
- const itemSelector = listElement.nodeName === 'UL' ? Selector.ACTIVE_UL : Selector.ACTIVE
- previous = $.makeArray($(listElement).find(itemSelector))
- previous = previous[previous.length - 1]
- }
+ if (showEvent.isDefaultPrevented() ||
+ hideEvent.isDefaultPrevented()) {
+ return
+ }
+
+ if (selector) {
+ target = document.querySelector(selector)
+ }
+
+ this._activate(
+ this._element,
+ listElement
+ )
- const hideEvent = $.Event(Event.HIDE, {
+ const complete = () => {
+ const hiddenEvent = $.Event(Event.HIDDEN, {
relatedTarget: this._element
})
- const showEvent = $.Event(Event.SHOW, {
+ const shownEvent = $.Event(Event.SHOWN, {
relatedTarget: previous
})
- if (previous) {
- $(previous).trigger(hideEvent)
- }
-
- $(this._element).trigger(showEvent)
+ $(previous).trigger(hiddenEvent)
+ $(this._element).trigger(shownEvent)
+ }
- if (showEvent.isDefaultPrevented() ||
- hideEvent.isDefaultPrevented()) {
- return
- }
+ if (target) {
+ this._activate(target, target.parentNode, complete)
+ } else {
+ complete()
+ }
+ }
- if (selector) {
- target = document.querySelector(selector)
- }
+ dispose() {
+ $.removeData(this._element, DATA_KEY)
+ this._element = null
+ }
- this._activate(
- this._element,
- listElement
- )
+ // Private
+
+ _activate(element, container, callback) {
+ const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL')
+ ? $(container).find(Selector.ACTIVE_UL)
+ : $(container).children(Selector.ACTIVE)
+
+ const active = activeElements[0]
+ const isTransitioning = callback && (active && $(active).hasClass(ClassName.FADE))
+ const complete = () => this._transitionComplete(
+ element,
+ active,
+ callback
+ )
+
+ if (active && isTransitioning) {
+ const transitionDuration = Util.getTransitionDurationFromElement(active)
+
+ $(active)
+ .removeClass(ClassName.SHOW)
+ .one(Util.TRANSITION_END, complete)
+ .emulateTransitionEnd(transitionDuration)
+ } else {
+ complete()
+ }
+ }
- const complete = () => {
- const hiddenEvent = $.Event(Event.HIDDEN, {
- relatedTarget: this._element
- })
+ _transitionComplete(element, active, callback) {
+ if (active) {
+ $(active).removeClass(ClassName.ACTIVE)
- const shownEvent = $.Event(Event.SHOWN, {
- relatedTarget: previous
- })
+ const dropdownChild = $(active.parentNode).find(
+ Selector.DROPDOWN_ACTIVE_CHILD
+ )[0]
- $(previous).trigger(hiddenEvent)
- $(this._element).trigger(shownEvent)
+ if (dropdownChild) {
+ $(dropdownChild).removeClass(ClassName.ACTIVE)
}
- if (target) {
- this._activate(target, target.parentNode, complete)
- } else {
- complete()
+ if (active.getAttribute('role') === 'tab') {
+ active.setAttribute('aria-selected', false)
}
}
- dispose() {
- $.removeData(this._element, DATA_KEY)
- this._element = null
+ $(element).addClass(ClassName.ACTIVE)
+ if (element.getAttribute('role') === 'tab') {
+ element.setAttribute('aria-selected', true)
}
- // Private
-
- _activate(element, container, callback) {
- let activeElements
- if (container.nodeName === 'UL') {
- activeElements = $(container).find(Selector.ACTIVE_UL)
- } else {
- activeElements = $(container).children(Selector.ACTIVE)
- }
-
- const active = activeElements[0]
- const isTransitioning = callback &&
- (active && $(active).hasClass(ClassName.FADE))
-
- const complete = () => this._transitionComplete(
- element,
- active,
- callback
- )
+ Util.reflow(element)
- if (active && isTransitioning) {
- const transitionDuration = Util.getTransitionDurationFromElement(active)
-
- $(active)
- .one(Util.TRANSITION_END, complete)
- .emulateTransitionEnd(transitionDuration)
- } else {
- complete()
- }
+ if (element.classList.contains(ClassName.FADE)) {
+ element.classList.add(ClassName.SHOW)
}
- _transitionComplete(element, active, callback) {
- if (active) {
- $(active).removeClass(`${ClassName.SHOW} ${ClassName.ACTIVE}`)
+ if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {
+ const dropdownElement = $(element).closest(Selector.DROPDOWN)[0]
- const dropdownChild = $(active.parentNode).find(
- Selector.DROPDOWN_ACTIVE_CHILD
- )[0]
+ if (dropdownElement) {
+ const dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector.DROPDOWN_TOGGLE))
- if (dropdownChild) {
- $(dropdownChild).removeClass(ClassName.ACTIVE)
- }
-
- if (active.getAttribute('role') === 'tab') {
- active.setAttribute('aria-selected', false)
- }
- }
-
- $(element).addClass(ClassName.ACTIVE)
- if (element.getAttribute('role') === 'tab') {
- element.setAttribute('aria-selected', true)
+ $(dropdownToggleList).addClass(ClassName.ACTIVE)
}
- Util.reflow(element)
- $(element).addClass(ClassName.SHOW)
-
- if (element.parentNode &&
- $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) {
- const dropdownElement = $(element).closest(Selector.DROPDOWN)[0]
- if (dropdownElement) {
- const dropdownToggleList = [].slice.call(dropdownElement.querySelectorAll(Selector.DROPDOWN_TOGGLE))
- $(dropdownToggleList).addClass(ClassName.ACTIVE)
- }
-
- element.setAttribute('aria-expanded', true)
- }
+ element.setAttribute('aria-expanded', true)
+ }
- if (callback) {
- callback()
- }
+ if (callback) {
+ callback()
}
+ }
- // Static
+ // Static
- static _jQueryInterface(config) {
- return this.each(function () {
- const $this = $(this)
- let data = $this.data(DATA_KEY)
+ static _jQueryInterface(config) {
+ return this.each(function () {
+ const $this = $(this)
+ let data = $this.data(DATA_KEY)
- if (!data) {
- data = new Tab(this)
- $this.data(DATA_KEY, data)
- }
+ if (!data) {
+ data = new Tab(this)
+ $this.data(DATA_KEY, data)
+ }
- if (typeof config === 'string') {
- if (typeof data[config] === 'undefined') {
- throw new TypeError(`No method named "${config}"`)
- }
- data[config]()
+ if (typeof config === 'string') {
+ if (typeof data[config] === 'undefined') {
+ throw new TypeError(`No method named "${config}"`)
}
- })
- }
+ data[config]()
+ }
+ })
}
+}
- /**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
- */
+/**
+ * ------------------------------------------------------------------------
+ * Data Api implementation
+ * ------------------------------------------------------------------------
+ */
- $(document)
- .on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
- event.preventDefault()
- Tab._jQueryInterface.call($(this), 'show')
- })
+$(document)
+ .on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) {
+ event.preventDefault()
+ Tab._jQueryInterface.call($(this), 'show')
+ })
- /**
- * ------------------------------------------------------------------------
- * jQuery
- * ------------------------------------------------------------------------
- */
-
- $.fn[NAME] = Tab._jQueryInterface
- $.fn[NAME].Constructor = Tab
- $.fn[NAME].noConflict = function () {
- $.fn[NAME] = JQUERY_NO_CONFLICT
- return Tab._jQueryInterface
- }
+/**
+ * ------------------------------------------------------------------------
+ * jQuery
+ * ------------------------------------------------------------------------
+ */
- return Tab
-})($)
+$.fn[NAME] = Tab._jQueryInterface
+$.fn[NAME].Constructor = Tab
+$.fn[NAME].noConflict = () => {
+ $.fn[NAME] = JQUERY_NO_CONFLICT
+ return Tab._jQueryInterface
+}
export default Tab