1/* 2 * jQuery.appear 3 * http://code.google.com/p/jquery-appear/ 4 * 5 * Copyright (c) 2009 Michael Hixson 6 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) 7*/ 8(function($){$.fn.appear=function(f,o){var s=$.extend({one:true},o);return this.each(function(){var t=$(this);t.appeared=false;if(!f){t.trigger('appear',s.data);return;}var w=$(window);var c=function(){if(!t.is(':visible')){t.appeared=false;return;}var a=w.scrollLeft();var b=w.scrollTop();var o=t.offset();var x=o.left;var y=o.top;if(y+t.height()>=b&&y<=b+w.height()&&x+t.width()>=a&&x<=a+w.width()){if(!t.appeared)t.trigger('appear',s.data);}else{t.appeared=false;}};var m=function(){t.appeared=true;if(s.one){w.unbind('scroll',c);var i=$.inArray(c,$.fn.appear.checks);if(i>=0)$.fn.appear.checks.splice(i,1);}f.apply(this,arguments);};if(s.one)t.one('appear',s.data,m);else t.bind('appear',s.data,m);w.scroll(c);$.fn.appear.checks.push(c);(c)();});};$.extend($.fn.appear,{checks:[],timeout:null,checkAll:function(){var l=$.fn.appear.checks.length;if(l>0)while(l--)($.fn.appear.checks[l])();},run:function(){if($.fn.appear.timeout)clearTimeout($.fn.appear.timeout);$.fn.appear.timeout=setTimeout($.fn.appear.checkAll,20);}});$.each(['append','prepend','after','before','attr','removeAttr','addClass','removeClass','toggleClass','remove','css','show','hide'],function(i,n){var u=$.fn[n];if(u){$.fn[n]=function(){var r=u.apply(this,arguments);$.fn.appear.run();return r;}}});})(jQuery); 9 10(function ($) { 11 $.fn.countTo = function (options) { 12 options = options || {}; 13 14 return $(this).each(function () { 15 // set options for current element 16 var settings = $.extend({}, $.fn.countTo.defaults, { 17 from: $(this).data('from'), 18 to: $(this).data('to'), 19 speed: $(this).data('speed'), 20 refreshInterval: $(this).data('refresh-interval'), 21 decimals: $(this).data('decimals'), 22 comma: $(this).data('comma') 23 }, options); 24 25 // how many times to update the value, and how much to increment the value on each update 26 var loops = Math.ceil(settings.speed / settings.refreshInterval), 27 increment = (settings.to - settings.from) / loops; 28 29 // references & variables that will change with each update 30 var self = this, 31 $self = $(this), 32 loopCount = 0, 33 value = settings.from, 34 data = $self.data('countTo') || {}; 35 36 $self.data('countTo', data); 37 38 // if an existing interval can be found, clear it first 39 if (data.interval) { 40 clearInterval(data.interval); 41 } 42 data.interval = setInterval(updateTimer, settings.refreshInterval); 43 44 // initialize the element with the starting value 45 render(value); 46 47 function updateTimer() { 48 value += increment; 49 loopCount++; 50 51 render(value); 52
53 if (typeof(settings.onUpdate) == 'function') { 54 settings.onUpdate.call(self, value); 55 } 56 57 if (loopCount >= loops) { 58 // remove the interval 59 $self.removeData('countTo'); 60 clearInterval(data.interval); 61 value = settings.to; 62 63 if (typeof(settings.onComplete) == 'function') { 64 settings.onComplete.call(self, value); 65 } 66 } 67 } 68 69 function render(value) { 70 var formattedValue = settings.formatter.call(self, value, settings); 71 $self.text(formattedValue); 72 } 73 }); 74 }; 75 76 $.fn.countTo.defaults = { 77 from: 0, // the number the element should start at 78 to: 0, // the number the element should end at 79 speed: 1000, // how long it should take to count between the target numbers 80 refreshInterval: 100, // how often the element should be updated 81 decimals: 0, // the number of decimal places to show 82 formatter: formatter, // handler for formatting the value before rendering 83 onUpdate: null, // callback method for every time the element is updated 84 onComplete: null // callback method for when the element finishes updating 85 }; 86 87 function formatter(value, settings) { 88 89 var count_val = value.toFixed(settings.decimals); 90 91 if(settings.comma){ 92 count_val = count_val.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"); 93 } 94 95 return count_val; 96 } 97}(jQuery)); 98
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.