vendor: 20,991 bytes, lines 1-644
1(function() { 2 var COUNT_FRAMERATE, COUNT_MS_PER_FRAME, DIGIT_FORMAT, DIGIT_HTML, DIGIT_SPEEDBOOST, DURATION, FORMAT_MARK_HTML, FORMAT_PARSER, FRAMERATE, FRAMES_PER_VALUE, MS_PER_FRAME, MutationObserver, Odometer, RIBBON_HTML, TRANSITION_END_EVENTS, TRANSITION_SUPPORT, VALUE_HTML, addClass, createFromHTML, fractionalPart, now, removeClass, requestAnimationFrame, round, transitionCheckStyles, trigger, truncate, wrapJQuery, _jQueryWrapped, _old, _ref, _ref1, 3 __slice = [].slice; 4 5 VALUE_HTML = '<span class="odometer-value"></span>'; 6 7 RIBBON_HTML = '<span class="odometer-ribbon"><span class="odometer-ribbon-inner">' + VALUE_HTML + '</span></span>'; 8 9 DIGIT_HTML = '<span class="odometer-digit"><span class="odometer-digit-spacer">8</span><span class="odometer-digit-inner">' + RIBBON_HTML + '</span></span>'; 10 11 FORMAT_MARK_HTML = '<span class="odometer-formatting-mark"></span>'; 12 13 DIGIT_FORMAT = '(,ddd).dd'; 14 15 FORMAT_PARSER = /^\(?([^)]*)\)?(?:(.)(d+))?$/; 16 17 FRAMERATE = 30; 18 19 DURATION = 2000; 20 21 COUNT_FRAMERATE = 20; 22 23 FRAMES_PER_VALUE = 2; 24 25 DIGIT_SPEEDBOOST = .5; 26 27 MS_PER_FRAME = 1000 / FRAMERATE; 28 29 COUNT_MS_PER_FRAME = 1000 / COUNT_FRAMERATE; 30 31 TRANSITION_END_EVENTS = 'transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd'; 32 33 transitionCheckStyles = document.createElement('div').style; 34 35 TRANSITION_SUPPORT = (transitionCheckStyles.transition != null) || (transitionCheckStyles.webkitTransition != null) || (transitionCheckStyles.mozTransition != null) || (transitionCheckStyles.oTransition != null); 36 37 requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; 38 39 MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; 40 41 createFromHTML = function(html) { 42 var el; 43 el = document.createElement('div'); 44 el.innerHTML = html; 45 return el.children[0]; 46 }; 47 48 removeClass = function(el, name) { 49 return el.className = el.className.replace(new RegExp("(^| )" + (name.split(' ').join('|')) + "( |$)", 'gi'), ' '); 50 }; 51 52 addClass = function(el, name) { 53 removeClass(el, name); 54 return el.className += " " + name; 55 }; 56 57 trigger = function(el, name) { 58 var evt; 59 if (document.createEvent != null) { 60 evt = document.createEvent('HTMLEvents'); 61 evt.initEvent(name, true, true); 62 return el.dispatchEvent(evt); 63 } 64 }; 65 66 now = function() { 67 var _ref, _ref1; 68 return (_ref = (_ref1 = window.performance) != null ? typeof _ref1.now === "function" ? _ref1.now() : void 0 : void 0) != null ? _ref : +(new Date); 69 }; 70 71 round = function(val, precision) { 72 if (precision == null) { 73 precision = 0; 74 } 75 if (!precision) { 76 return Math.round(val); 77 } 78 val *= Math.pow(10, precision); 79 val += 0.5; 80 val = Math.floor(val); 81 return val /= Math.pow(10, precision); 82 }; 83 84 truncate = function(val) { 85 if (val < 0) { 86 return Math.ceil(val); 87 } else { 88 return Math.floor(val); 89 } 90 }; 91 92 fractionalPart = function(val) { 93 return val - round(val); 94 }; 95 96 _jQueryWrapped = false; 97 98 (wrapJQuery = function() { 99 var property, _i, _len, _ref, _results; 100 if (_jQueryWrapped) { 101 return; 102 } 103 if (window.jQuery != null) { 104 _jQueryWrapped = true; 105 _ref = ['html', 'text']; 106 _results = []; 107 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 108 property = _ref[_i]; 109 _results.push((function(property) { 110 var old; 111 old = window.jQuery.fn[property]; 112 return window.jQuery.fn[property] = function(val) { 113 var _ref1; 114 if ((val == null) || (((_ref1 = this[0]) != null ? _ref1.odometer : void 0) == null)) { 115 return old.apply(this, arguments); 116 } 117 return this[0].odometer.update(val); 118 }; 119 })(property)); 120 } 121 return _results; 122 } 123 })(); 124 125 setTimeout(wrapJQuery, 0); 126 127 Odometer = (function() { 128 function Odometer(options) { 129 var e, k, property, v, _base, _i, _len, _ref, _ref1, _ref2, 130 _this = this; 131 this.options = options; 132 this.el = this.options.el; 133 if (this.el.odometer != null) { 134 return this.el.odometer; 135 } 136 this.el.odometer = this; 137 _ref = Odometer.options; 138 for (k in _ref) { 139 v = _ref[k]; 140 if (this.options[k] == null) { 141 this.options[k] = v; 142 } 143 } 144 if ((_base = this.options).duration == null) { 145 _base.duration = DURATION; 146 } 147 this.MAX_VALUES = ((this.options.duration / MS_PER_FRAME) / FRAMES_PER_VALUE) | 0; 148 this.resetFormat(); 149 this.value = this.cleanValue((_ref1 = this.options.value) != null ? _ref1 : ''); 150 this.renderInside(); 151 this.render(); 152 try { 153 _ref2 = ['innerHTML', 'innerText', 'textContent']; 154 for (_i = 0, _len = _ref2.length; _i < _len; _i++) { 155 property = _ref2[_i]; 156 if (this.el[property] != null) { 157 (function(property) { 158 return Object.defineProperty(_this.el, property, { 159 get: function() { 160 var _ref3; 161 if (property === 'innerHTML') { 162 return _this.inside.outerHTML; 163 } else { 164 return (_ref3 = _this.inside.innerText) != null ? _ref3 : _this.inside.textContent; 165 } 166 }, 167 set: function(val) { 168 return _this.update(val); 169 } 170 }); 171 })(property); 172 } 173 } 174 } catch (_error) { 175 e = _error; 176 this.watchForMutations(); 177 } 178 this; 179 } 180 181 Odometer.prototype.renderInside = function() { 182 this.inside = document.createElement('div'); 183 this.inside.className = 'odometer-inside'; 184 this.el.innerHTML = ''; 185 return this.el.appendChild(this.inside); 186 }; 187 188 Odometer.prototype.watchForMutations = function() { 189 var e, 190 _this = this; 191 if (MutationObserver == null) { 192 return; 193 } 194 try { 195 if (this.observer == null) { 196 this.observer = new MutationObserver(function(mutations) { 197 var newVal; 198 newVal = _this.el.innerText; 199 _this.renderInside(); 200 _this.render(_this.value); 201 return _this.update(newVal); 202 }); 203 } 204 this.watchMutations = true; 205 return this.startWatchingMutations(); 206 } catch (_error) { 207 e = _error; 208 } 209 }; 210 211 Odometer.prototype.startWatchingMutations = function() { 212 if (this.watchMutations) { 213 return this.observer.observe(this.el, { 214 childList: true 215 }); 216 } 217 }; 218 219 Odometer.prototype.stopWatchingMutations = function() { 220 var _ref; 221 return (_ref = this.observer) != null ? _ref.disconnect() : void 0; 222 }; 223 224 Odometer.prototype.cleanValue = function(val) { 225 var _ref; 226 if (typeof val === 'string') { 227 val = val.replace((_ref = this.format.radix) != null ? _ref : '.', '<radix>'); 228 val = val.replace(/[.,]/g, ''); 229 val = val.replace('<radix>', '.'); 230 val = parseFloat(val, 10) || 0; 231 } 232 return round(val, this.format.precision); 233 }; 234 235 Odometer.prototype.bindTransitionEnd = function() { 236 var event, renderEnqueued, _i, _len, _ref, _results, 237 _this = this; 238 if (this.transitionEndBound) { 239 return; 240 } 241 this.transitionEndBound = true; 242 renderEnqueued = false; 243 _ref = TRANSITION_END_EVENTS.split(' '); 244 _results = []; 245 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 246 event = _ref[_i]; 247 _results.push(this.el.addEventListener(event, function() { 248 if (renderEnqueued) { 249 return true; 250 } 251 renderEnqueued = true; 252 setTimeout(function() { 253 _this.render(); 254 renderEnqueued = false; 255 return trigger(_this.el, 'odometerdone'); 256 }, 0); 257 return true; 258 }, false)); 259 } 260 return _results; 261 }; 262 263 Odometer.prototype.resetFormat = function() { 264 var format, fractional, parsed, precision, radix, repeating, _ref, _ref1; 265 format = (_ref = this.options.format) != null ? _ref : DIGIT_FORMAT; 266 format || (format = 'd'); 267 parsed = FORMAT_PARSER.exec(format); 268 if (!parsed) { 269 throw new Error("Odometer: Unparsable digit format"); 270 } 271 _ref1 = parsed.slice(1, 4), repeating = _ref1[0], radix = _ref1[1], fractional = _ref1[2]; 272 precision = (fractional != null ? fractional.length : void 0) || 0; 273 return this.format = { 274 repeating: repeating, 275 radix: radix, 276 precision: precision 277 }; 278 }; 279 280 Odometer.prototype.render = function(value) { 281 var classes, cls, match, newClasses, theme, _i, _len; 282 if (value == null) { 283 value = this.value; 284 } 285 this.stopWatchingMutations(); 286 this.resetFormat(); 287 this.inside.innerHTML = ''; 288 theme = this.options.theme; 289 classes = this.el.className.split(' '); 290 newClasses = []; 291 for (_i = 0, _len = classes.length; _i < _len; _i++) { 292 cls = classes[_i]; 293 if (!cls.length) { 294 continue; 295 } 296 if (match = /^odometer-theme-(.+)$/.exec(cls)) { 297 theme = match[1]; 298 continue; 299 } 300 if (/^odometer(-|$)/.test(cls)) { 301 continue; 302 } 303 newClasses.push(cls); 304 } 305 newClasses.push('odometer'); 306 if (!TRANSITION_SUPPORT) { 307 newClasses.push('odometer-no-transitions'); 308 } 309 if (theme) { 310 newClasses.push("odometer-theme-" + theme); 311 } else { 312 newClasses.push("odometer-auto-theme"); 313 } 314 this.el.className = newClasses.join(' '); 315 this.ribbons = {}; 316 this.formatDigits(value); 317 return this.startWatchingMutations(); 318 }; 319 320 Odometer.prototype.formatDigits = function(value) { 321 var digit, valueDigit, valueString, wholePart, _i, _j, _len, _len1, _ref, _ref1; 322 this.digits = []; 323 if (this.options.formatFunction) { 324 valueString = this.options.formatFunction(value); 325 _ref = valueString.split('').reverse(); 326 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 327 valueDigit = _ref[_i]; 328 if (valueDigit.match(/0-9/)) { 329 digit = this.renderDigit(); 330 digit.querySelector('.odometer-value').innerHTML = valueDigit; 331 this.digits.push(digit); 332 this.insertDigit(digit); 333 } else { 334 this.addSpacer(valueDigit); 335 } 336 } 337 } else { 338 wholePart = !this.format.precision || !fractionalPart(value) || false; 339 _ref1 = value.toString().split('').reverse(); 340 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { 341 digit = _ref1[_j]; 342 if (digit === '.') { 343 wholePart = true; 344 } 345 this.addDigit(digit, wholePart); 346 } 347 } 348 }; 349 350 Odometer.prototype.update = function(newValue) { 351 var diff, 352 _this = this; 353 newValue = this.cleanValue(newValue); 354 if (!(diff = newValue - this.value)) { 355 return; 356 } 357 removeClass(this.el, 'odometer-animating-up odometer-animating-down odometer-animating'); 358 if (diff > 0) { 359 addClass(this.el, 'odometer-animating-up'); 360 } else { 361 addClass(this.el, 'odometer-animating-down'); 362 } 363 this.stopWatchingMutations(); 364 this.animate(newValue); 365 this.startWatchingMutations(); 366 setTimeout(function() { 367 _this.el.offsetHeight; 368 return addClass(_this.el, 'odometer-animating'); 369 }, 0); 370 return this.value = newValue; 371 }; 372 373 Odometer.prototype.renderDigit = function() { 374 return createFromHTML(DIGIT_HTML); 375 }; 376 377 Odometer.prototype.insertDigit = function(digit, before) { 378 if (before != null) { 379 return this.inside.insertBefore(digit, before); 380 } else if (!this.inside.children.length) { 381 return this.inside.appendChild(digit); 382 } else { 383 return this.inside.insertBefore(digit, this.inside.children[0]); 384 } 385 }; 386 387 Odometer.prototype.addSpacer = function(chr, before, extraClasses) { 388 var spacer; 389 spacer = createFromHTML(FORMAT_MARK_HTML); 390 spacer.innerHTML = chr; 391 if (extraClasses) { 392 addClass(spacer, extraClasses); 393 } 394 return this.insertDigit(spacer, before); 395 }; 396 397 Odometer.prototype.addDigit = function(value, repeating) { 398 var chr, digit, resetted, _ref; 399 if (repeating == null) { 400 repeating = true; 401 } 402 if (value === '-') { 403 return this.addSpacer(value, null, 'odometer-negation-mark'); 404 } 405 if (value === '.') { 406 return this.addSpacer((_ref = this.format.radix) != null ? _ref : '.', null, 'odometer-radix-mark'); 407 } 408 if (repeating) { 409 resetted = false; 410 while (true) { 411 if (!this.format.repeating.length) { 412 if (resetted) { 413 throw new Error("Bad odometer format without digits"); 414 } 415 this.resetFormat(); 416 resetted = true; 417 } 418 chr = this.format.repeating[this.format.repeating.length - 1]; 419 this.format.repeating = this.format.repeating.substring(0, this.format.repeating.length - 1); 420 if (chr === 'd') { 421 break; 422 } 423 this.addSpacer(chr); 424 } 425 } 426 digit = this.renderDigit(); 427 digit.querySelector('.odometer-value').innerHTML = value; 428 this.digits.push(digit); 429 return this.insertDigit(digit); 430 }; 431 432 Odometer.prototype.animate = function(newValue) { 433 if (!TRANSITION_SUPPORT || this.options.animation === 'count') { 434 return this.animateCount(newValue); 435 } else { 436 return this.animateSlide(newValue); 437 } 438 }; 439 440 Odometer.prototype.animateCount = function(newValue) { 441 var cur, diff, last, start, tick, 442 _this = this; 443 if (!(diff = +newValue - this.value)) { 444 return; 445 } 446 start = last = now(); 447 cur = this.value; 448 return (tick = function() { 449 var delta, dist, fraction; 450 if ((now() - start) > _this.options.duration) { 451 _this.value = newValue; 452 _this.render(); 453 trigger(_this.el, 'odometerdone'); 454 return; 455 } 456 delta = now() - last; 457 if (delta > COUNT_MS_PER_FRAME) { 458 last = now(); 459 fraction = delta / _this.options.duration; 460 dist = diff * fraction; 461 cur += dist; 462 _this.render(Math.round(cur)); 463 } 464 if (requestAnimationFrame != null) { 465 return requestAnimationFrame(tick); 466 } else { 467 return setTimeout(tick, COUNT_MS_PER_FRAME); 468 } 469 })(); 470 }; 471 472 Odometer.prototype.getDigitCount = function() { 473 var i, max, value, values, _i, _len; 474 values = 1 <= arguments.length ? __slice.call(arguments, 0) : []; 475 for (i = _i = 0, _len = values.length; _i < _len; i = ++_i) { 476 value = values[i]; 477 values[i] = Math.abs(value); 478 } 479 max = Math.max.apply(Math, values); 480 return Math.ceil(Math.log(max + 1) / Math.log(10)); 481 }; 482 483 Odometer.prototype.getFractionalDigitCount = function() { 484 var i, parser, parts, value, values, _i, _len; 485 values = 1 <= arguments.length ? __slice.call(arguments, 0) : []; 486 parser = /^\-?\d*\.(\d*?)0*$/; 487 for (i = _i = 0, _len = values.length; _i < _len; i = ++_i) { 488 value = values[i]; 489 values[i] = value.toString(); 490 parts = parser.exec(values[i]); 491 if (parts == null) { 492 values[i] = 0; 493 } else { 494 values[i] = parts[1].length; 495 } 496 } 497 return Math.max.apply(Math, values); 498 }; 499 500 Odometer.prototype.resetDigits = function() { 501 this.digits = []; 502 this.ribbons = []; 503 this.inside.innerHTML = ''; 504 return this.resetFormat(); 505 }; 506 507 Odometer.prototype.animateSlide = function(newValue) { 508 var boosted, cur, diff, digitCount, digits, dist, end, fractionalCount, frame, frames, i, incr, j, mark, numEl, oldValue, start, _base, _i, _j, _k, _l, _len, _len1, _len2, _m, _ref, _results; 509 oldValue = this.value; 510 fractionalCount = this.getFractionalDigitCount(oldValue, newValue); 511 if (fractionalCount) { 512 newValue = newValue * Math.pow(10, fractionalCount); 513 oldValue = oldValue * Math.pow(10, fractionalCount); 514 } 515 if (!(diff = newValue - oldValue)) { 516 return; 517 } 518 this.bindTransitionEnd(); 519 digitCount = this.getDigitCount(oldValue, newValue); 520 digits = []; 521 boosted = 0; 522 for (i = _i = 0; 0 <= digitCount ? _i < digitCount : _i > digitCount; i = 0 <= digitCount ? ++_i : --_i) { 523 start = truncate(oldValue / Math.pow(10, digitCount - i - 1)); 524 end = truncate(newValue / Math.pow(10, digitCount - i - 1)); 525 dist = end - start; 526 if (Math.abs(dist) > this.MAX_VALUES) { 527 frames = []; 528 incr = dist / (this.MAX_VALUES + this.MAX_VALUES * boosted * DIGIT_SPEEDBOOST); 529 cur = start; 530 while ((dist > 0 && cur < end) || (dist < 0 && cur > end)) { 531 frames.push(Math.round(cur)); 532 cur += incr; 533 } 534 if (frames[frames.length - 1] !== end) { 535 frames.push(end); 536 } 537 boosted++; 538 } else { 539 frames = (function() { 540 _results = []; 541 for (var _j = start; start <= end ? _j <= end : _j >= end; start <= end ? _j++ : _j--){ _results.push(_j); } 542 return _results; 543 }).apply(this); 544 } 545 for (i = _k = 0, _len = frames.length; _k < _len; i = ++_k) { 546 frame = frames[i]; 547 frames[i] = Math.abs(frame % 10); 548 } 549 digits.push(frames); 550 } 551 this.resetDigits(); 552 _ref = digits.reverse(); 553 for (i = _l = 0, _len1 = _ref.length; _l < _len1; i = ++_l) { 554 frames = _ref[i]; 555 if (!this.digits[i]) { 556 this.addDigit(' ', i >= fractionalCount); 557 } 558 if ((_base = this.ribbons)[i] == null) { 559 _base[i] = this.digits[i].querySelector('.odometer-ribbon-inner'); 560 } 561 this.ribbons[i].innerHTML = ''; 562 if (diff < 0) { 563 frames = frames.reverse(); 564 } 565 for (j = _m = 0, _len2 = frames.length; _m < _len2; j = ++_m) { 566 frame = frames[j]; 567 numEl = document.createElement('div'); 568 numEl.className = 'odometer-value'; 569 numEl.innerHTML = frame; 570 this.ribbons[i].appendChild(numEl); 571 if (j === frames.length - 1) { 572 addClass(numEl, 'odometer-last-value'); 573 } 574 if (j === 0) { 575 addClass(numEl, 'odometer-first-value'); 576 } 577 } 578 } 579 if (start < 0) { 580 this.addDigit('-'); 581 } 582 mark = this.inside.querySelector('.odometer-radix-mark'); 583 if (mark != null) { 584 mark.parent.removeChild(mark); 585 } 586 if (fractionalCount) { 587 return this.addSpacer(this.format.radix, this.digits[fractionalCount - 1], 'odometer-radix-mark'); 588 } 589 }; 590 591 return Odometer; 592 593 })(); 594 595 Odometer.options = (_ref = window.odometerOptions) != null ? _ref : {}; 596 597 setTimeout(function() { 598 var k, v, _base, _ref1, _results; 599 if (window.odometerOptions) { 600 _ref1 = window.odometerOptions; 601 _results = []; 602 for (k in _ref1) { 603 v = _ref1[k]; 604 _results.push((_base = Odometer.options)[k] != null ? (_base = Odometer.options)[k] : _base[k] = v); 605 } 606 return _results; 607 } 608 }, 0); 609 610 Odometer.init = function() { 611 var el, elements, _i, _len, _ref1, _results; 612 if (document.querySelectorAll == null) { 613 return; 614 } 615 elements = document.querySelectorAll(Odometer.options.selector || '.odometer'); 616 _results = []; 617 for (_i = 0, _len = elements.length; _i < _len; _i++) { 618 el = elements[_i]; 619 _results.push(el.odometer = new Odometer({ 620 el: el, 621 value: (_ref1 = el.innerText) != null ? _ref1 : el.textContent 622 })); 623 } 624 return _results; 625 }; 626 627 if ((((_ref1 = document.documentElement) != null ? _ref1.doScroll : void 0) != null) && (document.createEventObject != null)) { 628 _old = document.onreadystatechange; 629 document.onreadystatechange = function() { 630 if (document.readyState === 'complete' && Odometer.options.auto !== false) { 631 Odometer.init(); 632 } 633 return _old != null ? _old.apply(this, arguments) : void 0; 634 }; 635 } else { 636 document.addEventListener('DOMContentLoaded', function() { 637 if (Odometer.options.auto !== false) { 638 return Odometer.init(); 639 } 640 }, false); 641 } 642 643 if (typeof define === 'function' && define.amd) { 644 define([
644'jquery'], function() { 645 return Odometer; 646 }); 647 } else if (typeof exports !== "undefined" && exports !== null) { 648 module.exports = Odometer; 649 } else { 650 window.Odometer = Odometer; 651 } 652 653}).call(this);
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.