Sha256: fbb94e5e62d8f13f39f71a42b72eec4aac96b56a95bb888de73a9136ff789131

Contents?: true

Size: 1.58 KB

Versions: 52

Compression:

Stored size: 1.58 KB

Contents

(function(d){d.fn.stupidtable=function(b){return this.each(function(){var a=d(this);b=b||{};b=d.extend({},d.fn.stupidtable.default_sort_fns,b);var n=function(a,b){for(var f=[],c=0,e=a.slice(0).sort(b),h=0;h<a.length;h++){for(c=d.inArray(a[h],e);-1!=d.inArray(c,f);)c++;f.push(c)}return f},q=function(a,b){for(var d=a.slice(0),c=0,e=0;e<b.length;e++)c=b[e],d[c]=a[e];return d};a.on("click","th",function(){var m=a.children("tbody").children("tr"),g=d(this),f=0,c=d.fn.stupidtable.dir;a.find("th").slice(0, g.index()).each(function(){var a=d(this).attr("colspan")||1;f+=parseInt(a,10)});var e=g.data("sort-default")||c.ASC;g.data("sort-dir")&&(e=g.data("sort-dir")===c.ASC?c.DESC:c.ASC);var h=g.data("sort")||null;null!==h&&(a.trigger("beforetablesort",{column:f,direction:e}),a.css("display"),setTimeout(function(){var l=[],p=b[h];m.each(function(a,b){var c=d(b).children().eq(f),e=c.data("sort-value"),c="undefined"!==typeof e?e:c.text();l.push(c)});var k;k=e==c.ASC?n(l,p):n(l,function(a,b){return-p(a,b)}); a.find("th").data("sort-dir",null).removeClass("sorting-desc sorting-asc");g.data("sort-dir",e).addClass("sorting-"+e);k=d(q(m,k));a.children("tbody").remove();a.append("<tbody />").append(k);a.trigger("aftertablesort",{column:f,direction:e});a.css("display")},10))})})};d.fn.stupidtable.dir={ASC:"asc",DESC:"desc"};d.fn.stupidtable.default_sort_fns={"int":function(b,a){return parseInt(b,10)-parseInt(a,10)},"float":function(b,a){return parseFloat(b)-parseFloat(a)},string:function(b,a){return b<a?-1: b>a?1:0},"string-ins":function(b,a){b=b.toLowerCase();a=a.toLowerCase();return b<a?-1:b>a?1:0}}})(jQuery);

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
wunderbar-1.0.28 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.27 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.26 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.25 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.24 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.23 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.21 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.20 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.19 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.18 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.17 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.16 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.15 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.14 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.13 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.12 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.11 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.10 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.9 lib/wunderbar/vendor/stupidtable.min.js
wunderbar-1.0.8 lib/wunderbar/vendor/stupidtable.min.js