tbstu-btn-loading
Version:
Vue loading button component base on bootstrap
2 lines • 4.5 kB
JavaScript
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["btn-loading"]=e():t["btn-loading"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s="fb15")}({8875:function(t,e,n){var r,i,o;(function(n,c){i=[],r=c,o="function"===typeof r?r.apply(e,i):r,void 0===o||(t.exports=o)})("undefined"!==typeof self&&self,(function(){function t(){var e=Object.getOwnPropertyDescriptor(document,"currentScript");if(!e&&"currentScript"in document&&document.currentScript)return document.currentScript;if(e&&e.get!==t&&document.currentScript)return document.currentScript;try{throw new Error}catch(p){var n,r,i,o=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,c=/@([^@]*):(\d+):(\d+)\s*$/gi,u=o.exec(p.stack)||c.exec(p.stack),s=u&&u[1]||!1,a=u&&u[2]||!1,d=document.location.href.replace(document.location.hash,""),f=document.getElementsByTagName("script");s===d&&(n=document.documentElement.outerHTML,r=new RegExp("(?:[^\\n]+?\\n){0,"+(a-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),i=n.replace(r,"$1").trim());for(var l=0;l<f.length;l++){if("interactive"===f[l].readyState)return f[l];if(f[l].src===s)return f[l];if(s===d&&f[l].innerHTML&&f[l].innerHTML.trim()===i)return f[l]}return null}}return t}))},fb15:function(t,e,n){"use strict";if(n.r(e),"undefined"!==typeof window){var r=window.document.currentScript,i=n("8875");r=i(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:i});var o=r&&r.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);o&&(n.p=o[1])}var c=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("button",{attrs:{type:t.type,disabled:t.disabled_btn},on:{click:t.callFn}},[t.spinning?n("span",{staticClass:"spinner-border spinner-border-sm",staticStyle:{"margin-bottom":"2px","margin-left":"-2px"},attrs:{role:"status","aria-hidden":"true"}}):t.icon?n("i",{class:t.icon}):t._e(),t._t("default")],2)},u=[],s={name:"btn-loading",props:{fn:{type:Function,require:!0},icon:{type:String,require:!1,default:null},disabled:{type:Boolean,require:!1,default:!1},type:{type:String,require:!1,default:"button"},stopSpin:{type:Boolean,require:!1,default:!1}},data:function(){return{spinning:!1,disabled_btn:this.disabled||"function"!==typeof this.fn}},methods:{callFn:function(){var t=this;this.spinning=!0,this.disabled_btn=!0,this.fn().then((function(){t.stopLoading()}))["catch"]((function(){return t.stopLoading(!1)}))},stopLoading:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.stopSpin&&(this.spinning=!1,this.disabled_btn=!1),this.$emit("success",t),t||this.$emit("fail")}},watch:{disabled:function(t){this.disabled_btn=t}}},a=s;function d(t,e,n,r,i,o,c,u){var s,a="function"===typeof t?t.options:t;if(e&&(a.render=e,a.staticRenderFns=n,a._compiled=!0),r&&(a.functional=!0),o&&(a._scopeId="data-v-"+o),c?(s=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(c)},a._ssrRegister=s):i&&(s=u?function(){i.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:i),s)if(a.functional){a._injectStyles=s;var d=a.render;a.render=function(t,e){return s.call(e),d(t,e)}}else{var f=a.beforeCreate;a.beforeCreate=f?[].concat(f,s):[s]}return{exports:t,options:a}}var f=d(a,c,u,!1,null,null,null),l=f.exports,p=l;e["default"]=p}})}));
//# sourceMappingURL=btn-loading.umd.min.js.map