2020-05-19 11:43:42 +03:00

7 lines
3.7 KiB
JavaScript

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