0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-03-03 03:29:21 +01:00
Bootstrap/dist/js/bootstrap.min.js

7 lines
39 KiB
JavaScript
Raw Normal View History

/*!
2015-01-19 14:55:25 -08:00
* Bootstrap v4.0.0-alpha (http://getbootstrap.com)
2015-01-01 12:02:02 -08:00
* Copyright 2011-2015 Twitter, Inc.
2013-12-18 15:08:16 -08:00
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
2013-10-03 10:42:55 -07:00
*/
2015-05-13 10:13:34 -07:00
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(){"use strict";function a(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(a.__proto__=b)}function b(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}{var c=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(a,d.key,d)}}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),d=function(a){function b(){return{bindType:f.end,delegateType:f.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}}}function c(){if(window.QUnit)return!1;var a=document.createElement("bootstrap");for(var b in g)if(void 0!==a.style[b])return{end:g[b]};return!1}function d(b){var c=this,d=!1;return a(this).one(h.TRANSITION_END,function(){d=!0}),setTimeout(function(){d||h.triggerTransitionEnd(c)},b),this}function e(){f=c(),a.fn.emulateTransitionEnd=d,h.supportsTransitionEnd()&&(a.event.special[h.TRANSITION_END]=b())}var f=!1,g={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},h={TRANSITION_END:"bsTransitionEnd",getUID:function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},getSelectorFromElement:function(a){var b=a.getAttribute("data-target");return b||(b=a.getAttribute("href")||"",b=/^#[a-z]/i.test(b)?b:null),b},reflow:function(a){new Function("bs","return bs")(a.offsetHeight)},triggerTransitionEnd:function(b){a(b).trigger(f.end)},supportsTransitionEnd:function(){return!!f}};return e(),h}(jQuery),e=(function(a){var e="alert",f="4.0.0",g="bs.alert",h=a.fn[e],i=150,j={DISMISS:'[data-dismiss="alert"]'},k={CLOSE:"close.bs.alert",CLOSED:"closed.bs.alert",CLICK:"click.bs.alert.data-api"},l={ALERT:"alert",FADE:"fade",IN:"in"},m=function(){function e(a){b(this,e),this._element=a}return c(e,[{key:"close",value:function(a){a=a||this._element;var b=this._getRootElement(a),c=this._triggerCloseEvent(b);c.isDefaultPrevented()||this._removeElement(b)}},{key:"_getRootElement",value:function(b){var c=!1,e=d.getSelectorFromElement(b);return e&&(c=a(e)[0]),c||(c=a(b).closest("."+l.ALERT)[0]),c}},{key:"_triggerCloseEvent",value:function(b){var c=a.Event(k.CLOSE);return a(b).trigger(c),c}},{key:"_removeElement",value:function(b){return a(b).removeClass(l.IN),d.supportsTransitionEnd()&&a(b).hasClass(l.FADE)?void a(b).one(d.TRANSITION_END,this._destroyElement.bind(this,b)).emulateTransitionEnd(i):void this._destroyElement(b)}},{key:"_destroyElement",value:function(b){a(b).detach().trigger(k.CLOSED).remove()}}],[{key:"VERSION",get:function(){return f}},{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),d=c.data(g);d||(d=new e(this),c.data(g,d)),"close"===b&&d[b](this)})}},{key:"_handleDismiss",value:function(a){return function(b){b&&b.preventDefault(),a.close(this)}}}]),e}();return a(document).on(k.CLICK,j.DISMISS,m._handleDismiss(new m)),a.fn[e]=m._jQueryInterface,a.fn[e].Constructor=m,a.fn[e].noConflict=function(){return a.fn[e]=h,m._jQueryInterface},m}(jQuery),function(a){var d="button",e="4.0.0",f="bs.button",g=a.fn[d],h={ACTIVE:"active",BUTTON:"btn",FOCUS:"focus"},i={DATA_TOGGLE_CARROT:'[data-toggle^="button"]',DATA_TOGGLE:'[data-toggle="buttons"]',INPUT:"input",ACTIVE:".active",BUTTON:".btn"},j={CLICK:"click.bs.button.data-api",FOCUS_BLUR:"focus.bs.button.data-api blur.bs.button.data-api"},k=function(){function d(a){b(this,d),this._element=a}return c(d,[{key:"toggle",value:function(){var b=!0,c=a(this._element).closest(i.DATA_TOGGLE)[0];if(c){va
b.tip&&a(b.tip).detach(),b.tip=null})}},{key:"show",value:function(){var b=this,c=a.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){a(this.element).trigger(c);var e=a.contains(this.element.ownerDocument.documentElement,this.element);if(c.isDefaultPrevented()||!e)return;var f=this.getTipElement(),g=d.getUID(this.constructor.NAME);f.setAttribute("id",g),this.element.setAttribute("aria-describedby",g),this.setContent(),this.config.animation&&a(f).addClass(o.FADE);var i="function"==typeof this.config.placement?this.config.placement.call(this,f,this.element):this.config.placement,k=this._getAttachment(i);a(f).data(this.constructor.DATA_KEY,this).appendTo(document.body),a(this.element).trigger(this.constructor.Event.INSERTED),this._tether=new Tether({element:f,target:this.element,attachment:k,classes:q,classPrefix:j,offset:this.config.offset,constraints:this.config.constraints}),d.reflow(f),this._tether.position(),a(f).addClass(o.IN);var l=function(){var c=b._hoverState;b._hoverState=null,a(b.element).trigger(b.constructor.Event.SHOWN),c===m.OUT&&b._leave(null,b)};d.supportsTransitionEnd()&&a(this.tip).hasClass(o.FADE)?a(this.tip).one(d.TRANSITION_END,l).emulateTransitionEnd(h._TRANSITION_DURATION):l()}}},{key:"hide",value:function(b){var c=this,e=this.getTipElement(),f=a.Event(this.constructor.Event.HIDE),g=function(){c._hoverState!==m.IN&&e.parentNode&&e.parentNode.removeChild(e),c.element.removeAttribute("aria-describedby"),a(c.element).trigger(c.constructor.Event.HIDDEN),c.cleanupTether(),b&&b()};a(this.element).trigger(f),f.isDefaultPrevented()||(a(e).removeClass(o.IN),d.supportsTransitionEnd()&&a(this.tip).hasClass(o.FADE)?a(e).one(d.TRANSITION_END,g).emulateTransitionEnd(i):g(),this._hoverState="")}},{key:"isWithContent",value:function(){return!!this.getTitle()}},{key:"getTipElement",value:function(){return this.tip=this.tip||a(this.config.template)[0]}},{key:"setContent",value:function(){var b=this.getTipElement(),c=this.getTitle(),d=this.config.html?"innerHTML":"innerText";a(b).find(p.TOOLTIP_INNER)[0][d]=c,a(b).removeClass(o.FADE).removeClass(o.IN),this.cleanupTether()}},{key:"getTitle",value:function(){var a=this.element.getAttribute("data-original-title");return a||(a="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),a}},{key:"cleanupTether",value:function(){this._tether&&(this._tether.destroy(),a(this.element).removeClass(this._removeTetherClasses),a(this.tip).removeClass(this._removeTetherClasses))}},{key:"_getAttachment",value:function(a){return l[a.toUpperCase()]}},{key:"_setListeners",value:function(){var b=this,c=this.config.trigger.split(" ");c.forEach(function(c){if("click"===c)a(b.element).on(b.constructor.Event.CLICK,b.config.selector,a.proxy(b.toggle,b));else if(c!==r.MANUAL){var d=c==r.HOVER?b.constructor.Event.MOUSEENTER:b.constructor.Event.FOCUSIN,e=c==r.HOVER?b.constructor.Event.MOUSELEAVE:b.constructor.Event.FOCUSOUT;a(b.element).on(d,b.config.selector,a.proxy(b._enter,b)).on(e,b.config.selector,a.proxy(b._leave,b))}}),this.config.selector?this.config=a.extend({},this.config,{trigger:"manual",selector:""}):this._fixTitle()}},{key:"_removeTetherClasses",value:function(a,b){return((b.baseVal||b).match(new RegExp("(^|\\s)"+j+"-\\S+","g"))||[]).join(" ")}},{key:"_fixTitle",value:function(){var a=typeof this.element.getAttribute("data-original-title");(this.element.getAttribute("title")||"string"!==a)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))}},{key:"_enter",value:function(b,c){var d=this.constructor.DATA_KEY;return c=c||a(b.currentTarget).data(d),c||(c=new this.constructor(b.currentTarget,this._getDelegateConfig()),a(b.currentTarget).data(d,c)),b&&(c._activeTrigger["focusin"==b.type?r.FOCUS:r.HOVER]=!0),a(c.getTipElement()).hasClass(o.IN)||c._hoverState===m.IN?void(c._hoverState=m.IN):(clearTimeout(c._timeout),c._hoverState=m.IN,c.config.delay&&c.config.delay.show?void(c._timeout=setTimeout(function(){c._hoverState===m.IN&&c.show()},c.config.dela