jquery.tinysort.js (1150B)
1 /** 2 * jQuery plugin wrapper for TinySort 3 * Does not use the first argument in tinysort.js since that is handled internally by the jQuery selector. 4 * Sub-selections (option.selector) do not use the jQuery selector syntax but regular CSS3 selector syntax. 5 * @summary jQuery plugin wrapper for TinySort 6 * @version 2.3.6 7 * @requires tinysort 8 * @license MIT/GPL 9 * @author Ron Valstar (http://www.sjeiti.com/) 10 * @copyright Ron Valstar <ron@ronvalstar.nl> 11 */ 12 (function (factory) { 13 'use strict'; 14 if (typeof define==='function'&&define.amd) { 15 define(['jquery','tinysort'],factory); 16 } else if (jQuery && !jQuery.fn.tsort) { 17 factory(jQuery,tinysort); 18 } 19 }(function ($,tinysort) { 20 'use strict'; 21 $.tinysort = { defaults: tinysort.defaults }; 22 $.fn.extend({ 23 tinysort: function() { 24 var aArg = Array.prototype.slice.call(arguments) 25 ,aSorted,iSorted; 26 aArg.unshift(this); 27 aSorted = tinysort.apply(null,aArg); 28 iSorted = aSorted.length; 29 for (var i=0,l=this.length;i<l;i++) { 30 if (i<iSorted) this[i] = aSorted[i]; 31 else delete this[i]; 32 } 33 this.length = iSorted; 34 return this; 35 } 36 }); 37 $.fn.tsort = $.fn.tinysort; 38 }));