mdb-ui-kit/dist/js/bootstrap-material-design.min.js

6 lines
14 KiB
JavaScript
Raw Normal View History

2015-12-01 20:22:36 +03:00
/*!
* Bootstrap Material Design v4.0.0-alpha (https://github.com/FezVrasta/bootstrap-material-design)
* Copyright 2014-2015 Federico Zivolo
* Licensed under MIT (https://github.com/FezVrasta/bootstrap-material-design/blob/master/LICENSE)
*/
2015-12-03 00:03:02 +03:00
if("undefined"==typeof jQuery)throw new Error("Bootstrap Material Design'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||b[0]>=3)throw new Error("Bootstrap Material Design's JavaScript requires at least jQuery v1.9.1 but less than v3.0.0")}(jQuery),+function(a){"use strict";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(){if(window.QUnit)return!1;var a=document.createElement("mdb");for(var b in f)if(void 0!==a.style[b])return f[b];return!1}function c(){d=b();for(var a in f)e+=" "+f[a]}var d=!1,e="",f={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},g={IS_FOCUSED:"is-focused",FORM_GROUP:"form-group"},h={FORM_GROUP:"."+g.FORM_GROUP},i={transitionEndSupported:function(){return d},transitionEndSelector:function(){return e},isChar:function(a){return"undefined"==typeof a.which?!0:"number"==typeof a.which&&a.which>0?!a.ctrlKey&&!a.metaKey&&!a.altKey&&8!==a.which&&9!==a.which:!1},addFormGroupFocus:function(a){a.addClass(g.IS_FOCUSED)},removeFormGroupFocus:function(a){a.removeClass(g.IS_FOCUSED)},findFormGroup:function(b){var c=b.closest(h.FORM_GROUP);return 0===c.length&&a.error("Failed to find form-group for "+b),c}};return c(),i}(jQuery);(function(a){var e="ripples",f="mdb."+e,g=a.fn[e],h={CONTAINER:"ripple-container",DECORATOR:"ripple-decorator"},i={CONTAINER:"."+h.CONTAINER,DECORATOR:"."+h.DECORATOR},j={container:{template:"<div class='"+h.CONTAINER+"'></div>"},decorator:{template:h.DECORATOR+"'></div>"},trigger:{start:"mousedown touchstart",end:"mouseup mouseleave touchend"},touchUserAgentRegex:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i,duration:500},k=function(){function e(c,d){b(this,e),this.element=a(c),this.config=a.extend({},j,d),this.element.on(this.config.triggerStart,this._onStartRipple)}return c(e,[{key:"dispose",value:function(){a.removeData(this.element,f),this.element=null,this.containerElement=null,this.decoratorElement=null,this.config=null}},{key:"_onStartRipple",value:function(a){var b=this;if(!this.isTouch()||"mousedown"!==a.type){this._findOrCreateContainer();var c=this._getRelY(a),d=this._getRelX(a);(c||d)&&(this.decoratorElement.css({left:d,top:c,"background-color":this._getRipplesColor()}),this._forceStyleApplication(),this.rippleOn(),setTimeout(function(){b.rippleEnd()},this.config.duration),this.element.on(this.config.triggerEnd,function(){b.decoratorElement.data("mousedown","off"),"off"===b.decoratorElement.data("animating")&&b.rippleOut()}))}}},{key:"_findOrCreateContainer",value:function(){(!this.containerElement||!this.containerElement.length>0)&&(this.element.append(this.config.container.template),this.containerElement=this.element.find(i.CONTAINER)),this.containerElement.append(this.config.element.template),this.decoratorElement=this.containerElement.find(i.DECORATOR)}},{key:"_forceStyleApplication",value:function(){return window.getComputedStyle(this.decoratorElement[0]).opacity}},{key:"_getRelX",value:function(a){var b=this.containerElement.offset(),c=null;return this.isTouch()?(a=a.originalEvent,c=1===a.touches.length?a.touches[0].pageX-b.left:!1):c=a.pageX-b.left,c}},{key:"_getRelY",value:function(a){var b=this.containerElement.offset(),c=null;return this.isTouch()?(a=a.originalEvent,c=1===a.touches.length?a.touches[0].pageY-b.top:!1):c=a.pageY-b.top,c}},{key:"_getRipplesColor",value:function(){var a=this.element.data("ripple-color")?this.element.data("ripple-color"):window.getComputedStyle(this.element[0]).color;return a}},{key:"isTouch",value:function(){return this.config.touchUserAgentRegex.test(navigator.userAgent)}},{key:"rippleEnd",value:function(){this.decoratorElement.data