|
!function(e,t,r){"use strict";function n(e,r,n,a,i,o){function s(o,s,M){function $(t,n,i,s,d,u){function v(e){P.attr("stroke-dashoffset",m(w,M,e,C)),P.attr("transform","rotate("+k+" "+w/2+" "+w/2+")")}var g=++S,h=a.now(),p=n-t,w=l(o.mdDiameter),M=c(w),$=i||r.easeFn,I=s||r.duration,k=-90*(d||0),C=u||100;n===t?v(n):x=f(function F(){var r=e.Math.max(0,e.Math.min(a.now()-h,I));v($(r,t,p,I)),g===S&&r<I&&(x=f(F))})}function I(){$(y,q,r.easeFnIndeterminate,r.durationIndeterminate,D,75),D=++D%4}function k(){F||(F=i(I,r.durationIndeterminate,0,!1),I(),s.addClass(w).removeAttr("aria-valuenow"))}function C(){F&&(i.cancel(F),F=null,s.removeClass(w))}var x,F,b=s[0],A=t.element(b.querySelector("svg")),P=t.element(b.querySelector("path")),y=r.startIndeterminate,q=r.endIndeterminate,D=0,S=0;n(s),s.toggleClass(p,M.hasOwnProperty("disabled")),o.mdMode===h&&k(),o.$on("$destroy",function(){C(),x&&v(x)}),o.$watchGroup(["value","mdMode",function(){var e=b.disabled;return e===!0||e===!1?e:t.isDefined(s.attr("disabled"))}],function(e,t){var r=e[1],n=e[2],a=t[2];if(n!==a&&s.toggleClass(p,!!n),n)C();else if(r!==g&&r!==h&&(r=h,M.$set("mdMode",r)),r===h)k();else{var i=u(e[0]);C(),s.attr("aria-valuenow",i),$(u(t[0]),i)}}),o.$watch("mdDiameter",function(t){var r=l(t),n=c(r),a=u(o.value),i=r/2+"px",f={width:r+"px",height:r+"px"};A[0].setAttribute("viewBox","0 0 "+r+" "+r),A.css(f).css("transform-origin",i+" "+i+" "+i),s.css(f),P.attr("stroke-width",n),P.attr("stroke-linecap","square"),o.mdMode==h?(P.attr("d",d(r,n,!0)),P.attr("stroke-dasharray",(r-n)*e.Math.PI*.75),P.attr("stroke-dashoffset",m(r,n,1,75))):(P.attr("d",d(r,n,!1)),P.attr("stroke-dasharray",(r-n)*e.Math.PI),P.attr("stroke-dashoffset",m(r,n,0,100)),$(a,a))})}function d(e,t,r){var n=e/2,a=t/2,i=n+","+a,o=a+","+n,s=n-a;return"M"+i+"A"+s+","+s+" 0 1 1 "+o+(r?"":"A"+s+","+s+" 0 0 1 "+i)}function m(t,r,n,a){return(t-r)*e.Math.PI*(3*(a||100)/100-n/100)}function u(t){return e.Math.max(0,e.Math.min(t||0,100))}function l(e){var t=r.progressSize;if(e){var n=parseFloat(e);return e.lastIndexOf("%")===e.length-1&&(n=n/100*t),n}return t}function c(e){return r.strokeWidth/100*e}var f=e.requestAnimationFrame||e.webkitRequestAnimationFrame||t.noop,v=e.cancelAnimationFrame||e.webkitCancelAnimationFrame||e.webkitCancelRequestAnimationFrame||t.noop,g="determinate",h="indeterminate",p="_md-progress-circular-disabled",w="md-mode-indeterminate";return{restrict:"E",scope:{value:"@",mdDiameter:"@",mdMode:"@"},template:'<svg xmlns="http://www.w3.org/2000/svg"><path fill="none"/></svg>',compile:function(e,r){if(e.attr({"aria-valuemin":0,"aria-valuemax":100,role:"progressbar"}),t.isUndefined(r.mdMode)){var n=r.hasOwnProperty("value")?g:h;r.$set("mdMode",n)}else r.$set("mdMode",r.mdMode.trim());return s}}}function a(){function e(e,t,r,n){return r*e/n+t}function r(e,t,r,n){var a=(e/=n)*e,i=a*e;return t+r*(6*i*a+-15*a*a+10*i)}var n={progressSize:50,strokeWidth:10,duration:100,easeFn:e,durationIndeterminate:1333,startIndeterminate:1,endIndeterminate:149,easeFnIndeterminate:r,easingPresets:{linearEase:e,materialEase:r}};return{configure:function(e){return n=t.extend(n,e||{})},$get:function(){return n}}}t.module("material.components.progressCircular",["material.core"]),n.$inject=["$window","$mdProgressCircular","$mdTheming","$mdUtil","$interval","$log"],t.module("material.components.progressCircular").directive("mdProgressCircular",n),t.module("material.components.progressCircular").provider("$mdProgressCircular",a)}(window,window.angular);
|