1/* 2Plugin Name: scrollToTop for jQuery. 3Written by: Okler Themes - (http://www.okler.net) 4Version: 0.1 5*/ 6 7(function($) { 8 $.extend({ 9 10 scrollToTop: function() { 11 12 var _isScrolling = false; 13 14 // Append Button 15 $("body").append($("<a />") 16 .addClass("scroll-to-top") 17 .attr({ 18 "href": "#", 19 "id": "scrollToTop" 20 }) 21 .append( 22 $("<i />") 23 .addClass("icon icon-chevron-up icon-white") 24 )); 25 26 $("#scrollToTop").click(function(e) { 27 28 e.preventDefault(); 29 $("body, html").animate({scrollTop : 0}, 500); 30 return false; 31 32 }); 33 34 // Show/Hide Button on Window Scroll event. 35 $(window).scroll(function() { 36 37 if(!_isScrolling) { 38 39 _isScrolling = true; 40 41 if($(window).scrollTop() > 150) { 42 43 $("#scrollToTop").stop(true, true).addClass("visible"); 44 _isScrolling = false; 45 46 } else { 47 48 $("#scrollToTop").stop(true, true).removeClass("visible"); 49 _isScrolling = false; 50 51 } 52 53 } 54 55 }); 56 57 } 58 59 }); 60})(jQuery); 61 62/* 63Plugin Name: BrowserSelector 64Written by: Okler Themes - (http://www.okler.net) 65Version: 0.2 66*/ 67 68(function($) { 69 $.extend({ 70 71 browserSelector: function() { 72 73 var u = navigator.userAgent, 74 ua = u.toLowerCase(), 75 is = function (t) { 76 return ua.indexOf(t) > -1; 77 }, 78 g = 'gecko', 79 w = 'webkit', 80 s = 'safari', 81 o = 'opera', 82 h = document.documentElement, 83 b = [(!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + parseFloat(navigator.appVersion.split("MSIE")[1])) : is('firefox/2') ? g + ' ff2' : is('firefox/3.5') ? g + ' ff3 ff3_5' : is('firefox/3') ? g + ' ff3' : is('gecko/') ? g : is('opera') ? o + (/version\/(\d+)/.test(ua) ? ' ' + o + RegExp.jQuery1 : (/opera(\s|\/)(\d+)/.test(ua) ? ' ' + o + RegExp.jQuery2 : '')) : is('konqueror') ? 'konqueror' : is('chrome') ? w + ' chrome' : is('iron') ? w + ' iron' : is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.jQuery1 : '') : is('mozilla/') ? g : '', is('j2me') ? 'mobile' : is('iphone') ? 'iphone' : is('ipod') ? 'ipod' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', 'js']; 84 85 c = b.join(' '); 86 h.className += ' ' + c; 87 88 var isIE11 = !(window.ActiveXObject) && "ActiveXObject" in window; 89 90 if (isIE11) { 91 $('html').removeClass('gecko').addClass('ie ie11'); 92 return; 93 } 94 95 } 96 97 }); 98})(jQuery); 99 100/* 101Plugin Name: smoothScroll for jQuery. 102Written by: Okler Themes - (http://www.okler.net) 103Version: 0.1 104 105Based on: 106 107 SmoothScroll v1.2.1 108 Licensed under the terms of the MIT license. 109 110 People involved 111 - Balazs Galambosi (maintainer) 112 - Patrick Brunner (original idea) 113 - Michael Herf (Pulse Algorithm) 114 115*/ 116(function($) { 117 $.extend({ 118 119 smoothScroll: function() { 120 121 // Scroll Variables (tweakable) 122 var defaultOptions = { 123 124 // Scrolling Core 125 frameRate : 60, // [Hz] 126 animationTime : 700, // [px] 127 stepSize : 120, // [px] 128 129 // Pulse (less tweakable) 130 // ratio of "tail" to "acceleration" 131 pulseAlgorithm : true, 132 pulseScale : 10, 133 pulseNormalize : 1, 134 135 // Acceleration 136 accelerationDelta : 20, // 20 137 accelerationMax : 1, // 1 138 139 // Keyboard Settings 140 keyboardSupport : true, // option 141 arrowScroll : 50, // [px] 142 143 // Other 144 touchpadSupport : true, 145 fixedBackground : true, 146 excluded : "" 147 }; 148 149 var options = defaultOptions; 150 151 // Other Variables 152 var isExcluded = false; 153 var isFrame = false; 154 var direction = { x: 0, y: 0 }; 155 var initDone = false; 156 var root = document.documentElement; 157 var activeElement; 158 var observer; 159 var deltaBuffer = [ 120, 120, 120 ]; 160 161 var key = { left: 37, up: 38, right: 39, down: 40, spacebar: 32, 162 pageup: 33, pagedown: 34, end: 35, home: 36 }; 163 164 165 /*********************************************** 166 * INITIALIZE 167 ***********************************************/ 168 169 /** 170 * Tests if smooth scrolling is allowed. Shuts down everything if not. 171 */ 172 function initTest() { 173 174 var disableKeyboard = false; 175 176 // disable keys for google reader (spacebar conflict) 177 if (document.URL.indexOf("google.com/reader/view") > -1) { 178 disableKeyboard = true; 179 } 180 181 // disable everything if the page is blacklisted 182 if (options.excluded) { 183 var domains = options.excluded.split(/[,\n] ?/); 184 domains.push("mail.google.com"); // exclude Gmail for now 185 for (var i = domains.length; i--;) { 186 if (document.URL.indexOf(domains[i]) > -1) { 187 observer && observer.disconnect(); 188 removeEvent("mousewheel", wheel); 189 disableKeyboard = true;
190 isExcluded = true; 191 break; 192 } 193 } 194 } 195 196 // disable keyboard support if anything above requested it 197 if (disableKeyboard) { 198 removeEvent("keydown", keydown); 199 } 200 201 if (options.keyboardSupport && !disableKeyboard) { 202 addEvent("keydown", keydown); 203 } 204 } 205 206 /** 207 * Sets up scrolls array, determines if frames are involved. 208 */ 209 function init() { 210 211 if (!document.body) return; 212 213 var body = document.body; 214 var html = document.documentElement; 215 var windowHeight = window.innerHeight; 216 var scrollHeight = body.scrollHeight; 217 218 // check compat mode for root element 219 root = (document.compatMode.indexOf('CSS') >= 0) ? html : body; 220 activeElement = body; 221 222 initTest(); 223 initDone = true; 224 225 // Checks if this script is running in a frame 226 if (top != self) { 227 isFrame = true; 228 } 229 230 /** 231 * This fixes a bug where the areas left and right to 232 * the content does not trigger the onmousewheel event 233 * on some pages. e.g.: html, body { height: 100% } 234 */ 235 else if (scrollHeight > windowHeight && 236 (body.offsetHeight <= windowHeight || 237 html.offsetHeight <= windowHeight)) { 238 239 // DOMChange (throttle): fix height 240 var pending = false; 241 var refresh = function () { 242 if (!pending && html.scrollHeight != document.height) { 243 pending = true; // add a new pending action 244 setTimeout(function () { 245 html.style.height = document.height + 'px'; 246 pending = false; 247 }, 500); // act rarely to stay fast 248 } 249 }; 250 html.style.height = 'auto'; 251 setTimeout(refresh, 10); 252 253 var config = { 254 attributes: true, 255 childList: true, 256 characterData: false 257 }; 258 259 observer = new MutationObserver(refresh); 260 observer.observe(body, config); 261 262 // clearfix 263 if (root.offsetHeight <= windowHeight) { 264 var underlay = document.createElement("div"); 265 underlay.style.clear = "both"; 266 body.appendChild(underlay); 267 } 268 } 269 270 // gmail performance fix 271 if (document.URL.indexOf("mail.google.com") > -1) { 272 var s = document.createElement("style"); 273 s.innerHTML = ".iu { visibility: hidden }"; 274 (document.getElementsByTagName("head")[0] || html).appendChild(s); 275 } 276 // facebook better home timeline performance 277 // all the HTML resized images make rendering CPU intensive 278 else if (document.URL.indexOf("www.facebook.com") > -1) { 279 var home_stream = document.getElementById("home_stream"); 280 home_stream && (home_stream.style.webkitTransform = "translateZ(0)"); 281 } 282 // disable fixed background 283 if (!options.fixedBackground && !isExcluded) { 284 body.style.backgroundAttachment = "scroll"; 285 html.style.backgroundAttachment = "scroll"; 286 } 287 } 288 289 290 /************************************************ 291 * SCROLLING 292 ************************************************/ 293 294 var que = []; 295 var pending = false; 296 var lastScroll = +new Date; 297 298 /** 299 * Pushes scroll actions to the scrolling queue. 300 */ 301 function scrollArray(elem, left, top, delay) { 302 303 delay || (delay = 1000); 304 directionCheck(left, top); 305 306 if (options.accelerationMax != 1) { 307 var now = +new Date; 308 var elapsed = now - lastScroll; 309 if (elapsed < options.accelerationDelta) { 310 var factor = (1 + (30 / elapsed)) / 2; 311 if (factor > 1) { 312 factor = Math.min(factor, options.accelerationMax); 313 left *= factor; 314 top *= factor; 315 } 316 } 317 lastScroll = +new Date; 318 } 319 320 // push a scroll command 321 que.push({ 322 x: left, 323 y: top, 324 lastX: (left < 0) ? 0.99 : -0.99, 325 lastY: (top < 0) ? 0.99 : -0.99, 326 start: +new Date 327 }); 328 329 // don't act if there's a pending queue 330 if (pending) { 331 return; 332 } 333 334 var scrollWindow = (elem === document.body); 335 336 var step = function (time) { 337 338 var now = +new Date; 339 var scrollX = 0; 340 var scrollY = 0; 341 342 for (var i = 0; i < que.length; i++) { 343 344 var item = que[i]; 345 var elapsed = now - item.start; 346 var finished = (elapsed >= options.animationTime); 347 348 // scroll position: [0, 1] 349 var position = (finished) ? 1 : elapsed / options.animationTime; 350 351 // easing [optional] 352 if (options.pulseAlgorithm) { 353 position = pulse(position); 354 } 355 356 // only need the difference 357 var x = (item.x * position - item.lastX) >> 0; 358 var y = (item.y * position - item.lastY) >> 0; 359 360 // add this to the total scrolling 361 scrollX += x; 362 scrollY += y; 363 364 // update last values 365 item.lastX += x; 366 item.lastY += y; 367 368 // delete and step back if it's over 369 if (finished) { 370 que.splice(i, 1); i--; 371 } 372 } 373 374 // scroll left and top 375 if (scrollWindow) { 376 window.scrollBy(scrollX, scrollY); 377 } 378 else { 379 if (scrollX) elem.scrollLeft += scrollX; 380 if (scrollY) elem.scrollTop += scrollY; 381 } 382 383 // clean up if there's nothing left to do 384 if (!left && !top) { 385 que = []; 386 } 387 388 if (que.length) { 389 requestFrame(step, elem, (delay / options.frameRate + 1)); 390 } else { 391 pending = false; 392 } 393 }; 394 395 // start a new queue of actions 396 requestFrame(step, elem, 0); 397 pending = true; 398 } 399 400 401 /*********************************************** 402 * EVENTS 403 ***********************************************/ 404 405 /** 406 * Mouse wheel handler. 407 * @param {Object} event 408 */ 409 function wheel(event) { 410 411 if (!initDone) { 412 init(); 413 } 414 415 var target = event.target; 416 var overflowing = overflowingAncestor(target); 417 418 // use default if there's no overflowing 419 // element or default action is prevented 420 if (!overflowing || event.defaultPrevented || 421 isNodeName(activeElement, "embed") || 422 (isNodeName(target, "embed") && /\.pdf/i.test(target.src))) { 423 return true; 424 } 425 426 var deltaX = event.wheelDeltaX || 0; 427 var deltaY = event.wheelDeltaY || 0; 428 429 // use wheelDelta if deltaX/Y is not available 430 if (!deltaX && !deltaY) { 431 deltaY = event.wheelDelta || 0; 432 } 433 434 // check if it's a touchpad scroll that should be ignored 435 if (!options.touchpadSupport && isTouchpad(deltaY)) { 436 return true; 437 } 438 439 // scale by step size 440 // delta is 120 most of the time
441 // synaptics seems to send 1 sometimes 442 if (Math.abs(deltaX) > 1.2) { 443 deltaX *= options.stepSize / 120; 444 } 445 if (Math.abs(deltaY) > 1.2) { 446 deltaY *= options.stepSize / 120; 447 } 448 449 scrollArray(overflowing, -deltaX, -deltaY); 450 event.preventDefault(); 451 } 452 453 /** 454 * Keydown event handler. 455 * @param {Object} event 456 */ 457 function keydown(event) { 458 459 var target = event.target; 460 var modifier = event.ctrlKey || event.altKey || event.metaKey || 461 (event.shiftKey && event.keyCode !== key.spacebar); 462 463 // do nothing if user is editing text 464 // or using a modifier key (except shift) 465 // or in a dropdown 466 if ( /input|textarea|select|embed/i.test(target.nodeName) || 467 target.isContentEditable || 468 event.defaultPrevented || 469 modifier ) { 470 return true; 471 } 472 // spacebar should trigger button press 473 if (isNodeName(target, "button") && 474 event.keyCode === key.spacebar) { 475 return true; 476 } 477 478 var shift, x = 0, y = 0; 479 var elem = overflowingAncestor(activeElement); 480 var clientHeight = elem.clientHeight; 481 482 if (elem == document.body) { 483 clientHeight = window.innerHeight; 484 } 485 486 switch (event.keyCode) { 487 case key.up: 488 y = -options.arrowScroll; 489 break; 490 case key.down: 491 y = options.arrowScroll; 492 break; 493 case key.spacebar: // (+ shift) 494 shift = event.shiftKey ? 1 : -1; 495 y = -shift * clientHeight * 0.9; 496 break; 497 case key.pageup: 498 y = -clientHeight * 0.9; 499 break; 500 case key.pagedown: 501 y = clientHeight * 0.9; 502 break; 503 case key.home: 504 y = -elem.scrollTop; 505 break; 506 case key.end: 507 var damt = elem.scrollHeight - elem.scrollTop - clientHeight; 508 y = (damt > 0) ? damt+10 : 0; 509 break; 510 case key.left: 511 x = -options.arrowScroll; 512 break; 513 case key.right: 514 x = options.arrowScroll; 515 break; 516 default: 517 return true; // a key we don't care about 518 } 519 520 scrollArray(elem, x, y); 521 event.preventDefault(); 522 } 523 524 /** 525 * Mousedown event only for updating activeElement 526 */ 527 function mousedown(event) { 528 activeElement = event.target; 529 } 530 531 532 /*********************************************** 533 * OVERFLOW 534 ***********************************************/ 535 536 var cache = {}; // cleared out every once in while 537 setInterval(function () { cache = {}; }, 10 * 1000); 538 539 var uniqueID = (function () { 540 var i = 0; 541 return function (el) { 542 return el.uniqueID || (el.uniqueID = i++); 543 }; 544 })(); 545 546 function setCache(elems, overflowing) { 547 for (var i = elems.length; i--;) 548 cache[uniqueID(elems[i])] = overflowing; 549 return overflowing; 550 } 551 552 function overflowingAncestor(el) { 553 var elems = []; 554 var rootScrollHeight = root.scrollHeight; 555 do { 556 var cached = cache[uniqueID(el)]; 557 if (cached) { 558 return setCache(elems, cached); 559 } 560 elems.push(el); 561 if (rootScrollHeight === el.scrollHeight) { 562 if (!isFrame || root.clientHeight + 10 < rootScrollHeight) { 563 return setCache(elems, document.body); // scrolling root in WebKit 564 } 565 } else if (el.clientHeight + 10 < el.scrollHeight) { 566 overflow = getComputedStyle(el, "").getPropertyValue("overflow-y"); 567 if (overflow === "scroll" || overflow === "auto") { 568 return setCache(elems, el); 569 } 570 } 571 } while (el = el.parentNode); 572 } 573 574 575 /*********************************************** 576 * HELPERS 577 ***********************************************/ 578 579 function addEvent(type, fn, bubble) { 580 window.addEventListener(type, fn, (bubble||false)); 581 } 582 583 function removeEvent(type, fn, bubble) { 584 window.removeEventListener(type, fn, (bubble||false)); 585 } 586 587 function isNodeName(el, tag) { 588 return (el.nodeName||"").toLowerCase() === tag.toLowerCase(); 589 } 590 591 function directionCheck(x, y) { 592 x = (x > 0) ? 1 : -1; 593 y = (y > 0) ? 1 : -1; 594 if (direction.x !== x || direction.y !== y) { 595 direction.x = x; 596 direction.y = y; 597 que = []; 598 lastScroll = 0; 599 } 600 } 601 602 var deltaBufferTimer; 603 604 function isTouchpad(deltaY) { 605 if (!deltaY) return; 606 deltaY = Math.abs(deltaY) 607 deltaBuffer.push(deltaY); 608 deltaBuffer.shift(); 609 clearTimeout(deltaBufferTimer); 610 var allEquals = (deltaBuffer[0] == deltaBuffer[1] && 611 deltaBuffer[1] == deltaBuffer[2]); 612 var allDivisable = (isDivisible(deltaBuffer[0], 120) && 613 isDivisible(deltaBuffer[1], 120) && 614 isDivisible(deltaBuffer[2], 120)); 615 return !(allEquals || allDivisable); 616 } 617 618 function isDivisible(n, divisor) { 619 return (Math.floor(n / divisor) == n / divisor); 620 } 621 622 var requestFrame = (function () { 623 return window.requestAnimationFrame || 624 window.webkitRequestAnimationFrame || 625 function (callback, element, delay) { 626 window.setTimeout(callback, delay || (1000/60)); 627 }; 628 })(); 629 630 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; 631 632 633 /*********************************************** 634 * PULSE 635 ***********************************************/ 636 637 /** 638 * Viscous fluid with a pulse for part and decay for the rest. 639 * - Applies a fixed force over an interval (a damped acceleration), and 640 * - Lets the exponential bleed away the velocity over a longer interval 641 * - Michael Herf, http://stereopsis.com/stopping/ 642 */ 643 function pulse_(x) { 644 var val, start, expx; 645 // test 646 x = x * options.pulseScale; 647 if (x < 1) { // acceleartion 648 val = x - (1 - Math.exp(-x)); 649 } else { // tail 650 // the previous animation ended here: 651 start = Math.exp(-1); 652 // simple viscous drag 653 x -= 1; 654 expx = 1 - Math.exp(-x); 655 val = start + (expx * (1 - start)); 656 }
657 return val * options.pulseNormalize; 658 } 659 660 function pulse(x) { 661 if (x >= 1) return 1; 662 if (x <= 0) return 0; 663 664 if (options.pulseNormalize == 1) { 665 options.pulseNormalize /= pulse_(1); 666 } 667 return pulse_(x); 668 } 669 670 addEvent("mousedown", mousedown); 671 addEvent("mousewheel", wheel); 672 addEvent("load", init); 673 674 } 675 676 }); 677})(jQuery); 678 679/* 680Plugin Name: waitForImages jQuery Plugin - v1.5.0 - 2013-07-20 681Written by: https://github.com/alexanderdickson/waitForImages 682 683*/ 684;(function ($) { 685 // Namespace all events. 686 var eventNamespace = 'waitForImages'; 687 688 // CSS properties which contain references to images. 689 $.waitForImages = { 690 hasImageProperties: ['backgroundImage', 'listStyleImage', 'borderImage', 'borderCornerImage', 'cursor'] 691 }; 692 693 // Custom selector to find `img` elements that have a valid `src` attribute and have not already loaded. 694 $.expr[':'].uncached = function (obj) { 695 // Ensure we are dealing with an `img` element with a valid `src` attribute. 696 if (!$(obj).is('img[src!=""]')) { 697 return false; 698 } 699 700 // Firefox's `complete` property will always be `true` even if the image has not been downloaded. 701 // Doing it this way works in Firefox. 702 var img = new Image(); 703 img.src = obj.src; 704 return !img.complete; 705 }; 706 707 $.fn.waitForImages = function (finishedCallback, eachCallback, waitForAll) { 708 709 var allImgsLength = 0; 710 var allImgsLoaded = 0; 711 712 // Handle options object. 713 if ($.isPlainObject(arguments[0])) { 714 waitForAll = arguments[0].waitForAll; 715 eachCallback = arguments[0].each; 716 // This must be last as arguments[0] 717 // is aliased with finishedCallback. 718 finishedCallback = arguments[0].finished; 719 } 720 721 // Handle missing callbacks. 722 finishedCallback = finishedCallback || $.noop; 723 eachCallback = eachCallback || $.noop; 724 725 // Convert waitForAll to Boolean 726 waitForAll = !! waitForAll; 727 728 // Ensure callbacks are functions. 729 if (!$.isFunction(finishedCallback) || !$.isFunction(eachCallback)) { 730 throw new TypeError('An invalid callback was supplied.'); 731 } 732 733 return this.each(function () { 734 // Build a list of all imgs, dependent on what images will be considered. 735 var obj = $(this); 736 var allImgs = []; 737 // CSS properties which may contain an image. 738 var hasImgProperties = $.waitForImages.hasImageProperties || []; 739 // To match `url()` references. 740 // Spec: http://www.w3.org/TR/CSS2/syndata.html#value-def-uri 741 var matchUrl = /url\(\s*(['"]?)(.*?)\1\s*\)/g; 742 743 if (waitForAll) { 744 745 // Get all elements (including the original), as any one of them could have a background image. 746 obj.find('*').addBack().each(function () { 747 var element = $(this); 748 749 // If an `img` element, add it. But keep iterating in case it has a background image too. 750 if (element.is('img:uncached')) { 751 allImgs.push({ 752 src: element.attr('src'), 753 element: element[0] 754 }); 755 } 756 757 $.each(hasImgProperties, function (i, property) { 758 var propertyValue = element.css(property); 759 var match; 760 761 // If it doesn't contain this property, skip. 762 if (!propertyValue) { 763 return true; 764 } 765 766 // Get all url() of this element. 767 while (match = matchUrl.exec(propertyValue)) { 768 allImgs.push({ 769 src: match[2], 770 element: element[0] 771 }); 772 } 773 }); 774 }); 775 } else { 776 // For images only, the task is simpler. 777 obj.find('img:uncached') 778 .each(function () { 779 allImgs.push({ 780 src: this.src, 781 element: this 782 }); 783 }); 784 } 785 786 allImgsLength = allImgs.length; 787 allImgsLoaded = 0; 788 789 // If no images found, don't bother. 790 if (allImgsLength === 0) { 791 finishedCallback.call(obj[0]); 792 } 793 794 $.each(allImgs, function (i, img) { 795 796 var image = new Image(); 797 798 // Handle the image loading and error with the same callback. 799 $(image).on('load.' + eventNamespace + ' error.' + eventNamespace, function (event) { 800 allImgsLoaded++; 801 802 // If an error occurred with loading the image, set the third argument accordingly. 803 eachCallback.call(img.element, allImgsLoaded, allImgsLength, event.type == 'load'); 804 805 if (allImgsLoaded == allImgsLength) { 806 finishedCallback.call(obj[0]); 807 return false; 808 } 809 810 }); 811 812 image.src = img.src; 813 }); 814 }); 815 }; 816}(jQuery)); 817 818/* 819Plugin Name: Count To 820Written by: Matt Huggins - https://github.com/mhuggins/jquery-countTo 821 822*/ 823(function ($) { 824 $.fn.countTo = function (options) { 825 options = options || {}; 826 827 return $(this).each(function () { 828 // set options for current element 829 var settings = $.extend({}, $.fn.countTo.defaults, { 830 from: $(this).data('from'), 831 to: $(this).data('to'), 832 speed: $(this).data('speed'), 833 refreshInterval: $(this).data('refresh-interval'), 834 decimals: $(this).data('decimals') 835 }, options); 836 837 // how many times to update the value, and how much to increment the value on each update 838 var loops = Math.ceil(settings.speed / settings.refreshInterval), 839 increment = (settings.to - settings.from) / loops; 840 841 // references & variables that will change with each update 842 var self = this, 843 $self = $(this), 844 loopCount = 0, 845 value = settings.from, 846 data = $self.data('countTo') || {}; 847 848 $self.data('countTo', data); 849 850 // if an existing interval can be found, clear it first 851 if (data.interval) { 852 clearInterval(data.interval); 853 } 854 data.interval = setInterval(updateTimer, settings.refreshInterval); 855 856 // initialize the element with the starting value 857 render(value); 858 859 function updateTimer() { 860 value += increment; 861 loopCount++; 862 863 render(value); 864
865 if (typeof(settings.onUpdate) == 'function') { 866 settings.onUpdate.call(self, value); 867 } 868 869 if (loopCount >= loops) { 870 // remove the interval 871 $self.removeData('countTo'); 872 clearInterval(data.interval); 873 value = settings.to; 874 875 if (typeof(settings.onComplete) == 'function') { 876 settings.onComplete.call(self, value); 877 } 878 } 879 } 880 881 function render(value) { 882 var formattedValue = settings.formatter.call(self, value, settings); 883 $self.html(formattedValue); 884 } 885 }); 886 }; 887 888 $.fn.countTo.defaults = { 889 from: 0, // the number the element should start at 890 to: 0, // the number the element should end at 891 speed: 1000, // how long it should take to count between the target numbers 892 refreshInterval: 100, // how often the element should be updated 893 decimals: 0, // the number of decimal places to show 894 formatter: formatter, // handler for formatting the value before rendering 895 onUpdate: null, // callback method for every time the element is updated 896 onComplete: null // callback method for when the element finishes updating 897 }; 898 899 function formatter(value, settings) { 900 return value.toFixed(settings.decimals); 901 } 902}(jQuery)); 903 904/* 905Plugin Name: afterResize.js 906Written by: https://github.com/mcshaman/afterResize.js 907Description: Simple jQuery plugin designed to emulate an 'after resize' event. 908 909*/ 910( function( $ ) { 911 "use strict"; 912 913 // Define default settings 914 var defaults = { 915 action: function() {}, 916 runOnLoad: false, 917 duration: 500 918 }; 919 920 // Define global variables 921 var settings = defaults, 922 running = false, 923 start; 924 925 var methods = {}; 926 927 // Initial plugin configuration 928 methods.init = function() { 929 930 // Allocate passed arguments to settings based on type 931 for( var i = 0; i <= arguments.length; i++ ) { 932 var arg = arguments[i]; 933 switch ( typeof arg ) { 934 case "function": 935 settings.action = arg; 936 break; 937 case "boolean": 938 settings.runOnLoad = arg; 939 break; 940 case "number": 941 settings.duration = arg; 942 break; 943 } 944 } 945 946 // Process each matching jQuery object 947 return this.each(function() { 948 949 if( settings.runOnLoad ) { settings.action(); } 950 951 $(this).resize( function() { 952 953 methods.timedAction.call( this ); 954 955 } ); 956 957 } ); 958 }; 959 960 methods.timedAction = function( code, millisec ) { 961 962 var doAction = function() { 963 var remaining = settings.duration; 964 965 if( running ) { 966 var elapse = new Date() - start; 967 remaining = settings.duration - elapse; 968 if( remaining <= 0 ) { 969 // Clear timeout and reset running variable 970 clearTimeout(running); 971 running = false; 972 // Perform user defined function 973 settings.action(); 974 975 return; 976 } 977 } 978 wait( remaining ); 979 }; 980 981 var wait = function( time ) { 982 running = setTimeout( doAction, time ); 983 }; 984 985 // Define new action starting time 986 start = new Date(); 987 988 // Define runtime settings if function is run directly 989 if( typeof millisec === 'number' ) { settings.duration = millisec; } 990 if( typeof code === 'function' ) { settings.action = code; } 991 992 // Only run timed loop if not already running 993 if( !running ) { doAction(); } 994 995 }; 996 997 998 $.fn.afterResize = function( method ) { 999 1000 if( methods[method] ) { 1001 return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ) ); 1002 } else { 1003 return methods.init.apply( this, arguments ); 1004 } 1005 1006 }; 1007 1008})(jQuery);
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.