1var _____WB$wombat$assign$function_____=function(name){return (globalThis._wb_wombat && globalThis._wb_wombat.local_init && globalThis._wb_wombat.local_init(name))||globalThis[name];};if(!globalThis.__WB_pmw){globalThis.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ 2let window = _____WB$wombat$assign$function_____("window"); 3let self = _____WB$wombat$assign$function_____("self"); 4let document = _____WB$wombat$assign$function_____("document"); 5let location = _____WB$wombat$assign$function_____("location"); 6let top = _____WB$wombat$assign$function_____("top"); 7let parent = _____WB$wombat$assign$function_____("parent"); 8let frames = _____WB$wombat$assign$function_____("frames"); 9let opener = _____WB$wombat$assign$function_____("opener"); 10/*! 11* easyPieChart 12* Lightweight plugin to render simple, animated and retina optimized pie charts 13* 14* @author Robert Fleischmann <[email protected]> (http://robert-fleischmann.de) 15* @version 2.1.5 16* 17* Modified to adapt the latest jQuery version (v3 above) included on WordPress 5.6: 18* - (2020-12-15) - jQuery isFunction method is deprecated. 19*/ 20 21(function(root, factory) { 22 if(typeof exports === 'object') { 23 module.exports = factory(require('jquery')); 24 } 25 else if(typeof define === 'function' && define.amd) { 26 define(['jquery'], factory); 27 } 28 else { 29 factory(root.jQuery); 30 } 31}(this, function($) { 32 33/** 34 * Renderer to render the chart on a canvas object 35 * @param {DOMElement} el DOM element to host the canvas (root of the plugin) 36 * @param {object} options options object of the plugin 37 */ 38var CanvasRenderer = function(el, options) { 39 var cachedBackground; 40 var canvas = document.createElement('canvas'); 41 42 el.appendChild(canvas); 43 44 if (typeof(G_vmlCanvasManager) !== 'undefined') { 45 G_vmlCanvasManager.initElement(canvas); 46 } 47 48 var ctx = canvas.getContext('2d'); 49 50 canvas.width = canvas.height = options.size; 51 52 // canvas on retina devices 53 var scaleBy = 1; 54 if (window.devicePixelRatio > 1) { 55 scaleBy = window.devicePixelRatio; 56 canvas.style.width = canvas.style.height = [options.size, 'px'].join(''); 57 canvas.width = canvas.height = options.size * scaleBy; 58 ctx.scale(scaleBy, scaleBy); 59 } 60 61 // move 0,0 coordinates to the center 62 ctx.translate(options.size / 2, options.size / 2); 63 64 // rotate canvas -90deg 65 ctx.rotate((-1 / 2 + options.rotate / 180) * Math.PI); 66 67 var radius = (options.size - options.lineWidth) / 2; 68 if (options.scaleColor && options.scaleLength) { 69 radius -= options.scaleLength + 2; // 2 is the distance between scale and bar 70 } 71 72 // IE polyfill for Date 73 Date.now = Date.now || function() { 74 return +(new Date()); 75 }; 76 77 /** 78 * Draw a circle around the center of the canvas 79 * @param {strong} color Valid CSS color string 80 * @param {number} lineWidth Width of the line in px 81 * @param {number} percent Percentage to draw (float between -1 and 1) 82 */ 83 var drawCircle = function(color, lineWidth, percent, alpha ) { 84 percent = Math.min(Math.max(-1, percent || 0), 1); 85 var isNegative = percent <= 0 ? true : false; 86 87 ctx.beginPath(); 88 ctx.arc(0, 0, radius, 0, Math.PI * 2 * percent, isNegative); 89 90 ctx.strokeStyle = color; 91 ctx.globalAlpha = alpha; 92 ctx.lineWidth = lineWidth; 93 94 ctx.stroke(); 95 }; 96 97 /** 98 * Draw the scale of the chart 99 */ 100 var drawScale = function() { 101 var offset; 102 var length; 103 104 ctx.lineWidth = 1; 105 ctx.fillStyle = options.scaleColor; 106 107 ctx.save(); 108 for (var i = 24; i > 0; --i) { 109 if (i % 6 === 0) { 110 length = options.scaleLength; 111 offset = 0; 112 } else { 113 length = options.scaleLength * 0.6; 114 offset = options.scaleLength - length; 115 } 116 ctx.fillRect(-options.size/2 + offset, 0, length, 1); 117 ctx.rotate(Math.PI / 12); 118 } 119 ctx.restore(); 120 }; 121 122 /** 123 * Request animation frame wrapper with polyfill 124 * @return {function} Request animation frame method or timeout fallback 125 */ 126 var reqAnimationFrame = (function() { 127 return window.requestAnimationFrame || 128 window.webkitRequestAnimationFrame || 129 window.mozRequestAnimationFrame || 130 function(callback) { 131 window.setTimeout(callback, 1000 / 60); 132 }; 133 }()); 134 135 /** 136 * Draw the background of the plugin including the scale and the track 137 */
138 var drawBackground = function() { 139 if(options.scaleColor) drawScale(); 140 if(options.trackColor) drawCircle(options.trackColor, options.lineWidth, 1, options.trackAlpha ); 141 }; 142 143 /** 144 * Canvas accessor 145 */ 146 this.getCanvas = function() { 147 return canvas; 148 }; 149 150 /** 151 * Canvas 2D context 'ctx' accessor 152 */ 153 this.getCtx = function() { 154 return ctx; 155 }; 156 157 /** 158 * Clear the complete canvas 159 */ 160 this.clear = function() { 161 ctx.clearRect(options.size / -2, options.size / -2, options.size, options.size); 162 }; 163 164 /** 165 * Draw the complete chart 166 * @param {number} percent Percent shown by the chart between -100 and 100 167 */ 168 this.draw = function(percent) { 169 // do we need to render a background 170 if (!!options.scaleColor || !!options.trackColor) { 171 // getImageData and putImageData are supported 172 if (ctx.getImageData && ctx.putImageData) { 173 if (!cachedBackground) { 174 drawBackground(); 175 cachedBackground = ctx.getImageData(0, 0, options.size * scaleBy, options.size * scaleBy); 176 } else { 177 ctx.putImageData(cachedBackground, 0, 0); 178 } 179 } else { 180 this.clear(); 181 drawBackground(); 182 } 183 } else { 184 this.clear(); 185 } 186 187 ctx.lineCap = options.lineCap; 188 189 // if barcolor is a function execute it and pass the percent as a value 190 var color; 191 if (typeof(options.barColor) === 'function') { 192 color = options.barColor(percent); 193 } else { 194 color = options.barColor; 195 } 196 197 // draw bar 198 drawCircle(color, options.lineWidth, percent / 100, options.barAlpha ); 199 }.bind(this); 200 201 /** 202 * Animate from some percent to some other percentage 203 * @param {number} from Starting percentage 204 * @param {number} to Final percentage 205 */ 206 this.animate = function(from, to) { 207 var startTime = Date.now(); 208 options.onStart(from, to); 209 var animation = function() { 210 var process = Math.min(Date.now() - startTime, options.animate.duration); 211 var currentValue = options.easing(this, process, from, to - from, options.animate.duration); 212 this.draw(currentValue); 213 options.onStep(from, to, currentValue); 214 if (process >= options.animate.duration) { 215 options.onStop(from, to); 216 } else { 217 reqAnimationFrame(animation); 218 } 219 }.bind(this); 220 221 reqAnimationFrame(animation); 222 }.bind(this); 223}; 224 225var EasyPieChart = function(el, opts) { 226 var defaultOptions = { 227 barColor: '#ef1e25', 228 barAlpha: 1.0, 229 trackColor: '#f9f9f9', 230 trackAlpha: 1.0, 231 scaleColor: '#dfe0e0', 232 scaleLength: 5, 233 lineCap: 'round', 234 lineWidth: 3, 235 size: 110, 236 rotate: 0, 237 render: true, 238 animate: { 239 duration: 1000, 240 enabled: true 241 }, 242 easing: function (x, t, b, c, d) { // more can be found here: http://gsgd.co.uk/sandbox/jquery/easing/ 243 t = t / (d/2); 244 if (t < 1) { 245 return c / 2 * t * t + b; 246 } 247 return -c/2 * ((--t)*(t-2) - 1) + b; 248 }, 249 onStart: function(from, to) { 250 return; 251 }, 252 onStep: function(from, to, currentValue) { 253 return; 254 }, 255 onStop: function(from, to) { 256 return; 257 } 258 }; 259 260 // detect present renderer 261 if (typeof(CanvasRenderer) !== 'undefined') { 262 defaultOptions.renderer = CanvasRenderer; 263 } else if (typeof(SVGRenderer) !== 'undefined') { 264 defaultOptions.renderer = SVGRenderer; 265 } else { 266 throw new Error('Please load either the SVG- or the CanvasRenderer'); 267 } 268 269 var options = {}; 270 var currentValue = 0; 271 272 /** 273 * Initialize the plugin by creating the options object and initialize rendering 274 */ 275 var init = function() { 276 this.el = el; 277 this.options = options; 278 279 // merge user options into default options 280 for (var i in defaultOptions) { 281 if (defaultOptions.hasOwnProperty(i)) { 282 options[i] = opts && typeof(opts[i]) !== 'undefined' ? opts[i] : defaultOptions[i]; 283 if (typeof(options[i]) === 'function') { 284 options[i] = options[i].bind(this); 285 } 286 } 287 } 288 289 // check for jQuery easing 290 if (typeof(options.easing) === 'string' && typeof(jQuery) !== 'undefined' && 'function' === typeof jQuery.easing[options.easing]) { 291 options.easing = jQuery.easing[options.easing]; 292 } else { 293 options.easing = defaultOptions.easing; 294 } 295 296 // process earlier animate option to avoid bc breaks 297 if (typeof(options.animate) === 'number') { 298 options.animate = { 299 duration: options.animate, 300 enabled: true 301 }; 302 } 303 304 if (typeof(options.animate) === 'boolean' && !options.animate) { 305 options.animate = { 306 duration: 1000, 307 enabled: options.animate 308 }; 309 } 310 311 // create renderer 312 this.renderer = new options.renderer(el, options); 313 314 // initial draw 315 this.renderer.draw(currentValue); 316 317 // initial update 318 if (el.dataset && el.dataset.percent) { 319 this.update(parseFloat(el.dataset.percent)); 320 } else if (el.getAttribute && el.getAttribute('data-percent')) { 321 this.update(parseFloat(el.getAttribute('data-percent'))); 322 } 323 }.bind(this); 324 325 /** 326 * Update the value of the chart 327 * @param {number} newValue Number between 0 and 100 328 * @return {object} Instance of the plugin for method chaining 329 */ 330 this.update = function(newValue) { 331 newValue = parseFloat(newValue); 332 if (options.animate.enabled) { 333 this.renderer.animate(currentValue, newValue); 334 } else { 335 this.renderer.draw(newValue); 336 } 337 currentValue = newValue; 338 return this; 339 }.bind(this); 340 341 /** 342 * Disable animation 343 * @return {object} Instance of the plugin for method chaining 344 */ 345 this.disableAnimation = function() { 346 options.animate.enabled = false;
347 return this; 348 }; 349 350 /** 351 * Enable animation 352 * @return {object} Instance of the plugin for method chaining 353 */ 354 this.enableAnimation = function() { 355 options.animate.enabled = true; 356 return this; 357 }; 358 359 init(); 360}; 361 362$.fn.easyPieChart = function(options) { 363 return this.each(function() { 364 var instanceOptions; 365 366 if (!$.data(this, 'easyPieChart')) { 367 instanceOptions = $.extend({}, options, $(this).data()); 368 $.data(this, 'easyPieChart', new EasyPieChart(this, instanceOptions)); 369 } 370 }); 371}; 372 373 374})); 375 376}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.