From 834220ea20ce5b7cd31edfb624a28b4bf8b29a6a Mon Sep 17 00:00:00 2001 From: fat Date: Sat, 3 Jan 2015 13:58:44 -0800 Subject: bootstrap onto closure --- Gruntfile.js | 68 +- dist/js/bootstrap.js | 5593 ++++++++++++++++++++++++++++------------ dist/js/bootstrap.min.js | 74 +- dist/js/bootstrap.min.js.gz | Bin 0 -> 10652 bytes dist/js/npm.js | 8 +- js/alert.js | 280 +- js/button.js | 275 +- js/carousel.js | 669 +++-- js/collapse.js | 526 +++- js/dropdown.js | 375 ++- js/externs/bootstrap.js | 6 + js/externs/jQuery.js | 2159 ++++++++++++++++ js/hover.js | 4 - js/modal.js | 752 ++++-- js/popover.js | 320 ++- js/scrollspy.js | 427 ++- js/tab.js | 395 ++- js/tests/closure.html | 83 + js/tests/index.html | 4 +- js/tests/unit/button.js | 55 - js/tests/unit/carousel.js | 9 +- js/tests/unit/collapse.js | 2 +- js/tests/unit/modal.js | 2 +- js/tests/unit/tooltip.js | 22 +- js/tests/visual/affix.html | 299 --- js/tests/visual/alert.html | 2 +- js/tests/visual/button.html | 6 +- js/tests/visual/carousel.html | 2 +- js/tests/visual/collapse.html | 2 +- js/tests/visual/dropdown.html | 2 +- js/tests/visual/modal.html | 2 +- js/tests/visual/popover.html | 2 +- js/tests/visual/scrollspy.html | 2 +- js/tests/visual/tab.html | 2 +- js/tests/visual/tooltip.html | 2 +- js/tooltip.js | 1086 +++++--- js/util.js | 165 ++ package.json | 5 +- 38 files changed, 10158 insertions(+), 3529 deletions(-) create mode 100644 dist/js/bootstrap.min.js.gz create mode 100644 js/externs/bootstrap.js create mode 100644 js/externs/jQuery.js delete mode 100644 js/hover.js create mode 100644 js/tests/closure.html delete mode 100644 js/tests/visual/affix.html create mode 100644 js/util.js diff --git a/Gruntfile.js b/Gruntfile.js index fb9ec8202..38d6d20df 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -108,32 +108,78 @@ module.exports = function (grunt) { }, bootstrap: { src: [ - 'js/hover.js', - mq4HoverShim.featureDetector.umdGlobal, - 'js/transition.js', + 'js/util.js', 'js/alert.js', 'js/button.js', 'js/carousel.js', 'js/collapse.js', 'js/dropdown.js', 'js/modal.js', + 'js/scrollspy.js', 'js/tooltip.js', 'js/popover.js', - 'js/scrollspy.js', - 'js/tab.js', - 'js/affix.js' + 'js/tab.js' ], dest: 'dist/js/<%= pkg.name %>.js' } }, - uglify: { + closureCompiler: { + options: { - preserveComments: 'some' + compilerFile: require('superstartup-closure-compiler').getPath(), + checkModified: false, + + compilerOpts: { + // jscomp_warning: 'reportUnknownTypes', someday - maybe we will get to 100% typed, this helps track those down + compilation_level: 'ADVANCED_OPTIMIZATIONS', + warning_level: 'verbose', + summary_detail_level: 3, + output_wrapper: + '"<%= banner %><%= jqueryCheck %><%= jqueryVersionCheck %>' + + '(function($){%output%})(jQuery);"', + externs: 'js/externs/*.js' + }, + + execOpts: { + maxBuffer: 999999 * 1024 + }, + + // [OPTIONAL] Java VM optimization options + // see https://code.google.com/p/closure-compiler/wiki/FAQ#What_are_the_recommended_Java_VM_command-line_options? + // Setting one of these to 'true' is strongly recommended, + // and can reduce compile times by 50-80% depending on compilation size + // and hardware. + // On server-class hardware, such as with Github's Travis hook, + // TieredCompilation should be used; on standard developer hardware, + // d32 may be better. Set as appropriate for your environment. + // Default for both is 'false'; do not set both to 'true'. + d32: false, // will use 'java -client -d32 -jar compiler.jar' + TieredCompilation: false // will use 'java -server -XX:+TieredCompilation -jar compiler.jar' }, - core: { - src: '<%= concat.bootstrap.dest %>', + + targetName: { + src: [ + 'js/util.js', + 'js/alert.js', + 'js/button.js', + 'js/carousel.js', + 'js/collapse.js', + 'js/dropdown.js', + 'js/modal.js', + 'js/scrollspy.js', + 'js/tooltip.js', + 'js/popover.js', + 'js/tab.js' + ], dest: 'dist/js/<%= pkg.name %>.min.js' + } + + }, + + uglify: { + options: { + preserveComments: 'some' }, docsJs: { src: configBridge.paths.docsJs, @@ -388,7 +434,7 @@ module.exports = function (grunt) { grunt.registerTask('test-js', ['jshint:core', 'jshint:test', 'jshint:grunt', 'jscs:core', 'jscs:test', 'jscs:grunt', 'qunit']); // JS distribution task. - grunt.registerTask('dist-js', ['concat', 'uglify:core', 'commonjs']); + grunt.registerTask('dist-js', ['concat', 'closureCompiler', 'commonjs']); grunt.registerTask('test-scss', ['scsslint:scss']); diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index 584fe3ba2..5d3f63040 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -15,2291 +15,4566 @@ if (typeof jQuery === 'undefined') { } }(jQuery); -/* ======================================================================== - * Bootstrap: transition.js v3.3.2 - * http://getbootstrap.com/javascript/#transitions +/** ======================================================================= + * 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 +} + + +/** + * ------------------------------------------------------------------------ + * jQuery Interface + * ------------------------------------------------------------------------ + */ + +$.fn.emulateTransitionEnd = Bootstrap.transitionEndEmulator + +$(function () { + Bootstrap.transition = Bootstrap.transitionEndTest() + + if (!Bootstrap.transition) { + return + } + + $.event.special[Bootstrap.TRANSITION_END] = Bootstrap.getSpecialTransitionEndEvent() +}) + +$(document).on('mq4hsChange', function (e) { + $(document.documentElement).toggleClass('bs-true-hover', e.trueHover) +}) + +/*! + * mq4-hover-shim v0.1.0 + * https://github.com/twbs/mq4-hover-shim + * Copyright (c) 2014-2015 Christopher Rebert + * Licensed under the MIT License (https://github.com/twbs/mq4-hover-shim/blob/master/LICENSE). + */ + +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.mq4HoverShim=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0); + /* jshint +W018 */ + triggerEvent(); + return; + } + + // Mozilla's -moz-touch-enabled + // https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries#-moz-touch-enabled + var touchEnabledQuery = window.matchMedia("(touch-enabled),(-moz-touch-enabled),(-ms-touch-enabled),(-webkit-touch-enabled)"); + if (touchEnabledQuery.matches) { + canTrulyHover = false; + triggerEvent(); + return; + } + + // W3C Touch Events REC, 10 October 2013 + // http://www.w3.org/TR/2013/REC-touch-events-20131010/ + if ("ontouchstart" in window) { + canTrulyHover = false; + triggerEvent(); + return; + } + + // UA's pointer is non-touch and thus likely either supports true hovering or at least does not try to emulate it. + canTrulyHover = true; + triggerEvent(); +})();function supportsTrueHover() { + return canTrulyHover; +} +exports.__esModule = true; +},{"jquery":undefined}]},{},[1])(1) +}); +/** ======================================================================= + * Bootstrap: alert.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 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'; + + +/** + * 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' +} + + +/** + * @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) + } + + if (opt_config === 'close') { + data[opt_config](this) + } + }) +} + + +/** + * Close the alert component + * @param {Alert} alertInstance + * @return {Function} + * @private + */ +Alert._handleDismiss = function (alertInstance) { + return function (event) { + if (event) { + event.preventDefault() + } + + alertInstance['close'](this) + } +} + + +/** + * 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] + } + + 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) + } + } + } + + 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) + } + + if (typeof opt_config == 'number') { + data.to(opt_config) + + } else if (action) { + data[action]() + + } else if (config.interval) { + data['pause']() + data['cycle']() + } + }) +} + + +/** + * 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 + } +} + + +/** + * Get item index + * @param {Element} element + * @return {number} + * @private + */ +Carousel.prototype._getItemIndex = function (element) { + this._items = $.makeArray($(element).parent().find(Carousel._Selector.ITEM)) + + return this._items.indexOf(element) +} + + +/** + * 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 + } + + 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 +} + + +/** + * 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) + } + } +} + + +/** + * 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 isCycling = !!this._interval + + var directionalClassName = direction == Carousel._Direction.NEXT ? + Carousel._ClassName.LEFT : + Carousel._ClassName.RIGHT + + if (nextElement && $(nextElement).hasClass(Carousel._ClassName.ACTIVE)) { + this._isSliding = false + return + } + + 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) + + } else { + $(activeElement).removeClass(Carousel._ClassName.ACTIVE) + $(nextElement).addClass(Carousel._ClassName.ACTIVE) + + this._isSliding = false + $(this._element).trigger(slidEvent) + } + + if (isCycling) { + this['cycle']() + } +} + + +/** + * ------------------------------------------------------------------------ + * jQuery Interface + noConflict implementaiton + * ------------------------------------------------------------------------ + */ + +/** + * @const + * @type {Function} + */ +$.fn[Carousel._NAME] = Carousel._jQueryInterface + + +/** + * @const + * @type {Function} + */ +$.fn[Carousel._NAME]['Constructor'] = Carousel + + +/** + * @const + * @type {Function} + */ +$.fn[Carousel._NAME]['noConflict'] = function () { + $.fn[Carousel._NAME] = Carousel._JQUERY_NO_CONFLICT + return this +} + + +/** + * ------------------------------------------------------------------------ + * 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. * 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'; -+function ($) { - 'use strict'; - // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) - // ============================================================ +/** + * 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' +} + + +/** + * @const + * @enum {string} + * @private + */ +Collapse._ClassName = { + IN : 'in', + COLLAPSE : 'collapse', + COLLAPSING : 'collapsing', + COLLAPSED : 'collapsed' +} + + +/** + * @const + * @enum {string} + * @private + */ +Collapse._Dimension = { + WIDTH : 'width', + HEIGHT : 'height' +} + + +/** + * @const + * @enum {string} + * @private + */ +Collapse._Selector = { + ACTIVES : '.panel > .in, .panel > .collapsing' +} + + +/** + * 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 + } + + if (!data) { + data = new Collapse(this, config) + $this.data(Collapse._DATA_KEY, data) + } + + if (typeof opt_config == 'string') { + data[opt_config]() + } + }) +} + + +/** + * Function for getting target element from element + * @return {Element} + * @private + */ +Collapse._getTargetFromElement = function (element) { + var selector = Bootstrap.getSelectorFromElement(element) + + return selector ? $(selector)[0] : null +} + + +/** + * 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']() + } +} + + +/** + * Show's the collapsing element + */ +Collapse.prototype['show'] = function () { + if (this._isTransitioning || $(this._element).hasClass(Collapse._ClassName.IN)) { + return + } - function transitionEnd() { - var el = document.createElement('bootstrap') + var activesData, actives - var transEndEventNames = { - WebkitTransition : 'webkitTransitionEnd', - MozTransition : 'transitionend', - OTransition : 'oTransitionEnd otransitionend', - transition : 'transitionend' + if (this._parent) { + actives = $.makeArray($(Collapse._Selector.ACTIVES)) + if (!actives.length) { + actives = null } + } - for (var name in transEndEventNames) { - if (el.style[name] !== undefined) { - return { end: transEndEventNames[name] } - } + if (actives) { + activesData = $(actives).data(Collapse._DATA_KEY) + if (activesData && activesData._isTransitioning) { + return } + } - return false // explicit for ie8 ( ._.) + var startEvent = $.Event(Collapse._Event.SHOW) + $(this._element).trigger(startEvent) + if (startEvent.isDefaultPrevented()) { + return } - // http://blog.alexmaccaw.com/css-transitions - $.fn.emulateTransitionEnd = function (duration) { - var called = false - var $el = this - $(this).one('bsTransitionEnd', function () { called = true }) - var callback = function () { if (!called) $($el).trigger($.support.transition.end) } - setTimeout(callback, duration) - return this + if (actives) { + Collapse._jQueryInterface.call($(actives), 'hide') + if (!activesData) { + $(actives).data(Collapse._DATA_KEY, null) + } } - $(function () { - $.support.transition = transitionEnd() + var dimension = this._getDimension() - if (!$.support.transition) return + $(this._element) + .removeClass(Collapse._ClassName.COLLAPSE) + .addClass(Collapse._ClassName.COLLAPSING) - $.event.special.bsTransitionEnd = { - bindType: $.support.transition.end, - delegateType: $.support.transition.end, - handle: function (e) { - if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments) - } - } - }) + this._element.style[dimension] = 0 + this._element.setAttribute('aria-expanded', true) -}(jQuery); + if (this._trigger) { + $(this._trigger).removeClass(Collapse._ClassName.COLLAPSED) + this._trigger.setAttribute('aria-expanded', true) + } -/* ======================================================================== - * Bootstrap: alert.js v3.3.2 - * http://getbootstrap.com/javascript/#alerts - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== */ + this['setTransitioning'](true) + var complete = function () { + $(this._element) + .removeClass(Collapse._ClassName.COLLAPSING) + .addClass(Collapse._ClassName.COLLAPSE) + .addClass(Collapse._ClassName.IN) -+function ($) { - 'use strict'; + this._element.style[dimension] = '' - // ALERT CLASS DEFINITION - // ====================== + this['setTransitioning'](false) - var dismiss = '[data-dismiss="alert"]' - var Alert = function (el) { - $(el).on('click', dismiss, this.close) + $(this._element).trigger(Collapse._Event.SHOWN) + }.bind(this) + + if (!Bootstrap.transition) { + complete() + return } - Alert.VERSION = '3.3.2' + var scrollSize = 'scroll' + (dimension[0].toUpperCase() + dimension.slice(1)) - Alert.TRANSITION_DURATION = 150 + $(this._element) + .one(Bootstrap.TRANSITION_END, complete) + .emulateTransitionEnd(Collapse._TRANSITION_DURATION) - Alert.prototype.close = function (e) { - var $this = $(this) - var selector = $this.attr('data-target') + this._element.style[dimension] = this._element[scrollSize] + 'px' +} - if (!selector) { - selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 - } - var $parent = $(selector) +/** + * Hides's the collapsing element + */ +Collapse.prototype['hide'] = function () { + if (this._isTransitioning || !$(this._element).hasClass(Collapse._ClassName.IN)) { + return + } - if (e) e.preventDefault() + var startEvent = $.Event(Collapse._Event.HIDE) + $(this._element).trigger(startEvent) + if (startEvent.isDefaultPrevented()) return - if (!$parent.length) { - $parent = $this.closest('.alert') - } + var dimension = this._getDimension() + var offsetDimension = dimension === Collapse._Dimension.WIDTH ? + 'offsetWidth' : 'offsetHeight' - $parent.trigger(e = $.Event('close.bs.alert')) + this._element.style[dimension] = this._element[offsetDimension] + 'px' - if (e.isDefaultPrevented()) return + Bootstrap.reflow(this._element) - $parent.removeClass('in') + $(this._element) + .addClass(Collapse._ClassName.COLLAPSING) + .removeClass(Collapse._ClassName.COLLAPSE) + .removeClass(Collapse._ClassName.IN) - function removeElement() { - // detach from parent, fire event then clean up data - $parent.detach().trigger('closed.bs.alert').remove() - } + this._element.setAttribute('aria-expanded', false) - $.support.transition && $parent.hasClass('fade') ? - $parent - .one('bsTransitionEnd', removeElement) - .emulateTransitionEnd(Alert.TRANSITION_DURATION) : - removeElement() + if (this._trigger) { + $(this._trigger).addClass(Collapse._ClassName.COLLAPSED) + this._trigger.setAttribute('aria-expanded', false) } + this['setTransitioning'](true) - // ALERT PLUGIN DEFINITION - // ======================= + var complete = function () { + this['setTransitioning'](false) + $(this._element) + .removeClass(Collapse._ClassName.COLLAPSING) + .addClass(Collapse._ClassName.COLLAPSE) + .trigger(Collapse._Event.HIDDEN) - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.alert') + }.bind(this) - if (!data) $this.data('bs.alert', (data = new Alert(this))) - if (typeof option == 'string') data[option].call($this) - }) + this._element.style[dimension] = 0 + + if (!Bootstrap.transition) { + return complete() } - var old = $.fn.alert + $(this._element) + .one(Bootstrap.TRANSITION_END, complete) + .emulateTransitionEnd(Collapse._TRANSITION_DURATION) +} + + + +/** + * @param {boolean} isTransitioning + */ +Collapse.prototype['setTransitioning'] = function (isTransitioning) { + this._isTransitioning = isTransitioning +} + - $.fn.alert = Plugin - $.fn.alert.Constructor = Alert +/** + * 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 +} + + +/** + * 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.} */ ($.makeArray($(parent).find(selector))) + + for (var i = 0; i < elements.length; i++) { + this._addAriaAndCollapsedClass(Collapse._getTargetFromElement(elements[i]), elements[i]) + } + return parent +} - // ALERT NO CONFLICT - // ================= - $.fn.alert.noConflict = function () { - $.fn.alert = old - return this +/** + * 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) + } } +} + - // ALERT DATA-API - // ============== +/** + * ------------------------------------------------------------------------ + * jQuery Interface + noConflict implementaiton + * ------------------------------------------------------------------------ + */ - $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) +/** + * @const + * @type {Function} + */ +$.fn[Collapse._NAME] = Collapse._jQueryInterface -}(jQuery); -/* ======================================================================== - * Bootstrap: button.js v3.3.2 - * http://getbootstrap.com/javascript/#buttons +/** + * @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 +} + + +/** + * ------------------------------------------------------------------------ + * 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. * 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'; -+function ($) { - 'use strict'; - // BUTTON PUBLIC CLASS DEFINITION - // ============================== +/** + * Our dropdown class. + * @param {Element!} element + * @constructor + */ +var Dropdown = function (element) { + $(element).on('click.bs.dropdown', this['toggle']) +} + + +/** + * @const + * @type {string} + */ +Dropdown['VERSION'] = '4.0.0' + + +/** + * @const + * @type {string} + * @private + */ +Dropdown._NAME = 'dropdown' + + +/** + * @const + * @type {string} + * @private + */ +Dropdown._DATA_KEY = 'bs.dropdown' + + +/** + * @const + * @type {Function} + * @private + */ +Dropdown._JQUERY_NO_CONFLICT = $.fn[Dropdown._NAME] + + +/** + * @const + * @enum {string} + * @private + */ +Dropdown._Event = { + HIDE : 'hide.bs.dropdown', + HIDDEN : 'hidden.bs.dropdown', + SHOW : 'show.bs.dropdown', + SHOWN : 'shown.bs.dropdown' +} + + +/** + * @const + * @enum {string} + * @private + */ +Dropdown._ClassName = { + BACKDROP : 'dropdown-backdrop', + DISABLED : 'disabled', + OPEN : 'open' +} + + +/** + * @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' +} + + +/** + * 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) + + if (!data) { + $(this).data(Dropdown._DATA_KEY, (data = new Dropdown(this))) + } + + if (typeof opt_config === 'string') { + data[opt_config].call(this) + } + }) +} + + +/** + * @param {Event=} opt_event + * @private + */ +Dropdown._clearMenus = function (opt_event) { + if (opt_event && opt_event.which == 3) { + return + } + + var backdrop = $(Dropdown._Selector.BACKDROP)[0] + if (backdrop) { + backdrop.parentNode.removeChild(backdrop) + } + + var toggles = /** @type {Array.} */ ($.makeArray($(Dropdown._Selector.DATA_TOGGLE))) + + for (var i = 0; i < toggles.length; i++) { + var parent = Dropdown._getParentFromElement(toggles[i]) + var relatedTarget = { 'relatedTarget': toggles[i] } + + if (!$(parent).hasClass(Dropdown._ClassName.OPEN)) { + continue + } + + var hideEvent = $.Event(Dropdown._Event.HIDE, relatedTarget) + $(parent).trigger(hideEvent) + if (hideEvent.isDefaultPrevented()) { + continue + } + + toggles[i].setAttribute('aria-expanded', 'false') - var Button = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Button.DEFAULTS, options) - this.isLoading = false + $(parent) + .removeClass(Dropdown._ClassName.OPEN) + .trigger(Dropdown._Event.HIDDEN, relatedTarget) } +} - Button.VERSION = '3.3.2' - Button.DEFAULTS = { - loadingText: 'loading...' +/** + * @param {Element} element + * @return {Element} + * @private + */ +Dropdown._getParentFromElement = function (element) { + var selector = Bootstrap.getSelectorFromElement(element) + + if (selector) { + var parent = $(selector)[0] } - Button.prototype.setState = function (state) { - var d = 'disabled' - var $el = this.$element - var val = $el.is('input') ? 'val' : 'html' - var data = $el.data() + return /** @type {Element} */ (parent || element.parentNode) +} - state = state + 'Text' - if (data.resetText == null) $el.data('resetText', $el[val]()) +/** + * @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 + } - // push to event loop to allow forms to submit - setTimeout($.proxy(function () { - $el[val](data[state] == null ? this.options[state] : data[state]) + event.preventDefault() + event.stopPropagation() - if (state == 'loadingText') { - this.isLoading = true - $el.addClass(d).attr(d, d) - } else if (this.isLoading) { - this.isLoading = false - $el.removeClass(d).removeAttr(d) - } - }, this), 0) + if (this.disabled || $(this).hasClass(Dropdown._ClassName.DISABLED)) { + return } - Button.prototype.toggle = function () { - var changed = true - var $parent = this.$element.closest('[data-toggle="buttons"]') + var parent = Dropdown._getParentFromElement(this) + var isActive = $(parent).hasClass(Dropdown._ClassName.OPEN) - if ($parent.length) { - var $input = this.$element.find('input') - if ($input.prop('type') == 'radio') { - if ($input.prop('checked') && this.$element.hasClass('active')) changed = false - else $parent.find('.active').removeClass('active') - } - if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') - } else { - this.$element.attr('aria-pressed', !this.$element.hasClass('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 + } + + var items = $.makeArray($(Dropdown._Selector.VISIBLE_ITEMS)) - if (changed) this.$element.toggleClass('active') + items = items.filter(function (item) { + return item.offsetWidth || item.offsetHeight + }) + + if (!items.length) { + return } + var index = items.indexOf(event.target) - // BUTTON PLUGIN DEFINITION - // ======================== + if (event.which == 38 && index > 0) index-- // up + if (event.which == 40 && index < items.length - 1) index++ // down + if (!~index) index = 0 - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.button') - var options = typeof option == 'object' && option + items[index].focus() +} - if (!data) $this.data('bs.button', (data = new Button(this, options))) - if (option == 'toggle') data.toggle() - else if (option) data.setState(option) - }) +/** + * Toggles the dropdown + * @this {Element} + * @return {boolean|undefined} + */ +Dropdown.prototype['toggle'] = function () { + if (this.disabled || $(this).hasClass(Dropdown._ClassName.DISABLED)) { + return } - var old = $.fn.button + var parent = Dropdown._getParentFromElement(this) + var isActive = $(parent).hasClass(Dropdown._ClassName.OPEN) + + Dropdown._clearMenus() + + if (isActive) { + return false + } - $.fn.button = Plugin - $.fn.button.Constructor = Button + 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) + } + var relatedTarget = { 'relatedTarget': this } + var showEvent = $.Event(Dropdown._Event.SHOW, relatedTarget) - // BUTTON NO CONFLICT - // ================== + $(parent).trigger(showEvent) - $.fn.button.noConflict = function () { - $.fn.button = old - return this + if (showEvent.isDefaultPrevented()) { + return } + this.focus() + this.setAttribute('aria-expanded', 'true') - // BUTTON DATA-API - // =============== + $(parent).toggleClass(Dropdown._ClassName.OPEN) - $(document) - .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { - var $btn = $(e.target) - if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') - Plugin.call($btn, 'toggle') - e.preventDefault() - }) - .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { - $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type)) - }) + $(parent).trigger(Dropdown._Event.SHOWN, relatedTarget) -}(jQuery); + return false +} -/* ======================================================================== - * Bootstrap: carousel.js v3.3.2 - * http://getbootstrap.com/javascript/#carousel + +/** + * ------------------------------------------------------------------------ + * jQuery Interface + noConflict implementaiton + * ------------------------------------------------------------------------ + */ + +/** + * @const + * @type {Function} + */ +$.fn[Dropdown._NAME] = Dropdown._jQueryInterface + + +/** + * @const + * @type {Function} + */ +$.fn[Dropdown._NAME]['Constructor'] = Dropdown + + +/** + * @const + * @type {Function} + */ +$.fn[Dropdown._NAME]['noConflict'] = function () { + $.fn[Dropdown._NAME] = Dropdown._JQUERY_NO_CONFLICT + return this +} + + +/** + * ------------------------------------------------------------------------ + * 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. * 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'; -+function ($) { - 'use strict'; - // CAROUSEL CLASS DEFINITION - // ========================= +/** + * Our modal class. + * @param {Element} element + * @param {Object} config + * @constructor + */ +var Modal = function (element, config) { + + /** @private {Object} */ + this._config = config - var Carousel = function (element, options) { - this.$element = $(element) - this.$indicators = this.$element.find('.carousel-indicators') - this.options = options - this.paused = - this.sliding = - this.interval = - this.$active = - this.$items = null + /** @private {Element} */ + this._element = element - this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this)) + /** @private {Element} */ + this._backdrop = null - this.options.pause == 'hover' && !('ontouchstart' in document.documentElement) && this.$element - .on('mouseenter.bs.carousel', $.proxy(this.pause, this)) - .on('mouseleave.bs.carousel', $.proxy(this.cycle, this)) - } + /** @private {boolean} */ + this._isShown = false - Carousel.VERSION = '3.3.2' + /** @private {boolean} */ + this._isBodyOverflowing = false - Carousel.TRANSITION_DURATION = 600 + /** @private {number} */ + this._scrollbarWidth = 0 - Carousel.DEFAULTS = { - interval: 5000, - pause: 'hover', - wrap: true, - keyboard: true - } +} - Carousel.prototype.keydown = function (e) { - if (/input|textarea/i.test(e.target.tagName)) return - switch (e.which) { - case 37: this.prev(); break - case 39: this.next(); break - default: return - } - e.preventDefault() - } +/** + * @const + * @type {string} + */ +Modal['VERSION'] = '4.0.0' - Carousel.prototype.cycle = function (e) { - e || (this.paused = false) - this.interval && clearInterval(this.interval) +/** + * @const + * @type {Object} + */ +Modal['Defaults'] = { + 'backdrop' : true, + 'keyboard' : true, + 'show' : true +} - this.options.interval - && !this.paused - && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - return this - } +/** + * @const + * @type {string} + * @private + */ +Modal._NAME = 'modal' - Carousel.prototype.getItemIndex = function (item) { - this.$items = item.parent().children('.carousel-item') - return this.$items.index(item || this.$active) - } - Carousel.prototype.getItemForDirection = function (direction, active) { - var activeIndex = this.getItemIndex(active) - var willWrap = (direction == 'prev' && activeIndex === 0) - || (direction == 'next' && activeIndex == (this.$items.length - 1)) - if (willWrap && !this.options.wrap) return active - var delta = direction == 'prev' ? -1 : 1 - var itemIndex = (activeIndex + delta) % this.$items.length - return this.$items.eq(itemIndex) - } +/** + * @const + * @type {string} + * @private + */ +Modal._DATA_KEY = 'bs.modal' - Carousel.prototype.to = function (pos) { - var that = this - var activeIndex = this.getItemIndex(this.$active = this.$element.find('.carousel-item.active')) - if (pos > (this.$items.length - 1) || pos < 0) return +/** + * @const + * @type {number} + * @private + */ +Modal._TRANSITION_DURATION = 300 - if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid" - if (activeIndex == pos) return this.pause().cycle() - return this.slide(pos > activeIndex ? 'next' : 'prev', this.$items.eq(pos)) - } +/** + * @const + * @type {number} + * @private + */ +Modal._BACKDROP_TRANSITION_DURATION = 150 + + +/** + * @const + * @type {Function} + * @private + */ +Modal._JQUERY_NO_CONFLICT = $.fn[Modal._NAME] + + +/** + * @const + * @enum {string} + * @private + */ +Modal._Event = { + HIDE : 'hide.bs.modal', + HIDDEN : 'hidden.bs.modal', + SHOW : 'show.bs.modal', + SHOWN : 'shown.bs.modal' +} + + +/** + * @const + * @enum {string} + * @private + */ +Modal._ClassName = { + BACKDROP : 'modal-backdrop', + OPEN : 'modal-open', + FADE : 'fade', + IN : 'in' +} + + +/** + * @const + * @enum {string} + * @private + */ +Modal._Selector = { + DIALOG : '.modal-dialog', + DATA_TOGGLE : '[data-toggle="modal"]', + DATA_DISMISS : '[data-dismiss="modal"]', + SCROLLBAR_MEASURER : 'modal-scrollbar-measure' +} - Carousel.prototype.pause = function (e) { - e || (this.paused = true) - if (this.$element.find('.next, .prev').length && $.support.transition) { - this.$element.trigger($.support.transition.end) - this.cycle(true) + +/** + * 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.interval = clearInterval(this.interval) + if (typeof opt_config == 'string') { + data[opt_config](opt_relatedTarget) - return this - } + } else if (config['show']) { + data['show'](opt_relatedTarget) + } + }) +} - Carousel.prototype.next = function () { - if (this.sliding) return - return this.slide('next') - } - Carousel.prototype.prev = function () { - if (this.sliding) return - return this.slide('prev') +/** + * @param {Element} relatedTarget + */ +Modal.prototype['toggle'] = function (relatedTarget) { + return this._isShown ? this['hide']() : this['show'](relatedTarget) +} + + +/** + * @param {Element} relatedTarget + */ +Modal.prototype['show'] = function (relatedTarget) { + var showEvent = $.Event(Modal._Event.SHOW, { relatedTarget: relatedTarget }) + + $(this._element).trigger(showEvent) + + if (this._isShown || showEvent.isDefaultPrevented()) { + return } - Carousel.prototype.slide = function (type, next) { - var $active = this.$element.find('.carousel-item.active') - var $next = next || this.getItemForDirection(type, $active) - var isCycling = this.interval - var direction = type == 'next' ? 'left' : 'right' - var that = this + this._isShown = true - if ($next.hasClass('active')) return (this.sliding = false) + this._checkScrollbar() + this._setScrollbar() - var relatedTarget = $next[0] - var slideEvent = $.Event('slide.bs.carousel', { - relatedTarget: relatedTarget, - direction: direction - }) - this.$element.trigger(slideEvent) - if (slideEvent.isDefaultPrevented()) return - - this.sliding = true - - isCycling && this.pause() - - if (this.$indicators.length) { - this.$indicators.find('.active').removeClass('active') - var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)]) - $nextIndicator && $nextIndicator.addClass('active') - } - - var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid" - if ($.support.transition && this.$element.hasClass('slide')) { - $next.addClass(type) - $next[0].offsetWidth // force reflow - $active.addClass(direction) - $next.addClass(direction) - $active - .one('bsTransitionEnd', function () { - $next.removeClass([type, direction].join(' ')).addClass('active') - $active.removeClass(['active', direction].join(' ')) - that.sliding = false - setTimeout(function () { - that.$element.trigger(slidEvent) - }, 0) - }) - .emulateTransitionEnd(Carousel.TRANSITION_DURATION) - } else { - $active.removeClass('active') - $next.addClass('active') - this.sliding = false - this.$element.trigger(slidEvent) - } + $(document.body).addClass(Modal._ClassName.OPEN) + + this._escape() + this._resize() + + $(this._element).on('click.dismiss.bs.modal', Modal._Selector.DATA_DISMISS, this['hide'].bind(this)) + + this._showBackdrop(this._showElement.bind(this, relatedTarget)) +} - isCycling && this.cycle() - return this +/** + * @param {Event} event + */ +Modal.prototype['hide'] = function (event) { + if (event) { + event.preventDefault() } + var hideEvent = $.Event(Modal._Event.HIDE) - // CAROUSEL PLUGIN DEFINITION - // ========================== + $(this._element).trigger(hideEvent) - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.carousel') - var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) - var action = typeof option == 'string' ? option : options.slide + if (!this._isShown || hideEvent.isDefaultPrevented()) { + return + } - if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) - if (typeof option == 'number') data.to(option) - else if (action) data[action]() - else if (options.interval) data.pause().cycle() - }) + this._isShown = false + + this._escape() + this._resize() + + $(document).off('focusin.bs.modal') + + $(this._element).removeClass(Modal._ClassName.IN) + this._element.setAttribute('aria-hidden', true) + + $(this._element).off('click.dismiss.bs.modal') + + 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() } +} - var old = $.fn.carousel - $.fn.carousel = Plugin - $.fn.carousel.Constructor = Carousel +/** + * @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 + } - // CAROUSEL NO CONFLICT - // ==================== + this._element.style.display = 'block' + this._element.scrollTop = 0 - $.fn.carousel.noConflict = function () { - $.fn.carousel = old - return this + if (this._config['backdrop']) { + this._adjustBackdrop() } + if (transition) { + Bootstrap.reflow(this._element) + } - // CAROUSEL DATA-API - // ================= + $(this._element).addClass(Modal._ClassName.IN) + this._element.setAttribute('aria-hidden', false) - var clickHandler = function (e) { - var href - var $this = $(this) - var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7 - if (!$target.hasClass('carousel')) return - var options = $.extend({}, $target.data(), $this.data()) - var slideIndex = $this.attr('data-slide-to') - if (slideIndex) options.interval = false + this._enforceFocus() - Plugin.call($target, options) + var shownEvent = $.Event(Modal._Event.SHOWN, { relatedTarget: relatedTarget }) - if (slideIndex) { - $target.data('bs.carousel').to(slideIndex) - } + var transitionComplete = function () { + this._element.focus() + $(this._element).trigger(shownEvent) + }.bind(this) - e.preventDefault() + if (transition) { + var dialog = $(this._element).find(Modal._Selector.DIALOG)[0] + $(dialog) + .one(Bootstrap.TRANSITION_END, transitionComplete) + .emulateTransitionEnd(Modal._TRANSITION_DURATION) + } else { + transitionComplete() } +} + + +/** + * @private + */ +Modal.prototype._enforceFocus = function () { $(document) - .on('click.bs.carousel.data-api', '[data-slide]', clickHandler) - .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler) + .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)) +} - $(window).on('load', function () { - $('[data-ride="carousel"]').each(function () { - var $carousel = $(this) - Plugin.call($carousel, $carousel.data()) - }) - }) -}(jQuery); +/** + * @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']() + } + }.bind(this)) -/* ======================================================================== - * Bootstrap: collapse.js v3.3.2 - * http://getbootstrap.com/javascript/#collapse - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== */ + } else if (!this._isShown) { + $(this._element).off('keydown.dismiss.bs.modal') + } +} -+function ($) { - 'use strict'; +/** + * @private + */ +Modal.prototype._resize = function () { + if (this._isShown) { + $(window).on('resize.bs.modal', this._handleUpdate.bind(this)) + } else { + $(window).off('resize.bs.modal') + } +} - // COLLAPSE PUBLIC CLASS DEFINITION - // ================================ - var Collapse = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Collapse.DEFAULTS, options) - this.$trigger = $(this.options.trigger).filter('[href="#' + element.id + '"], [data-target="#' + element.id + '"]') - this.transitioning = null +/** + * @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)) +} - if (this.options.parent) { - this.$parent = this.getParent() - } else { - this.addAriaAndCollapsedClass(this.$element, this.$trigger) - } - if (this.options.toggle) this.toggle() - } +/** + * @private + */ +Modal.prototype._removeBackdrop = function () { + if (this._backdrop) { + this._backdrop.parentNode.removeChild(this._backdrop) + this._backdrop = null + } +} + - Collapse.VERSION = '3.3.2' +/** + * @param {Function} callback + * @private + */ +Modal.prototype._showBackdrop = function (callback) { + var animate = $(this._element).hasClass(Modal._ClassName.FADE) ? Modal._ClassName.FADE : '' - Collapse.TRANSITION_DURATION = 350 + if (this._isShown && this._config['backdrop']) { + var doAnimate = Bootstrap.transition && animate - Collapse.DEFAULTS = { - toggle: true, - trigger: '[data-toggle="collapse"]' - } + this._backdrop = document.createElement('div') + this._backdrop.className = Modal._ClassName.BACKDROP - Collapse.prototype.dimension = function () { - var hasWidth = this.$element.hasClass('width') - return hasWidth ? 'width' : 'height' - } + if (animate) { + $(this._backdrop).addClass(animate) + } - Collapse.prototype.show = function () { - if (this.transitioning || this.$element.hasClass('in')) return + $(this._element).prepend(this._backdrop) - var activesData - var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') + $(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)) - if (actives && actives.length) { - activesData = actives.data('bs.collapse') - if (activesData && activesData.transitioning) return + if (doAnimate) { + Bootstrap.reflow(this._backdrop) } - var startEvent = $.Event('show.bs.collapse') - this.$element.trigger(startEvent) - if (startEvent.isDefaultPrevented()) return + $(this._backdrop).addClass(Modal._ClassName.IN) - if (actives && actives.length) { - Plugin.call(actives, 'hide') - activesData || actives.data('bs.collapse', null) + if (!callback) { + return } - var dimension = this.dimension() + if (!doAnimate) { + callback() + return + } - this.$element - .removeClass('collapse') - .addClass('collapsing')[dimension](0) - .attr('aria-expanded', true) + $(this._backdrop) + .one(Bootstrap.TRANSITION_END, callback) + .emulateTransitionEnd(Modal._BACKDROP_TRANSITION_DURATION) - this.$trigger - .removeClass('collapsed') - .attr('aria-expanded', true) + } else if (!this._isShown && this._backdrop) { + $(this._backdrop).removeClass(Modal._ClassName.IN) - this.transitioning = 1 + var callbackRemove = function () { + this._removeBackdrop() + if (callback) { + callback() + } + }.bind(this) - var complete = function () { - this.$element - .removeClass('collapsing') - .addClass('collapse in')[dimension]('') - this.transitioning = 0 - this.$element - .trigger('shown.bs.collapse') + if (Bootstrap.transition && $(this._element).hasClass(Modal._ClassName.FADE)) { + $(this._backdrop) + .one(Bootstrap.TRANSITION_END, callbackRemove) + .emulateTransitionEnd(Modal._BACKDROP_TRANSITION_DURATION) + } else { + callbackRemove() } - if (!$.support.transition) return complete.call(this) + } else if (callback) { + callback() + } +} - var scrollSize = $.camelCase(['scroll', dimension].join('-')) - this.$element - .one('bsTransitionEnd', $.proxy(complete, this)) - .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) - } +/** + * ------------------------------------------------------------------------ + * the following methods are used to handle overflowing modals + * todo (fat): these should probably be refactored into a + * ------------------------------------------------------------------------ + */ - Collapse.prototype.hide = function () { - if (this.transitioning || !this.$element.hasClass('in')) return - var startEvent = $.Event('hide.bs.collapse') - this.$element.trigger(startEvent) - if (startEvent.isDefaultPrevented()) return +/** + * @private + */ +Modal.prototype._handleUpdate = function () { + if (this._config['backdrop']) this._adjustBackdrop() + this._adjustDialog() +} - var dimension = this.dimension() +/** + * @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' +} - this.$element[dimension](this.$element[dimension]())[0].offsetHeight - this.$element - .addClass('collapsing') - .removeClass('collapse in') - .attr('aria-expanded', false) +/** + * @private + */ +Modal.prototype._adjustDialog = function () { + var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight - this.$trigger - .addClass('collapsed') - .attr('aria-expanded', false) + if (!this._isBodyOverflowing && isModalOverflowing) { + this._element.style.paddingLeft = this._scrollbarWidth + 'px' + } - this.transitioning = 1 + if (this._isBodyOverflowing && !isModalOverflowing) { + this._element.style.paddingRight = this._scrollbarWidth + 'px' + } +} - var complete = function () { - this.transitioning = 0 - this.$element - .removeClass('collapsing') - .addClass('collapse') - .trigger('hidden.bs.collapse') - } - if (!$.support.transition) return complete.call(this) +/** + * @private + */ +Modal.prototype._resetAdjustments = function () { + this._element.style.paddingLeft = '' + this._element.style.paddingRight = '' +} - this.$element - [dimension](0) - .one('bsTransitionEnd', $.proxy(complete, this)) - .emulateTransitionEnd(Collapse.TRANSITION_DURATION) - } - Collapse.prototype.toggle = function () { - this[this.$element.hasClass('in') ? 'hide' : 'show']() - } +/** + * @private + */ +Modal.prototype._checkScrollbar = function () { + this._isBodyOverflowing = document.body.scrollHeight > document.documentElement.clientHeight + this._scrollbarWidth = this._getScrollbarWidth() +} - Collapse.prototype.getParent = function () { - return $(this.options.parent) - .find('[data-toggle="collapse"][data-parent="' + this.options.parent + '"]') - .each($.proxy(function (i, element) { - var $element = $(element) - this.addAriaAndCollapsedClass(getTargetFromTrigger($element), $element) - }, this)) - .end() - } - Collapse.prototype.addAriaAndCollapsedClass = function ($element, $trigger) { - var isOpen = $element.hasClass('in') +/** + * @private + */ +Modal.prototype._setScrollbar = function () { + var bodyPadding = parseInt(($(document.body).css('padding-right') || 0), 10) - $element.attr('aria-expanded', isOpen) - $trigger - .toggleClass('collapsed', !isOpen) - .attr('aria-expanded', isOpen) + if (this._isBodyOverflowing) { + document.body.style.paddingRight = bodyPadding + this._scrollbarWidth + 'px' } +} - function getTargetFromTrigger($trigger) { - var href - var target = $trigger.attr('data-target') - || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 - return $(target) - } +/** + * @private + */ +Modal.prototype._resetScrollbar = function () { + document.body.style.paddingRight = '' +} - // COLLAPSE PLUGIN DEFINITION - // ========================== +/** + * @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 +} - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.collapse') - var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) - if (!data && options.toggle && option == 'show') options.toggle = false - if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) - if (typeof option == 'string') data[option]() - }) - } +/** + * ------------------------------------------------------------------------ + * jQuery Interface + noConflict implementaiton + * ------------------------------------------------------------------------ + */ - var old = $.fn.collapse +/** + * @const + * @type {Function} + */ +$.fn[Modal._NAME] = Modal._jQueryInterface - $.fn.collapse = Plugin - $.fn.collapse.Constructor = Collapse +/** + * @const + * @type {Function} + */ +$.fn[Modal._NAME]['Constructor'] = Modal - // COLLAPSE NO CONFLICT - // ==================== - $.fn.collapse.noConflict = function () { - $.fn.collapse = old - return this - } +/** + * @const + * @type {Function} + */ +$.fn[Modal._NAME]['noConflict'] = function () { + $.fn[Modal._NAME] = Modal._JQUERY_NO_CONFLICT + return this +} - // COLLAPSE DATA-API - // ================= +/** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ - $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { - var $this = $(this) +$(document).on('click.bs.modal.data-api', Modal._Selector.DATA_TOGGLE, function (event) { + var selector = Bootstrap.getSelectorFromElement(this) - if (!$this.attr('data-target')) e.preventDefault() + if (selector) { + var target = $(selector)[0] + } - var $target = getTargetFromTrigger($this) - var data = $target.data('bs.collapse') - var option = data ? 'toggle' : $.extend({}, $this.data(), { trigger: this }) + var config = $(target).data(Modal._DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()) - Plugin.call($target, option) - }) + if (this.tagName == 'A') { + event.preventDefault() + } -}(jQuery); + var $target = $(target).one(Modal._Event.SHOW, function (showEvent) { + if (showEvent.isDefaultPrevented()) { + return // only register focus restorer if modal will actually get shown + } -/* ======================================================================== - * Bootstrap: dropdown.js v3.3.2 - * http://getbootstrap.com/javascript/#dropdowns + $target.one(Modal._Event.HIDDEN, function () { + if ($(this).is(':visible')) { + this.focus() + } + }.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) - * ======================================================================== */ - - -+function ($) { - 'use strict'; + * ======================================================================== + * @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 + * + * ======================================================================== + */ - // DROPDOWN CLASS DEFINITION - // ========================= +'use strict'; - var backdrop = '.dropdown-backdrop' - var toggle = '[data-toggle="dropdown"]' - var Dropdown = function (element) { - $(element).on('click.bs.dropdown', this.toggle) - } - Dropdown.VERSION = '3.3.2' +/** + * Our scrollspy class. + * @param {Element!} element + * @param {Object=} opt_config + * @constructor + */ +function ScrollSpy(element, opt_config) { - Dropdown.prototype.toggle = function (e) { - var $this = $(this) + /** @private {Element|Window} */ + this._scrollElement = element.tagName == 'BODY' ? window : element - if ($this.is('.disabled, :disabled')) return + /** @private {Object} */ + this._config = $.extend({}, ScrollSpy['Defaults'], opt_config) - var $parent = getParent($this) - var isActive = $parent.hasClass('open') + /** @private {string} */ + this._selector = (this._config.target || '') + ' .nav li > a' - clearMenus() + /** @private {Array} */ + this._offsets = [] - if (!isActive) { - if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { - // if mobile we use a backdrop because click events don't delegate - $('