mirror of
https://github.com/mdbootstrap/mdb-ui-kit.git
synced 2024-11-27 12:04:09 +03:00
7 lines
4.2 KiB
JavaScript
7 lines
4.2 KiB
JavaScript
/*!
|
|
* 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)
|
|
*/
|
|
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}}();(function(a){var d="ripples",e="bmd."+d,f=a.fn[d],g={},h=function(){function f(c,d){b(this,f),this.element=a(c),this.config=a.extend({},g,d),this.element.on("mousedown touchstart",this._createRipple)}return c(f,[{key:"close",value:function(a){a=a||this.element;var b=this._getRootElement(a),c=this._triggerCloseEvent(b);c.isDefaultPrevented()||this._removeElement(b)}},{key:"dispose",value:function(){a.removeData(this.element,e),this.element=null}},{key:"_createRipple",value:function(b){if(!this.isTouch()||"mousedown"!==b.type){this.element.find(".ripple-container").length||this.element.append('<div class="ripple-container"></div>');var c=this.element.children(".ripple-container"),d=this._getRelY(c,b),e=this._getRelX(c,b);if(d||e){var f=this._getRipplesColor(this.element),g=a("<div></div>");g.addClass("ripple").css({left:e,top:d,"background-color":f}),c.append(g),function(){return window.getComputedStyle(g[0]).opacity}(),this.rippleOn(this.element,g),setTimeout(function(){this.rippleEnd(g)},500),this.element.on("mouseup mouseleave touchend",function(){g.data("mousedown","off"),"off"===g.data("animating")&&this.rippleOut(g)})}}}},{key:"_getRelX",value:function(a, b){var c=a.offset();return this.isTouch()?(b=b.originalEvent,1===b.touches.length?b.touches[0].pageX-c.left:!1):b.pageX-c.left}},{key:"_getRelY",value:function(a, b){var c=a.offset();return this.isTouch()?(b=b.originalEvent,1===b.touches.length?b.touches[0].pageY-c.top:!1):b.pageY-c.top}},{key:"_getRipplesColor",value:function(a){var b=a.data("ripple-color")?a.data("ripple-color"):window.getComputedStyle(a[0]).color;return b}},{key:"_hasTransitionSupport",value:function(){var a=document.body||document.documentElement,b=a.style,c=void 0!==b.transition||void 0!==b.WebkitTransition||void 0!==b.MozTransition||void 0!==b.MsTransition||void 0!==b.OTransition;return c}},{key:"isTouch",value:function(){return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}},{key:"rippleEnd",value:function(a){a.data("animating","off"),"off"===a.data("mousedown")&&this.rippleOut(a)}},{key:"rippleOut",value:function(a){a.off(),this._hasTransitionSupport()?a.addClass("ripple-out"):a.animate({opacity:0},100,function(){a.triggerStart("transitionend")}),a.on("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){a.remove()})}},{key:"rippleOn",value:function(a, b){var c=this._getNewSize(a,b);this._hasTransitionSupport()?b.css({"-ms-transform":"scale("+c+")","-moz-transform":"scale("+c+")","-webkit-transform":"scale("+c+")",transform:"scale("+c+")"}).addClass("ripple-on").data("animating","on").data("mousedown","on"):b.animate({width:2*Math.max(a.outerWidth(),a.outerHeight()),height:2*Math.max(a.outerWidth(),a.outerHeight()),"margin-left":-1*Math.max(a.outerWidth(),a.outerHeight()),"margin-top":-1*Math.max(a.outerWidth(),a.outerHeight()),opacity:.2},500,function(){b.triggerStart("transitionend")})}}],[{key:"_getNewSize",value:function(a, b){return Math.max(a.outerWidth(),a.outerHeight())/b.outerWidth()*2.5}},{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),d=c.data(e);d||(d=new f(this,b),c.data(e,d))})}},{key:"NAME",get:function(){return d}}]),f}();return a.fn[d]=h._jQueryInterface,a.fn[d].Constructor=h,a.fn[d].noConflict=function(){return a.fn[d]=f,h._jQueryInterface},h})(jQuery)}(jQuery);
|