diff options
Diffstat (limited to 'dist/js/bootstrap.js')
-rw-r--r-- | dist/js/bootstrap.js | 6756 |
1 files changed, 2915 insertions, 3841 deletions
diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index b22c41b9ac..6f11dbaced 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -15,4417 +15,3491 @@ if (typeof jQuery === 'undefined') { } }(jQuery); -/** ======================================================================= - * Bootstrap: util.js v4.0.0 - * http://getbootstrap.com/javascript/#alerts - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's private util helper. Adds private util - * helpers for things like accesibility and transitions. These methods are - * shared across all bootstrap plugins. - * ======================================================================== - */ - -'use strict'; - - -/** - * @type {Object} - */ -var Bootstrap = {} - - -/** - * @const - * @type {string} - */ -Bootstrap.TRANSITION_END = 'bsTransitionEnd' - - -/** - * @const - * @type {Object} - */ -Bootstrap.TransitionEndEvent = { - 'WebkitTransition' : 'webkitTransitionEnd', - 'MozTransition' : 'transitionend', - 'OTransition' : 'oTransitionEnd otransitionend', - 'transition' : 'transitionend' -} - - -/** - * @param {Function} childConstructor - * @param {Function} parentConstructor - */ -Bootstrap.inherits = function(childConstructor, parentConstructor) { - /** @constructor */ - function tempConstructor() {} - tempConstructor.prototype = parentConstructor.prototype - childConstructor.prototype = new tempConstructor() - /** @override */ - childConstructor.prototype.constructor = childConstructor -} - - -/** - * @param {Element} element - * @return {string|null} - */ -Bootstrap.getSelectorFromElement = function (element) { - var selector = element.getAttribute('data-target') - - if (!selector) { - selector = element.getAttribute('href') || '' - selector = /^#[a-z]/i.test(selector) ? selector : null - } - - return selector -} - - -/** - * @param {string} prefix - * @return {string} - */ -Bootstrap.getUID = function (prefix) { - do prefix += ~~(Math.random() * 1000000) - while (document.getElementById(prefix)) - return prefix -} - - -/** - * @return {Object} - */ -Bootstrap.getSpecialTransitionEndEvent = function () { - return { - bindType: Bootstrap.transition.end, - delegateType: Bootstrap.transition.end, - handle: /** @param {jQuery.Event} event */ (function (event) { - if ($(event.target).is(this)) { - return event.handleObj.handler.apply(this, arguments) - } - }) - } -} - - -/** - * @param {Element} element - */ -Bootstrap.reflow = function (element) { - new Function('bs',"return bs")(element.offsetHeight) -} - - -/** - * @return {Object|boolean} - */ -Bootstrap.transitionEndTest = function () { - if (window['QUnit']) { - return false - } - - var el = document.createElement('bootstrap') - for (var name in Bootstrap.TransitionEndEvent) { - if (el.style[name] !== undefined) { - return { end: Bootstrap.TransitionEndEvent[name] } - } - } - return false -} - - -/** - * @param {number} duration - * @this {Element} - * @return {Object} - */ -Bootstrap.transitionEndEmulator = function (duration) { - var called = false - - $(this).one(Bootstrap.TRANSITION_END, function () { - called = true - }) - - var callback = function () { - if (!called) { - $(this).trigger(Bootstrap.transition.end) - } - }.bind(this) - - setTimeout(callback, duration) - - return this -} ++function ($) { /** - * ------------------------------------------------------------------------ - * jQuery Interface - * ------------------------------------------------------------------------ - */ - -$.fn.emulateTransitionEnd = Bootstrap.transitionEndEmulator - -$(function () { - Bootstrap.transition = Bootstrap.transitionEndTest() - - if (!Bootstrap.transition) { - return - } - - $.event.special[Bootstrap.TRANSITION_END] = Bootstrap.getSpecialTransitionEndEvent() -}) - -/** ======================================================================= - * Bootstrap: alert.js v4.0.0 - * http://getbootstrap.com/javascript/#alerts - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): util.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's generic alert component. Add dismiss - * functionality to all alert messages with this plugin. - * - * Public Methods & Properties: - * - * + $.alert - * + $.alert.noConflict - * + $.alert.Constructor - * + $.alert.Constructor.VERSION - * + $.alert.Constructor.prototype.close - * - * ======================================================================== + * -------------------------------------------------------------------------- */ 'use strict'; +var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); -/** - * Our Alert class. - * @param {Element=} opt_element - * @constructor - */ -var Alert = function (opt_element) { - if (opt_element) { - $(opt_element).on('click', Alert._DISMISS_SELECTOR, Alert._handleDismiss(this)) - } -} - - -/** - * @const - * @type {string} - */ -Alert['VERSION'] = '4.0.0' - - -/** - * @const - * @type {string} - * @private - */ -Alert._NAME = 'alert' - - -/** - * @const - * @type {string} - * @private - */ -Alert._DATA_KEY = 'bs.alert' - - -/** - * @const - * @type {string} - * @private - */ -Alert._DISMISS_SELECTOR = '[data-dismiss="alert"]' - - -/** - * @const - * @type {number} - * @private - */ -Alert._TRANSITION_DURATION = 150 - - -/** - * @const - * @type {Function} - * @private - */ -Alert._JQUERY_NO_CONFLICT = $.fn[Alert._NAME] - - -/** - * @const - * @enum {string} - * @private - */ -Alert._Event = { - CLOSE : 'close.bs.alert', - CLOSED : 'closed.bs.alert' -} +function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; } +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } -/** - * @const - * @enum {string} - * @private - */ -Alert._ClassName = { - ALERT : 'alert', - FADE : 'fade', - IN : 'in' -} - - -/** - * Provides the jQuery Interface for the alert component. - * @param {string=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -Alert._jQueryInterface = function (opt_config) { - return this.each(function () { - var $this = $(this) - var data = $this.data(Alert._DATA_KEY) - - if (!data) { - data = new Alert(this) - $this.data(Alert._DATA_KEY, data) - } +var Util = (function ($) { - if (opt_config === 'close') { - data[opt_config](this) - } - }) -} + /** + * ------------------------------------------------------------------------ + * Private TransitionEnd Helpers + * ------------------------------------------------------------------------ + */ + var transition = false; -/** - * Close the alert component - * @param {Alert} alertInstance - * @return {Function} - * @private - */ -Alert._handleDismiss = function (alertInstance) { - return function (event) { - if (event) { - event.preventDefault() - } + var TransitionEndEvent = { + WebkitTransition: 'webkitTransitionEnd', + MozTransition: 'transitionend', + OTransition: 'oTransitionEnd otransitionend', + transition: 'transitionend' + }; - alertInstance['close'](this) + // shoutout AngusCroll (https://goo.gl/pxwQGp) + function toType(obj) { + return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); } -} - -/** - * Close the alert component - * @param {Element} element - */ -Alert.prototype['close'] = function (element) { - var rootElement = this._getRootElement(element) - var customEvent = this._triggerCloseEvent(rootElement) - - if (customEvent.isDefaultPrevented()) return - - this._removeElement(rootElement) -} - - -/** - * Tries to get the alert's root element - * @return {Element} - * @private - */ -Alert.prototype._getRootElement = function (element) { - var parent = false - var selector = Bootstrap.getSelectorFromElement(element) - - if (selector) { - parent = $(selector)[0] - } - - if (!parent) { - parent = $(element).closest('.' + Alert._ClassName.ALERT)[0] + function isElement(obj) { + return (obj[0] || obj).nodeType; } - return parent -} - - -/** - * Trigger close event on element - * @return {$.Event} - * @private - */ -Alert.prototype._triggerCloseEvent = function (element) { - var closeEvent = $.Event(Alert._Event.CLOSE) - $(element).trigger(closeEvent) - return closeEvent -} - - -/** - * Trigger closed event and remove element from dom - * @private - */ -Alert.prototype._removeElement = function (element) { - $(element).removeClass(Alert._ClassName.IN) - - if (!Bootstrap.transition || !$(element).hasClass(Alert._ClassName.FADE)) { - this._destroyElement(element) - return - } - - $(element) - .one(Bootstrap.TRANSITION_END, this._destroyElement.bind(this, element)) - .emulateTransitionEnd(Alert._TRANSITION_DURATION) -} - - -/** - * clean up any lingering jquery data and kill element - * @private - */ -Alert.prototype._destroyElement = function (element) { - $(element) - .detach() - .trigger(Alert._Event.CLOSED) - .remove() -} - - -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ - -/** - * @const - * @type {Function} - */ -$.fn[Alert._NAME] = Alert._jQueryInterface - - -/** - * @const - * @type {Function} - */ -$.fn[Alert._NAME]['Constructor'] = Alert - - -/** - * @return {Function} - */ -$.fn[Alert._NAME]['noConflict'] = function () { - $.fn[Alert._NAME] = Alert._JQUERY_NO_CONFLICT - return Alert._jQueryInterface -} - - -/** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - -$(document).on('click.bs.alert.data-api', Alert._DISMISS_SELECTOR, Alert._handleDismiss(new Alert)) - -/** ======================================================================= - * Bootstrap: button.js v4.0.0 - * http://getbootstrap.com/javascript/#buttons - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's generic button component. - * - * Note (@fat): Deprecated "setState" – imo, better solutions for managing a - * buttons state should exist outside this plugin. - * - * Public Methods & Properties: - * - * + $.button - * + $.button.noConflict - * + $.button.Constructor - * + $.button.Constructor.VERSION - * + $.button.Constructor.prototype.toggle - * - * ======================================================================== - */ - -'use strict'; - - -/** - * Our Button class. - * @param {Element!} element - * @constructor - */ -var Button = function (element) { - - /** @private {Element} */ - this._element = element - -} - - -/** - * @const - * @type {string} - */ -Button['VERSION'] = '4.0.0' - - -/** - * @const - * @type {string} - * @private - */ -Button._NAME = 'button' - - -/** - * @const - * @type {string} - * @private - */ -Button._DATA_KEY = 'bs.button' - - -/** - * @const - * @type {Function} - * @private - */ -Button._JQUERY_NO_CONFLICT = $.fn[Button._NAME] - - -/** - * @const - * @enum {string} - * @private - */ -Button._ClassName = { - ACTIVE : 'active', - BUTTON : 'btn', - FOCUS : 'focus' -} - - -/** - * @const - * @enum {string} - * @private - */ -Button._Selector = { - DATA_TOGGLE_CARROT : '[data-toggle^="button"]', - DATA_TOGGLE : '[data-toggle="buttons"]', - INPUT : 'input', - ACTIVE : '.active', - BUTTON : '.btn' -} - - -/** - * Provides the jQuery Interface for the Button component. - * @param {string=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -Button._jQueryInterface = function (opt_config) { - return this.each(function () { - var data = $(this).data(Button._DATA_KEY) - - if (!data) { - data = new Button(this) - $(this).data(Button._DATA_KEY, data) - } - - if (opt_config === 'toggle') { - data[opt_config]() - } - }) -} - - -/** - * Toggle's the button active state - */ -Button.prototype['toggle'] = function () { - var triggerChangeEvent = true - var rootElement = $(this._element).closest(Button._Selector.DATA_TOGGLE)[0] - - if (rootElement) { - var input = $(this._element).find(Button._Selector.INPUT)[0] - if (input) { - if (input.type == 'radio') { - if (input.checked && $(this._element).hasClass(Button._ClassName.ACTIVE)) { - triggerChangeEvent = false - } else { - var activeElement = $(rootElement).find(Button._Selector.ACTIVE)[0] - if (activeElement) { - $(activeElement).removeClass(Button._ClassName.ACTIVE) - } + function getSpecialTransitionEndEvent() { + return { + bindType: transition.end, + delegateType: transition.end, + handle: function handle(event) { + if ($(event.target).is(this)) { + return event.handleObj.handler.apply(this, arguments); } } - - if (triggerChangeEvent) { - input.checked = !$(this._element).hasClass(Button._ClassName.ACTIVE) - $(this._element).trigger('change') - } - } - } else { - this._element.setAttribute('aria-pressed', !$(this._element).hasClass(Button._ClassName.ACTIVE)) - } - - if (triggerChangeEvent) { - $(this._element).toggleClass(Button._ClassName.ACTIVE) + }; } -} - - -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ - -/** - * @const - * @type {Function} - */ -$.fn[Button._NAME] = Button._jQueryInterface - - -/** - * @const - * @type {Function} - */ -$.fn[Button._NAME]['Constructor'] = Button - - -/** - * @const - * @type {Function} - */ -$.fn[Button._NAME]['noConflict'] = function () { - $.fn[Button._NAME] = Button._JQUERY_NO_CONFLICT - return this -} - - -/** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - -$(document) - .on('click.bs.button.data-api', Button._Selector.DATA_TOGGLE_CARROT, function (event) { - event.preventDefault() - - var button = event.target - - if (!$(button).hasClass(Button._ClassName.BUTTON)) { - button = $(button).closest(Button._Selector.BUTTON) - } - - Button._jQueryInterface.call($(button), 'toggle') - }) - .on('focus.bs.button.data-api blur.bs.button.data-api', Button._Selector.DATA_TOGGLE_CARROT, function (event) { - var button = $(event.target).closest(Button._Selector.BUTTON)[0] - $(button).toggleClass(Button._ClassName.FOCUS, /^focus(in)?$/.test(event.type)) - }) - -/** ======================================================================= - * Bootstrap: carousel.js v4.0.0 - * http://getbootstrap.com/javascript/#carousel - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's carousel. A slideshow component for cycling - * through elements, like a carousel. Nested carousels are not supported. - * - * Public Methods & Properties: - * - * + $.carousel - * + $.carousel.noConflict - * + $.carousel.Constructor - * + $.carousel.Constructor.VERSION - * + $.carousel.Constructor.Defaults - * + $.carousel.Constructor.Defaults.interval - * + $.carousel.Constructor.Defaults.pause - * + $.carousel.Constructor.Defaults.wrap - * + $.carousel.Constructor.Defaults.keyboard - * + $.carousel.Constructor.Defaults.slide - * + $.carousel.Constructor.prototype.next - * + $.carousel.Constructor.prototype.prev - * + $.carousel.Constructor.prototype.pause - * + $.carousel.Constructor.prototype.cycle - * - * ======================================================================== - */ - -'use strict'; - - -/** - * Our carousel class. - * @param {Element!} element - * @param {Object=} opt_config - * @constructor - */ -var Carousel = function (element, opt_config) { - - /** @private {Element} */ - this._element = $(element)[0] - - /** @private {Element} */ - this._indicatorsElement = $(this._element).find(Carousel._Selector.INDICATORS)[0] - - /** @private {?Object} */ - this._config = opt_config || null - - /** @private {boolean} */ - this._isPaused = false - - /** @private {boolean} */ - this._isSliding = false - - /** @private {?number} */ - this._interval = null - - /** @private {?Element} */ - this._activeElement = null - - /** @private {?Array} */ - this._items = null - - this._addEventListeners() - -} - - -/** - * @const - * @type {string} - */ -Carousel['VERSION'] = '4.0.0' - - -/** - * @const - * @type {Object} - */ -Carousel['Defaults'] = { - 'interval' : 5000, - 'pause' : 'hover', - 'wrap' : true, - 'keyboard' : true, - 'slide' : false -} - - -/** - * @const - * @type {string} - * @private - */ -Carousel._NAME = 'carousel' - - -/** - * @const - * @type {string} - * @private - */ -Carousel._DATA_KEY = 'bs.carousel' - - -/** - * @const - * @type {number} - * @private - */ -Carousel._TRANSITION_DURATION = 600 - - -/** - * @const - * @enum {string} - * @private - */ -Carousel._Direction = { - NEXT : 'next', - PREVIOUS : 'prev' -} - -/** - * @const - * @enum {string} - * @private - */ -Carousel._Event = { - SLIDE : 'slide.bs.carousel', - SLID : 'slid.bs.carousel' -} - - -/** - * @const - * @enum {string} - * @private - */ -Carousel._ClassName = { - CAROUSEL : 'carousel', - ACTIVE : 'active', - SLIDE : 'slide', - RIGHT : 'right', - LEFT : 'left', - ITEM : 'carousel-item' -} - - -/** - * @const - * @enum {string} - * @private - */ -Carousel._Selector = { - ACTIVE : '.active', - ACTIVE_ITEM : '.active.carousel-item', - ITEM : '.carousel-item', - NEXT_PREV : '.next, .prev', - INDICATORS : '.carousel-indicators' -} - - -/** - * @const - * @type {Function} - * @private - */ -Carousel._JQUERY_NO_CONFLICT = $.fn[Carousel._NAME] - - -/** - * @param {Object=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -Carousel._jQueryInterface = function (opt_config) { - return this.each(function () { - var data = $(this).data(Carousel._DATA_KEY) - var config = $.extend({}, Carousel['Defaults'], $(this).data(), typeof opt_config == 'object' && opt_config) - var action = typeof opt_config == 'string' ? opt_config : config.slide - - if (!data) { - data = new Carousel(this, config) - $(this).data(Carousel._DATA_KEY, data) + function transitionEndTest() { + if (window.QUnit) { + return false; } - if (typeof opt_config == 'number') { - data.to(opt_config) - - } else if (action) { - data[action]() + var el = document.createElement('bootstrap'); - } else if (config.interval) { - data['pause']() - data['cycle']() + for (var name in TransitionEndEvent) { + if (el.style[name] !== undefined) { + return { end: TransitionEndEvent[name] }; + } } - }) -} - - -/** - * Click handler for data api - * @param {Event} event - * @this {Element} - * @private - */ -Carousel._dataApiClickHandler = function (event) { - var selector = Bootstrap.getSelectorFromElement(this) - - if (!selector) { - return - } - - var target = $(selector)[0] - - if (!target || !$(target).hasClass(Carousel._ClassName.CAROUSEL)) { - return - } - - var config = $.extend({}, $(target).data(), $(this).data()) - - var slideIndex = this.getAttribute('data-slide-to') - if (slideIndex) { - config.interval = false - } - - Carousel._jQueryInterface.call($(target), config) - - if (slideIndex) { - $(target).data(Carousel._DATA_KEY).to(slideIndex) - } - - event.preventDefault() -} - - -/** - * Advance the carousel to the next slide - */ -Carousel.prototype['next'] = function () { - if (!this._isSliding) { - this._slide(Carousel._Direction.NEXT) - } -} - - -/** - * Return the carousel to the previous slide - */ -Carousel.prototype['prev'] = function () { - if (!this._isSliding) { - this._slide(Carousel._Direction.PREVIOUS) - } -} - - -/** - * Pause the carousel cycle - * @param {Event=} opt_event - */ -Carousel.prototype['pause'] = function (opt_event) { - if (!opt_event) { - this._isPaused = true - } - - if ($(this._element).find(Carousel._Selector.NEXT_PREV)[0] && Bootstrap.transition) { - $(this._element).trigger(Bootstrap.transition.end) - this['cycle'](true) - } - - clearInterval(this._interval) - this._interval = null -} - - -/** - * Cycle to the next carousel item - * @param {Event|boolean=} opt_event - */ -Carousel.prototype['cycle'] = function (opt_event) { - if (!opt_event) { - this._isPaused = false - } - - if (this._interval) { - clearInterval(this._interval) - this._interval = null - } - - if (this._config['interval'] && !this._isPaused) { - this._interval = setInterval(this['next'].bind(this), this._config['interval']) - } -} - - -/** - * @return {Object} - */ -Carousel.prototype['getConfig'] = function () { - return this._config -} - - -/** - * Move active carousel item to specified index - * @param {number} index - */ -Carousel.prototype.to = function (index) { - this._activeElement = $(this._element).find(Carousel._Selector.ACTIVE_ITEM)[0] - - var activeIndex = this._getItemIndex(this._activeElement) - - if (index > (this._items.length - 1) || index < 0) { - return - } - - if (this._isSliding) { - $(this._element).one(Carousel._Event.SLID, function () { this.to(index) }.bind(this)) - return - } - - if (activeIndex == index) { - this['pause']() - this['cycle']() - return - } - - var direction = index > activeIndex ? - Carousel._Direction.NEXT : - Carousel._Direction.PREVIOUS - - this._slide(direction, this._items[index]) -} - - -/** - * Add event listeners to root element - * @private - */ -Carousel.prototype._addEventListeners = function () { - if (this._config['keyboard']) { - $(this._element).on('keydown.bs.carousel', this._keydown.bind(this)) - } - - if (this._config['pause'] == 'hover' && !('ontouchstart' in document.documentElement)) { - $(this._element) - .on('mouseenter.bs.carousel', this['pause'].bind(this)) - .on('mouseleave.bs.carousel', this['cycle'].bind(this)) - } -} - - -/** - * Keydown handler - * @param {Event} event - * @private - */ -Carousel.prototype._keydown = function (event) { - event.preventDefault() - if (/input|textarea/i.test(event.target.tagName)) return - - switch (event.which) { - case 37: this['prev'](); break - case 39: this['next'](); break - default: return + return false; } -} + function transitionEndEmulator(duration) { + var _this = this; -/** - * Get item index - * @param {Element} element - * @return {number} - * @private - */ -Carousel.prototype._getItemIndex = function (element) { - this._items = $.makeArray($(element).parent().find(Carousel._Selector.ITEM)) + var called = false; - return this._items.indexOf(element) -} + $(this).one(Util.TRANSITION_END, function () { + called = true; + }); + setTimeout(function () { + if (!called) { + Util.triggerTransitionEnd(_this); + } + }, duration); -/** - * Get next displayed item based on direction - * @param {Carousel._Direction} direction - * @param {Element} activeElement - * @return {Element} - * @private - */ -Carousel.prototype._getItemByDirection = function (direction, activeElement) { - var activeIndex = this._getItemIndex(activeElement) - var isGoingToWrap = (direction === Carousel._Direction.PREVIOUS && activeIndex === 0) || - (direction === Carousel._Direction.NEXT && activeIndex == (this._items.length - 1)) - - if (isGoingToWrap && !this._config['wrap']) { - return activeElement + return this; } - var delta = direction == Carousel._Direction.PREVIOUS ? -1 : 1 - var itemIndex = (activeIndex + delta) % this._items.length - - return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex] -} - - -/** - * Trigger slide event on element - * @param {Element} relatedTarget - * @param {Carousel._ClassName} directionalClassname - * @return {$.Event} - * @private - */ -Carousel.prototype._triggerSlideEvent = function (relatedTarget, directionalClassname) { - var slideEvent = $.Event(Carousel._Event.SLIDE, { - relatedTarget: relatedTarget, - direction: directionalClassname - }) - - $(this._element).trigger(slideEvent) - - return slideEvent -} + function setTransitionEndSupport() { + transition = transitionEndTest(); + $.fn.emulateTransitionEnd = transitionEndEmulator; -/** - * Set the active indicator if available - * @param {Element} element - * @private - */ -Carousel.prototype._setActiveIndicatorElement = function (element) { - if (this._indicatorsElement) { - $(this._indicatorsElement) - .find(Carousel._Selector.ACTIVE) - .removeClass(Carousel._ClassName.ACTIVE) - - var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)] - if (nextIndicator) { - $(nextIndicator).addClass(Carousel._ClassName.ACTIVE) + if (Util.supportsTransitionEnd()) { + $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); } } -} + /** + * -------------------------------------------------------------------------- + * Public Util Api + * -------------------------------------------------------------------------- + */ -/** - * Slide the carousel element in a direction - * @param {Carousel._Direction} direction - * @param {Element=} opt_nextElement - */ -Carousel.prototype._slide = function (direction, opt_nextElement) { - var activeElement = $(this._element).find(Carousel._Selector.ACTIVE_ITEM)[0] - var nextElement = opt_nextElement || activeElement && this._getItemByDirection(direction, activeElement) + var Util = { - var isCycling = !!this._interval + TRANSITION_END: 'bsTransitionEnd', - var directionalClassName = direction == Carousel._Direction.NEXT ? - Carousel._ClassName.LEFT : - Carousel._ClassName.RIGHT + getUID: function getUID(prefix) { + do prefix += ~ ~(Math.random() * 1000000); while (document.getElementById(prefix)); + return prefix; + }, - if (nextElement && $(nextElement).hasClass(Carousel._ClassName.ACTIVE)) { - this._isSliding = false - return - } + getSelectorFromElement: function getSelectorFromElement(element) { + var selector = element.getAttribute('data-target'); - var slideEvent = this._triggerSlideEvent(nextElement, directionalClassName) - if (slideEvent.isDefaultPrevented()) { - return - } - - if (!activeElement || !nextElement) { - // some weirdness is happening, so we bail (maybe throw exception here alerting user that they're dom is off - return - } - - this._isSliding = true - - if (isCycling) { - this['pause']() - } - - this._setActiveIndicatorElement(nextElement) - - var slidEvent = $.Event(Carousel._Event.SLID, { relatedTarget: nextElement, direction: directionalClassName }) - - if (Bootstrap.transition && $(this._element).hasClass(Carousel._ClassName.SLIDE)) { - $(nextElement).addClass(direction) - - Bootstrap.reflow(nextElement) - - $(activeElement).addClass(directionalClassName) - $(nextElement).addClass(directionalClassName) - - $(activeElement) - .one(Bootstrap.TRANSITION_END, function () { - $(nextElement) - .removeClass(directionalClassName) - .removeClass(direction) - - $(nextElement).addClass(Carousel._ClassName.ACTIVE) - - $(activeElement) - .removeClass(Carousel._ClassName.ACTIVE) - .removeClass(direction) - .removeClass(directionalClassName) - - this._isSliding = false - - setTimeout(function () { - $(this._element).trigger(slidEvent) - }.bind(this), 0) - }.bind(this)) - .emulateTransitionEnd(Carousel._TRANSITION_DURATION) + if (!selector) { + selector = element.getAttribute('href') || ''; + selector = /^#[a-z]/i.test(selector) ? selector : null; + } - } else { - $(activeElement).removeClass(Carousel._ClassName.ACTIVE) - $(nextElement).addClass(Carousel._ClassName.ACTIVE) + return selector; + }, - this._isSliding = false - $(this._element).trigger(slidEvent) - } + reflow: function reflow(element) { + new Function('bs', 'return bs')(element.offsetHeight); + }, - if (isCycling) { - this['cycle']() - } -} + triggerTransitionEnd: function triggerTransitionEnd(element) { + $(element).trigger(transition.end); + }, + supportsTransitionEnd: function supportsTransitionEnd() { + return !!transition; + }, -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ + typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { -/** - * @const - * @type {Function} - */ -$.fn[Carousel._NAME] = Carousel._jQueryInterface + for (var property in configTypes) { + var expectedTypes = configTypes[property]; + var value = config[property]; + var valueType = undefined; + if (value && isElement(value)) valueType = 'element';else valueType = toType(value); -/** - * @const - * @type {Function} - */ -$.fn[Carousel._NAME]['Constructor'] = Carousel + if (!new RegExp(expectedTypes).test(valueType)) { + throw new Error('' + componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".')); + } + } + } + }; -/** - * @const - * @type {Function} - */ -$.fn[Carousel._NAME]['noConflict'] = function () { - $.fn[Carousel._NAME] = Carousel._JQUERY_NO_CONFLICT - return this -} + setTransitionEndSupport(); + return Util; +})(jQuery); /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - -$(document) - .on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', Carousel._dataApiClickHandler) - -$(window).on('load', function () { - $('[data-ride="carousel"]').each(function () { - var $carousel = $(this) - Carousel._jQueryInterface.call($carousel, /** @type {Object} */ ($carousel.data())) - }) -}) - -/** ======================================================================= - * Bootstrap: collapse.js v4.0.0 - * http://getbootstrap.com/javascript/#collapse - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's collapse plugin. Flexible support for - * collapsible components like accordions and navigation. - * - * Public Methods & Properties: - * - * + $.carousel - * + $.carousel.noConflict - * + $.carousel.Constructor - * + $.carousel.Constructor.VERSION - * + $.carousel.Constructor.Defaults - * + $.carousel.Constructor.Defaults.toggle - * + $.carousel.Constructor.Defaults.trigger - * + $.carousel.Constructor.Defaults.parent - * + $.carousel.Constructor.prototype.toggle - * + $.carousel.Constructor.prototype.show - * + $.carousel.Constructor.prototype.hide - * - * ======================================================================== - */ - -'use strict'; - - -/** - * Our collapse class. - * @param {Element!} element - * @param {Object=} opt_config - * @constructor - */ -var Collapse = function (element, opt_config) { - - /** @private {Element} */ - this._element = element - - /** @private {Object} */ - this._config = $.extend({}, Collapse['Defaults'], opt_config) - - /** @private {Element} */ - this._trigger = typeof this._config['trigger'] == 'string' ? - $(this._config['trigger'])[0] : this._config['trigger'] - - /** @private {boolean} */ - this._isTransitioning = false - - /** @private {?Element} */ - this._parent = this._config['parent'] ? this._getParent() : null - - if (!this._config['parent']) { - this._addAriaAndCollapsedClass(this._element, this._trigger) - } - - if (this._config['toggle']) { - this['toggle']() - } - -} - - -/** - * @const - * @type {string} - */ -Collapse['VERSION'] = '4.0.0' - - -/** - * @const - * @type {Object} - */ -Collapse['Defaults'] = { - 'toggle' : true, - 'trigger' : '[data-toggle="collapse"]', - 'parent' : null -} - - -/** - * @const - * @type {string} - * @private - */ -Collapse._NAME = 'collapse' - - -/** - * @const - * @type {string} - * @private - */ -Collapse._DATA_KEY = 'bs.collapse' - - -/** - * @const - * @type {number} - * @private - */ -Collapse._TRANSITION_DURATION = 600 - - -/** - * @const - * @type {Function} - * @private + * -------------------------------------------------------------------------- */ -Collapse._JQUERY_NO_CONFLICT = $.fn[Collapse._NAME] - -/** - * @const - * @enum {string} - * @private - */ -Collapse._Event = { - SHOW : 'show.bs.collapse', - SHOWN : 'shown.bs.collapse', - HIDE : 'hide.bs.collapse', - HIDDEN : 'hidden.bs.collapse' -} +var Alert = (function ($) { + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ -/** - * @const - * @enum {string} - * @private - */ -Collapse._ClassName = { - IN : 'in', - COLLAPSE : 'collapse', - COLLAPSING : 'collapsing', - COLLAPSED : 'collapsed' -} - - -/** - * @const - * @enum {string} - * @private - */ -Collapse._Dimension = { - WIDTH : 'width', - HEIGHT : 'height' -} + var NAME = 'alert'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.alert'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + var Selector = { + DISMISS: '[data-dismiss="alert"]' + }; -/** - * @const - * @enum {string} - * @private - */ -Collapse._Selector = { - ACTIVES : '.panel > .in, .panel > .collapsing' -} + var Event = { + CLOSE: 'close' + EVENT_KEY, + CLOSED: 'closed' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY + }; + var ClassName = { + ALERT: 'alert', + FADE: 'fade', + IN: 'in' + }; -/** - * Provides the jQuery Interface for the alert component. - * @param {Object|string=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -Collapse._jQueryInterface = function (opt_config) { - return this.each(function () { - var $this = $(this) - var data = $this.data(Collapse._DATA_KEY) - var config = $.extend({}, Collapse['Defaults'], $this.data(), typeof opt_config == 'object' && opt_config) - - if (!data && config['toggle'] && opt_config == 'show') { - config['toggle'] = false - } + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ - if (!data) { - data = new Collapse(this, config) - $this.data(Collapse._DATA_KEY, data) - } + var Alert = (function () { + function Alert(element) { + _classCallCheck(this, Alert); - if (typeof opt_config == 'string') { - data[opt_config]() + this._element = element; } - }) -} + _createClass(Alert, [{ + key: 'close', -/** - * Function for getting target element from element - * @return {Element} - * @private - */ -Collapse._getTargetFromElement = function (element) { - var selector = Bootstrap.getSelectorFromElement(element) + // public - return selector ? $(selector)[0] : null -} + value: function close(element) { + element = element || this._element; + var rootElement = this._getRootElement(element); + var customEvent = this._triggerCloseEvent(rootElement); -/** - * Toggles the collapse element based on the presence of the 'in' class - */ -Collapse.prototype['toggle'] = function () { - if ($(this._element).hasClass(Collapse._ClassName.IN)) { - this['hide']() - } else { - this['show']() - } -} - + if (customEvent.isDefaultPrevented()) { + return; + } -/** - * Show's the collapsing element - */ -Collapse.prototype['show'] = function () { - if (this._isTransitioning || $(this._element).hasClass(Collapse._ClassName.IN)) { - return - } + this._removeElement(rootElement); + } + }, { + key: 'dispose', + value: function dispose() { + $.removeData(this._element, DATA_KEY); + this._element = null; + } + }, { + key: '_getRootElement', - var activesData, actives + // private - if (this._parent) { - actives = $.makeArray($(Collapse._Selector.ACTIVES)) - if (!actives.length) { - actives = null - } - } + value: function _getRootElement(element) { + var parent = false; + var selector = Util.getSelectorFromElement(element); - if (actives) { - activesData = $(actives).data(Collapse._DATA_KEY) - if (activesData && activesData._isTransitioning) { - return - } - } + if (selector) { + parent = $(selector)[0]; + } - var startEvent = $.Event(Collapse._Event.SHOW) - $(this._element).trigger(startEvent) - if (startEvent.isDefaultPrevented()) { - return - } + if (!parent) { + parent = $(element).closest('.' + ClassName.ALERT)[0]; + } - if (actives) { - Collapse._jQueryInterface.call($(actives), 'hide') - if (!activesData) { - $(actives).data(Collapse._DATA_KEY, null) - } - } + return parent; + } + }, { + key: '_triggerCloseEvent', + value: function _triggerCloseEvent(element) { + var closeEvent = $.Event(Event.CLOSE); + $(element).trigger(closeEvent); + return closeEvent; + } + }, { + key: '_removeElement', + value: function _removeElement(element) { + $(element).removeClass(ClassName.IN); + + if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { + this._destroyElement(element); + return; + } - var dimension = this._getDimension() + $(element).one(Util.TRANSITION_END, this._destroyElement.bind(this, element)).emulateTransitionEnd(TRANSITION_DURATION); + } + }, { + key: '_destroyElement', + value: function _destroyElement(element) { + $(element).detach().trigger(Event.CLOSED).remove(); + } + }], [{ + key: 'VERSION', - $(this._element) - .removeClass(Collapse._ClassName.COLLAPSE) - .addClass(Collapse._ClassName.COLLAPSING) + // getters - this._element.style[dimension] = 0 - this._element.setAttribute('aria-expanded', true) + get: function () { + return VERSION; + } + }, { + key: '_jQueryInterface', - if (this._trigger) { - $(this._trigger).removeClass(Collapse._ClassName.COLLAPSED) - this._trigger.setAttribute('aria-expanded', true) - } + // static - this['setTransitioning'](true) + value: function _jQueryInterface(config) { + return this.each(function () { + var $element = $(this); + var data = $element.data(DATA_KEY); - var complete = function () { - $(this._element) - .removeClass(Collapse._ClassName.COLLAPSING) - .addClass(Collapse._ClassName.COLLAPSE) - .addClass(Collapse._ClassName.IN) + if (!data) { + data = new Alert(this); + $element.data(DATA_KEY, data); + } - this._element.style[dimension] = '' + if (config === 'close') { + data[config](this); + } + }); + } + }, { + key: '_handleDismiss', + value: function _handleDismiss(alertInstance) { + return function (event) { + if (event) { + event.preventDefault(); + } - this['setTransitioning'](false) + alertInstance.close(this); + }; + } + }]); - $(this._element).trigger(Collapse._Event.SHOWN) - }.bind(this) + return Alert; + })(); - if (!Bootstrap.transition) { - complete() - return - } + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - var scrollSize = 'scroll' + (dimension[0].toUpperCase() + dimension.slice(1)) + $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); - $(this._element) - .one(Bootstrap.TRANSITION_END, complete) - .emulateTransitionEnd(Collapse._TRANSITION_DURATION) + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ - this._element.style[dimension] = this._element[scrollSize] + 'px' -} + $.fn[NAME] = Alert._jQueryInterface; + $.fn[NAME].Constructor = Alert; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Alert._jQueryInterface; + }; + return Alert; +})(jQuery); /** - * Hides's the collapsing element - */ -Collapse.prototype['hide'] = function () { - if (this._isTransitioning || !$(this._element).hasClass(Collapse._ClassName.IN)) { - return - } - - var startEvent = $.Event(Collapse._Event.HIDE) - $(this._element).trigger(startEvent) - if (startEvent.isDefaultPrevented()) return - - var dimension = this._getDimension() - var offsetDimension = dimension === Collapse._Dimension.WIDTH ? - 'offsetWidth' : 'offsetHeight' - - this._element.style[dimension] = this._element[offsetDimension] + 'px' - - Bootstrap.reflow(this._element) - - $(this._element) - .addClass(Collapse._ClassName.COLLAPSING) - .removeClass(Collapse._ClassName.COLLAPSE) - .removeClass(Collapse._ClassName.IN) - - this._element.setAttribute('aria-expanded', false) - - if (this._trigger) { - $(this._trigger).addClass(Collapse._ClassName.COLLAPSED) - this._trigger.setAttribute('aria-expanded', false) - } - - this['setTransitioning'](true) - - var complete = function () { - this['setTransitioning'](false) - $(this._element) - .removeClass(Collapse._ClassName.COLLAPSING) - .addClass(Collapse._ClassName.COLLAPSE) - .trigger(Collapse._Event.HIDDEN) - - }.bind(this) - - this._element.style[dimension] = 0 - - if (!Bootstrap.transition) { - return complete() - } + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): button.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Button = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'button'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.button'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + + var ClassName = { + ACTIVE: 'active', + BUTTON: 'btn', + FOCUS: 'focus' + }; + + var Selector = { + DATA_TOGGLE_CARROT: '[data-toggle^="button"]', + DATA_TOGGLE: '[data-toggle="buttons"]', + INPUT: 'input', + ACTIVE: '.active', + BUTTON: '.btn' + }; + + var Event = { + CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY, + FOCUS_BLUR_DATA_API: 'focus' + EVENT_KEY + '' + DATA_API_KEY + ' ' + ('blur' + EVENT_KEY + '' + DATA_API_KEY) + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Button = (function () { + function Button(element) { + _classCallCheck(this, Button); + + this._element = element; + } + + _createClass(Button, [{ + key: 'toggle', + + // public + + value: function toggle() { + var triggerChangeEvent = true; + var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0]; + + if (rootElement) { + var input = $(this._element).find(Selector.INPUT)[0]; + + if (input) { + if (input.type === 'radio') { + if (input.checked && $(this._element).hasClass(ClassName.ACTIVE)) { + triggerChangeEvent = false; + } else { + var activeElement = $(rootElement).find(Selector.ACTIVE)[0]; + + if (activeElement) { + $(activeElement).removeClass(ClassName.ACTIVE); + } + } + } + + if (triggerChangeEvent) { + input.checked = !$(this._element).hasClass(ClassName.ACTIVE); + $(this._element).trigger('change'); + } + } + } else { + this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE)); + } - $(this._element) - .one(Bootstrap.TRANSITION_END, complete) - .emulateTransitionEnd(Collapse._TRANSITION_DURATION) -} + if (triggerChangeEvent) { + $(this._element).toggleClass(ClassName.ACTIVE); + } + } + }, { + key: 'dispose', + value: function dispose() { + $.removeData(this._element, DATA_KEY); + this._element = null; + } + }], [{ + key: 'VERSION', + // getters + get: function () { + return VERSION; + } + }, { + key: '_jQueryInterface', -/** - * @param {boolean} isTransitioning - */ -Collapse.prototype['setTransitioning'] = function (isTransitioning) { - this._isTransitioning = isTransitioning -} + // static + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); -/** - * Returns the collapsing dimension - * @return {string} - * @private - */ -Collapse.prototype._getDimension = function () { - var hasWidth = $(this._element).hasClass(Collapse._Dimension.WIDTH) - return hasWidth ? Collapse._Dimension.WIDTH : Collapse._Dimension.HEIGHT -} + if (!data) { + data = new Button(this); + $(this).data(DATA_KEY, data); + } + if (config === 'toggle') { + data[config](); + } + }); + } + }]); -/** - * Returns the parent element - * @return {Element} - * @private - */ -Collapse.prototype._getParent = function () { - var selector = '[data-toggle="collapse"][data-parent="' + this._config['parent'] + '"]' - var parent = $(this._config['parent'])[0] - var elements = /** @type {Array.<Element>} */ ($.makeArray($(parent).find(selector))) + return Button; + })(); - for (var i = 0; i < elements.length; i++) { - this._addAriaAndCollapsedClass(Collapse._getTargetFromElement(elements[i]), elements[i]) - } + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - return parent -} + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { + event.preventDefault(); + var button = event.target; -/** - * Returns the parent element - * @param {Element} element - * @param {Element} trigger - * @private - */ -Collapse.prototype._addAriaAndCollapsedClass = function (element, trigger) { - if (element) { - var isOpen = $(element).hasClass(Collapse._ClassName.IN) - element.setAttribute('aria-expanded', isOpen) - - if (trigger) { - trigger.setAttribute('aria-expanded', isOpen) - $(trigger).toggleClass(Collapse._ClassName.COLLAPSED, !isOpen) + if (!$(button).hasClass(ClassName.BUTTON)) { + button = $(button).closest(Selector.BUTTON); } - } -} + Button._jQueryInterface.call($(button), 'toggle'); + }).on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { + var button = $(event.target).closest(Selector.BUTTON)[0]; + $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)); + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ - -/** - * @const - * @type {Function} - */ -$.fn[Collapse._NAME] = Collapse._jQueryInterface - - -/** - * @const - * @type {Function} - */ -$.fn[Collapse._NAME]['Constructor'] = Collapse - - -/** - * @const - * @type {Function} - */ -$.fn[Collapse._NAME]['noConflict'] = function () { - $.fn[Collapse._NAME] = Collapse._JQUERY_NO_CONFLICT - return this -} + $.fn[NAME] = Button._jQueryInterface; + $.fn[NAME].Constructor = Button; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Button._jQueryInterface; + }; + return Button; +})(jQuery); /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - -$(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (event) { - event.preventDefault() - - var target = Collapse._getTargetFromElement(this) - - var data = $(target).data(Collapse._DATA_KEY) - var config = data ? 'toggle' : $.extend({}, $(this).data(), { trigger: this }) - - Collapse._jQueryInterface.call($(target), config) -}) - -/** ======================================================================= - * Bootstrap: dropdown.js v4.0.0 - * http://getbootstrap.com/javascript/#dropdown - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Add dropdown menus to nearly anything with this simple - * plugin, including the navbar, tabs, and pills. - * - * Public Methods & Properties: - * - * + $.dropdown - * + $.dropdown.noConflict - * + $.dropdown.Constructor - * + $.dropdown.Constructor.VERSION - * + $.dropdown.Constructor.prototype.toggle - * - * ======================================================================== - */ - -'use strict'; - - -/** - * Our dropdown class. - * @param {Element!} element - * @constructor - */ -var Dropdown = function (element) { - $(element).on('click.bs.dropdown', this['toggle']) -} + * -------------------------------------------------------------------------- + */ + +var Carousel = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'carousel'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.carousel'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 600; + + var Default = { + interval: 5000, + keyboard: true, + slide: false, + pause: 'hover', + wrap: true + }; + + var DefaultType = { + interval: '(number|boolean)', + keyboard: 'boolean', + slide: '(boolean|string)', + pause: '(string|boolean)', + wrap: 'boolean' + }; + + var Direction = { + NEXT: 'next', + PREVIOUS: 'prev' + }; + + var Event = { + SLIDE: 'slide' + EVENT_KEY, + SLID: 'slid' + EVENT_KEY, + KEYDOWN: 'keydown' + EVENT_KEY, + MOUSEENTER: 'mouseenter' + EVENT_KEY, + MOUSELEAVE: 'mouseleave' + EVENT_KEY, + LOAD_DATA_API: 'load' + EVENT_KEY + '' + DATA_API_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY + }; + + var ClassName = { + CAROUSEL: 'carousel', + ACTIVE: 'active', + SLIDE: 'slide', + RIGHT: 'right', + LEFT: 'left', + ITEM: 'carousel-item' + }; + + var Selector = { + ACTIVE: '.active', + ACTIVE_ITEM: '.active.carousel-item', + ITEM: '.carousel-item', + NEXT_PREV: '.next, .prev', + INDICATORS: '.carousel-indicators', + DATA_SLIDE: '[data-slide], [data-slide-to]', + DATA_RIDE: '[data-ride="carousel"]' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Carousel = (function () { + function Carousel(element, config) { + _classCallCheck(this, Carousel); + + this._items = null; + this._interval = null; + this._activeElement = null; + + this._isPaused = false; + this._isSliding = false; + + this._config = this._getConfig(config); + this._element = $(element)[0]; + this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0]; + + this._addEventListeners(); + } + + _createClass(Carousel, [{ + key: 'next', + + // public + + value: function next() { + if (!this._isSliding) { + this._slide(Direction.NEXT); + } + } + }, { + key: 'prev', + value: function prev() { + if (!this._isSliding) { + this._slide(Direction.PREVIOUS); + } + } + }, { + key: 'pause', + value: function pause(event) { + if (!event) { + this._isPaused = true; + } + if ($(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) { + Util.triggerTransitionEnd(this._element); + this.cycle(true); + } -/** - * @const - * @type {string} - */ -Dropdown['VERSION'] = '4.0.0' + clearInterval(this._interval); + this._interval = null; + } + }, { + key: 'cycle', + value: function cycle(event) { + if (!event) { + this._isPaused = false; + } + if (this._interval) { + clearInterval(this._interval); + this._interval = null; + } -/** - * @const - * @type {string} - * @private - */ -Dropdown._NAME = 'dropdown' + if (this._config.interval && !this._isPaused) { + this._interval = setInterval($.proxy(this.next, this), this._config.interval); + } + } + }, { + key: 'to', + value: function to(index) { + var _this2 = this; + this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; -/** - * @const - * @type {string} - * @private - */ -Dropdown._DATA_KEY = 'bs.dropdown' + var activeIndex = this._getItemIndex(this._activeElement); + if (index > this._items.length - 1 || index < 0) { + return; + } -/** - * @const - * @type {Function} - * @private - */ -Dropdown._JQUERY_NO_CONFLICT = $.fn[Dropdown._NAME] + if (this._isSliding) { + $(this._element).one(Event.SLID, function () { + return _this2.to(index); + }); + return; + } + if (activeIndex == index) { + this.pause(); + this.cycle(); + return; + } -/** - * @const - * @enum {string} - * @private - */ -Dropdown._Event = { - HIDE : 'hide.bs.dropdown', - HIDDEN : 'hidden.bs.dropdown', - SHOW : 'show.bs.dropdown', - SHOWN : 'shown.bs.dropdown' -} + var direction = index > activeIndex ? Direction.NEXT : Direction.PREVIOUS; + this._slide(direction, this._items[index]); + } + }, { + key: 'dispose', + value: function dispose() { + $(this._element).off(EVENT_KEY); + $.removeData(this._element, DATA_KEY); + + this._items = null; + this._config = null; + this._element = null; + this._interval = null; + this._isPaused = null; + this._isSliding = null; + this._activeElement = null; + this._indicatorsElement = null; + } + }, { + key: '_getConfig', -/** - * @const - * @enum {string} - * @private - */ -Dropdown._ClassName = { - BACKDROP : 'dropdown-backdrop', - DISABLED : 'disabled', - OPEN : 'open' -} + // private + value: function _getConfig(config) { + config = $.extend({}, Default, config); + Util.typeCheckConfig(NAME, config, DefaultType); + return config; + } + }, { + key: '_addEventListeners', + value: function _addEventListeners() { + if (this._config.keyboard) { + $(this._element).on(Event.KEYDOWN, $.proxy(this._keydown, this)); + } -/** - * @const - * @enum {string} - * @private - */ -Dropdown._Selector = { - BACKDROP : '.dropdown-backdrop', - DATA_TOGGLE : '[data-toggle="dropdown"]', - FORM_CHILD : '.dropdown form', - ROLE_MENU : '[role="menu"]', - ROLE_LISTBOX : '[role="listbox"]', - NAVBAR_NAV : '.navbar-nav', - VISIBLE_ITEMS : '[role="menu"] li:not(.divider) a, [role="listbox"] li:not(.divider) a' -} + if (this._config.pause == 'hover' && !('ontouchstart' in document.documentElement)) { + $(this._element).on(Event.MOUSEENTER, $.proxy(this.pause, this)).on(Event.MOUSELEAVE, $.proxy(this.cycle, this)); + } + } + }, { + key: '_keydown', + value: function _keydown(event) { + event.preventDefault(); + + if (/input|textarea/i.test(event.target.tagName)) return; + + switch (event.which) { + case 37: + this.prev();break; + case 39: + this.next();break; + default: + return; + } + } + }, { + key: '_getItemIndex', + value: function _getItemIndex(element) { + this._items = $.makeArray($(element).parent().find(Selector.ITEM)); + return this._items.indexOf(element); + } + }, { + key: '_getItemByDirection', + value: function _getItemByDirection(direction, activeElement) { + var isNextDirection = direction === Direction.NEXT; + var isPrevDirection = direction === Direction.PREVIOUS; + var activeIndex = this._getItemIndex(activeElement); + var lastItemIndex = this._items.length - 1; + var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex == lastItemIndex; + + if (isGoingToWrap && !this._config.wrap) { + return activeElement; + } + var delta = direction == Direction.PREVIOUS ? -1 : 1; + var itemIndex = (activeIndex + delta) % this._items.length; -/** - * Provides the jQuery Interface for the alert component. - * @param {string=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -Dropdown._jQueryInterface = function (opt_config) { - return this.each(function () { - var data = $(this).data(Dropdown._DATA_KEY) + return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; + } + }, { + key: '_triggerSlideEvent', + value: function _triggerSlideEvent(relatedTarget, directionalClassname) { + var slideEvent = $.Event(Event.SLIDE, { + relatedTarget: relatedTarget, + direction: directionalClassname + }); - if (!data) { - $(this).data(Dropdown._DATA_KEY, (data = new Dropdown(this))) - } + $(this._element).trigger(slideEvent); - if (typeof opt_config === 'string') { - data[opt_config].call(this) - } - }) -} + return slideEvent; + } + }, { + key: '_setActiveIndicatorElement', + value: function _setActiveIndicatorElement(element) { + if (this._indicatorsElement) { + $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE); + var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; -/** - * @param {Event=} opt_event - * @private - */ -Dropdown._clearMenus = function (opt_event) { - if (opt_event && opt_event.which == 3) { - return - } + if (nextIndicator) { + $(nextIndicator).addClass(ClassName.ACTIVE); + } + } + } + }, { + key: '_slide', + value: function _slide(direction, element) { + var _this3 = this; - var backdrop = $(Dropdown._Selector.BACKDROP)[0] - if (backdrop) { - backdrop.parentNode.removeChild(backdrop) - } + var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; + var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); - var toggles = /** @type {Array.<Element>} */ ($.makeArray($(Dropdown._Selector.DATA_TOGGLE))) + var isCycling = !!this._interval; - for (var i = 0; i < toggles.length; i++) { - var parent = Dropdown._getParentFromElement(toggles[i]) - var relatedTarget = { 'relatedTarget': toggles[i] } + var directionalClassName = direction == Direction.NEXT ? ClassName.LEFT : ClassName.RIGHT; - if (!$(parent).hasClass(Dropdown._ClassName.OPEN)) { - continue - } + if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) { + this._isSliding = false; + return; + } - var hideEvent = $.Event(Dropdown._Event.HIDE, relatedTarget) - $(parent).trigger(hideEvent) - if (hideEvent.isDefaultPrevented()) { - continue - } + var slideEvent = this._triggerSlideEvent(nextElement, directionalClassName); + if (slideEvent.isDefaultPrevented()) { + return; + } - toggles[i].setAttribute('aria-expanded', 'false') + if (!activeElement || !nextElement) { + // some weirdness is happening, so we bail + return; + } - $(parent) - .removeClass(Dropdown._ClassName.OPEN) - .trigger(Dropdown._Event.HIDDEN, relatedTarget) - } -} + this._isSliding = true; + if (isCycling) { + this.pause(); + } -/** - * @param {Element} element - * @return {Element} - * @private - */ -Dropdown._getParentFromElement = function (element) { - var selector = Bootstrap.getSelectorFromElement(element) + this._setActiveIndicatorElement(nextElement); - if (selector) { - var parent = $(selector)[0] - } + var slidEvent = $.Event(Event.SLID, { + relatedTarget: nextElement, + direction: directionalClassName + }); - return /** @type {Element} */ (parent || element.parentNode) -} + if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) { + $(nextElement).addClass(direction); -/** - * @param {Event} event - * @this {Element} - * @private - */ -Dropdown._dataApiKeydownHandler = function (event) { - if (!/(38|40|27|32)/.test(event.which) || /input|textarea/i.test(event.target.tagName)) { - return - } + Util.reflow(nextElement); - event.preventDefault() - event.stopPropagation() + $(activeElement).addClass(directionalClassName); + $(nextElement).addClass(directionalClassName); - if (this.disabled || $(this).hasClass(Dropdown._ClassName.DISABLED)) { - return - } + $(activeElement).one(Util.TRANSITION_END, function () { + $(nextElement).removeClass(directionalClassName).removeClass(direction); - var parent = Dropdown._getParentFromElement(this) - var isActive = $(parent).hasClass(Dropdown._ClassName.OPEN) + $(nextElement).addClass(ClassName.ACTIVE); - if ((!isActive && event.which != 27) || (isActive && event.which == 27)) { - if (event.which == 27) { - var toggle = $(parent).find(Dropdown._Selector.DATA_TOGGLE)[0] - $(toggle).trigger('focus') - } - $(this).trigger('click') - return - } + $(activeElement).removeClass(ClassName.ACTIVE).removeClass(direction).removeClass(directionalClassName); - var items = $.makeArray($(Dropdown._Selector.VISIBLE_ITEMS)) + _this3._isSliding = false; - items = items.filter(function (item) { - return item.offsetWidth || item.offsetHeight - }) + setTimeout(function () { + return $(_this3._element).trigger(slidEvent); + }, 0); + }).emulateTransitionEnd(TRANSITION_DURATION); + } else { + $(activeElement).removeClass(ClassName.ACTIVE); + $(nextElement).addClass(ClassName.ACTIVE); - if (!items.length) { - return - } + this._isSliding = false; + $(this._element).trigger(slidEvent); + } - var index = items.indexOf(event.target) + if (isCycling) { + this.cycle(); + } + } + }], [{ + key: 'VERSION', - if (event.which == 38 && index > 0) index-- // up - if (event.which == 40 && index < items.length - 1) index++ // down - if (!~index) index = 0 + // getters - items[index].focus() -} + get: function () { + return VERSION; + } + }, { + key: 'Default', + get: function () { + return Default; + } + }, { + key: '_jQueryInterface', + // static -/** - * Toggles the dropdown - * @this {Element} - * @return {boolean|undefined} - */ -Dropdown.prototype['toggle'] = function () { - if (this.disabled || $(this).hasClass(Dropdown._ClassName.DISABLED)) { - return - } + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = $.extend({}, Default, $(this).data()); - var parent = Dropdown._getParentFromElement(this) - var isActive = $(parent).hasClass(Dropdown._ClassName.OPEN) + if (typeof config === 'object') { + $.extend(_config, config); + } - Dropdown._clearMenus() + var action = typeof config === 'string' ? config : _config.slide; - if (isActive) { - return false - } + if (!data) { + data = new Carousel(this, _config); + $(this).data(DATA_KEY, data); + } - if ('ontouchstart' in document.documentElement && !$(parent).closest(Dropdown._Selector.NAVBAR_NAV).length) { - // if mobile we use a backdrop because click events don't delegate - var dropdown = document.createElement('div') - dropdown.className = Dropdown._ClassName.BACKDROP - this.parentNode.insertBefore(this, dropdown) - $(dropdown).on('click', Dropdown._clearMenus) - } + if (typeof config == 'number') { + data.to(config); + } else if (action) { + data[action](); + } else if (_config.interval) { + data.pause(); + data.cycle(); + } + }); + } + }, { + key: '_dataApiClickHandler', + value: function _dataApiClickHandler(event) { + var selector = Util.getSelectorFromElement(this); - var relatedTarget = { 'relatedTarget': this } - var showEvent = $.Event(Dropdown._Event.SHOW, relatedTarget) + if (!selector) { + return; + } - $(parent).trigger(showEvent) + var target = $(selector)[0]; - if (showEvent.isDefaultPrevented()) { - return - } + if (!target || !$(target).hasClass(ClassName.CAROUSEL)) { + return; + } - this.focus() - this.setAttribute('aria-expanded', 'true') + var config = $.extend({}, $(target).data(), $(this).data()); - $(parent).toggleClass(Dropdown._ClassName.OPEN) + var slideIndex = this.getAttribute('data-slide-to'); + if (slideIndex) { + config.interval = false; + } - $(parent).trigger(Dropdown._Event.SHOWN, relatedTarget) + Carousel._jQueryInterface.call($(target), config); - return false -} + if (slideIndex) { + $(target).data(DATA_KEY).to(slideIndex); + } + event.preventDefault(); + } + }]); -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ + return Carousel; + })(); -/** - * @const - * @type {Function} - */ -$.fn[Dropdown._NAME] = Dropdown._jQueryInterface + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler); -/** - * @const - * @type {Function} - */ -$.fn[Dropdown._NAME]['Constructor'] = Dropdown + $(window).on(Event.LOAD_DATA_API, function () { + $(Selector.DATA_RIDE).each(function () { + var $carousel = $(this); + Carousel._jQueryInterface.call($carousel, $carousel.data()); + }); + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ -/** - * @const - * @type {Function} - */ -$.fn[Dropdown._NAME]['noConflict'] = function () { - $.fn[Dropdown._NAME] = Dropdown._JQUERY_NO_CONFLICT - return this -} + $.fn[NAME] = Carousel._jQueryInterface; + $.fn[NAME].Constructor = Carousel; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Carousel._jQueryInterface; + }; + return Carousel; +})(jQuery); /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - -$(document) - .on('click.bs.dropdown.data-api', Dropdown._clearMenus) - .on('click.bs.dropdown.data-api', Dropdown._Selector.FORM_CHILD, function (e) { e.stopPropagation() }) - .on('click.bs.dropdown.data-api', Dropdown._Selector.DATA_TOGGLE, Dropdown.prototype['toggle']) - .on('keydown.bs.dropdown.data-api', Dropdown._Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler) - .on('keydown.bs.dropdown.data-api', Dropdown._Selector.ROLE_MENU, Dropdown._dataApiKeydownHandler) - .on('keydown.bs.dropdown.data-api', Dropdown._Selector.ROLE_LISTBOX, Dropdown._dataApiKeydownHandler) - -/** ======================================================================= - * Bootstrap: modal.js v4.0.0 - * http://getbootstrap.com/javascript/#modal - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's modal plugin. Modals are streamlined, but - * flexible, dialog prompts with the minimum required functionality and - * smart defaults. - * - * Public Methods & Properties: - * - * + $.modal - * + $.modal.noConflict - * + $.modal.Constructor - * + $.modal.Constructor.VERSION - * + $.modal.Constructor.Defaults - * + $.modal.Constructor.Defaults.backdrop - * + $.modal.Constructor.Defaults.keyboard - * + $.modal.Constructor.Defaults.show - * + $.modal.Constructor.prototype.toggle - * + $.modal.Constructor.prototype.show - * + $.modal.Constructor.prototype.hide - * - * ======================================================================== - */ - -'use strict'; - - -/** - * Our modal class. - * @param {Element} element - * @param {Object} config - * @constructor - */ -var Modal = function (element, config) { + * -------------------------------------------------------------------------- + */ + +var Collapse = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'collapse'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.collapse'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 600; + + var Default = { + toggle: true, + parent: '' + }; + + var DefaultType = { + toggle: 'boolean', + parent: 'string' + }; + + var Event = { + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY + }; + + var ClassName = { + IN: 'in', + COLLAPSE: 'collapse', + COLLAPSING: 'collapsing', + COLLAPSED: 'collapsed' + }; + + var Dimension = { + WIDTH: 'width', + HEIGHT: 'height' + }; + + var Selector = { + ACTIVES: '.panel > .in, .panel > .collapsing', + DATA_TOGGLE: '[data-toggle="collapse"]' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Collapse = (function () { + function Collapse(element, config) { + _classCallCheck(this, Collapse); + + this._isTransitioning = false; + this._element = element; + this._config = this._getConfig(config); + this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]'))); + + this._parent = this._config.parent ? this._getParent() : null; + + if (!this._config.parent) { + this._addAriaAndCollapsedClass(this._element, this._triggerArray); + } - /** @private {Object} */ - this._config = config + if (this._config.toggle) { + this.toggle(); + } + } - /** @private {Element} */ - this._element = element + _createClass(Collapse, [{ + key: 'toggle', - /** @private {Element} */ - this._backdrop = null + // public - /** @private {boolean} */ - this._isShown = false + value: function toggle() { + if ($(this._element).hasClass(ClassName.IN)) { + this.hide(); + } else { + this.show(); + } + } + }, { + key: 'show', + value: function show() { + var _this4 = this; - /** @private {boolean} */ - this._isBodyOverflowing = false + if (this._isTransitioning || $(this._element).hasClass(ClassName.IN)) { + return; + } - /** @private {number} */ - this._scrollbarWidth = 0 + var actives = undefined; + var activesData = undefined; -} + if (this._parent) { + actives = $.makeArray($(Selector.ACTIVES)); + if (!actives.length) { + actives = null; + } + } + if (actives) { + activesData = $(actives).data(DATA_KEY); + if (activesData && activesData._isTransitioning) { + return; + } + } -/** - * @const - * @type {string} - */ -Modal['VERSION'] = '4.0.0' + var startEvent = $.Event(Event.SHOW); + $(this._element).trigger(startEvent); + if (startEvent.isDefaultPrevented()) { + return; + } + if (actives) { + Collapse._jQueryInterface.call($(actives), 'hide'); + if (!activesData) { + $(actives).data(DATA_KEY, null); + } + } -/** - * @const - * @type {Object} - */ -Modal['Defaults'] = { - 'backdrop' : true, - 'keyboard' : true, - 'show' : true -} + var dimension = this._getDimension(); + $(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING); -/** - * @const - * @type {string} - * @private - */ -Modal._NAME = 'modal' + this._element.style[dimension] = 0; + this._element.setAttribute('aria-expanded', true); + if (this._triggerArray.length) { + $(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true); + } -/** - * @const - * @type {string} - * @private - */ -Modal._DATA_KEY = 'bs.modal' + this.setTransitioning(true); + var complete = function complete() { + $(_this4._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.IN); -/** - * @const - * @type {number} - * @private - */ -Modal._TRANSITION_DURATION = 300 + _this4._element.style[dimension] = ''; + _this4.setTransitioning(false); -/** - * @const - * @type {number} - * @private - */ -Modal._BACKDROP_TRANSITION_DURATION = 150 + $(_this4._element).trigger(Event.SHOWN); + }; + if (!Util.supportsTransitionEnd()) { + complete(); + return; + } -/** - * @const - * @type {Function} - * @private - */ -Modal._JQUERY_NO_CONFLICT = $.fn[Modal._NAME] + var scrollSize = 'scroll' + (dimension[0].toUpperCase() + dimension.slice(1)); + $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); -/** - * @const - * @enum {string} - * @private - */ -Modal._Event = { - HIDE : 'hide.bs.modal', - HIDDEN : 'hidden.bs.modal', - SHOW : 'show.bs.modal', - SHOWN : 'shown.bs.modal' -} + this._element.style[dimension] = this._element[scrollSize] + 'px'; + } + }, { + key: 'hide', + value: function hide() { + var _this5 = this; + if (this._isTransitioning || !$(this._element).hasClass(ClassName.IN)) { + return; + } -/** - * @const - * @enum {string} - * @private - */ -Modal._ClassName = { - BACKDROP : 'modal-backdrop', - OPEN : 'modal-open', - FADE : 'fade', - IN : 'in' -} + var startEvent = $.Event(Event.HIDE); + $(this._element).trigger(startEvent); + if (startEvent.isDefaultPrevented()) { + return; + } + var dimension = this._getDimension(); + var offsetDimension = dimension === Dimension.WIDTH ? 'offsetWidth' : 'offsetHeight'; -/** - * @const - * @enum {string} - * @private - */ -Modal._Selector = { - DIALOG : '.modal-dialog', - DATA_TOGGLE : '[data-toggle="modal"]', - DATA_DISMISS : '[data-dismiss="modal"]', - SCROLLBAR_MEASURER : 'modal-scrollbar-measure' -} + this._element.style[dimension] = this._element[offsetDimension] + 'px'; + Util.reflow(this._element); + $(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.IN); -/** - * Provides the jQuery Interface for the alert component. - * @param {Object|string=} opt_config - * @param {Element=} opt_relatedTarget - * @this {jQuery} - * @return {jQuery} - * @private - */ -Modal._jQueryInterface = function Plugin(opt_config, opt_relatedTarget) { - return this.each(function () { - var data = $(this).data(Modal._DATA_KEY) - var config = $.extend({}, Modal['Defaults'], $(this).data(), typeof opt_config == 'object' && opt_config) - - if (!data) { - data = new Modal(this, config) - $(this).data(Modal._DATA_KEY, data) - } + this._element.setAttribute('aria-expanded', false); - if (typeof opt_config == 'string') { - data[opt_config](opt_relatedTarget) + if (this._triggerArray.length) { + $(this._triggerArray).addClass(ClassName.COLLAPSED).attr('aria-expanded', false); + } - } else if (config['show']) { - data['show'](opt_relatedTarget) - } - }) -} + this.setTransitioning(true); + var complete = function complete() { + _this5.setTransitioning(false); + $(_this5._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); + }; -/** - * @param {Element} relatedTarget - */ -Modal.prototype['toggle'] = function (relatedTarget) { - return this._isShown ? this['hide']() : this['show'](relatedTarget) -} + this._element.style[dimension] = 0; + if (!Util.supportsTransitionEnd()) { + return complete(); + } -/** - * @param {Element} relatedTarget - */ -Modal.prototype['show'] = function (relatedTarget) { - var showEvent = $.Event(Modal._Event.SHOW, { relatedTarget: relatedTarget }) + $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + } + }, { + key: 'setTransitioning', + value: function setTransitioning(isTransitioning) { + this._isTransitioning = isTransitioning; + } + }, { + key: 'dispose', + value: function dispose() { + $.removeData(this._element, DATA_KEY); + + this._config = null; + this._parent = null; + this._element = null; + this._triggerArray = null; + this._isTransitioning = null; + } + }, { + key: '_getConfig', - $(this._element).trigger(showEvent) + // private - if (this._isShown || showEvent.isDefaultPrevented()) { - return - } + value: function _getConfig(config) { + config = $.extend({}, Default, config); + config.toggle = !!config.toggle; // coerce string values + Util.typeCheckConfig(NAME, config, DefaultType); + return config; + } + }, { + key: '_getDimension', + value: function _getDimension() { + var hasWidth = $(this._element).hasClass(Dimension.WIDTH); + return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; + } + }, { + key: '_getParent', + value: function _getParent() { + var _this6 = this; - this._isShown = true + var parent = $(this._config.parent)[0]; + var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]'; - this._checkScrollbar() - this._setScrollbar() + $(parent).find(selector).each(function (i, element) { + _this6._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); + }); - $(document.body).addClass(Modal._ClassName.OPEN) + return parent; + } + }, { + key: '_addAriaAndCollapsedClass', + value: function _addAriaAndCollapsedClass(element, triggerArray) { + if (element) { + var isOpen = $(element).hasClass(ClassName.IN); + element.setAttribute('aria-expanded', isOpen); + + if (triggerArray.length) { + $(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); + } + } + } + }], [{ + key: 'VERSION', - this._escape() - this._resize() + // getters - $(this._element).on('click.dismiss.bs.modal', Modal._Selector.DATA_DISMISS, this['hide'].bind(this)) + get: function () { + return VERSION; + } + }, { + key: 'Default', + get: function () { + return Default; + } + }, { + key: '_getTargetFromElement', - this._showBackdrop(this._showElement.bind(this, relatedTarget)) -} + // static + value: function _getTargetFromElement(element) { + var selector = Util.getSelectorFromElement(element); + return selector ? $(selector)[0] : null; + } + }, { + key: '_jQueryInterface', + value: function _jQueryInterface(config) { + return this.each(function () { + var $this = $(this); + var data = $this.data(DATA_KEY); + var _config = $.extend({}, Default, $this.data(), typeof config === 'object' && config); + + if (!data && _config.toggle && /show|hide/.test(config)) { + _config.toggle = false; + } -/** - * @param {Event} event - */ -Modal.prototype['hide'] = function (event) { - if (event) { - event.preventDefault() - } + if (!data) { + data = new Collapse(this, _config); + $this.data(DATA_KEY, data); + } - var hideEvent = $.Event(Modal._Event.HIDE) + if (typeof config === 'string') { + data[config](); + } + }); + } + }]); - $(this._element).trigger(hideEvent) + return Collapse; + })(); - if (!this._isShown || hideEvent.isDefaultPrevented()) { - return - } + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - this._isShown = false + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + event.preventDefault(); - this._escape() - this._resize() + var target = Collapse._getTargetFromElement(this); - $(document).off('focusin.bs.modal') + var data = $(target).data(DATA_KEY); + var config = data ? 'toggle' : $(this).data(); - $(this._element).removeClass(Modal._ClassName.IN) - this._element.setAttribute('aria-hidden', true) + Collapse._jQueryInterface.call($(target), config); + }); - $(this._element).off('click.dismiss.bs.modal') + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ - if (Bootstrap.transition && $(this._element).hasClass(Modal._ClassName.FADE)) { - $(this._element) - .one(Bootstrap.TRANSITION_END, this._hideModal.bind(this)) - .emulateTransitionEnd(Modal._TRANSITION_DURATION) - } else { - this._hideModal() - } -} + $.fn[NAME] = Collapse._jQueryInterface; + $.fn[NAME].Constructor = Collapse; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Collapse._jQueryInterface; + }; + return Collapse; +})(jQuery); /** - * @param {Element} relatedTarget - * @private - */ -Modal.prototype._showElement = function (relatedTarget) { - var transition = Bootstrap.transition && $(this._element).hasClass(Modal._ClassName.FADE) - - if (!this._element.parentNode || this._element.parentNode.nodeType != Node.ELEMENT_NODE) { - document.body.appendChild(this._element) // don't move modals dom position - } - - this._element.style.display = 'block' - this._element.scrollTop = 0 - - if (this._config['backdrop']) { - this._adjustBackdrop() - } + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): dropdown.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Dropdown = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'dropdown'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.dropdown'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + CLICK: 'click' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY, + KEYDOWN_DATA_API: 'keydown' + EVENT_KEY + '' + DATA_API_KEY + }; + + var ClassName = { + BACKDROP: 'dropdown-backdrop', + DISABLED: 'disabled', + OPEN: 'open' + }; + + var Selector = { + BACKDROP: '.dropdown-backdrop', + DATA_TOGGLE: '[data-toggle="dropdown"]', + FORM_CHILD: '.dropdown form', + ROLE_MENU: '[role="menu"]', + ROLE_LISTBOX: '[role="listbox"]', + NAVBAR_NAV: '.navbar-nav', + VISIBLE_ITEMS: '[role="menu"] li:not(.disabled) a, ' + '[role="listbox"] li:not(.disabled) a' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Dropdown = (function () { + function Dropdown(element) { + _classCallCheck(this, Dropdown); + + this._element = element; + + this._addEventListeners(); + } + + _createClass(Dropdown, [{ + key: 'toggle', + + // public + + value: function toggle() { + if (this.disabled || $(this).hasClass(ClassName.DISABLED)) { + return; + } - if (transition) { - Bootstrap.reflow(this._element) - } + var parent = Dropdown._getParentFromElement(this); + var isActive = $(parent).hasClass(ClassName.OPEN); - $(this._element).addClass(Modal._ClassName.IN) - this._element.setAttribute('aria-hidden', false) + Dropdown._clearMenus(); - this._enforceFocus() + if (isActive) { + return false; + } - var shownEvent = $.Event(Modal._Event.SHOWN, { relatedTarget: relatedTarget }) + if ('ontouchstart' in document.documentElement && !$(parent).closest(Selector.NAVBAR_NAV).length) { - var transitionComplete = function () { - this._element.focus() - $(this._element).trigger(shownEvent) - }.bind(this) + // if mobile we use a backdrop because click events don't delegate + var dropdown = document.createElement('div'); + dropdown.className = ClassName.BACKDROP; + $(dropdown).insertBefore(this); + $(dropdown).on('click', Dropdown._clearMenus); + } - if (transition) { - var dialog = $(this._element).find(Modal._Selector.DIALOG)[0] - $(dialog) - .one(Bootstrap.TRANSITION_END, transitionComplete) - .emulateTransitionEnd(Modal._TRANSITION_DURATION) - } else { - transitionComplete() - } -} + var relatedTarget = { relatedTarget: this }; + var showEvent = $.Event(Event.SHOW, relatedTarget); + $(parent).trigger(showEvent); + if (showEvent.isDefaultPrevented()) { + return; + } -/** - * @private - */ -Modal.prototype._enforceFocus = function () { - $(document) - .off('focusin.bs.modal') // guard against infinite focus loop - .on('focusin.bs.modal', function (e) { - if (this._element !== e.target && !$(this._element).has(e.target).length) { - this._element.focus() - } - }.bind(this)) -} + this.focus(); + this.setAttribute('aria-expanded', 'true'); + $(parent).toggleClass(ClassName.OPEN); + $(parent).trigger(Event.SHOWN, relatedTarget); -/** - * @private - */ -Modal.prototype._escape = function () { - if (this._isShown && this._config['keyboard']) { - $(this._element).on('keydown.dismiss.bs.modal', function (event) { - if (event.which === 27) { - this['hide']() + return false; } - }.bind(this)) - - } else if (!this._isShown) { - $(this._element).off('keydown.dismiss.bs.modal') - } -} - - -/** - * @private - */ -Modal.prototype._resize = function () { - if (this._isShown) { - $(window).on('resize.bs.modal', this._handleUpdate.bind(this)) - } else { - $(window).off('resize.bs.modal') - } -} - - -/** - * @private - */ -Modal.prototype._hideModal = function () { - this._element.style.display = 'none' - this._showBackdrop(function () { - $(document.body).removeClass(Modal._ClassName.OPEN) - this._resetAdjustments() - this._resetScrollbar() - $(this._element).trigger(Modal._Event.HIDDEN) - }.bind(this)) -} + }, { + key: 'dispose', + value: function dispose() { + $.removeData(this._element, DATA_KEY); + $(this._element).off(EVENT_KEY); + this._element = null; + } + }, { + key: '_addEventListeners', + // private -/** - * @private - */ -Modal.prototype._removeBackdrop = function () { - if (this._backdrop) { - this._backdrop.parentNode.removeChild(this._backdrop) - this._backdrop = null - } -} + value: function _addEventListeners() { + $(this._element).on(Event.CLICK, this.toggle); + } + }], [{ + key: 'VERSION', + // getters -/** - * @param {Function} callback - * @private - */ -Modal.prototype._showBackdrop = function (callback) { - var animate = $(this._element).hasClass(Modal._ClassName.FADE) ? Modal._ClassName.FADE : '' + get: function () { + return VERSION; + } + }, { + key: '_jQueryInterface', - if (this._isShown && this._config['backdrop']) { - var doAnimate = Bootstrap.transition && animate + // static - this._backdrop = document.createElement('div') - this._backdrop.className = Modal._ClassName.BACKDROP + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); - if (animate) { - $(this._backdrop).addClass(animate) - } + if (!data) { + $(this).data(DATA_KEY, data = new Dropdown(this)); + } - $(this._element).prepend(this._backdrop) + if (typeof config === 'string') { + data[config].call(this); + } + }); + } + }, { + key: '_clearMenus', + value: function _clearMenus(event) { + if (event && event.which === 3) { + return; + } - $(this._backdrop).on('click.dismiss.bs.modal', function (event) { - if (event.target !== event.currentTarget) return - this._config['backdrop'] === 'static' - ? this._element.focus() - : this['hide']() - }.bind(this)) + var backdrop = $(Selector.BACKDROP)[0]; + if (backdrop) { + backdrop.parentNode.removeChild(backdrop); + } - if (doAnimate) { - Bootstrap.reflow(this._backdrop) - } + var toggles = $.makeArray($(Selector.DATA_TOGGLE)); - $(this._backdrop).addClass(Modal._ClassName.IN) + for (var i = 0; i < toggles.length; i++) { + var _parent = Dropdown._getParentFromElement(toggles[i]); + var relatedTarget = { relatedTarget: toggles[i] }; - if (!callback) { - return - } + if (!$(_parent).hasClass(ClassName.OPEN)) { + continue; + } - if (!doAnimate) { - callback() - return - } + if (event && event.type === 'click' && /input|textarea/i.test(event.target.tagName) && $.contains(_parent, event.target)) { + continue; + } - $(this._backdrop) - .one(Bootstrap.TRANSITION_END, callback) - .emulateTransitionEnd(Modal._BACKDROP_TRANSITION_DURATION) + var hideEvent = $.Event(Event.HIDE, relatedTarget); + $(_parent).trigger(hideEvent); + if (hideEvent.isDefaultPrevented()) { + continue; + } - } else if (!this._isShown && this._backdrop) { - $(this._backdrop).removeClass(Modal._ClassName.IN) + toggles[i].setAttribute('aria-expanded', 'false'); - var callbackRemove = function () { - this._removeBackdrop() - if (callback) { - callback() + $(_parent).removeClass(ClassName.OPEN).trigger(Event.HIDDEN, relatedTarget); + } } - }.bind(this) - - if (Bootstrap.transition && $(this._element).hasClass(Modal._ClassName.FADE)) { - $(this._backdrop) - .one(Bootstrap.TRANSITION_END, callbackRemove) - .emulateTransitionEnd(Modal._BACKDROP_TRANSITION_DURATION) - } else { - callbackRemove() - } - - } else if (callback) { - callback() - } -} - - -/** - * ------------------------------------------------------------------------ - * the following methods are used to handle overflowing modals - * todo (fat): these should probably be refactored into a - * ------------------------------------------------------------------------ - */ - - -/** - * @private - */ -Modal.prototype._handleUpdate = function () { - if (this._config['backdrop']) this._adjustBackdrop() - this._adjustDialog() -} - -/** - * @private - */ -Modal.prototype._adjustBackdrop = function () { - this._backdrop.style.height = 0 // todo (fat): no clue why we do this - this._backdrop.style.height = this._element.scrollHeight + 'px' -} + }, { + key: '_getParentFromElement', + value: function _getParentFromElement(element) { + var parent = undefined; + var selector = Util.getSelectorFromElement(element); + + if (selector) { + parent = $(selector)[0]; + } + return parent || element.parentNode; + } + }, { + key: '_dataApiKeydownHandler', + value: function _dataApiKeydownHandler(event) { + if (!/(38|40|27|32)/.test(event.which) || /input|textarea/i.test(event.target.tagName)) { + return; + } -/** - * @private - */ -Modal.prototype._adjustDialog = function () { - var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight + event.preventDefault(); + event.stopPropagation(); - if (!this._isBodyOverflowing && isModalOverflowing) { - this._element.style.paddingLeft = this._scrollbarWidth + 'px' - } + if (this.disabled || $(this).hasClass(ClassName.DISABLED)) { + return; + } - if (this._isBodyOverflowing && !isModalOverflowing) { - this._element.style.paddingRight = this._scrollbarWidth + 'px' - } -} + var parent = Dropdown._getParentFromElement(this); + var isActive = $(parent).hasClass(ClassName.OPEN); + if (!isActive && event.which !== 27 || isActive && event.which === 27) { -/** - * @private - */ -Modal.prototype._resetAdjustments = function () { - this._element.style.paddingLeft = '' - this._element.style.paddingRight = '' -} + if (event.which === 27) { + var toggle = $(parent).find(Selector.DATA_TOGGLE)[0]; + $(toggle).trigger('focus'); + } + $(this).trigger('click'); + return; + } -/** - * @private - */ -Modal.prototype._checkScrollbar = function () { - this._isBodyOverflowing = document.body.scrollHeight > document.documentElement.clientHeight - this._scrollbarWidth = this._getScrollbarWidth() -} + var items = $.makeArray($(Selector.VISIBLE_ITEMS)); + items = items.filter(function (item) { + return item.offsetWidth || item.offsetHeight; + }); -/** - * @private - */ -Modal.prototype._setScrollbar = function () { - var bodyPadding = parseInt(($(document.body).css('padding-right') || 0), 10) + if (!items.length) { + return; + } - if (this._isBodyOverflowing) { - document.body.style.paddingRight = bodyPadding + this._scrollbarWidth + 'px' - } -} + var index = items.indexOf(event.target); + if (event.which === 38 && index > 0) index--; // up + if (event.which === 40 && index < items.length - 1) index++; // down + if (! ~index) index = 0; -/** - * @private - */ -Modal.prototype._resetScrollbar = function () { - document.body.style.paddingRight = '' -} + items[index].focus(); + } + }]); + return Dropdown; + })(); -/** - * @private - */ -Modal.prototype._getScrollbarWidth = function () { // thx walsh - var scrollDiv = document.createElement('div') - scrollDiv.className = Modal._Selector.SCROLLBAR_MEASURER - document.body.appendChild(scrollDiv) - var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth - document.body.removeChild(scrollDiv) - return scrollbarWidth -} + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.ROLE_MENU, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.ROLE_LISTBOX, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, Dropdown.prototype.toggle).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) { + e.stopPropagation(); + }); -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ -/** - * @const - * @type {Function} - */ -$.fn[Modal._NAME] = Modal._jQueryInterface + $.fn[NAME] = Dropdown._jQueryInterface; + $.fn[NAME].Constructor = Dropdown; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Dropdown._jQueryInterface; + }; + return Dropdown; +})(jQuery); /** - * @const - * @type {Function} - */ -$.fn[Modal._NAME]['Constructor'] = Modal + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): modal.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Modal = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'modal'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.modal'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 300; + var BACKDROP_TRANSITION_DURATION = 150; + + var Default = { + backdrop: true, + keyboard: true, + focus: true, + show: true + }; + + var DefaultType = { + backdrop: '(boolean|string)', + keyboard: 'boolean', + focus: 'boolean', + show: 'boolean' + }; + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + FOCUSIN: 'focusin' + EVENT_KEY, + RESIZE: 'resize' + EVENT_KEY, + CLICK_DISMISS: 'click.dismiss' + EVENT_KEY, + KEYDOWN_DISMISS: 'keydown.dismiss' + EVENT_KEY, + MOUSEUP_DISMISS: 'mouseup.dismiss' + EVENT_KEY, + MOUSEDOWN_DISMISS: 'mousedown.dismiss' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + '' + DATA_API_KEY + }; + + var ClassName = { + BACKDROP: 'modal-backdrop', + OPEN: 'modal-open', + FADE: 'fade', + IN: 'in' + }; + + var Selector = { + DIALOG: '.modal-dialog', + DATA_TOGGLE: '[data-toggle="modal"]', + DATA_DISMISS: '[data-dismiss="modal"]', + SCROLLBAR_MEASURER: 'modal-scrollbar-measure' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Modal = (function () { + function Modal(element, config) { + _classCallCheck(this, Modal); + + this._config = this._getConfig(config); + this._element = element; + this._dialog = $(element).find(Selector.DIALOG)[0]; + this._backdrop = null; + this._isShown = false; + this._isBodyOverflowing = false; + this._ignoreBackdropClick = false; + this._originalBodyPadding = 0; + this._scrollbarWidth = 0; + } + + _createClass(Modal, [{ + key: 'toggle', + + // public + + value: function toggle(relatedTarget) { + return this._isShown ? this.hide() : this.show(relatedTarget); + } + }, { + key: 'show', + value: function show(relatedTarget) { + var _this7 = this; + var showEvent = $.Event(Event.SHOW, { + relatedTarget: relatedTarget + }); -/** - * @const - * @type {Function} - */ -$.fn[Modal._NAME]['noConflict'] = function () { - $.fn[Modal._NAME] = Modal._JQUERY_NO_CONFLICT - return this -} + $(this._element).trigger(showEvent); + if (this._isShown || showEvent.isDefaultPrevented()) { + return; + } -/** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ + this._isShown = true; -$(document).on('click.bs.modal.data-api', Modal._Selector.DATA_TOGGLE, function (event) { - var selector = Bootstrap.getSelectorFromElement(this) + this._checkScrollbar(); + this._setScrollbar(); - if (selector) { - var target = $(selector)[0] - } + $(document.body).addClass(ClassName.OPEN); - var config = $(target).data(Modal._DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()) + this._setEscapeEvent(); + this._setResizeEvent(); - if (this.tagName == 'A') { - event.preventDefault() - } + $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, $.proxy(this.hide, this)); - var $target = $(target).one(Modal._Event.SHOW, function (showEvent) { - if (showEvent.isDefaultPrevented()) { - return // only register focus restorer if modal will actually get shown - } + $(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () { + $(_this7._element).one(Event.MOUSEUP_DISMISS, function (event) { + if ($(event.target).is(_this7._element)) { + that._ignoreBackdropClick = true; + } + }); + }); - $target.one(Modal._Event.HIDDEN, function () { - if ($(this).is(':visible')) { - this.focus() + this._showBackdrop($.proxy(this._showElement, this, relatedTarget)); } - }.bind(this)) - }.bind(this)) - - Modal._jQueryInterface.call($(target), config, this) -}) - -/** ======================================================================= - * Bootstrap: scrollspy.js v4.0.0 - * http://getbootstrap.com/javascript/#scrollspy - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's scrollspy plugin. - * - * Public Methods & Properties: - * - * + $.scrollspy - * + $.scrollspy.noConflict - * + $.scrollspy.Constructor - * + $.scrollspy.Constructor.VERSION - * + $.scrollspy.Constructor.Defaults - * + $.scrollspy.Constructor.Defaults.offset - * + $.scrollspy.Constructor.prototype.refresh - * - * ======================================================================== - */ - -'use strict'; - - -/** - * Our scrollspy class. - * @param {Element!} element - * @param {Object=} opt_config - * @constructor - */ -function ScrollSpy(element, opt_config) { - - /** @private {Element|Window} */ - this._scrollElement = element.tagName == 'BODY' ? window : element + }, { + key: 'hide', + value: function hide(event) { + if (event) { + event.preventDefault(); + } - /** @private {Object} */ - this._config = $.extend({}, ScrollSpy['Defaults'], opt_config) + var hideEvent = $.Event(Event.HIDE); - /** @private {string} */ - this._selector = (this._config.target || '') + ' .nav li > a' + $(this._element).trigger(hideEvent); - /** @private {Array} */ - this._offsets = [] + if (!this._isShown || hideEvent.isDefaultPrevented()) { + return; + } - /** @private {Array} */ - this._targets = [] + this._isShown = false; - /** @private {Element} */ - this._activeTarget = null + this._setEscapeEvent(); + this._setResizeEvent(); - /** @private {number} */ - this._scrollHeight = 0 + $(document).off(Event.FOCUSIN); - $(this._scrollElement).on('scroll.bs.scrollspy', this._process.bind(this)) + $(this._element).removeClass(ClassName.IN); - this['refresh']() + $(this._element).off(Event.CLICK_DISMISS); + $(this._dialog).off(Event.MOUSEDOWN_DISMISS); - this._process() -} + if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { + $(this._element).one(Util.TRANSITION_END, $.proxy(this._hideModal, this)).emulateTransitionEnd(TRANSITION_DURATION); + } else { + this._hideModal(); + } + } + }, { + key: 'dispose', + value: function dispose() { + $.removeData(this._element, DATA_KEY); + + $(window).off(EVENT_KEY); + $(document).off(EVENT_KEY); + $(this._element).off(EVENT_KEY); + $(this._backdrop).off(EVENT_KEY); + + this._config = null; + this._element = null; + this._dialog = null; + this._backdrop = null; + this._isShown = null; + this._isBodyOverflowing = null; + this._ignoreBackdropClick = null; + this._originalBodyPadding = null; + this._scrollbarWidth = null; + } + }, { + key: '_getConfig', -/** - * @const - * @type {string} - */ -ScrollSpy['VERSION'] = '4.0.0' + // private + value: function _getConfig(config) { + config = $.extend({}, Default, config); + Util.typeCheckConfig(NAME, config, DefaultType); + return config; + } + }, { + key: '_showElement', + value: function _showElement(relatedTarget) { + var _this8 = this; -/** - * @const - * @type {Object} - */ -ScrollSpy['Defaults'] = { - 'offset': 10 -} + var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); + if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { + // don't move modals dom position + document.body.appendChild(this._element); + } -/** - * @const - * @type {string} - * @private - */ -ScrollSpy._NAME = 'scrollspy' + this._element.style.display = 'block'; + this._element.scrollTop = 0; + if (transition) { + Util.reflow(this._element); + } -/** - * @const - * @type {string} - * @private - */ -ScrollSpy._DATA_KEY = 'bs.scrollspy' + $(this._element).addClass(ClassName.IN); + if (this._config.focus) this._enforceFocus(); -/** - * @const - * @type {Function} - * @private - */ -ScrollSpy._JQUERY_NO_CONFLICT = $.fn[ScrollSpy._NAME] + var shownEvent = $.Event(Event.SHOWN, { + relatedTarget: relatedTarget + }); + var transitionComplete = function transitionComplete() { + if (_this8._config.focus) _this8._element.focus(); + $(_this8._element).trigger(shownEvent); + }; -/** - * @const - * @enum {string} - * @private - */ -ScrollSpy._Event = { - ACTIVATE: 'activate.bs.scrollspy' -} + if (transition) { + $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + transitionComplete(); + } + } + }, { + key: '_enforceFocus', + value: function _enforceFocus() { + var _this9 = this; + + $(document).off(Event.FOCUSIN) // guard against infinite focus loop + .on(Event.FOCUSIN, function (event) { + if (_this9._element !== event.target && !$(_this9._element).has(event.target).length) { + _this9._element.focus(); + } + }); + } + }, { + key: '_setEscapeEvent', + value: function _setEscapeEvent() { + var _this10 = this; + + if (this._isShown && this._config.keyboard) { + $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { + if (event.which === 27) { + _this10.hide(); + } + }); + } else if (!this._isShown) { + $(this._element).off(Event.KEYDOWN_DISMISS); + } + } + }, { + key: '_setResizeEvent', + value: function _setResizeEvent() { + if (this._isShown) { + $(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this)); + } else { + $(window).off(Event.RESIZE); + } + } + }, { + key: '_hideModal', + value: function _hideModal() { + var _this11 = this; + + this._element.style.display = 'none'; + this._showBackdrop(function () { + $(document.body).removeClass(ClassName.OPEN); + _this11._resetAdjustments(); + _this11._resetScrollbar(); + $(_this11._element).trigger(Event.HIDDEN); + }); + } + }, { + key: '_removeBackdrop', + value: function _removeBackdrop() { + if (this._backdrop) { + $(this._backdrop).remove(); + this._backdrop = null; + } + } + }, { + key: '_showBackdrop', + value: function _showBackdrop(callback) { + var _this12 = this; + var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : ''; -/** - * @const - * @enum {string} - * @private - */ -ScrollSpy._ClassName = { - DROPDOWN_MENU : 'dropdown-menu', - ACTIVE : 'active' -} + if (this._isShown && this._config.backdrop) { + var doAnimate = Util.supportsTransitionEnd() && animate; + this._backdrop = document.createElement('div'); + this._backdrop.className = ClassName.BACKDROP; -/** - * @const - * @enum {string} - * @private - */ -ScrollSpy._Selector = { - DATA_SPY : '[data-spy="scroll"]', - ACTIVE : '.active', - LI_DROPDOWN : 'li.dropdown', - LI : 'li' -} + if (animate) { + $(this._backdrop).addClass(animate); + } + $(this._backdrop).appendTo(this.$body); + + $(this._element).on(Event.CLICK_DISMISS, function (event) { + if (_this12._ignoreBackdropClick) { + _this12._ignoreBackdropClick = false; + return; + } + if (event.target !== event.currentTarget) { + return; + } + if (_this12._config.backdrop === 'static') { + _this12._element.focus(); + } else { + _this12.hide(); + } + }); + + if (doAnimate) { + Util.reflow(this._backdrop); + } -/** - * @param {Object=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -ScrollSpy._jQueryInterface = function (opt_config) { - return this.each(function () { - var data = $(this).data(ScrollSpy._DATA_KEY) - var config = typeof opt_config === 'object' && opt_config || null - - if (!data) { - data = new ScrollSpy(this, config) - $(this).data(ScrollSpy._DATA_KEY, data) - } + $(this._backdrop).addClass(ClassName.IN); - if (typeof opt_config === 'string') { - data[opt_config]() - } - }) -} + if (!callback) { + return; + } + if (!doAnimate) { + callback(); + return; + } -/** - * Refresh the scrollspy target cache - */ -ScrollSpy.prototype['refresh'] = function () { - var offsetMethod = 'offset' - var offsetBase = 0 + $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION); + } else if (!this._isShown && this._backdrop) { + $(this._backdrop).removeClass(ClassName.IN); + + var callbackRemove = function callbackRemove() { + _this12._removeBackdrop(); + if (callback) { + callback(); + } + }; + + if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { + $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION); + } else { + callbackRemove(); + } + } else if (callback) { + callback(); + } + } + }, { + key: '_handleUpdate', - if (this._scrollElement !== this._scrollElement.window) { - offsetMethod = 'position' - offsetBase = this._getScrollTop() - } + // ---------------------------------------------------------------------- + // the following methods are used to handle overflowing modals + // todo (fat): these should probably be refactored out of modal.js + // ---------------------------------------------------------------------- - this._offsets = [] - this._targets = [] + value: function _handleUpdate() { + this._adjustDialog(); + } + }, { + key: '_adjustDialog', + value: function _adjustDialog() { + var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; - this._scrollHeight = this._getScrollHeight() + if (!this._isBodyOverflowing && isModalOverflowing) { + this._element.style.paddingLeft = this._scrollbarWidth + 'px'; + } - var targets = /** @type {Array.<Element>} */ ($.makeArray($(this._selector))) + if (this._isBodyOverflowing && !isModalOverflowing) { + this._element.style.paddingRight = this._scrollbarWidth + 'px'; + } + } + }, { + key: '_resetAdjustments', + value: function _resetAdjustments() { + this._element.style.paddingLeft = ''; + this._element.style.paddingRight = ''; + } + }, { + key: '_checkScrollbar', + value: function _checkScrollbar() { + var fullWindowWidth = window.innerWidth; + if (!fullWindowWidth) { + // workaround for missing window.innerWidth in IE8 + var documentElementRect = document.documentElement.getBoundingClientRect(); + fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left); + } + this._isBodyOverflowing = document.body.clientWidth < fullWindowWidth; + this._scrollbarWidth = this._getScrollbarWidth(); + } + }, { + key: '_setScrollbar', + value: function _setScrollbar() { + var bodyPadding = parseInt($(document.body).css('padding-right') || 0, 10); - targets - .map(function (element, index) { - var target - var targetSelector = Bootstrap.getSelectorFromElement(element) + this._originalBodyPadding = document.body.style.paddingRight || ''; - if (targetSelector) { - target = $(targetSelector)[0] + if (this._isBodyOverflowing) { + document.body.style.paddingRight = bodyPadding + this._scrollbarWidth + 'px'; + } } - - if (target && (target.offsetWidth || target.offsetHeight)) { - // todo (fat): remove sketch reliance on jQuery position/offset - return [$(target)[offsetMethod]().top + offsetBase, targetSelector] + }, { + key: '_resetScrollbar', + value: function _resetScrollbar() { + document.body.style.paddingRight = this._originalBodyPadding; } - }) - .filter(function (item) { return item }) - .sort(function (a, b) { return a[0] - b[0] }) - .forEach(function (item, index) { - this._offsets.push(item[0]) - this._targets.push(item[1]) - }.bind(this)) -} - + }, { + key: '_getScrollbarWidth', + value: function _getScrollbarWidth() { + // thx d.walsh + var scrollDiv = document.createElement('div'); + scrollDiv.className = Selector.SCROLLBAR_MEASURER; + document.body.appendChild(scrollDiv); + var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; + document.body.removeChild(scrollDiv); + return scrollbarWidth; + } + }], [{ + key: 'VERSION', -/** - * @private - */ -ScrollSpy.prototype._getScrollTop = function () { - return this._scrollElement === window ? - this._scrollElement.scrollY : this._scrollElement.scrollTop -} + // getters + get: function () { + return VERSION; + } + }, { + key: 'Default', + get: function () { + return Default; + } + }, { + key: '_jQueryInterface', -/** - * @private - */ -ScrollSpy.prototype._getScrollHeight = function () { - return this._scrollElement.scrollHeight - || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight) -} + // static + value: function _jQueryInterface(config, relatedTarget) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = $.extend({}, Modal.Default, $(this).data(), typeof config === 'object' && config); -/** - * @private - */ -ScrollSpy.prototype._process = function () { - var scrollTop = this._getScrollTop() + this._config.offset - var scrollHeight = this._getScrollHeight() - var maxScroll = this._config.offset + scrollHeight - this._scrollElement.offsetHeight + if (!data) { + data = new Modal(this, _config); + $(this).data(DATA_KEY, data); + } - if (this._scrollHeight != scrollHeight) { - this['refresh']() - } + if (typeof config === 'string') { + data[config](relatedTarget); + } else if (_config.show) { + data.show(relatedTarget); + } + }); + } + }]); - if (scrollTop >= maxScroll) { - var target = this._targets[this._targets.length - 1] + return Modal; + })(); - if (this._activeTarget != target) { - this._activate(target) - } - } + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - if (this._activeTarget && scrollTop < this._offsets[0]) { - this._activeTarget = null - this._clear() - return - } + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + var _this13 = this; - for (var i = this._offsets.length; i--;) { - var isActiveTarget = this._activeTarget != this._targets[i] - && scrollTop >= this._offsets[i] - && (!this._offsets[i + 1] || scrollTop < this._offsets[i + 1]) + var target = undefined; + var selector = Util.getSelectorFromElement(this); - if (isActiveTarget) { - this._activate(this._targets[i]) + if (selector) { + target = $(selector)[0]; } - } -} + var config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()); -/** - * @param {Element} target - * @private - */ -ScrollSpy.prototype._activate = function (target) { - this._activeTarget = target - - this._clear() - - var selector = this._selector - + '[data-target="' + target + '"],' - + this._selector + '[href="' + target + '"]' - - // todo (fat): this seems horribly wrong… getting all raw li elements up the tree ,_, - var parentListItems = $(selector).parents(ScrollSpy._Selector.LI) - - for (var i = parentListItems.length; i--;) { - $(parentListItems[i]).addClass(ScrollSpy._ClassName.ACTIVE) - - var itemParent = parentListItems[i].parentNode - - if (itemParent && $(itemParent).hasClass(ScrollSpy._ClassName.DROPDOWN_MENU)) { - var closestDropdown = $(itemParent).closest(ScrollSpy._Selector.LI_DROPDOWN)[0] - $(closestDropdown).addClass(ScrollSpy._ClassName.ACTIVE) + if (this.tagName === 'A') { + event.preventDefault(); } - } - - $(this._scrollElement).trigger(ScrollSpy._Event.ACTIVATE, { - relatedTarget: target - }) -} - - -/** - * @private - */ -ScrollSpy.prototype._clear = function () { - var activeParents = $(this._selector).parentsUntil(this._config.target, ScrollSpy._Selector.ACTIVE) - for (var i = activeParents.length; i--;) { - $(activeParents[i]).removeClass(ScrollSpy._ClassName.ACTIVE) - } -} - - -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ - -/** - * @const - * @type {Function} - */ -$.fn[ScrollSpy._NAME] = ScrollSpy._jQueryInterface + var $target = $(target).one(Event.SHOW, function (showEvent) { + if (showEvent.isDefaultPrevented()) { + // only register focus restorer if modal will actually get shown + return; + } + $target.one(Event.HIDDEN, function () { + if ($(_this13).is(':visible')) { + _this13.focus(); + } + }); + }); -/** - * @const - * @type {Function} - */ -$.fn[ScrollSpy._NAME]['Constructor'] = ScrollSpy + Modal._jQueryInterface.call($(target), config, this); + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ -/** - * @const - * @type {Function} - */ -$.fn[ScrollSpy._NAME]['noConflict'] = function () { - $.fn[ScrollSpy._NAME] = ScrollSpy._JQUERY_NO_CONFLICT - return this -} + $.fn[NAME] = Modal._jQueryInterface; + $.fn[NAME].Constructor = Modal; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Modal._jQueryInterface; + }; + return Modal; +})(jQuery); /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ - -$(window).on('load.bs.scrollspy.data-api', function () { - var scrollSpys = /** @type {Array.<Element>} */ ($.makeArray($(ScrollSpy._Selector.DATA_SPY))) - - for (var i = scrollSpys.length; i--;) { - var $spy = $(scrollSpys[i]) - ScrollSpy._jQueryInterface.call($spy, /** @type {Object|null} */ ($spy.data())) - } -}) - -/** ======================================================================= - * Bootstrap: tooltip.js v4.0.0 - * http://getbootstrap.com/javascript/#tooltip - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's tooltip plugin. - * (Inspired by jQuery.tipsy by Jason Frame) - * - * Public Methods & Properties: - * - * + $.tooltip - * + $.tooltip.noConflict - * + $.tooltip.Constructor - * + $.tooltip.Constructor.VERSION - * + $.tooltip.Constructor.Defaults - * + $.tooltip.Constructor.Defaults.container - * + $.tooltip.Constructor.Defaults.animation - * + $.tooltip.Constructor.Defaults.placement - * + $.tooltip.Constructor.Defaults.selector - * + $.tooltip.Constructor.Defaults.template - * + $.tooltip.Constructor.Defaults.trigger - * + $.tooltip.Constructor.Defaults.title - * + $.tooltip.Constructor.Defaults.delay - * + $.tooltip.Constructor.Defaults.html - * + $.tooltip.Constructor.Defaults.viewport - * + $.tooltip.Constructor.Defaults.viewport.selector - * + $.tooltip.Constructor.Defaults.viewport.padding - * + $.tooltip.Constructor.prototype.enable - * + $.tooltip.Constructor.prototype.disable - * + $.tooltip.Constructor.prototype.destroy - * + $.tooltip.Constructor.prototype.toggleEnabled - * + $.tooltip.Constructor.prototype.toggle - * + $.tooltip.Constructor.prototype.show - * + $.tooltip.Constructor.prototype.hide - * - * ======================================================================== - */ - -'use strict'; - - -/** - * Our tooltip class. - * @param {Element!} element - * @param {Object=} opt_config - * @constructor - */ -var Tooltip = function (element, opt_config) { - - /** @private {boolean} */ - this._isEnabled = true - - /** @private {number} */ - this._timeout = 0 - - /** @private {string} */ - this._hoverState = '' - - /** @protected {Element} */ - this.element = element - - /** @protected {Object} */ - this.config = this._getConfig(opt_config) - - /** @protected {Element} */ - this.tip = null - - /** @protected {Element} */ - this.arrow = null - - if (this.config['viewport']) { - - /** @private {Element} */ - this._viewport = $(this.config['viewport']['selector'] || this.config['viewport'])[0] - - } - - this._setListeners() -} - - -/** - * @const - * @type {string} - */ -Tooltip['VERSION'] = '4.0.0' - - -/** - * @const - * @type {Object} - */ -Tooltip['Defaults'] = { - 'container' : false, - 'animation' : true, - 'placement' : 'top', - 'selector' : false, - 'template' : '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', - 'trigger' : 'hover focus', - 'title' : '', - 'delay' : 0, - 'html' : false, - 'viewport': { - 'selector': 'body', - 'padding' : 0 - } -} - - -/** - * @const - * @enum {string} - * @protected + * -------------------------------------------------------------------------- */ -Tooltip.Direction = { - TOP: 'top', - LEFT: 'left', - RIGHT: 'right', - BOTTOM: 'bottom' -} +var ScrollSpy = (function ($) { -/** - * @const - * @type {string} - * @private - */ -Tooltip._NAME = 'tooltip' + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + var NAME = 'scrollspy'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.scrollspy'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; -/** - * @const - * @type {string} - * @private - */ -Tooltip._DATA_KEY = 'bs.tooltip' - - -/** - * @const - * @type {number} - * @private - */ -Tooltip._TRANSITION_DURATION = 150 + var Default = { + offset: 10, + method: 'auto', + target: '' + }; + var DefaultType = { + offset: 'number', + method: 'string', + target: '(string|element)' + }; -/** - * @const - * @enum {string} - * @private - */ -Tooltip._HoverState = { - IN: 'in', - OUT: 'out' -} + var Event = { + ACTIVATE: 'activate' + EVENT_KEY, + SCROLL: 'scroll' + EVENT_KEY, + LOAD_DATA_API: 'load' + EVENT_KEY + '' + DATA_API_KEY + }; + var ClassName = { + DROPDOWN_MENU: 'dropdown-menu', + ACTIVE: 'active' + }; -/** - * @const - * @enum {string} - * @private - */ -Tooltip._Event = { - HIDE : 'hide.bs.tooltip', - HIDDEN : 'hidden.bs.tooltip', - SHOW : 'show.bs.tooltip', - SHOWN : 'shown.bs.tooltip' -} + var Selector = { + DATA_SPY: '[data-spy="scroll"]', + ACTIVE: '.active', + LI: 'li', + LI_DROPDOWN: 'li.dropdown', + NAV_ANCHORS: '.nav li > a' + }; + var OffsetMethod = { + OFFSET: 'offset', + POSITION: 'position' + }; -/** - * @const - * @enum {string} - * @private - */ -Tooltip._ClassName = { - FADE : 'fade', - IN : 'in' -} + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + var ScrollSpy = (function () { + function ScrollSpy(element, config) { + _classCallCheck(this, ScrollSpy); -/** - * @const - * @enum {string} - * @private - */ -Tooltip._Selector = { - TOOLTIP : '.tooltip', - TOOLTIP_INNER : '.tooltip-inner', - TOOLTIP_ARROW : '.tooltip-arrow' -} + this._element = element; + this._scrollElement = element.tagName === 'BODY' ? window : element; + this._config = this._getConfig(config); + this._selector = '' + this._config.target + ' ' + Selector.NAV_ANCHORS; + this._offsets = []; + this._targets = []; + this._activeTarget = null; + this._scrollHeight = 0; + $(this._scrollElement).on(Event.SCROLL, $.proxy(this._process, this)); -/** - * @const - * @type {Function} - * @private - */ -Tooltip._JQUERY_NO_CONFLICT = $.fn[Tooltip._NAME] - - -/** - * @param {Object=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -Tooltip._jQueryInterface = function (opt_config) { - return this.each(function () { - var data = $(this).data(Tooltip._DATA_KEY) - var config = typeof opt_config == 'object' ? opt_config : null - - if (!data && opt_config == 'destroy') { - return + this.refresh(); + this._process(); } - if (!data) { - data = new Tooltip(this, config) - $(this).data(Tooltip._DATA_KEY, data) - } + _createClass(ScrollSpy, [{ + key: 'refresh', - if (typeof opt_config === 'string') { - data[opt_config]() - } - }) -} + // public + value: function refresh() { + var _this14 = this; -/** - * Enable tooltip - */ -Tooltip.prototype['enable'] = function () { - this._isEnabled = true -} + var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET; + var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; -/** - * Disable tooltip - */ -Tooltip.prototype['disable'] = function () { - this._isEnabled = false -} - - -/** - * Toggle the tooltip enable state - */ -Tooltip.prototype['toggleEnabled'] = function () { - this._isEnabled = !this._isEnabled -} + var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0; -/** - * Toggle the tooltips display - * @param {Event} opt_event - */ -Tooltip.prototype['toggle'] = function (opt_event) { - var context = this - var dataKey = this.getDataKey() + this._offsets = []; + this._targets = []; - if (opt_event) { - context = $(opt_event.currentTarget).data(dataKey) + this._scrollHeight = this._getScrollHeight(); - if (!context) { - context = new this.constructor(opt_event.currentTarget, this._getDelegateConfig()) - $(opt_event.currentTarget).data(dataKey, context) - } - } + var targets = $.makeArray($(this._selector)); - $(context.getTipElement()).hasClass(Tooltip._ClassName.IN) ? - context._leave(null, context) : - context._enter(null, context) -} + targets.map(function (element) { + var target = undefined; + var targetSelector = Util.getSelectorFromElement(element); + if (targetSelector) { + target = $(targetSelector)[0]; + } -/** - * Remove tooltip functionality - */ -Tooltip.prototype['destroy'] = function () { - clearTimeout(this._timeout) - this['hide'](function () { - $(this.element) - .off(Tooltip._Selector.TOOLTIP) - .removeData(this.getDataKey()) - }.bind(this)) -} + if (target && (target.offsetWidth || target.offsetHeight)) { + // todo (fat): remove sketch reliance on jQuery position/offset + return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; + } + }).filter(function (item) { + return item; + }).sort(function (a, b) { + return a[0] - b[0]; + }).forEach(function (item) { + _this14._offsets.push(item[0]); + _this14._targets.push(item[1]); + }); + } + }, { + key: 'dispose', + value: function dispose() { + $.removeData(this._element, DATA_KEY); + $(this._scrollElement).off(EVENT_KEY); + + this._element = null; + this._scrollElement = null; + this._config = null; + this._selector = null; + this._offsets = null; + this._targets = null; + this._activeTarget = null; + this._scrollHeight = null; + } + }, { + key: '_getConfig', + // private -/** - * Show the tooltip - * todo (fat): ~fuck~ this is a big function - refactor out all of positioning logic - * and replace with external lib - */ -Tooltip.prototype['show'] = function () { - var showEvent = $.Event(this.getEventObject().SHOW) + value: function _getConfig(config) { + config = $.extend({}, Default, config); - if (this.isWithContent() && this._isEnabled) { - $(this.element).trigger(showEvent) + if (typeof config.target !== 'string') { + var id = $(config.target).attr('id'); + if (!id) { + id = Util.getUID(NAME); + $(config.target).attr('id', id); + } + config.target = '#' + id; + } - var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element) + Util.typeCheckConfig(NAME, config, DefaultType); - if (showEvent.isDefaultPrevented() || !isInTheDom) { - return - } + return config; + } + }, { + key: '_getScrollTop', + value: function _getScrollTop() { + return this._scrollElement === window ? this._scrollElement.scrollY : this._scrollElement.scrollTop; + } + }, { + key: '_getScrollHeight', + value: function _getScrollHeight() { + return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); + } + }, { + key: '_process', + value: function _process() { + var scrollTop = this._getScrollTop() + this._config.offset; + var scrollHeight = this._getScrollHeight(); + var maxScroll = this._config.offset + scrollHeight - this._scrollElement.offsetHeight; + + if (this._scrollHeight !== scrollHeight) { + this.refresh(); + } - var tip = this.getTipElement() - var tipId = Bootstrap.getUID(this.getName()) + if (scrollTop >= maxScroll) { + var target = this._targets[this._targets.length - 1]; - tip.setAttribute('id', tipId) - this.element.setAttribute('aria-describedby', tipId) + if (this._activeTarget !== target) { + this._activate(target); + } + } - this.setContent() + if (this._activeTarget && scrollTop < this._offsets[0]) { + this._activeTarget = null; + this._clear(); + return; + } - if (this.config['animation']) { - $(tip).addClass(Tooltip._ClassName.FADE) - } + for (var i = this._offsets.length; i--;) { + var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (this._offsets[i + 1] === undefined || scrollTop < this._offsets[i + 1]); - var placement = typeof this.config['placement'] == 'function' ? - this.config['placement'].call(this, tip, this.element) : - this.config['placement'] + if (isActiveTarget) { + this._activate(this._targets[i]); + } + } + } + }, { + key: '_activate', + value: function _activate(target) { + this._activeTarget = target; - var autoToken = /\s?auto?\s?/i - var isWithAutoPlacement = autoToken.test(placement) + this._clear(); - if (isWithAutoPlacement) { - placement = placement.replace(autoToken, '') || Tooltip.Direction.TOP - } + var selector = '' + this._selector + '[data-target="' + target + '"],' + ('' + this._selector + '[href="' + target + '"]'); - if (tip.parentNode && tip.parentNode.nodeType == Node.ELEMENT_NODE) { - tip.parentNode.removeChild(tip) - } + // todo (fat): getting all the raw li's up the tree is not great. + var parentListItems = $(selector).parents(Selector.LI); - tip.style.top = 0 - tip.style.left = 0 - tip.style.display = 'block' + for (var i = parentListItems.length; i--;) { + $(parentListItems[i]).addClass(ClassName.ACTIVE); - $(tip).addClass(Tooltip._NAME + '-' + placement) + var itemParent = parentListItems[i].parentNode; - $(tip).data(this.getDataKey(), this) + if (itemParent && $(itemParent).hasClass(ClassName.DROPDOWN_MENU)) { + var closestDropdown = $(itemParent).closest(Selector.LI_DROPDOWN)[0]; + $(closestDropdown).addClass(ClassName.ACTIVE); + } + } - if (this.config['container']) { - $(this.config['container'])[0].appendChild(tip) - } else { - this.element.parentNode.insertBefore(tip, this.element.nextSibling) - } + $(this._scrollElement).trigger(Event.ACTIVATE, { + relatedTarget: target + }); + } + }, { + key: '_clear', + value: function _clear() { + var activeParents = $(this._selector).parentsUntil(this._config.target, Selector.ACTIVE); - var position = this._getPosition() - var actualWidth = tip.offsetWidth - var actualHeight = tip.offsetHeight + for (var i = activeParents.length; i--;) { + $(activeParents[i]).removeClass(ClassName.ACTIVE); + } + } + }], [{ + key: 'VERSION', - var calculatedPlacement = this._getCalculatedAutoPlacement(isWithAutoPlacement, placement, position, actualWidth, actualHeight) - var calculatedOffset = this._getCalculatedOffset(calculatedPlacement, position, actualWidth, actualHeight) + // getters - this._applyCalculatedPlacement(calculatedOffset, calculatedPlacement) + get: function () { + return VERSION; + } + }, { + key: 'Default', + get: function () { + return Default; + } + }, { + key: '_jQueryInterface', - var complete = function () { - var prevHoverState = this.hoverState - $(this.element).trigger(this.getEventObject().SHOWN) - this.hoverState = null + // static - if (prevHoverState == 'out') this._leave(null, this) - }.bind(this) + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = typeof config === 'object' && config || null; - Bootstrap.transition && $(this._tip).hasClass(Tooltip._ClassName.FADE) ? - $(this._tip) - .one(Bootstrap.TRANSITION_END, complete) - .emulateTransitionEnd(Tooltip._TRANSITION_DURATION) : - complete() - } -} + if (!data) { + data = new ScrollSpy(this, _config); + $(this).data(DATA_KEY, data); + } + if (typeof config === 'string') { + data[config](); + } + }); + } + }]); -/** - * Hide the tooltip breh - */ -Tooltip.prototype['hide'] = function (callback) { - var tip = this.getTipElement() - var hideEvent = $.Event(this.getEventObject().HIDE) + return ScrollSpy; + })(); - var complete = function () { - if (this._hoverState != Tooltip._HoverState.IN) { - tip.parentNode.removeChild(tip) - } + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - this.element.removeAttribute('aria-describedby') - $(this.element).trigger(this.getEventObject().HIDDEN) + $(window).on(Event.LOAD_DATA_API, function () { + var scrollSpys = $.makeArray($(Selector.DATA_SPY)); - if (callback) { - callback() + for (var i = scrollSpys.length; i--;) { + var $spy = $(scrollSpys[i]); + ScrollSpy._jQueryInterface.call($spy, $spy.data()); } - }.bind(this) - - $(this.element).trigger(hideEvent) - - if (hideEvent.isDefaultPrevented()) return - - $(tip).removeClass(Tooltip._ClassName.IN) - - if (Bootstrap.transition && $(this._tip).hasClass(Tooltip._ClassName.FADE)) { - $(tip) - .one(Bootstrap.TRANSITION_END, complete) - .emulateTransitionEnd(Tooltip._TRANSITION_DURATION) - } else { - complete() - } - - this._hoverState = '' -} + }); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ -/** - * @return {string} - */ -Tooltip.prototype['getHoverState'] = function (callback) { - return this._hoverState -} + $.fn[NAME] = ScrollSpy._jQueryInterface; + $.fn[NAME].Constructor = ScrollSpy; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return ScrollSpy._jQueryInterface; + }; + return ScrollSpy; +})(jQuery); /** - * @return {string} - * @protected - */ -Tooltip.prototype.getName = function () { - return Tooltip._NAME -} - - -/** - * @return {string} - * @protected - */ -Tooltip.prototype.getDataKey = function () { - return Tooltip._DATA_KEY -} - - -/** - * @return {Object} - * @protected - */ -Tooltip.prototype.getEventObject = function () { - return Tooltip._Event -} - - -/** - * @return {string} - * @protected - */ -Tooltip.prototype.getTitle = function () { - var title = this.element.getAttribute('data-original-title') - - if (!title) { - title = typeof this.config['title'] === 'function' ? - this.config['title'].call(this.element) : - this.config['title'] - } - - return /** @type {string} */ (title) -} - - -/** - * @return {Element} - * @protected - */ -Tooltip.prototype.getTipElement = function () { - return (this._tip = this._tip || $(this.config['template'])[0]) -} - - -/** - * @return {Element} - * @protected - */ -Tooltip.prototype.getArrowElement = function () { - return (this.arrow = this.arrow || $(this.getTipElement()).find(Tooltip._Selector.TOOLTIP_ARROW)[0]) -} - - -/** - * @return {boolean} - * @protected - */ -Tooltip.prototype.isWithContent = function () { - return !!this.getTitle() -} - - -/** - * @protected - */ -Tooltip.prototype.setContent = function () { - var tip = this.getTipElement() - var title = this.getTitle() - - $(tip).find(Tooltip._Selector.TOOLTIP_INNER)[0][this.config['html'] ? 'innerHTML' : 'innerText'] = title - - $(tip) - .removeClass(Tooltip._ClassName.FADE) - .removeClass(Tooltip._ClassName.IN) - - for (var direction in Tooltip.Direction) { - $(tip).removeClass(Tooltip._NAME + '-' + direction) - } -} - - -/** - * @private - */ -Tooltip.prototype._setListeners = function () { - var triggers = this.config['trigger'].split(' ') - - triggers.forEach(function (trigger) { - if (trigger == 'click') { - $(this.element).on('click.bs.tooltip', this.config['selector'], this['toggle'].bind(this)) - - } else if (trigger != 'manual') { - var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin' - var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout' - - $(this.element) - .on(eventIn + '.bs.tooltip', this.config['selector'], this._enter.bind(this)) - .on(eventOut + '.bs.tooltip', this.config['selector'], this._leave.bind(this)) - } - }.bind(this)) + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): tab.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Tab = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'tab'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.tab'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + + var 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 + }; + + var ClassName = { + DROPDOWN_MENU: 'dropdown-menu', + ACTIVE: 'active', + FADE: 'fade', + IN: 'in' + }; + + var Selector = { + A: 'a', + LI: 'li', + LI_DROPDOWN: 'li.dropdown', + UL: 'ul:not(.dropdown-menu)', + FADE_CHILD: '> .fade', + ACTIVE: '.active', + ACTIVE_CHILD: '> .active', + DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"]', + DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu > .active' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Tab = (function () { + function Tab(element) { + _classCallCheck(this, Tab); + + this._element = element; + } + + _createClass(Tab, [{ + key: 'show', + + // public + + value: function show() { + var _this15 = this; + + if (this._element.parentNode && this._element.parentNode.nodeType == Node.ELEMENT_NODE && $(this._element).parent().hasClass(ClassName.ACTIVE)) { + return; + } - if (this.config['selector']) { - this.config = $.extend({}, this.config, { 'trigger': 'manual', 'selector': '' }) - } else { - this._fixTitle() - } -} + var target = undefined; + var previous = undefined; + var ulElement = $(this._element).closest(Selector.UL)[0]; + var selector = Util.getSelectorFromElement(this._element); + if (ulElement) { + previous = $.makeArray($(ulElement).find(Selector.ACTIVE)); + previous = previous[previous.length - 1]; -/** - * @param {Object=} opt_config - * @return {Object} - * @private - */ -Tooltip.prototype._getConfig = function (opt_config) { - var config = $.extend({}, this.constructor['Defaults'], $(this.element).data(), opt_config) + if (previous) { + previous = $(previous).find(Selector.A)[0]; + } + } - if (config['delay'] && typeof config['delay'] == 'number') { - config['delay'] = { - 'show': config['delay'], - 'hide': config['delay'] - } - } + var hideEvent = $.Event(Event.HIDE, { + relatedTarget: this._element + }); - return config -} + var showEvent = $.Event(Event.SHOW, { + relatedTarget: previous + }); + if (previous) { + $(previous).trigger(hideEvent); + } -/** - * @return {Object} - * @private - */ -Tooltip.prototype._getDelegateConfig = function () { - var config = {} - var defaults = this.constructor['Defaults'] - - if (this.config) { - for (var key in this.config) { - var value = this.config[key] - if (defaults[key] != value) config[key] = value - } - } + $(this._element).trigger(showEvent); - return config -} + if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { + return; + } + if (selector) { + target = $(selector)[0]; + } + this._activate($(this._element).closest(Selector.LI)[0], ulElement); -/** - * @param {boolean} isWithAutoPlacement - * @param {string} placement - * @param {Object} position - * @param {number} actualWidth - * @param {number} actualHeight - * @return {string} - * @private - */ -Tooltip.prototype._getCalculatedAutoPlacement = function (isWithAutoPlacement, placement, position, actualWidth, actualHeight) { - if (isWithAutoPlacement) { - var originalPlacement = placement - var container = this.config['container'] ? $(this.config['container'])[0] : this.element.parentNode - var containerDim = this._getPosition(/** @type {Element} */ (container)) - - placement = placement == Tooltip.Direction.BOTTOM && position.bottom + actualHeight > containerDim.bottom ? Tooltip.Direction.TOP : - placement == Tooltip.Direction.TOP && position.top - actualHeight < containerDim.top ? Tooltip.Direction.BOTTOM : - placement == Tooltip.Direction.RIGHT && position.right + actualWidth > containerDim.width ? Tooltip.Direction.LEFT : - placement == Tooltip.Direction.LEFT && position.left - actualWidth < containerDim.left ? Tooltip.Direction.RIGHT : - placement - - $(this._tip) - .removeClass(Tooltip._NAME + '-' + originalPlacement) - .addClass(Tooltip._NAME + '-' + placement) - } + var complete = function complete() { + var hiddenEvent = $.Event(Event.HIDDEN, { + relatedTarget: _this15._element + }); - return placement -} + var shownEvent = $.Event(Event.SHOWN, { + relatedTarget: previous + }); + $(previous).trigger(hiddenEvent); + $(_this15._element).trigger(shownEvent); + }; -/** - * @param {string} placement - * @param {Object} position - * @param {number} actualWidth - * @param {number} actualHeight - * @return {{left: number, top: number}} - * @private - */ -Tooltip.prototype._getCalculatedOffset = function (placement, position, actualWidth, actualHeight) { - return placement == Tooltip.Direction.BOTTOM ? { top: position.top + position.height, left: position.left + position.width / 2 - actualWidth / 2 } : - placement == Tooltip.Direction.TOP ? { top: position.top - actualHeight, left: position.left + position.width / 2 - actualWidth / 2 } : - placement == Tooltip.Direction.LEFT ? { top: position.top + position.height / 2 - actualHeight / 2, left: position.left - actualWidth } : - /* placement == Tooltip.Direction.RIGHT */ { top: position.top + position.height / 2 - actualHeight / 2, left: position.left + position.width } -} + if (target) { + this._activate(target, target.parentNode, complete); + } else { + complete(); + } + } + }, { + key: 'dispose', + value: function dispose() { + $.removeClass(this._element, DATA_KEY); + this._element = null; + } + }, { + key: '_activate', + // private -/** - * @param {string} placement - * @param {Object} position - * @param {number} actualWidth - * @param {number} actualHeight - * @return {Object} - * @private - */ -Tooltip.prototype._getViewportAdjustedDelta = function (placement, position, actualWidth, actualHeight) { - var delta = { top: 0, left: 0 } + value: function _activate(element, container, callback) { + var active = $(container).find(Selector.ACTIVE_CHILD)[0]; + var isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || !!$(container).find(Selector.FADE_CHILD)[0]); - if (!this._viewport) { - return delta - } - - var viewportPadding = this.config['viewport'] && this.config['viewport']['padding'] || 0 - var viewportDimensions = this._getPosition(this._viewport) + var complete = $.proxy(this._transitionComplete, this, element, active, isTransitioning, callback); - if (placement === Tooltip.Direction.RIGHT || placement === Tooltip.Direction.LEFT) { - var topEdgeOffset = position.top - viewportPadding - viewportDimensions.scroll - var bottomEdgeOffset = position.top + viewportPadding - viewportDimensions.scroll + actualHeight + if (active && isTransitioning) { + $(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + complete(); + } - if (topEdgeOffset < viewportDimensions.top) { // top overflow - delta.top = viewportDimensions.top - topEdgeOffset + if (active) { + $(active).removeClass(ClassName.IN); + } + } + }, { + key: '_transitionComplete', + value: function _transitionComplete(element, active, isTransitioning, callback) { + if (active) { + $(active).removeClass(ClassName.ACTIVE); + + var dropdownChild = $(active).find(Selector.DROPDOWN_ACTIVE_CHILD)[0]; + if (dropdownChild) { + $(dropdownChild).removeClass(ClassName.ACTIVE); + } - } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow - delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset - } + var activeToggle = $(active).find(Selector.DATA_TOGGLE)[0]; + if (activeToggle) { + activeToggle.setAttribute('aria-expanded', false); + } + } - } else { - var leftEdgeOffset = position.left - viewportPadding - var rightEdgeOffset = position.left + viewportPadding + actualWidth + $(element).addClass(ClassName.ACTIVE); - if (leftEdgeOffset < viewportDimensions.left) { // left overflow - delta.left = viewportDimensions.left - leftEdgeOffset + var elementToggle = $(element).find(Selector.DATA_TOGGLE)[0]; + if (elementToggle) { + elementToggle.setAttribute('aria-expanded', true); + } - } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow - delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset - } - } + if (isTransitioning) { + Util.reflow(element); + $(element).addClass(ClassName.IN); + } else { + $(element).removeClass(ClassName.FADE); + } - return delta -} + if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) { + var dropdownElement = $(element).closest(Selector.LI_DROPDOWN)[0]; + if (dropdownElement) { + $(dropdownElement).addClass(ClassName.ACTIVE); + } -/** - * @param {Element=} opt_element - * @return {Object} - * @private - */ -Tooltip.prototype._getPosition = function (opt_element) { - var element = opt_element || this.element - var isBody = element.tagName == 'BODY' - var rect = element.getBoundingClientRect() - var offset = isBody ? { top: 0, left: 0 } : $(element).offset() - var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : this.element.scrollTop } - var outerDims = isBody ? { width: window.innerWidth, height: window.innerHeight } : null - - return $.extend({}, rect, scroll, outerDims, offset) -} + elementToggle = $(element).find(Selector.DATA_TOGGLE)[0]; + if (elementToggle) { + elementToggle.setAttribute('aria-expanded', true); + } + } + if (callback) { + callback(); + } + } + }], [{ + key: 'VERSION', -/** - * @param {{left: number, top: number}} offset - * @param {string} placement - * @private - */ -Tooltip.prototype._applyCalculatedPlacement = function (offset, placement) { - var tip = this.getTipElement() - var width = tip.offsetWidth - var height = tip.offsetHeight - - // manually read margins because getBoundingClientRect includes difference - var marginTop = parseInt(tip.style.marginTop, 10) - var marginLeft = parseInt(tip.style.marginLeft, 10) - - // we must check for NaN for ie 8/9 - if (isNaN(marginTop)) { - marginTop = 0 - } - if (isNaN(marginLeft)) { - marginLeft = 0 - } + // getters - offset.top = offset.top + marginTop - offset.left = offset.left + marginLeft + get: function () { + return VERSION; + } + }, { + key: '_jQueryInterface', - // $.fn.offset doesn't round pixel values - // so we use setOffset directly with our own function B-0 - $.offset.setOffset(tip, $.extend({ - using: function (props) { - tip.style.top = Math.round(props.top) + 'px' - tip.style.left = Math.round(props.left) + 'px' - } - }, offset), 0) + // static - $(tip).addClass(Tooltip._ClassName.IN) + value: function _jQueryInterface(config) { + return this.each(function () { + var $this = $(this); + var data = $this.data(DATA_KEY); - // check to see if placing tip in new offset caused the tip to resize itself - var actualWidth = tip.offsetWidth - var actualHeight = tip.offsetHeight + if (!data) { + data = data = new Tab(this); + $this.data(DATA_KEY, data); + } - if (placement == Tooltip.Direction.TOP && actualHeight != height) { - offset.top = offset.top + height - actualHeight - } + if (typeof config === 'string') { + data[config](); + } + }); + } + }]); - var delta = this._getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight) + return Tab; + })(); - if (delta.left) { - offset.left += delta.left - } else { - offset.top += delta.top - } + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - var isVertical = placement === Tooltip.Direction.TOP || placement === Tooltip.Direction.BOTTOM - var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight - var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight' + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + event.preventDefault(); + Tab._jQueryInterface.call($(this), 'show'); + }); - $(tip).offset(offset) + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ - this._replaceArrow(arrowDelta, tip[arrowOffsetPosition], isVertical) -} + $.fn[NAME] = Tab._jQueryInterface; + $.fn[NAME].Constructor = Tab; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Tab._jQueryInterface; + }; + return Tab; +})(jQuery); /** - * @param {number} delta - * @param {number} dimension - * @param {boolean} isHorizontal - * @private - */ -Tooltip.prototype._replaceArrow = function (delta, dimension, isHorizontal) { - var arrow = this.getArrowElement() - - arrow.style[isHorizontal ? 'left' : 'top'] = 50 * (1 - delta / dimension) + '%' - arrow.style[isHorizontal ? 'top' : 'left'] = '' -} - + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): tooltip.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Tooltip = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'tooltip'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.tooltip'; + var EVENT_KEY = '.' + DATA_KEY; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + var CLASS_PREFIX = 'bs-tether'; + + var Default = { + animation: true, + template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div></div>', + trigger: 'hover focus', + title: '', + delay: 0, + html: false, + selector: false, + placement: 'top', + offset: '0 0', + constraints: [] + }; + + var DefaultType = { + animation: 'boolean', + template: 'string', + title: '(string|function)', + trigger: 'string', + delay: '(number|object)', + html: 'boolean', + selector: '(string|boolean)', + placement: '(string|function)', + offset: 'string', + constraints: 'array' + }; + + var AttachmentMap = { + TOP: 'bottom center', + RIGHT: 'middle left', + BOTTOM: 'top center', + LEFT: 'middle right' + }; + + var HoverState = { + IN: 'in', + OUT: 'out' + }; + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + INSERTED: 'inserted' + EVENT_KEY, + CLICK: 'click' + EVENT_KEY, + FOCUSIN: 'focusin' + EVENT_KEY, + FOCUSOUT: 'focusout' + EVENT_KEY, + MOUSEENTER: 'mouseenter' + EVENT_KEY, + MOUSELEAVE: 'mouseleave' + EVENT_KEY + }; + + var ClassName = { + FADE: 'fade', + IN: 'in' + }; + + var Selector = { + TOOLTIP: '.tooltip', + TOOLTIP_INNER: '.tooltip-inner' + }; + + var TetherClass = { + element: false, + enabled: false + }; + + var Trigger = { + HOVER: 'hover', + FOCUS: 'focus', + CLICK: 'click', + MANUAL: 'manual' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Tooltip = (function () { + function Tooltip(element, config) { + _classCallCheck(this, Tooltip); + + // private + this._isEnabled = true; + this._timeout = 0; + this._hoverState = ''; + this._activeTrigger = {}; + this._tether = null; + + // protected + this.element = element; + this.config = this._getConfig(config); + this.tip = null; + + this._setListeners(); + } + + _createClass(Tooltip, [{ + key: 'enable', + + // public + + value: function enable() { + this._isEnabled = true; + } + }, { + key: 'disable', + value: function disable() { + this._isEnabled = false; + } + }, { + key: 'toggleEnabled', + value: function toggleEnabled() { + this._isEnabled = !this._isEnabled; + } + }, { + key: 'toggle', + value: function toggle(event) { + var context = this; + var dataKey = this.constructor.DATA_KEY; + + if (event) { + context = $(event.currentTarget).data(dataKey); + + if (!context) { + context = new this.constructor(event.currentTarget, this._getDelegateConfig()); + $(event.currentTarget).data(dataKey, context); + } + context._activeTrigger.click = !context._activeTrigger.click; -/** - * @private - */ -Tooltip.prototype._fixTitle = function () { - if (this.element.getAttribute('title') || typeof this.element.getAttribute('data-original-title') != 'string') { - this.element.setAttribute('data-original-title', this.element.getAttribute('title') || '') - this.element.setAttribute('title', '') - } -} + if (context._isWithActiveTrigger()) { + context._enter(null, context); + } else { + context._leave(null, context); + } + } else { + $(context.getTipElement()).hasClass(ClassName.IN) ? context._leave(null, context) : context._enter(null, context); + } + } + }, { + key: 'dispose', + value: function dispose() { + clearTimeout(this._timeout); + this.cleanupTether(); -/** - * @param {Event=} opt_event - * @param {Object=} opt_context - * @private - */ -Tooltip.prototype._enter = function (opt_event, opt_context) { - var dataKey = this.getDataKey() - var context = opt_context || $(opt_event.currentTarget).data(dataKey) + $.removeData(this.element, this.constructor.DATA_KEY); - if (context && context._tip && context._tip.offsetWidth) { - context._hoverState = Tooltip._HoverState.IN - return - } + $(this.element).off(this.constructor.EVENT_KEY); - if (!context) { - context = new this.constructor(opt_event.currentTarget, this._getDelegateConfig()) - $(opt_event.currentTarget).data(dataKey, context) - } + if (this.tip) { + $(this.tip).remove(); + } - clearTimeout(context._timeout) + this._isEnabled = null; + this._timeout = null; + this._hoverState = null; + this._activeTrigger = null; + this._tether = null; - context._hoverState = Tooltip._HoverState.IN + this.element = null; + this.config = null; + this.tip = null; + } + }, { + key: 'show', + value: function show() { + var _this16 = this; - if (!context.config['delay'] || !context.config['delay']['show']) { - context['show']() - return - } + var showEvent = $.Event(this.constructor.Event.SHOW); - context._timeout = setTimeout(function () { - if (context._hoverState == Tooltip._HoverState.IN) { - context['show']() - } - }, context.config['delay']['show']) -} + if (this.isWithContent() && this._isEnabled) { + $(this.element).trigger(showEvent); + var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element); -/** - * @param {Event=} opt_event - * @param {Object=} opt_context - * @private - */ -Tooltip.prototype._leave = function (opt_event, opt_context) { - var dataKey = this.getDataKey() - var context = opt_context || $(opt_event.currentTarget).data(dataKey) + if (showEvent.isDefaultPrevented() || !isInTheDom) { + return; + } - if (!context) { - context = new this.constructor(opt_event.currentTarget, this._getDelegateConfig()) - $(opt_event.currentTarget).data(dataKey, context) - } + var tip = this.getTipElement(); + var tipId = Util.getUID(this.constructor.NAME); - clearTimeout(context._timeout) + tip.setAttribute('id', tipId); + this.element.setAttribute('aria-describedby', tipId); - context._hoverState = Tooltip._HoverState.OUT + this.setContent(); - if (!context.config['delay'] || !context.config['delay']['hide']) { - context['hide']() - return - } + if (this.config.animation) { + $(tip).addClass(ClassName.FADE); + } - context._timeout = setTimeout(function () { - if (context._hoverState == Tooltip._HoverState.OUT) { - context['hide']() - } - }, context.config['delay']['hide']) -} + var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; + var attachment = this._getAttachment(placement); + $(tip).data(this.constructor.DATA_KEY, this).appendTo(document.body); -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ + $(this.element).trigger(this.constructor.Event.INSERTED); -/** - * @const - * @type {Function} - */ -$.fn[Tooltip._NAME] = Tooltip._jQueryInterface + this._tether = new Tether({ + element: tip, + target: this.element, + attachment: attachment, + classes: TetherClass, + classPrefix: CLASS_PREFIX, + offset: this.config.offset, + constraints: this.config.constraints + }); + Util.reflow(tip); + this._tether.position(); -/** - * @const - * @type {Function} - */ -$.fn[Tooltip._NAME]['Constructor'] = Tooltip + $(tip).addClass(ClassName.IN); + var complete = function complete() { + var prevHoverState = _this16._hoverState; + _this16._hoverState = null; -/** - * @const - * @type {Function} - */ -$.fn[Tooltip._NAME]['noConflict'] = function () { - $.fn[Tooltip._NAME] = Tooltip._JQUERY_NO_CONFLICT - return this -} + $(_this16.element).trigger(_this16.constructor.Event.SHOWN); -/** ======================================================================= - * Bootstrap: popover.js v4.0.0 - * http://getbootstrap.com/javascript/#popovers - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's popover plugin - extends tooltip. - * - * Public Methods & Properties: - * - * + $.popover - * + $.popover.noConflict - * + $.popover.Constructor - * + $.popover.Constructor.VERSION - * + $.popover.Constructor.Defaults - * + $.popover.Constructor.Defaults.container - * + $.popover.Constructor.Defaults.animation - * + $.popover.Constructor.Defaults.placement - * + $.popover.Constructor.Defaults.selector - * + $.popover.Constructor.Defaults.template - * + $.popover.Constructor.Defaults.trigger - * + $.popover.Constructor.Defaults.title - * + $.popover.Constructor.Defaults.content - * + $.popover.Constructor.Defaults.delay - * + $.popover.Constructor.Defaults.html - * + $.popover.Constructor.Defaults.viewport - * + $.popover.Constructor.Defaults.viewport.selector - * + $.popover.Constructor.Defaults.viewport.padding - * + $.popover.Constructor.prototype.enable - * + $.popover.Constructor.prototype.disable - * + $.popover.Constructor.prototype.destroy - * + $.popover.Constructor.prototype.toggleEnabled - * + $.popover.Constructor.prototype.toggle - * + $.popover.Constructor.prototype.show - * + $.popover.Constructor.prototype.hide - * - * ======================================================================== - */ + if (prevHoverState === HoverState.OUT) { + _this16._leave(null, _this16); + } + }; + Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE) ? $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION) : complete(); + } + } + }, { + key: 'hide', + value: function hide(callback) { + var _this17 = this; + + var tip = this.getTipElement(); + var hideEvent = $.Event(this.constructor.Event.HIDE); + var complete = function complete() { + if (_this17._hoverState !== HoverState.IN && tip.parentNode) { + tip.parentNode.removeChild(tip); + } -'use strict'; + _this17.element.removeAttribute('aria-describedby'); + $(_this17.element).trigger(_this17.constructor.Event.HIDDEN); + _this17.cleanupTether(); + if (callback) { + callback(); + } + }; -if (!Tooltip) throw new Error('Popover requires tooltip.js') + $(this.element).trigger(hideEvent); + if (hideEvent.isDefaultPrevented()) { + return; + } -/** - * Our tooltip class. - * @param {Element!} element - * @param {Object=} opt_config - * @constructor - * @extends {Tooltip} - */ -var Popover = function (element, opt_config) { - Tooltip.apply(this, arguments) -} -Bootstrap.inherits(Popover, Tooltip) + $(tip).removeClass(ClassName.IN); + if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { -/** - * @const - * @type {string} - */ -Popover['VERSION'] = '4.0.0' + $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + complete(); + } + this._hoverState = ''; + } + }, { + key: 'isWithContent', -/** - * @const - * @type {Object} - */ -Popover['Defaults'] = $.extend({}, $.fn['tooltip']['Constructor']['Defaults'], { - 'placement': 'right', - 'trigger': 'click', - 'content': '', - 'template': '<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' -}) + // protected + value: function isWithContent() { + return !!this.getTitle(); + } + }, { + key: 'getTipElement', + value: function getTipElement() { + return this.tip = this.tip || $(this.config.template)[0]; + } + }, { + key: 'setContent', + value: function setContent() { + var tip = this.getTipElement(); + var title = this.getTitle(); + var method = this.config.html ? 'innerHTML' : 'innerText'; -/** - * @const - * @type {string} - * @private - */ -Popover._NAME = 'popover' + $(tip).find(Selector.TOOLTIP_INNER)[0][method] = title; + $(tip).removeClass(ClassName.FADE).removeClass(ClassName.IN); -/** - * @const - * @type {string} - * @private - */ -Popover._DATA_KEY = 'bs.popover' + this.cleanupTether(); + } + }, { + key: 'getTitle', + value: function getTitle() { + var title = this.element.getAttribute('data-original-title'); + if (!title) { + title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title; + } -/** - * @const - * @enum {string} - * @private - */ -Popover._Event = { - HIDE : 'hide.bs.popover', - HIDDEN : 'hidden.bs.popover', - SHOW : 'show.bs.popover', - SHOWN : 'shown.bs.popover' -} + return title; + } + }, { + key: 'cleanupTether', + value: function cleanupTether() { + if (this._tether) { + this._tether.destroy(); + + // clean up after tether's junk classes + // remove after they fix issue + // (https://github.com/HubSpot/tether/issues/36) + $(this.element).removeClass(this._removeTetherClasses); + $(this.tip).removeClass(this._removeTetherClasses); + } + } + }, { + key: '_getAttachment', + // private -/** - * @const - * @enum {string} - * @private - */ -Popover._ClassName = { - FADE : 'fade', - IN : 'in' -} + value: function _getAttachment(placement) { + return AttachmentMap[placement.toUpperCase()]; + } + }, { + key: '_setListeners', + value: function _setListeners() { + var _this18 = this; + var triggers = this.config.trigger.split(' '); -/** - * @const - * @enum {string} - * @private - */ -Popover._Selector = { - TITLE : '.popover-title', - CONTENT : '.popover-content', - ARROW : '.popover-arrow' -} + triggers.forEach(function (trigger) { + if (trigger === 'click') { + $(_this18.element).on(_this18.constructor.Event.CLICK, _this18.config.selector, $.proxy(_this18.toggle, _this18)); + } else if (trigger !== Trigger.MANUAL) { + var eventIn = trigger == Trigger.HOVER ? _this18.constructor.Event.MOUSEENTER : _this18.constructor.Event.FOCUSIN; + var eventOut = trigger == Trigger.HOVER ? _this18.constructor.Event.MOUSELEAVE : _this18.constructor.Event.FOCUSOUT; + $(_this18.element).on(eventIn, _this18.config.selector, $.proxy(_this18._enter, _this18)).on(eventOut, _this18.config.selector, $.proxy(_this18._leave, _this18)); + } + }); -/** - * @const - * @type {Function} - * @private - */ -Popover._JQUERY_NO_CONFLICT = $.fn[Popover._NAME] + if (this.config.selector) { + this.config = $.extend({}, this.config, { + trigger: 'manual', + selector: '' + }); + } else { + this._fixTitle(); + } + } + }, { + key: '_removeTetherClasses', + value: function _removeTetherClasses(i, css) { + return ((css.baseVal || css).match(new RegExp('(^|\\s)' + CLASS_PREFIX + '-\\S+', 'g')) || []).join(' '); + } + }, { + key: '_fixTitle', + value: function _fixTitle() { + var titleType = typeof this.element.getAttribute('data-original-title'); + if (this.element.getAttribute('title') || titleType !== 'string') { + this.element.setAttribute('data-original-title', this.element.getAttribute('title') || ''); + this.element.setAttribute('title', ''); + } + } + }, { + key: '_enter', + value: function _enter(event, context) { + var dataKey = this.constructor.DATA_KEY; + context = context || $(event.currentTarget).data(dataKey); -/** - * @param {Object|string=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -Popover._jQueryInterface = function (opt_config) { - return this.each(function () { - var data = $(this).data(Popover._DATA_KEY) - var config = typeof opt_config === 'object' ? opt_config : null + if (!context) { + context = new this.constructor(event.currentTarget, this._getDelegateConfig()); + $(event.currentTarget).data(dataKey, context); + } - if (!data && opt_config === 'destroy') { - return - } + if (event) { + context._activeTrigger[event.type == 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true; + } - if (!data) { - data = new Popover(this, config) - $(this).data(Popover._DATA_KEY, data) - } + if ($(context.getTipElement()).hasClass(ClassName.IN) || context._hoverState === HoverState.IN) { + context._hoverState = HoverState.IN; + return; + } - if (typeof opt_config === 'string') { - data[opt_config]() - } - }) -} + clearTimeout(context._timeout); + context._hoverState = HoverState.IN; -/** - * @return {string} - * @protected - */ -Popover.prototype.getName = function () { - return Popover._NAME -} + if (!context.config.delay || !context.config.delay.show) { + context.show(); + return; + } + context._timeout = setTimeout(function () { + if (context._hoverState === HoverState.IN) { + context.show(); + } + }, context.config.delay.show); + } + }, { + key: '_leave', + value: function _leave(event, context) { + var dataKey = this.constructor.DATA_KEY; -/** - * @override - */ -Popover.prototype.getDataKey = function () { - return Popover._DATA_KEY -} + context = context || $(event.currentTarget).data(dataKey); + if (!context) { + context = new this.constructor(event.currentTarget, this._getDelegateConfig()); + $(event.currentTarget).data(dataKey, context); + } -/** - * @override - */ -Popover.prototype.getEventObject = function () { - return Popover._Event -} + if (event) { + context._activeTrigger[event.type == 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false; + } + if (context._isWithActiveTrigger()) { + return; + } -/** - * @override - */ -Popover.prototype.getArrowElement = function () { - return (this.arrow = this.arrow || $(this.getTipElement()).find(Popover._Selector.ARROW)[0]) -} + clearTimeout(context._timeout); + context._hoverState = HoverState.OUT; -/** - * @override - */ -Popover.prototype.setContent = function () { - var tip = this.getTipElement() - var title = this.getTitle() - var content = this._getContent() - var titleElement = $(tip).find(Popover._Selector.TITLE)[0] - - if (titleElement) { - titleElement[this.config['html'] ? 'innerHTML' : 'innerText'] = title - } + if (!context.config.delay || !context.config.delay.hide) { + context.hide(); + return; + } - // we use append for html objects to maintain js events - $(tip).find(Popover._Selector.CONTENT).children().detach().end()[ - this.config['html'] ? (typeof content == 'string' ? 'html' : 'append') : 'text' - ](content) + context._timeout = setTimeout(function () { + if (context._hoverState === HoverState.OUT) { + context.hide(); + } + }, context.config.delay.hide); + } + }, { + key: '_isWithActiveTrigger', + value: function _isWithActiveTrigger() { + for (var trigger in this._activeTrigger) { + if (this._activeTrigger[trigger]) { + return true; + } + } - $(tip) - .removeClass(Popover._ClassName.FADE) - .removeClass(Popover._ClassName.IN) + return false; + } + }, { + key: '_getConfig', + value: function _getConfig(config) { + config = $.extend({}, this.constructor.Default, $(this.element).data(), config); + + if (config.delay && typeof config.delay === 'number') { + config.delay = { + show: config.delay, + hide: config.delay + }; + } - for (var direction in Tooltip.Direction) { - $(tip).removeClass(Popover._NAME + '-' + Tooltip.Direction[direction]) - } -} + Util.typeCheckConfig(NAME, config, this.constructor.DefaultType); + return config; + } + }, { + key: '_getDelegateConfig', + value: function _getDelegateConfig() { + var config = {}; + + if (this.config) { + for (var key in this.config) { + var value = this.config[key]; + if (this.constructor.Default[key] !== value) { + config[key] = value; + } + } + } -/** - * @override - */ -Popover.prototype.isWithContent = function () { - return this.getTitle() || this._getContent() -} + return config; + } + }], [{ + key: 'VERSION', + // getters -/** - * @override - */ -Popover.prototype.getTipElement = function () { - return (this.tip = this.tip || $(this.config['template'])[0]) -} + get: function () { + return VERSION; + } + }, { + key: 'Default', + get: function () { + return Default; + } + }, { + key: 'NAME', + get: function () { + return NAME; + } + }, { + key: 'DATA_KEY', + get: function () { + return DATA_KEY; + } + }, { + key: 'Event', + get: function () { + return Event; + } + }, { + key: 'EVENT_KEY', + get: function () { + return EVENT_KEY; + } + }, { + key: 'DefaultType', + get: function () { + return DefaultType; + } + }, { + key: '_jQueryInterface', + // static -/** - * @private - */ -Popover.prototype._getContent = function () { - return this.element.getAttribute('data-content') - || (typeof this.config['content'] == 'function' ? - this.config['content'].call(this.element) : - this.config['content']) -} + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = typeof config === 'object' ? config : null; + if (!data && /destroy|hide/.test(config)) { + return; + } + if (!data) { + data = new Tooltip(this, _config); + $(this).data(DATA_KEY, data); + } -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ + if (typeof config === 'string') { + data[config](); + } + }); + } + }]); -/** - * @const - * @type {Function} - */ -$.fn[Popover._NAME] = Popover._jQueryInterface + return Tooltip; + })(); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ -/** - * @const - * @type {Function} - */ -$.fn[Popover._NAME]['Constructor'] = Popover + $.fn[NAME] = Tooltip._jQueryInterface; + $.fn[NAME].Constructor = Tooltip; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Tooltip._jQueryInterface; + }; + return Tooltip; +})(jQuery); /** - * @const - * @type {Function} - */ -$.fn[Popover._NAME]['noConflict'] = function () { - $.fn[Popover._NAME] = Popover._JQUERY_NO_CONFLICT - return this -} - -/** ======================================================================= - * Bootstrap: tab.js v4.0.0 - * http://getbootstrap.com/javascript/#tabs - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== - * @fileoverview - Bootstrap's tab plugin. Tab O_O - * - * Public Methods & Properties: - * - * + $.tab - * + $.tab.noConflict - * + $.tab.Constructor - * + $.tab.Constructor.VERSION - * + $.tab.Constructor.prototype.show - * - * ======================================================================== - */ - - -'use strict'; - -/** - * Our Tab class. - * @param {Element!} element - * @constructor - */ -var Tab = function (element) { - - /** @type {Element} */ - this._element = element - -} - - -/** - * @const - * @type {string} - */ -Tab['VERSION'] = '4.0.0' - - -/** - * @const - * @type {string} - * @private - */ -Tab._NAME = 'tab' - - -/** - * @const - * @type {string} - * @private - */ -Tab._DATA_KEY = 'bs.tab' - - -/** - * @const - * @type {number} - * @private - */ -Tab._TRANSITION_DURATION = 150 - - -/** - * @const - * @enum {string} - * @private - */ -Tab._Event = { - HIDE : 'hide.bs.tab', - HIDDEN : 'hidden.bs.tab', - SHOW : 'show.bs.tab', - SHOWN : 'shown.bs.tab' -} - - -/** - * @const - * @enum {string} - * @private - */ -Tab._ClassName = { - DROPDOWN_MENU : 'dropdown-menu', - ACTIVE : 'active', - FADE : 'fade', - IN : 'in' -} - - -/** - * @const - * @enum {string} - * @private - */ -Tab._Selector = { - A : 'a', - LI : 'li', - LI_DROPDOWN : 'li.dropdown', - UL : 'ul:not(.dropdown-menu)', - FADE_CHILD : ':scope > .fade', - ACTIVE : '.active', - ACTIVE_CHILD : ':scope > .active', - DATA_TOGGLE : '[data-toggle="tab"], [data-toggle="pill"]', - DROPDOWN_ACTIVE_CHILD : ':scope > .dropdown-menu > .active' -} - - -/** - * @param {Object|string=} opt_config - * @this {jQuery} - * @return {jQuery} - * @private - */ -Tab._jQueryInterface = function (opt_config) { - return this.each(function () { - var $this = $(this) - var data = $this.data(Tab._DATA_KEY) - - if (!data) { - data = data = new Tab(this) - $this.data(Tab._DATA_KEY, data) - } - - if (typeof opt_config === 'string') { - data[opt_config]() - } - }) -} - - -/** - * Show the tab - */ -Tab.prototype['show'] = function () { - if ( this._element.parentNode - && this._element.parentNode.nodeType == Node.ELEMENT_NODE - && $(this._element).parent().hasClass(Tab._ClassName.ACTIVE)) { - return - } - - var ulElement = $(this._element).closest(Tab._Selector.UL)[0] - var selector = Bootstrap.getSelectorFromElement(this._element) - - if (ulElement) { - var previous = /** @type {Array.<Element>} */ ($.makeArray($(ulElement).find(Tab._Selector.ACTIVE))) - previous = previous[previous.length - 1] - - if (previous) { - previous = $(previous).find('a')[0] + * -------------------------------------------------------------------------- + */ + +var Popover = (function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'popover'; + var VERSION = '4.0.0'; + var DATA_KEY = 'bs.popover'; + var EVENT_KEY = '.' + DATA_KEY; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + + var Default = $.extend({}, Tooltip.Default, { + placement: 'right', + trigger: 'click', + content: '', + template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-title"></h3>' + '<div class="popover-content"></div></div>' + }); + + var DefaultType = $.extend({}, Tooltip.DefaultType, { + content: '(string|function)' + }); + + var ClassName = { + FADE: 'fade', + IN: 'in' + }; + + var Selector = { + TITLE: '.popover-title', + CONTENT: '.popover-content', + ARROW: '.popover-arrow' + }; + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + INSERTED: 'inserted' + EVENT_KEY, + CLICK: 'click' + EVENT_KEY, + FOCUSIN: 'focusin' + EVENT_KEY, + FOCUSOUT: 'focusout' + EVENT_KEY, + MOUSEENTER: 'mouseenter' + EVENT_KEY, + MOUSELEAVE: 'mouseleave' + EVENT_KEY + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Popover = (function (_Tooltip) { + function Popover() { + _classCallCheck(this, Popover); + + if (_Tooltip != null) { + _Tooltip.apply(this, arguments); + } } - } - - var hideEvent = $.Event(Tab._Event.HIDE, { - relatedTarget: this._element - }) - var showEvent = $.Event(Tab._Event.SHOW, { - relatedTarget: previous - }) + _inherits(Popover, _Tooltip); - if (previous) { - $(previous).trigger(hideEvent) - } - - $(this._element).trigger(showEvent) - - if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return - - if (selector) { - var target = $(selector)[0] - } - - this._activate($(this._element).closest(Tab._Selector.LI)[0], ulElement) - - var complete = function () { - var hiddenEvent = $.Event(Tab._Event.HIDDEN, { - relatedTarget: this._element - }) - - var shownEvent = $.Event(Tab._Event.SHOWN, { - relatedTarget: previous - }) - - $(previous).trigger(hiddenEvent) - $(this._element).trigger(shownEvent) - }.bind(this) - - if (target) { - this._activate(target, /** @type {Element} */ (target.parentNode), complete) - } else { - complete() - } -} + _createClass(Popover, [{ + key: 'isWithContent', + // overrides -/** - * @param {Element} element - * @param {Element} container - * @param {Function=} opt_callback - * @private - */ -Tab.prototype._activate = function (element, container, opt_callback) { - var active = $(container).find(Tab._Selector.ACTIVE_CHILD)[0] - var isTransitioning = opt_callback - && Bootstrap.transition - && ((active && $(active).hasClass(Tab._ClassName.FADE)) - || !!$(container).find(Tab._Selector.FADE_CHILD)[0]) - - var complete = this._transitionComplete.bind(this, element, active, isTransitioning, opt_callback) - - if (active && isTransitioning) { - $(active) - .one(Bootstrap.TRANSITION_END, complete) - .emulateTransitionEnd(Tab._TRANSITION_DURATION) - - } else { - complete() - } - - if (active) { - $(active).removeClass(Tab._ClassName.IN) - } -} - - -/** - * @param {Element} element - * @param {Element} active - * @param {boolean} isTransitioning - * @param {Function=} opt_callback - * @private - */ -Tab.prototype._transitionComplete = function (element, active, isTransitioning, opt_callback) { - if (active) { - $(active).removeClass(Tab._ClassName.ACTIVE) - - var dropdownChild = $(active).find(Tab._Selector.DROPDOWN_ACTIVE_CHILD)[0] - if (dropdownChild) { - $(dropdownChild).removeClass(Tab._ClassName.ACTIVE) - } - - var activeToggle = $(active).find(Tab._Selector.DATA_TOGGLE)[0] - if (activeToggle) { - activeToggle.setAttribute('aria-expanded', false) - } - } - - $(element).addClass(Tab._ClassName.ACTIVE) + value: function isWithContent() { + return this.getTitle() || this._getContent(); + } + }, { + key: 'getTipElement', + value: function getTipElement() { + return this.tip = this.tip || $(this.config.template)[0]; + } + }, { + key: 'setContent', + value: function setContent() { + var tip = this.getTipElement(); + var title = this.getTitle(); + var content = this._getContent(); + var titleElement = $(tip).find(Selector.TITLE)[0]; + + if (titleElement) { + titleElement[this.config.html ? 'innerHTML' : 'innerText'] = title; + } - var elementToggle = $(element).find(Tab._Selector.DATA_TOGGLE)[0] - if (elementToggle) { - elementToggle.setAttribute('aria-expanded', true) - } + // we use append for html objects to maintain js events + $(tip).find(Selector.CONTENT).children().detach().end()[this.config.html ? typeof content === 'string' ? 'html' : 'append' : 'text'](content); - if (isTransitioning) { - Bootstrap.reflow(element) - $(element).addClass(Tab._ClassName.IN) - } else { - $(element).removeClass(Tab._ClassName.FADE) - } + $(tip).removeClass(ClassName.FADE).removeClass(ClassName.IN); - if (element.parentNode && $(element.parentNode).hasClass(Tab._ClassName.DROPDOWN_MENU)) { - var dropdownElement = $(element).closest(Tab._Selector.LI_DROPDOWN)[0] - if (dropdownElement) { - $(dropdownElement).addClass(Tab._ClassName.ACTIVE) - } + this.cleanupTether(); + } + }, { + key: '_getContent', - elementToggle = $(element).find(Tab._Selector.DATA_TOGGLE)[0] - if (elementToggle) { - elementToggle.setAttribute('aria-expanded', true) - } - } + // private - if (opt_callback) { - opt_callback() - } -} + value: function _getContent() { + return this.element.getAttribute('data-content') || (typeof this.config.content == 'function' ? this.config.content.call(this.element) : this.config.content); + } + }], [{ + key: 'VERSION', + // getters -/** - * ------------------------------------------------------------------------ - * jQuery Interface + noConflict implementaiton - * ------------------------------------------------------------------------ - */ + get: function () { + return VERSION; + } + }, { + key: 'Default', + get: function () { + return Default; + } + }, { + key: 'NAME', + get: function () { + return NAME; + } + }, { + key: 'DATA_KEY', + get: function () { + return DATA_KEY; + } + }, { + key: 'Event', + get: function () { + return Event; + } + }, { + key: 'EVENT_KEY', + get: function () { + return EVENT_KEY; + } + }, { + key: 'DefaultType', + get: function () { + return DefaultType; + } + }, { + key: '_jQueryInterface', -/** - * @const - * @type {Function} - */ -$.fn[Tab._NAME] = Tab._jQueryInterface + // static + value: function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = typeof config === 'object' ? config : null; -/** - * @const - * @type {Function} - */ -$.fn[Tab._NAME]['Constructor'] = Tab + if (!data && /destroy|hide/.test(config)) { + return; + } + if (!data) { + data = new Popover(this, _config); + $(this).data(DATA_KEY, data); + } -/** - * @const - * @type {Function} - */ -$.fn[Tab._NAME]['noConflict'] = function () { - $.fn[Tab._NAME] = Tab._JQUERY_NO_CONFLICT - return this -} + if (typeof config === 'string') { + data[config](); + } + }); + } + }]); + return Popover; + })(Tooltip); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ -// TAB DATA-API -// ============ + $.fn[NAME] = Popover._jQueryInterface; + $.fn[NAME].Constructor = Popover; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Popover._jQueryInterface; + }; -var clickHandler = function (e) { - e.preventDefault() - Tab._jQueryInterface.call($(this), 'show') -} + return Popover; +})(jQuery); -$(document) - .on('click.bs.tab.data-api', Tab._Selector.DATA_TOGGLE, clickHandler) +}(jQuery); |