/**
* jQuery asPieProgress
* A jQuery plugin that animate the progress bar
* Compiled: Fri Sep 02 2016 14:07:00 GMT+0800 (CST)
* @version v0.3.4
* @link https://github.com/amazingSurge/jquery-asPieProgress
* @copyright LGPL-3.0
*/
!function(t,e){if("function"==typeof define&&define.amd)define(["exports","jQuery"],e);else if("undefined"!=typeof exports)e(exports,require("jQuery"));else{var i={exports:{}};e(i.exports,t.jQuery),t.jqueryAsPieProgress=i.exports}}(this,function(t,e){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var s=i(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},a=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),o=function(){return"undefined"!=typeof window.performance&&window.performance.now?window.performance.now():Date.now()},u=function(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg",t);return s.default.each(e,function(t,e){i.setAttribute(t,e)}),i},h=function(t){return"string"==typeof t&&t.indexOf("%")!==-1},l=function(t,e,i,n){function s(t,e){return 1-3*e+3*t}function r(t,e){return 3*e-6*t}function a(t){return 3*t}function o(t,e,i){return((s(e,i)*t+r(e,i))*t+a(e))*t}function u(t,e,i){return 3*s(e,i)*t*t+2*r(e,i)*t+a(e)}function h(e){for(var n=e,s=0;s<4;++s){var r=u(n,t,i);if(0===r)return n;var a=o(n,t,i)-e;n-=a/r}return n}return t===e&&i===n?{css:"linear",fn:function(t){return t}}:{css:"cubic-bezier("+t+","+e+","+i+","+n+")",fn:function(t){return o(h(t),e,n)}}},f={namespace:"",classes:{svg:"pie_progress__svg",element:"pie_progress",number:"pie_progress__number",content:"pie_progress__content"},min:0,max:100,goal:100,size:160,speed:15,barcolor:"#ef1e25",barsize:"4",trackcolor:"#f2f2f2",fillcolor:"none",easing:"ease",numberCallback:function(t){var e=Math.round(this.getPercentage(t));return e+"%"},contentCallback:null};Date.now||(Date.now=function(){return(new Date).getTime()});for(var c=["webkit","moz"],d=0;d<c.length&&!window.requestAnimationFrame;++d){var m=c[d];window.requestAnimationFrame=window[m+"RequestAnimationFrame"],window.cancelAnimationFrame=window[m+"CancelAnimationFrame"]||window[m+"CancelRequestAnimationFrame"]}!/iP(ad|hone|od).*OS (6|7)/.test(window.navigator.userAgent)&&window.requestAnimationFrame&&window.cancelAnimationFrame||!function(){var t=0;window.requestAnimationFrame=function(e){var i=o(),n=Math.max(t+16,i);return setTimeout(function(){e(t=n)},n-i)},window.cancelAnimationFrame=clearTimeout}();var p="createElementNS"in document&&new u("svg",{}).createSVGRect,g="asPieProgress";f.namespace=g;var v=function(){function t(e,i){n(this,t),this.element=e,this.$element=(0,s.default)(e),this.options=s.default.extend({},f,i,this.$element.data()),this.namespace=this.options.namespace,this.classes=this.options.classes,this.easing=t.easing[this.options.easing]||t.easing.ease,this.$element.addClass(this.classes.element),this.min=this.$element.attr("aria-valuemin"),this.max=this.$element.attr("aria-valuemax"),this.min=this.min?parseInt(this.min,10):this.options.min,this.max=this.max?parseInt(this.max,10):this.options.max,this.first=this.$element.attr("aria-valuenow"),this.first=this.first?parseInt(this.first,10):this.options.first?this.options.first:this.min,this.now=this.first,this.goal=this.options.goal,this._frameId=null,this.initialized=!1,this._trigger("init"),this.init()}return a(t,[{key:"init",value:function(){this.$number=this.$element.find("."+this.classes.number),this.$content=this.$element.find("."+this.classes.content),this.size=this.options.size,this.width=this.size,this.height=this.size,this.prepare(),this.initialized=!0,this._trigger("ready")}},{key:"prepare",value:function(){p&&(this.svg=new u("svg",{version:"1.1",preserveAspectRatio:"xMinYMin meet",viewBox:"0 0 "+this.width+" "+this.height}),this.buildTrack(),this.buildBar(),(0,s.default)('<div class="'+this.classes.svg+'"></div>').append(this.svg).appendTo(this.$element))}},{key:"buildTrack",value:function(){var t=this.size,e=this.size,i=e/2,n=t/2,s=this.options.barsize,r=new u("ellipse",{rx:i-s/2,ry:n-s/2,cx:i,cy:n,stroke:this.options.trackcolor,fill:this.options.fillcolor,"stroke-width":s});this.svg.appendChild(r)}},{key:"buildBar",value:function(){if(p){var t=new u("path",{fill:"none","stroke-width":this.options.barsize,stroke:this.options.barcolor});this.bar=t,this.svg.appendChild(t),this._drawBar(this.first),this._updateBar()}}},{key:"_drawBar",value:function(t){if(p){this.barGoal=t;var e=this.size,i=this.size,n=i/2,s=e/2,r=0,a=this.options.barsize,o=Math.min(n,s)-a/2;this.r=o;var u=this.getPercentage(t);100===u&&(u-=1e-4);var h=r+u*Math.PI*2/100,l=n+o*Math.sin(r),f=n+o*Math.sin(h),c=s-o*Math.cos(r),d=s-o*Math.cos(h),m=0;h-r>Math.PI&&(m=1);var g="M"+l+","+c+" A"+o+","+o+" 0 "+m+" 1 "+f+","+d;this.bar.setAttribute("d",g)}}},{key:"_updateBar",value:function(){if(p){var t=this.getPercentage(this.now),e=this.bar.getTotalLength(),i=e*(1-t/this.getPercentage(this.barGoal));this.bar.style.strokeDasharray=e+" "+e,this.bar.style.strokeDashoffset=i}}},{key:"_trigger",value:function(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];var s=[this].concat(i);this.$element.trigger(g+"::"+t,s),t=t.replace(/\b\w+\b/g,function(t){return t.substring(0,1).toUpperCase()+t.substring(1)});var r="on"+t;"function"==typeof this.options[r]&&this.options[r](i)}},{key:"getPercentage",value:function(t){return 100*(t-this.min)/(this.max-this.min)}},{key:"go",value:function(t){var e=this;this._clear(),h(t)&&(t=parseInt(t.replace("%",""),10),t=Math.round(this.min+t/100*(this.max-this.min))),"undefined"==typeof t&&(t=this.goal),t>this.max?t=this.max:t<this.min&&(t=this.min),this.barGoal<t&&this._drawBar(t);var i=e.now,n=o(),s=n+100*Math.abs(i-t)*e.options.speed/(e.max-e.min),r=function r(a){var o=void 0;if(a>s)o=t;else{var u=(a-n)/e.options.speed;o=Math.round(e.easing.fn(u/100)*(e.max-e.min)),t>i?(o=i+o,o>t&&(o=t)):(o=i-o,o<t&&(o=t))}e._update(o),o===t?(window.cancelAnimationFrame(e._frameId),e._frameId=null,e.now===e.goal&&e._trigger("finish")):e._frameId=window.requestAnimationFrame(r)};e._frameId=window.requestAnimationFrame(r)}},{key:"_update",value:function(t){this.now=t,this._updateBar(),this.$element.attr("aria-valuenow",this.now),this.$number.length>0&&"function"==typeof this.options.numberCallback&&this.$number.html(this.options.numberCallback.call(this,[this.now])),this.$content.length>0&&"function"==typeof this.options.contentCallback&&this.$content.html(this.options.contentCallback.call(this,[this.now])),this._trigger("update",t)}},{key:"_clear",value:function(){this._frameId&&(window.cancelAnimationFrame(this._frameId),this._frameId=null)}},{key:"get",value:function(){return this.now}},{key:"start",value:function(){this._clear(),this._trigger("start"),this.go(this.goal)}},{key:"reset",value:function(){this._clear(),this._drawBar(this.first),this._update(this.first),this._trigger("reset")}},{key:"stop",value:function(){this._clear(),this._trigger("stop")}},{key:"finish",value:function(){this._clear(),this._update(this.goal),this._trigger("finish")}},{key:"destory",value:function(){this.$element.data(g,null),this._trigger("destory")}}],[{key:"_jQueryInterface",value:function(e){for(var i=this,n=arguments.length,a=Array(n>1?n-1:0),o=1;o<n;o++)a[o-1]=arguments[o];if("string"==typeof e){var u=function(){var t=e;if(/^\_/.test(t))return{v:!1};if(!/^(get)$/.test(t))return{v:i.each(function(){var e=s.default.data(this,g);e&&"function"==typeof e[t]&&e[t].apply(e,a)})};var n=i.first().data(g);return n&&"function"==typeof n[t]?{v:n[t].apply(n,a)}:void 0}();if("object"===("undefined"==typeof u?"undefined":r(u)))return u.v}return this.each(function(){s.default.data(this,g)||s.default.data(this,g,new t(this,e))})}}]),t}();s.default.extend(v.easing={},{ease:l(.25,.1,.25,1),linear:l(0,0,1,1),"ease-in":l(.42,0,1,1),"ease-out":l(0,0,.58,1),"ease-in-out":l(.42,0,.58,1)}),s.default.fn[g]=v._jQueryInterface,s.default.fn[g].constructor=v,s.default.fn[g].noConflict=function(){return s.default.fn[g]=window.JQUERY_NO_CONFLICT,v._jQueryInterface},t.default=v});

//initialization
var isBuilder=$('html').hasClass('is-builder');function initCircleProgress(card){$ID=$(card).attr('id')+'-svg-gradient';$('.pie_progress').asPieProgress({namespace:'asPieProgress',classes:{element:'pie_progress',number:'pie_progress__number'},min:0,max:100,size:150,speed:30,barsize:'8',fillcolor:'none',easing:'ease'});$(card).find('.pie_progress').each(function(){$(this).asPieProgress('go',$(this).attr('data-goal')+'%')});$(card).find('.svg-gradient > *').attr('id',$ID);$(card).find('svg linearGradient').attr('id',$ID);$(card).find('.pie_progress svg path').each(function(){$(this).attr('stroke','url(#'+$ID+')')})}
function setCurrentCircleProgress(card,paramName){var $elem=$(card).find("."+paramName);$elem.asPieProgress('go',$elem.attr('data-goal')+'%')}
if(isBuilder){$(document).on('add.cards',function(event){if($('.pie_progress').length){initCircleProgress(event.target)}}).on('delete.cards',function(event){$(event.target).find('.pie_progress').asPieProgress('destroy')}).on('changeParameter.cards',function(event,paramName){if(paramName.indexOf('progress')==0){if($('.pie_progress').length){setCurrentCircleProgress(event.target,paramName)}
initCircleProgress(event.target)}})}else{$('section').each(function(){if($(this).is(':has(.pie_progress)')){initCircleProgress($(this))}})}