vendor: 3,572 bytes, lines 1-121
1/* 2 * jQuery Numerator Plugin 0.2.0 3 * https://github.com/garethdn/jquery-numerator 4 * 5 * Copyright 2013, Gareth Nolan 6 * http://ie.linkedin.com/in/garethnolan/ 7 8 * Based on jQuery Boilerplate by Zeno Rocha with the help of Addy Osmani 9 * http://jqueryboilerplate.com 10 * 11 * Licensed under the MIT license: 12 * http://www.opensource.org/licenses/MIT 13 */ 14 15;(function ( $, window, document, undefined ) { 16 17 var pluginName = "numerator", 18 defaults = { 19 easing: 'swing', 20 duration: 500, 21 delimiter: undefined, 22 rounding: 0, 23 toValue: undefined, 24 fromValue: undefined, 25 queue: false, 26 onStart: function(){}, 27 onStep: function(){}, 28 onProgress: function(){}, 29 onComplete: function(){} 30 }; 31 32 function Plugin ( element, options ) { 33 this.element = element; 34 this.settings = $.extend( {}, defaults, options ); 35 this._defaults = defaults; 36 this._name = pluginName; 37 this.init(); 38 } 39 40 Plugin.prototype = { 41 init: function () { 42 this.parseElement(); 43 this.setValue(); 44 }, 45 46 parseElement: function () { 47 var elText = $(this.element).text().trim(); 48 49 this.settings.fromValue = this.format(elText); 50 }, 51 52 setValue: function() { 53 var self = this; 54 55 $({value: self.settings.fromValue}).animate({value: self.settings.toValue}, { 56 57 duration: parseInt(self.settings.duration), 58 59 easing: self.settings.easing, 60 61 start: self.settings.onStart, 62 63 step: function(now, fx) { 64 $(self.element).text(self.format(now)); 65 // accepts two params - (now, fx) 66 self.settings.onStep(now, fx); 67 }, 68 69 // accepts three params - (animation object, progress ratio, time remaining(ms)) 70 progress: self.settings.onProgress, 71 72 complete: self.settings.onComplete 73 }); 74 }, 75 76 format: function(value){ 77 var self = this; 78 79 if ( parseInt(this.settings.rounding ) < 1) { 80 value = parseInt(value); 81 } else { 82 value = parseFloat(value).toFixed( parseInt(this.settings.rounding) ); 83 } 84 85 if (self.settings.delimiter) { 86 return this.delimit(value) 87 } else { 88 return value; 89 } 90 }, 91 92 delimit: function(value){ 93 var self = this; 94 95 value = value.toString(); 96 97 if (self.settings.rounding && parseInt(self.settings.rounding) > 0) { 98 var decimals = value.substring( (value.length - (self.settings.rounding + 1)), value.length ), 99 wholeValue = value.substring( 0, (value.length - (self.settings.rounding + 1))); 100 101 return self.addCommas(wholeValue) + decimals; 102 } else { 103 return self.addCommas(value); 104 } 105 }, 106 107 addCommas: function(value){ 108 return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, this.settings.delimiter); 109 } 110 }; 111 112 $.fn[ pluginName ] = function ( options ) { 113 return this.each(function() { 114 if ( $.data( this, "plugin_" + pluginName ) ) { 115 $.data(this, 'plugin_' + pluginName, null); 116 } 117 $.data( this, "plugin_" + pluginName, new Plugin( this, options ) ); 118 }); 119 }; 120 121})( jQuery, window, document );
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.