emsApplication/applications/WebConfigure/web/js/lib/roundProgress.min.js

5 lines
8.1 KiB
JavaScript

/* angular-svg-round-progressbar@0.4.8 2016-09-18 */
(function(){
"use strict";
!function(){for(var a=0,b=["webkit","moz"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(b){var c=(new Date).getTime(),d=Math.max(0,16-(c-a)),e=window.setTimeout(function(){b(c+d)},d);return a=c+d,e}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(a){window.clearTimeout(a)})}(),angular.module("angular-svg-round-progressbar",[]),angular.module("angular-svg-round-progressbar").constant("roundProgressConfig",{max:50,semi:!1,rounded:!1,responsive:!1,clockwise:!0,radius:100,color:"#45ccce",bgcolor:"#eaeaea",stroke:15,duration:800,animation:"easeOutCubic",animationDelay:0,offset:0}),angular.module("angular-svg-round-progressbar").service("roundProgressService",["$window",function(a){function b(a,b,c,d){var e=(d-90)*Math.PI/180,f=a+c*Math.cos(e),g=b+c*Math.sin(e);return f+" "+g}var c={},d=angular.isNumber,e=document.head.querySelector("base");return c.isSupported=!(!document.createElementNS||!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect),c.resolveColor=e&&e.href?function(a){var b=a.indexOf("#");return b>-1&&a.indexOf("url")>-1?a.slice(0,b)+window.location.href+a.slice(b):a}:function(a){return a},c.toNumber=function(a){return d(a)?a:parseFloat((a+"").replace(",","."))},c.getOffset=function(a,b){var c=+b.offset||0;if("inherit"===b.offset)for(var d=a.$parent;d;){if(d.hasOwnProperty("$$getRoundProgressOptions")){var e=d.$$getRoundProgressOptions();c+=(+e.offset||0)+(+e.stroke||0)}d=d.$parent}return c},c.getTimestamp=a.performance&&a.performance.now&&angular.isNumber(a.performance.now())?function(){return a.performance.now()}:function(){return(new a.Date).getTime()},c.updateState=function(a,c,d,e,f,g){if(!f)return e;var h=a>0?Math.min(a,c):0,i=g?180:359.9999,j=0===c?0:h/c*i,k=b(f,f,d,j),l=b(f,f,d,0),m=j<=180?0:1,n="M "+k+" A "+d+" "+d+" 0 "+m+" 0 "+l;return e.attr("d",n)},c.animations={linearEase:function(a,b,c,d){return c*a/d+b},easeInQuad:function(a,b,c,d){return c*(a/=d)*a+b},easeOutQuad:function(a,b,c,d){return-c*(a/=d)*(a-2)+b},easeInOutQuad:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a+b:-c/2*(--a*(a-2)-1)+b},easeInCubic:function(a,b,c,d){return c*(a/=d)*a*a+b},easeOutCubic:function(a,b,c,d){return c*((a=a/d-1)*a*a+1)+b},easeInOutCubic:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a*a+b:c/2*((a-=2)*a*a+2)+b},easeInQuart:function(a,b,c,d){return c*(a/=d)*a*a*a+b},easeOutQuart:function(a,b,c,d){return-c*((a=a/d-1)*a*a*a-1)+b},easeInOutQuart:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a*a*a+b:-c/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(a,b,c,d){return c*(a/=d)*a*a*a*a+b},easeOutQuint:function(a,b,c,d){return c*((a=a/d-1)*a*a*a*a+1)+b},easeInOutQuint:function(a,b,c,d){return(a/=d/2)<1?c/2*a*a*a*a*a+b:c/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(a,b,c,d){return-c*Math.cos(a/d*(Math.PI/2))+c+b},easeOutSine:function(a,b,c,d){return c*Math.sin(a/d*(Math.PI/2))+b},easeInOutSine:function(a,b,c,d){return-c/2*(Math.cos(Math.PI*a/d)-1)+b},easeInExpo:function(a,b,c,d){return 0==a?b:c*Math.pow(2,10*(a/d-1))+b},easeOutExpo:function(a,b,c,d){return a==d?b+c:c*(-Math.pow(2,-10*a/d)+1)+b},easeInOutExpo:function(a,b,c,d){return 0==a?b:a==d?b+c:(a/=d/2)<1?c/2*Math.pow(2,10*(a-1))+b:c/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(a,b,c,d){return-c*(Math.sqrt(1-(a/=d)*a)-1)+b},easeOutCirc:function(a,b,c,d){return c*Math.sqrt(1-(a=a/d-1)*a)+b},easeInOutCirc:function(a,b,c,d){return(a/=d/2)<1?-c/2*(Math.sqrt(1-a*a)-1)+b:c/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(a,b,c,d){var e=1.70158,f=0,g=c;return 0==a?b:1==(a/=d)?b+c:(f||(f=.3*d),g<Math.abs(c)?(g=c,e=f/4):e=f/(2*Math.PI)*Math.asin(c/g),-(g*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*(2*Math.PI)/f))+b)},easeOutElastic:function(a,b,c,d){var e=1.70158,f=0,g=c;return 0==a?b:1==(a/=d)?b+c:(f||(f=.3*d),g<Math.abs(c)?(g=c,e=f/4):e=f/(2*Math.PI)*Math.asin(c/g),g*Math.pow(2,-10*a)*Math.sin((a*d-e)*(2*Math.PI)/f)+c+b)},easeInOutElastic:function(a,b,c,d){var e=1.70158,f=0,g=c;return 0==a?b:2==(a/=d/2)?b+c:(f||(f=d*(.3*1.5)),g<Math.abs(c)?(g=c,e=f/4):e=f/(2*Math.PI)*Math.asin(c/g),a<1?-.5*(g*Math.pow(2,10*(a-=1))*Math.sin((a*d-e)*(2*Math.PI)/f))+b:g*Math.pow(2,-10*(a-=1))*Math.sin((a*d-e)*(2*Math.PI)/f)*.5+c+b)},easeInBack:function(a,b,c,d,e){return void 0==e&&(e=1.70158),c*(a/=d)*a*((e+1)*a-e)+b},easeOutBack:function(a,b,c,d,e){return void 0==e&&(e=1.70158),c*((a=a/d-1)*a*((e+1)*a+e)+1)+b},easeInOutBack:function(a,b,c,d,e){return void 0==e&&(e=1.70158),(a/=d/2)<1?c/2*(a*a*(((e*=1.525)+1)*a-e))+b:c/2*((a-=2)*a*(((e*=1.525)+1)*a+e)+2)+b},easeInBounce:function(a,b,d,e){return d-c.animations.easeOutBounce(e-a,0,d,e)+b},easeOutBounce:function(a,b,c,d){return(a/=d)<1/2.75?c*(7.5625*a*a)+b:a<2/2.75?c*(7.5625*(a-=1.5/2.75)*a+.75)+b:a<2.5/2.75?c*(7.5625*(a-=2.25/2.75)*a+.9375)+b:c*(7.5625*(a-=2.625/2.75)*a+.984375)+b},easeInOutBounce:function(a,b,d,e){return a<e/2?.5*c.animations.easeInBounce(2*a,0,d,e)+b:.5*c.animations.easeOutBounce(2*a-e,0,d,e)+.5*d+b}},c}]),angular.module("angular-svg-round-progressbar").directive("roundProgress",["$window","roundProgressService","roundProgressConfig",function(a,b,c){var d={restrict:"EA",replace:!0,transclude:!0,scope:{current:"=",max:"=",semi:"=",rounded:"=",clockwise:"=",responsive:"=",onRender:"=",radius:"@",color:"@",bgcolor:"@",stroke:"@",duration:"@",animation:"@",offset:"@",animationDelay:"@"}};return b.isSupported?angular.extend(d,{link:function(e,f,g){function h(a){return g.hasOwnProperty(a)}var i,j,k=!f.hasClass("round-progress-wrapper"),l=k?f:f.find("svg").eq(0),m=l.find("path").eq(0),n=l.find("circle").eq(0),o=angular.copy(c),p=0;e.$$getRoundProgressOptions=function(){return o};var q=function(){var a=o.semi,c=o.responsive,d=+o.radius||0,g=+o.stroke,h=2*d,i=d-g/2-b.getOffset(e,o);l.css({top:0,left:0,position:c?"absolute":"static",width:c?"100%":h+"px",height:c?"100%":(a?d:h)+"px",overflow:"hidden"}),k||l[0].setAttribute("viewBox","0 0 "+h+" "+(a?d:h)),f.css({width:c?"100%":"auto",position:"relative",paddingBottom:c?a?"50%":"100%":0}),m.css({stroke:b.resolveColor(o.color),strokeWidth:g,strokeLinecap:o.rounded?"round":"butt"}),a?m.attr("transform",o.clockwise?"translate(0, "+h+") rotate(-90)":"translate("+h+", "+h+") rotate(90) scale(-1, 1)"):m.attr("transform",o.clockwise?"":"scale(-1, 1) translate("+-h+" 0)"),n.attr({cx:d,cy:d,r:i>=0?i:0}).css({stroke:b.resolveColor(o.bgcolor),strokeWidth:g})},r=function(c,d,g){var h=b.toNumber(o.max||0),j=c>0?a.Math.min(c,h):0,k=d===j||d<0?0:d||0,n=j-k,q=b.animations[o.animation],r=+o.duration||0,s=g||c>h&&d>h||c<0&&d<0||r<25,t=b.toNumber(o.radius),u=t-o.stroke/2-b.getOffset(e,o),v=o.semi;l.attr({"aria-valuemax":h,"aria-valuenow":j});var w=function(){if(s)b.updateState(j,h,u,m,t,v),o.onRender&&o.onRender(j,o,f);else{var c=b.getTimestamp(),d=++p;a.requestAnimationFrame(function e(){var g=a.Math.min(b.getTimestamp()-c,r),i=q(g,k,n,r);b.updateState(i,h,u,m,t,v),o.onRender&&o.onRender(i,o,f),d===p&&g<r&&a.requestAnimationFrame(e)})}};o.animationDelay>0?(a.clearTimeout(i),a.setTimeout(w,o.animationDelay)):w()},s=Object.keys(d.scope).filter(function(a){return h(a)&&"current"!==a});e.$watchGroup(s,function(a){for(var b=0;b<a.length;b++)"undefined"!=typeof a[b]&&(o[s[b]]=a[b]);q(),e.$broadcast("$parentOffsetChanged"),"inherit"!==o.offset||j?"inherit"!==o.offset&&j&&j():j=e.$on("$parentOffsetChanged",function(){r(e.current,e.current,!0),q()})}),e.$watchGroup(["current","max","radius","stroke","semi","offset"].filter(h),function(a,c){r(b.toNumber(a[0]),b.toNumber(c[0]))})},template:function(a){for(var b=a.parent(),c="round-progress",d=['<svg class="'+c+'" xmlns="http://www.w3.org/2000/svg" role="progressbar" aria-valuemin="0">','<circle fill="none"/>','<path fill="none"/>',"<g ng-transclude></g>","</svg>"];b.length&&b[0].nodeName.toLowerCase()!==c&&"undefined"==typeof b.attr(c);)b=b.parent();return b&&b.length||(d.unshift('<div class="round-progress-wrapper">'),d.push("</div>")),d.join("\n")}}):angular.extend(d,{template:'<div class="round-progress" ng-transclude></div>'})}]);
})();