-
Notifications
You must be signed in to change notification settings - Fork 48
/
angular-loading.min.js
1 lines (1 loc) · 1.97 KB
/
angular-loading.min.js
1
!function(a){"function"==typeof define&&define.amd?define(["angular","spinjs"],a):"object"==typeof exports?a(require("angular"),require("spinjs")):a(window.angular,window.Spinner)}(function(a,b){"use strict";function c(b){var d=!1,e=1;return"boolean"==typeof b&&(d=b,b=arguments[1]||{},e++),a.forEach([].slice.call(arguments,e),function(e){var f,g,h,i,j;for(i in e)j=b[i],h=e[i],b!==h&&(d&&h&&(a.isObject(h)||(f=a.isArray(h)))?(g=f?j&&a.isArray(j)?j:[]:j&&a.isObject(j)?j:{},b[i]=c(d,g,h)):void 0!==h&&(b[i]=h))}),b}a.module("darthwade.loading",[]).value("loadingOptions",{active:!1,text:"Loading...",className:"",overlay:!0,spinner:!0,spinnerOptions:{lines:12,length:7,width:4,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:2,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"dw-spinner",top:"auto",left:"auto",position:"relative"}}).service("$loading",["$timeout","$rootScope","loadingOptions",function(a,b,d){var e=this;e.setDefaultOptions=function(a){c(!0,d,a)},e.start=function(c){a(function(){b.$broadcast("$loadingStart",c)})},e.finish=function(c){a(function(){b.$broadcast("$loadingFinish",c)})}}]).directive("dwLoading",["$rootScope","loadingOptions",function(d,e){return{link:function(f,g,h){var i,j,k,l,m,n=null,o=h.dwLoading||!1,p=function(){j&&j.addClass("dw-loading-active"),n&&n.spin(l[0])},q=function(){j&&j.removeClass("dw-loading-active"),n&&n.stop()};f.$watch(h.dwLoadingOptions,function(d){q(),i=c(!0,{},e,d),k=a.element("<div></div>").addClass("dw-loading-body"),j=a.element("<div></div>").addClass("dw-loading").append(k),i.overlay&&j.addClass("dw-loading-overlay"),i.className&&j.addClass(i.className),i.spinner&&(l=a.element("<div></div>").addClass("dw-loading-spinner"),k.append(l),n=new b(i.spinnerOptions)),i.text&&(m=a.element("<div></div>").addClass("dw-loading-text").text(i.text),k.append(m)),g.append(j),(i.active||!o)&&p()},!0),d.$on("$loadingStart",function(a,b){b===o&&p()}),d.$on("$loadingFinish",function(a,b){b===o&&q()}),f.$on("$destroy",function(){q(),n=null})}}}])});