@df-legacy/angular-ladda
Version:
An angular directive wrapper for Ladda.
2 lines • 1.31 kB
JavaScript
/*! angular-ladda 0.3.4 */
!function(e,n){"use strict";if("function"==typeof define&&define.amd)define(["angular","ladda"],n);else{if("undefined"==typeof module||"object"!=typeof module.exports)return n(e.angular,e.Ladda);module.exports=n(window.angular||require("angular"),require("ladda"))}}(this,function(e,n){"use strict";var t="angular-ladda";return e.module(t,[]).provider("ladda",function(){var n={style:"zoom-in"};return{setOption:function(t){e.extend(n,t)},$get:function(){return n}}}).directive("ladda",["ladda",function(t){return{restrict:"A",priority:-1,link:function(a,r,d){if(r.addClass("ladda-button"),e.isUndefined(r.attr("data-style"))&&r.attr("data-style",t.style||"zoom-in"),e.isUndefined(r.attr("data-spinner-size"))&&t.spinnerSize&&r.attr("data-spinner-size",t.spinnerSize),e.isUndefined(r.attr("data-spinner-color"))&&t.spinnerColor&&r.attr("data-spinner-color",t.spinnerColor),!r[0].querySelector(".ladda-label")){var i=document.createElement("span");i.className="ladda-label",e.element(i).append(r.contents()),r.append(i)}var o=n.create(r[0]);a.$watch(d.ladda,function(n){return n||e.isNumber(n)?(o.isLoading()||o.start(),void(e.isNumber(n)&&o.setProgress(n))):(o.stop(),void(d.ngDisabled&&r.attr("disabled",a.$eval(d.ngDisabled))))}),a.$on("$destroy",function(){o.remove()})}}}]),t});