mirror of
https://github.com/mdbootstrap/mdb-ui-kit.git
synced 2024-11-23 18:14:04 +03:00
6 lines
14 KiB
JavaScript
6 lines
14 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}}(),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("animating","off"),"off"===this.decoratorElement.data("mousedown")&&this.rippleOut(this.decoratorElement)}},{key:"rippleOut",value:function(){var a=this;this.decoratorElement.off(),d.transitionEndSupported()?this.decoratorElement.addClass("ripple-out"):this.decoratorElement.animate({opacity:0},100,function(){a.decoratorElement.triggerStart("transitionend")}),this.decoratorElement.on(d.transitionEndSelector(),function(){a.decoratorElement.remove(),a.decoratorElement=null})}},{key:"rippleOn",value:function(){var a=this,b=this._getNewSize();d.transitionEndSupported()?this.decoratorElement.css({"-ms-transform":"scale("+b+")","-moz-transform":"scale("+b+")","-webkit-transform":"scale("+b+")",transform:"scale("+b+")"}).addClass("ripple-on").data("animating","on").data("mousedown","on"):this.decoratorElement.animate({width:2*Math.max(this.element.outerWidth(),this.element.outerHeight()),height:2*Math.max(this.element.outerWidth(),this.element.outerHeight()),"margin-left":-1*Math.max(this.element.outerWidth(),this.element.outerHeight()),"margin-top":-1*Math.max(this.element.outerWidth(),this.element.outerHeight()),opacity:.2},this.config.duration,function(){a.decoratorElement.triggerStart("transitionend")})}},{key:"_getNewSize",value:function(){return Math.max(this.element.outerWidth(),this.element.outerHeight())/this.decoratorElement.outerWidth()*2.5}}],[{key:"_jQueryInterface",value:function(b){var c=this;return this.each(function(){var d=a(c),g=d.data(f);g||(g=new e(c,b),d.data(f,g))})}}]),e}();return a.fn[e]=k._jQueryInterface,a.fn[e].Constructor=k,a.fn[e].noConflict=function(){return a.fn[e]=g,k._jQueryInterface},k})(jQuery),function(a){var d="autofill",e="mdb."+d,f=a.fn[d],g={},h=function(){function d(c,e){b(this,d),this.element=c,this.config=a.extend({},g,e),this._watchLoading(),this._attachEventHandlers()}return c(d,[{key:"dispose",value:function(){a.removeData(this.element,e),this.element=null,this.config=null}},{key:"_watchLoading",value:function(){var a=this;setTimeout(function(){clearInterval(a._onLoading)},1e4)}},{key:"_onLoading",value:function(){setInterval(function(){a("input[type!=checkbox]").each(function(b,c){var d=a(c);d.val()&&d.val()!==d.attr("value")&&d.triggerStart("change")})},100)}},{key:"_attachEventHandlers",value:function(){var b=null;a(document).on("focus","input",function(c){var d=a(c.currentTarget).closest("form").find("input").not("[type=file]");b=setInterval(function(){d.each(function(b,c){var d=a(c);d.val()!==d.attr("value")&&d.triggerStart("change")})},100)}).on("blur",".form-group input",function(){clearInterval(b)})}}],[{key:"_jQueryInterface",value:function(b){var c=this;return this.each(function(){var f=a(c),g=f.data(e);g||(g=new d(c,b),f.data(e,g))})}}]),d}();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),function(a){var e="input",f="mdb."+e,g=a.fn[e],h={convertInputSizeVariations:!0,template:"<span class='material-input'></span>",formGroup:{template:"<div class='form-group'></div>"}},i={"input-lg":"form-group-lg","input-sm":"form-group-sm"},j={IS_EMPTY:"is-empty",FORM_GROUP:"form-group",HAS_ERROR:"has-error"},k={FORM_GROUP:"."+j.FORM_GROUP},l=function(){function e(c,d){b(this,e),this.element=c,this.config=a.extend({},h,d),this.formGroup=this._findOrCreateFormGroup(),this._convertInputSizeVariations(),this._isEmpty()&&this.formGroup.addClass(j.IS_EMPTY),this.formGroup.append(this.config.template),this._bindEventListeners()}return c(e,[{key:"dispose",value:function(){a.removeData(this.element,f),this.element=null,this.formGroup=null,this.config=null}},{key:"_bindEventListeners",value:function(){var a=this;this.element.on("keydown paste",function(b){d.isChar(b)&&a._removeIsEmpty()}).on("keyup change",function(b){var c="undefined"==typeof a.element[0].checkValidity||a.element[0].checkValidity();""===a.element.val()&&c?a._addIsEmpty():a._removeIsEmpty(),c?a._removeHasError():a._addHasError()}).on("focus",function(){d.addFormGroupFocus(a.formGroup)}).on("blur",function(){d.removeFormGroupFocus(a.formGroup)}).on("change",function(){if("file"!==a.element.attr("type")){var b=a.element.val();b?a._removeIsEmpty():a._addIsEmpty()}})}},{key:"_addHasError",value:function(){this.formGroup.addClass(j.HAS_ERROR)}},{key:"_removeHasError",value:function(){this.formGroup.removeClass(j.HAS_ERROR)}},{key:"_addIsEmpty",value:function(){this.formGroup.addClass(j.IS_EMPTY)}},{key:"_removeIsEmpty",value:function(){this.formGroup.removeClass(j.IS_EMPTY)}},{key:"_isEmpty",value:function(){return null===this.element.val()||void 0===this.element.val()||""===this.element.val()}},{key:"_convertInputSizeVariations",value:function(){if(this.config.convertInputSizeVariations)for(var a in i)this.element.hasClass(a)&&(this.element.removeClass(a),this.formGroup.addClass(i[a]))}},{key:"_findOrCreateFormGroup",value:function(){var a=this.element.closest(k.FORM_GROUP);return 0===a.length&&(this.element.wrap(this.config.formGroup.template),a=this.element.closest(k.FORM_GROUP)),a}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),d=c.data(f);d||(d=new e(this,b),c.data(f,d))})}}]),e}();return a.fn[e]=l._jQueryInterface,a.fn[e].Constructor=l,a.fn[e].noConflict=function(){return a.fn[e]=g,l._jQueryInterface},l}(jQuery),function(a){var e="checkbox",f="mdb."+e,g=a.fn[e],h={template:"<span class='checkbox-material'><span class='check'></span></span>"},i=function(){function e(c,f){b(this,e),this.element=c,this.config=a.extend({},h,f),this.element.after(this.config.template),this.formGroup=d.findFormGroup(this.element),this._bindEventListeners()}return c(e,[{key:"dispose",value:function(){a.removeData(this.element,f),this.element=null,this.formGroup=null,this.config=null}},{key:"_bindEventListeners",value:function(){var a=this;this.formGroup.find(".checkbox label").hover(function(){d.addFormGroupFocus(a.formGroup)},function(){d.removeFormGroupFocus(a.formGroup)}),this.element.change(function(){a.element.blur()})}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),d=c.data(f);d||(d=new e(this,b),c.data(f,d))})}}]),e}();return a.fn[e]=i._jQueryInterface,a.fn[e].Constructor=i,a.fn[e].noConflict=function(){return a.fn[e]=g,i._jQueryInterface},i}(jQuery),function(a){var d="togglebutton",e="mdb."+d,f=a.fn[d],g={template:"<span class='toggle'></span>"},h=function(){function d(c,e){b(this,d),this.element=c,this.config=a.extend({},g,e),this.element.after(this.config.template)}return c(d,[{key:"dispose",value:function(){a.removeData(this.element,e),this.element=null,this.config=null}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),f=c.data(e);f||(f=new d(this,b),c.data(e,f))})}}]),d}();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),function(a){var d="radio",e="mdb."+d,f=a.fn[d],g={template:"<span class='circle'></span><span class='check'></span>"},h=function(){function d(c,e){b(this,d),this.element=c,this.config=a.extend({},g,e),this.element.after(this.config.template)}return c(d,[{key:"dispose",value:function(){a.removeData(this.element,e),this.element=null,this.config=null}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),f=c.data(e);f||(f=new d(this,b),c.data(e,f))})}}]),d}();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),function(a){var e="fileInput",f="mdb."+e,g=a.fn[e],h={},i={IS_FILEINPUT:"is-fileinput",IS_EMPTY:"is-empty"},j=function(){function e(c,f){b(this,e),this.element=c,this.config=a.extend({},h,f),this.formGroup=d.findFormGroup(this.element),this.formGroup.addClass(i.IS_FILEINPUT),this._bindEventListeners()}return c(e,[{key:"dispose",value:function(){a.removeData(this.element,f),this.element=null,this.formGroup=null,this.config=null}},{key:"_bindEventListeners",value:function(){var b=this;this.formGroup.on("focus",function(){d.addFormGroupFocus(b.formGroup)}).on("blur",function(){d.removeFormGroupFocus(b.formGroup)}),this.element.on("change",function(){var c="";a.each(b.element.files,function(a,b){c+=b.name+" , "}),c=c.substring(0,c.length-2),c?b._removeIsEmpty():b._addIsEmpty(),b.formGroup.find("input.form-control[readonly]").val(c)})}},{key:"_addIsEmpty",value:function(){this.formGroup.addClass(i.IS_EMPTY)}},{key:"_removeIsEmpty",value:function(){this.formGroup.removeClass(i.IS_EMPTY)}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),d=c.data(f);d||(d=new e(this,b),c.data(f,d))})}}]),e}();return a.fn[e]=j._jQueryInterface,a.fn[e].Constructor=j,a.fn[e].noConflict=function(){return a.fn[e]=g,j._jQueryInterface},j}(jQuery),function(a){var d="bootstrapMaterialDesign",e="mdb."+d,f=a.fn[d],g={ripples:{selector:[".btn:not(.btn-link):not(.ripple-none)",".card-image:not(.ripple-none)",".navbar a:not(.ripple-none)",".dropdown-menu a:not(.ripple-none)",".nav-tabs a:not(.ripple-none)",".pagination li:not(.active):not(.disabled) a:not(.ripple-none)",".ripple"]},input:{selector:["input.form-control","textarea.form-control","select.form-control"]},checkbox:{selector:".checkbox > label > input[type=checkbox]"},togglebutton:{selector:".togglebutton > label > input[type=checkbox]"},radio:{selector:".radio > label > input[type=radio]"},fileInput:{selector:"input[type=file]"},autofill:{selector:"body"},arrive:!0,instantiation:["ripples","input","checkbox","togglebutton","radio","fileInput","autofill"]},h=function(){function d(c,e){var f=this;b(this,d),this.element=c,this.config=a.extend({},g,e);var h=a(document),i=function(b){var c=f.config[b];if(c){var d=f._resolveSelector(c);a(d)[b](c),document.arrive&&f.config.arrive&&h.arrive(d,function(d){a(d)[b](c)})}};for(var j in this.config.instantiation)i(j)}return c(d,[{key:"dispose",value:function(){a.removeData(this.element,e),this.element=null,this.config=null}},{key:"_resolveSelector",value:function(a){var b=a.selector;return Array.isArray(b)&&(b=b.join(", ")),b}}],[{key:"_jQueryInterface",value:function(b){return this.each(function(){var c=a(this),f=c.data(e);f||(f=new d(this,b),c.data(e,f))})}}]),d}();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); |