From 834220ea20ce5b7cd31edfb624a28b4bf8b29a6a Mon Sep 17 00:00:00 2001 From: fat Date: Sat, 3 Jan 2015 13:58:44 -0800 Subject: [PATCH] bootstrap onto closure --- Gruntfile.js | 68 +- dist/js/bootstrap.js | 6293 ++++++++++++++++++++++---------- dist/js/bootstrap.min.js | 74 +- dist/js/bootstrap.min.js.gz | Bin 0 -> 10652 bytes dist/js/npm.js | 8 +- js/alert.js | 288 +- js/button.js | 265 +- js/carousel.js | 725 +++- js/collapse.js | 612 +++- js/dropdown.js | 403 +- js/externs/bootstrap.js | 6 + js/externs/jQuery.js | 2159 +++++++++++ js/hover.js | 4 - js/modal.js | 894 +++-- js/popover.js | 340 +- js/scrollspy.js | 481 ++- js/tab.js | 405 +- 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 | 1154 ++++-- js/util.js | 165 + package.json | 5 +- 38 files changed, 10739 insertions(+), 4110 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 fb9ec82020..38d6d20dfb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -108,33 +108,79 @@ 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' } }, + closureCompiler: { + + options: { + 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' + }, + + 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' }, - core: { - src: '<%= concat.bootstrap.dest %>', - dest: 'dist/js/<%= pkg.name %>.min.js' - }, docsJs: { src: configBridge.paths.docsJs, dest: 'docs/assets/js/docs.min.js' @@ -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 584fe3ba20..5d3f63040d 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 - * ======================================================================== - * Copyright 2011-2015 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * ======================================================================== */ - - -+function ($) { - 'use strict'; - - // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) - // ============================================================ - - function transitionEnd() { - var el = document.createElement('bootstrap') - - var transEndEventNames = { - WebkitTransition : 'webkitTransitionEnd', - MozTransition : 'transitionend', - OTransition : 'oTransitionEnd otransitionend', - transition : 'transitionend' - } - - for (var name in transEndEventNames) { - if (el.style[name] !== undefined) { - return { end: transEndEventNames[name] } - } - } - - return false // explicit for ie8 ( ._.) - } - - // 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 - } - - $(function () { - $.support.transition = transitionEnd() - - if (!$.support.transition) return - - $.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) - } - } - }) - -}(jQuery); - -/* ======================================================================== - * Bootstrap: alert.js v3.3.2 +/** ======================================================================= + * 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'; -+function ($) { - 'use strict'; +/** + * @type {Object} + */ +var Bootstrap = {} - // ALERT CLASS DEFINITION - // ====================== - var dismiss = '[data-dismiss="alert"]' - var Alert = function (el) { - $(el).on('click', dismiss, this.close) +/** + * @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 } - Alert.VERSION = '3.3.2' - - Alert.TRANSITION_DURATION = 150 - - Alert.prototype.close = function (e) { - var $this = $(this) - var selector = $this.attr('data-target') - - if (!selector) { - selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 - } - - var $parent = $(selector) - - if (e) e.preventDefault() - - if (!$parent.length) { - $parent = $this.closest('.alert') - } - - $parent.trigger(e = $.Event('close.bs.alert')) - - if (e.isDefaultPrevented()) return - - $parent.removeClass('in') - - function removeElement() { - // detach from parent, fire event then clean up data - $parent.detach().trigger('closed.bs.alert').remove() - } - - $.support.transition && $parent.hasClass('fade') ? - $parent - .one('bsTransitionEnd', removeElement) - .emulateTransitionEnd(Alert.TRANSITION_DURATION) : - removeElement() - } + return selector +} - // ALERT PLUGIN DEFINITION - // ======================= +/** + * @param {string} prefix + * @return {string} + */ +Bootstrap.getUID = function (prefix) { + do prefix += ~~(Math.random() * 1000000) + while (document.getElementById(prefix)) + return prefix +} - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.alert') - if (!data) $this.data('bs.alert', (data = new Alert(this))) - if (typeof option == 'string') data[option].call($this) +/** + * @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) + } }) } - - var old = $.fn.alert - - $.fn.alert = Plugin - $.fn.alert.Constructor = Alert +} - // ALERT NO CONFLICT - // ================= +/** + * @param {Element} element + */ +Bootstrap.reflow = function (element) { + new Function('bs',"return bs")(element.offsetHeight) +} - $.fn.alert.noConflict = function () { - $.fn.alert = old - return this + +/** + * @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 +} - // ALERT DATA-API - // ============== - $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) +/** + * @param {number} duration + * @this {Element} + * @return {Object} + */ +Bootstrap.transitionEndEmulator = function (duration) { + var called = false -}(jQuery); + $(this).one(Bootstrap.TRANSITION_END, function () { + called = true + }) -/* ======================================================================== - * Bootstrap: button.js v3.3.2 + 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'; -+function ($) { - 'use strict'; +/** + * Our Button class. + * @param {Element!} element + * @constructor + */ +var Button = function (element) { - // BUTTON PUBLIC CLASS DEFINITION - // ============================== + /** @private {Element} */ + this._element = element - var Button = function (element, options) { - this.$element = $(element) - this.options = $.extend({}, Button.DEFAULTS, options) - this.isLoading = false - } +} - Button.VERSION = '3.3.2' - Button.DEFAULTS = { - loadingText: 'loading...' - } +/** + * @const + * @type {string} + */ +Button['VERSION'] = '4.0.0' - Button.prototype.setState = function (state) { - var d = 'disabled' - var $el = this.$element - var val = $el.is('input') ? 'val' : 'html' - var data = $el.data() - state = state + 'Text' +/** + * @const + * @type {string} + * @private + */ +Button._NAME = 'button' - if (data.resetText == null) $el.data('resetText', $el[val]()) - // push to event loop to allow forms to submit - setTimeout($.proxy(function () { - $el[val](data[state] == null ? this.options[state] : data[state]) +/** + * @const + * @type {string} + * @private + */ +Button._DATA_KEY = 'bs.button' - 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) - } - Button.prototype.toggle = function () { - var changed = true - var $parent = this.$element.closest('[data-toggle="buttons"]') +/** + * @const + * @type {Function} + * @private + */ +Button._JQUERY_NO_CONFLICT = $.fn[Button._NAME] - 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')) + +/** + * @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 (changed) this.$element.toggleClass('active') + 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)) } - - // BUTTON PLUGIN DEFINITION - // ======================== - - function Plugin(option) { - return this.each(function () { - var $this = $(this) - var data = $this.data('bs.button') - var options = typeof option == 'object' && option - - if (!data) $this.data('bs.button', (data = new Button(this, options))) - - if (option == 'toggle') data.toggle() - else if (option) data.setState(option) - }) + if (triggerChangeEvent) { + $(this._element).toggleClass(Button._ClassName.ACTIVE) } - - var old = $.fn.button - - $.fn.button = Plugin - $.fn.button.Constructor = Button +} - // BUTTON NO CONFLICT - // ================== +/** + * ------------------------------------------------------------------------ + * jQuery Interface + noConflict implementaiton + * ------------------------------------------------------------------------ + */ - $.fn.button.noConflict = function () { - $.fn.button = old - return this - } +/** + * @const + * @type {Function} + */ +$.fn[Button._NAME] = Button._jQueryInterface - // BUTTON DATA-API - // =============== +/** + * @const + * @type {Function} + */ +$.fn[Button._NAME]['Constructor'] = Button - $(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)) - }) -}(jQuery); +/** + * @const + * @type {Function} + */ +$.fn[Button._NAME]['noConflict'] = function () { + $.fn[Button._NAME] = Button._JQUERY_NO_CONFLICT + return this +} -/* ======================================================================== - * Bootstrap: carousel.js v3.3.2 + +/** + * ------------------------------------------------------------------------ + * 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'; -+function ($) { - 'use strict'; +/** + * Our carousel class. + * @param {Element!} element + * @param {Object=} opt_config + * @constructor + */ +var Carousel = function (element, opt_config) { - // CAROUSEL CLASS DEFINITION - // ========================= + /** @private {Element} */ + this._element = $(element)[0] - 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._indicatorsElement = $(this._element).find(Carousel._Selector.INDICATORS)[0] - this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this)) + /** @private {?Object} */ + this._config = opt_config || 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._isPaused = false - Carousel.VERSION = '3.3.2' + /** @private {boolean} */ + this._isSliding = false - Carousel.TRANSITION_DURATION = 600 + /** @private {?number} */ + this._interval = null - Carousel.DEFAULTS = { - interval: 5000, - pause: 'hover', - wrap: true, - keyboard: true - } + /** @private {?Element} */ + this._activeElement = null - 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 + /** @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) } - e.preventDefault() - } + if (typeof opt_config == 'number') { + data.to(opt_config) - Carousel.prototype.cycle = function (e) { - e || (this.paused = false) + } else if (action) { + data[action]() - this.interval && clearInterval(this.interval) - - this.options.interval - && !this.paused - && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) - - return this - } - - 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) - } - - 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 - - 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)) - } - - 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) + } else if (config.interval) { + data['pause']() + data['cycle']() } + }) +} - this.interval = clearInterval(this.interval) - return this +/** + * Click handler for data api + * @param {Event} event + * @this {Element} + * @private + */ +Carousel._dataApiClickHandler = function (event) { + var selector = Bootstrap.getSelectorFromElement(this) + + if (!selector) { + return } - Carousel.prototype.next = function () { - if (this.sliding) return - return this.slide('next') + var target = $(selector)[0] + + if (!target || !$(target).hasClass(Carousel._ClassName.CAROUSEL)) { + return } - Carousel.prototype.prev = function () { - if (this.sliding) return - return this.slide('prev') + var config = $.extend({}, $(target).data(), $(this).data()) + + var slideIndex = this.getAttribute('data-slide-to') + if (slideIndex) { + config.interval = false } - 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 + Carousel._jQueryInterface.call($(target), config) - if ($next.hasClass('active')) return (this.sliding = false) - - 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) - } - - isCycling && this.cycle() - - return this + if (slideIndex) { + $(target).data(Carousel._DATA_KEY).to(slideIndex) } + event.preventDefault() +} - // CAROUSEL PLUGIN DEFINITION - // ========================== - 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 +/** + * Advance the carousel to the next slide + */ +Carousel.prototype['next'] = function () { + if (!this._isSliding) { + this._slide(Carousel._Direction.NEXT) + } +} - 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() - }) + +/** + * 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 } - var old = $.fn.carousel - - $.fn.carousel = Plugin - $.fn.carousel.Constructor = Carousel - - - // CAROUSEL NO CONFLICT - // ==================== - - $.fn.carousel.noConflict = function () { - $.fn.carousel = old - return this + 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 +} - // CAROUSEL DATA-API - // ================= - 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 - - Plugin.call($target, options) - - if (slideIndex) { - $target.data('bs.carousel').to(slideIndex) - } - - e.preventDefault() +/** + * Cycle to the next carousel item + * @param {Event|boolean=} opt_event + */ +Carousel.prototype['cycle'] = function (opt_event) { + if (!opt_event) { + this._isPaused = false } - $(document) - .on('click.bs.carousel.data-api', '[data-slide]', clickHandler) - .on('click.bs.carousel.data-api', '[data-slide-to]', clickHandler) + if (this._interval) { + clearInterval(this._interval) + this._interval = null + } - $(window).on('load', function () { - $('[data-ride="carousel"]').each(function () { - var $carousel = $(this) - Plugin.call($carousel, $carousel.data()) - }) + 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 }) -}(jQuery); + $(this._element).trigger(slideEvent) -/* ======================================================================== - * Bootstrap: collapse.js v3.3.2 + 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'; +/** + * Our collapse class. + * @param {Element!} element + * @param {Object=} opt_config + * @constructor + */ +var Collapse = function (element, opt_config) { - // COLLAPSE PUBLIC CLASS DEFINITION - // ================================ + /** @private {Element} */ + this._element = element - 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 {Object} */ + this._config = $.extend({}, Collapse['Defaults'], opt_config) - if (this.options.parent) { - this.$parent = this.getParent() - } else { - this.addAriaAndCollapsedClass(this.$element, this.$trigger) - } + /** @private {Element} */ + this._trigger = typeof this._config['trigger'] == 'string' ? + $(this._config['trigger'])[0] : this._config['trigger'] - if (this.options.toggle) this.toggle() + /** @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) } - Collapse.VERSION = '3.3.2' - - Collapse.TRANSITION_DURATION = 350 - - Collapse.DEFAULTS = { - toggle: true, - trigger: '[data-toggle="collapse"]' + if (this._config['toggle']) { + this['toggle']() } - Collapse.prototype.dimension = function () { - var hasWidth = this.$element.hasClass('width') - return hasWidth ? 'width' : 'height' - } - - Collapse.prototype.show = function () { - if (this.transitioning || this.$element.hasClass('in')) return - - var activesData - var actives = this.$parent && this.$parent.children('.panel').children('.in, .collapsing') - - if (actives && actives.length) { - activesData = actives.data('bs.collapse') - if (activesData && activesData.transitioning) return - } - - var startEvent = $.Event('show.bs.collapse') - this.$element.trigger(startEvent) - if (startEvent.isDefaultPrevented()) return - - if (actives && actives.length) { - Plugin.call(actives, 'hide') - activesData || actives.data('bs.collapse', null) - } - - var dimension = this.dimension() - - this.$element - .removeClass('collapse') - .addClass('collapsing')[dimension](0) - .attr('aria-expanded', true) - - this.$trigger - .removeClass('collapsed') - .attr('aria-expanded', true) - - this.transitioning = 1 - - var complete = function () { - this.$element - .removeClass('collapsing') - .addClass('collapse in')[dimension]('') - this.transitioning = 0 - this.$element - .trigger('shown.bs.collapse') - } - - if (!$.support.transition) return complete.call(this) - - var scrollSize = $.camelCase(['scroll', dimension].join('-')) - - this.$element - .one('bsTransitionEnd', $.proxy(complete, this)) - .emulateTransitionEnd(Collapse.TRANSITION_DURATION)[dimension](this.$element[0][scrollSize]) - } - - 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 - - var dimension = this.dimension() - - this.$element[dimension](this.$element[dimension]())[0].offsetHeight - - this.$element - .addClass('collapsing') - .removeClass('collapse in') - .attr('aria-expanded', false) - - this.$trigger - .addClass('collapsed') - .attr('aria-expanded', false) - - this.transitioning = 1 - - var complete = function () { - this.transitioning = 0 - this.$element - .removeClass('collapsing') - .addClass('collapse') - .trigger('hidden.bs.collapse') - } - - if (!$.support.transition) return complete.call(this) - - this.$element - [dimension](0) - .one('bsTransitionEnd', $.proxy(complete, this)) - .emulateTransitionEnd(Collapse.TRANSITION_DURATION) - } - - Collapse.prototype.toggle = function () { - this[this.$element.hasClass('in') ? 'hide' : 'show']() - } - - 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') - - $element.attr('aria-expanded', isOpen) - $trigger - .toggleClass('collapsed', !isOpen) - .attr('aria-expanded', isOpen) - } - - function getTargetFromTrigger($trigger) { - var href - var target = $trigger.attr('data-target') - || (href = $trigger.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7 - - return $(target) - } +} - // COLLAPSE PLUGIN DEFINITION - // ========================== - - 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]() - }) - } - - var old = $.fn.collapse - - $.fn.collapse = Plugin - $.fn.collapse.Constructor = Collapse +/** + * @const + * @type {string} + */ +Collapse['VERSION'] = '4.0.0' - // COLLAPSE NO CONFLICT - // ==================== - - $.fn.collapse.noConflict = function () { - $.fn.collapse = old - return this - } +/** + * @const + * @type {Object} + */ +Collapse['Defaults'] = { + 'toggle' : true, + 'trigger' : '[data-toggle="collapse"]', + 'parent' : null +} - // COLLAPSE DATA-API - // ================= +/** + * @const + * @type {string} + * @private + */ +Collapse._NAME = 'collapse' - $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) { + +/** + * @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 (!$this.attr('data-target')) e.preventDefault() + if (!data && config['toggle'] && opt_config == 'show') { + config['toggle'] = false + } - var $target = getTargetFromTrigger($this) - var data = $target.data('bs.collapse') - var option = data ? 'toggle' : $.extend({}, $this.data(), { trigger: this }) + if (!data) { + data = new Collapse(this, config) + $this.data(Collapse._DATA_KEY, data) + } - Plugin.call($target, option) + if (typeof opt_config == 'string') { + data[opt_config]() + } }) +} -}(jQuery); -/* ======================================================================== - * Bootstrap: dropdown.js v3.3.2 - * http://getbootstrap.com/javascript/#dropdowns +/** + * 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 + } + + var activesData, actives + + if (this._parent) { + actives = $.makeArray($(Collapse._Selector.ACTIVES)) + if (!actives.length) { + actives = null + } + } + + if (actives) { + activesData = $(actives).data(Collapse._DATA_KEY) + if (activesData && activesData._isTransitioning) { + return + } + } + + var startEvent = $.Event(Collapse._Event.SHOW) + $(this._element).trigger(startEvent) + if (startEvent.isDefaultPrevented()) { + return + } + + if (actives) { + Collapse._jQueryInterface.call($(actives), 'hide') + if (!activesData) { + $(actives).data(Collapse._DATA_KEY, null) + } + } + + var dimension = this._getDimension() + + $(this._element) + .removeClass(Collapse._ClassName.COLLAPSE) + .addClass(Collapse._ClassName.COLLAPSING) + + this._element.style[dimension] = 0 + this._element.setAttribute('aria-expanded', true) + + if (this._trigger) { + $(this._trigger).removeClass(Collapse._ClassName.COLLAPSED) + this._trigger.setAttribute('aria-expanded', true) + } + + this['setTransitioning'](true) + + var complete = function () { + $(this._element) + .removeClass(Collapse._ClassName.COLLAPSING) + .addClass(Collapse._ClassName.COLLAPSE) + .addClass(Collapse._ClassName.IN) + + this._element.style[dimension] = '' + + this['setTransitioning'](false) + + $(this._element).trigger(Collapse._Event.SHOWN) + }.bind(this) + + if (!Bootstrap.transition) { + complete() + return + } + + var scrollSize = 'scroll' + (dimension[0].toUpperCase() + dimension.slice(1)) + + $(this._element) + .one(Bootstrap.TRANSITION_END, complete) + .emulateTransitionEnd(Collapse._TRANSITION_DURATION) + + this._element.style[dimension] = this._element[scrollSize] + 'px' +} + + +/** + * 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() + } + + $(this._element) + .one(Bootstrap.TRANSITION_END, complete) + .emulateTransitionEnd(Collapse._TRANSITION_DURATION) +} + + + +/** + * @param {boolean} isTransitioning + */ +Collapse.prototype['setTransitioning'] = function (isTransitioning) { + this._isTransitioning = isTransitioning +} + + +/** + * 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 +} + + +/** + * 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) + } + } +} + + + +/** + * ------------------------------------------------------------------------ + * 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 +} + + +/** + * ------------------------------------------------------------------------ + * 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'; +/** + * Our dropdown class. + * @param {Element!} element + * @constructor + */ +var Dropdown = function (element) { + $(element).on('click.bs.dropdown', this['toggle']) +} - // DROPDOWN CLASS DEFINITION - // ========================= - var backdrop = '.dropdown-backdrop' - var toggle = '[data-toggle="dropdown"]' - var Dropdown = function (element) { - $(element).on('click.bs.dropdown', this.toggle) - } +/** + * @const + * @type {string} + */ +Dropdown['VERSION'] = '4.0.0' - Dropdown.VERSION = '3.3.2' - Dropdown.prototype.toggle = function (e) { - var $this = $(this) +/** + * @const + * @type {string} + * @private + */ +Dropdown._NAME = 'dropdown' - if ($this.is('.disabled, :disabled')) return - var $parent = getParent($this) - var isActive = $parent.hasClass('open') +/** + * @const + * @type {string} + * @private + */ +Dropdown._DATA_KEY = 'bs.dropdown' - clearMenus() - if (!isActive) { - if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { - // if mobile we use a backdrop because click events don't delegate - $('