Skip to content
Browse files

Minified the changes using uglifyjs

  • Loading branch information...
1 parent 6fa9199 commit bf1d4eeafc2724e1f252acd11fcc5046477ea35d @jasonrhodes committed Oct 3, 2012
Showing with 1 addition and 6 deletions.
  1. +1 −6 jquery.tablesort.min.js
View
7 jquery.tablesort.min.js
@@ -2,9 +2,4 @@
A simple, lightweight jQuery plugin for creating sortable tables.
https://github.com/kylefox/jquery-tablesort
Version 0.0.1
-*/
-$(function(){var $=window.jQuery;function sortValueForCell(th,td,sorter){if(th.data().sortBy){var sortBy=th.data().sortBy;return typeof sortBy==="function"?sortBy(th,td,sorter):sortBy}if(td.data().sortValue)return td.data().sortValue;else return td.text()}$.tablesort=function($table,settings){var self=this;this.$table=$table;this.settings=$.extend({},$.tablesort.defaults,settings);this.$table.find("thead th").bind("click.tablesort",function(){self.sort($(this))});this.index=null;this.$th=null;this.direction=
-null};$.tablesort.prototype={sort:function(th,direction){var start=new Date,self=this,table=this.$table,rows=table.find("tbody tr"),aRow,bRow,aIndex,bIndex,cache=[];if(rows.length===0)return;self.$table.find("thead th").removeClass(self.settings.asc+" "+self.settings.desc);this.index=th.index();this.$th=th;if(direction!=="asc"&&direction!=="desc")this.direction=this.direction==="asc"?"desc":"asc";else this.direction=direction;direction=this.direction=="asc"?1:-1;self.$table.trigger("tablesort:start",
-[self]);self.log("Sorting by "+this.index+" "+this.direction);rows.sort(function(a,b){aRow=$(a);bRow=$(b);aIndex=aRow.index();bIndex=bRow.index();if(cache[aIndex])a=cache[aIndex];else{a=sortValueForCell(th,self.cellToSort(a),self);cache[aIndex]=a}if(cache[bIndex])b=cache[bIndex];else{b=sortValueForCell(th,self.cellToSort(b),self);cache[bIndex]=b}if(a>b)return 1*direction;else if(a<b)return-1*direction;else return 0});rows.each(function(i,tr){table.append(tr)});th.addClass(self.settings[self.direction]);
-self.log("Sort finished in "+((new Date).getTime()-start.getTime())+"ms");self.$table.trigger("tablesort:complete",[self])},cellToSort:function(row){return $($(row).find("td").get(this.index))},log:function(msg){if(($.tablesort.DEBUG||this.settings.debug)&&console&&console.log)console.log("[tablesort] "+msg)},destroy:function(){this.$table.find("thead th").unbind("click.tablesort");this.$table.data("tablesort",null);return null}};$.tablesort.DEBUG=false;$.tablesort.defaults={debug:$.tablesort.DEBUG,
-asc:"sorted ascending",desc:"sorted descending"};$.fn.tablesort=function(settings){var table,sortable,previous;return this.each(function(){table=$(this);previous=table.data("tablesort");if(previous)previous.destroy();table.data("tablesort",new $.tablesort(table,settings))})}});
+*/$(function(){function t(e,t,n){if(e.data().sortBy){var r=e.data().sortBy;return typeof r=="function"?r(e,t,n):r}return t.data().sortValue?t.data().sortValue:t.text()}var e=window.jQuery;e.tablesort=function(t,n){var r=this;this.$table=t,this.$thead=this.$table.find("thead"),this.settings=e.extend({},e.tablesort.defaults,n),this.$table.find("th").bind("click.tablesort",function(){r.sort(e(this))}),this.index=null,this.$th=null,this.direction=null},e.tablesort.prototype={sort:function(n,r){var i=new Date,s=this,o=this.$table,u=this.$thead.length>0?o.find("tbody tr"):o.find("tr").has("td"),a,f,l,c,h=[];if(u.length===0)return;s.$table.find("th").removeClass(s.settings.asc+" "+s.settings.desc),this.index=n.index(),this.$th=n,r!=="asc"&&r!=="desc"?this.direction=this.direction==="asc"?"desc":"asc":this.direction=r,r=this.direction=="asc"?1:-1,s.$table.trigger("tablesort:start",[s]),s.log("Sorting by "+this.index+" "+this.direction),u.sort(function(i,o){return a=e(i),f=e(o),l=a.index(),c=f.index(),h[l]?i=h[l]:(i=t(n,s.cellToSort(i),s),h[l]=i),h[c]?o=h[c]:(o=t(n,s.cellToSort(o),s),h[c]=o),i>o?1*r:i<o?-1*r:0}),u.each(function(e,t){o.append(t)}),n.addClass(s.settings[s.direction]),s.log("Sort finished in "+((new Date).getTime()-i.getTime())+"ms"),s.$table.trigger("tablesort:complete",[s])},cellToSort:function(t){return e(e(t).find("td").get(this.index))},log:function(t){(e.tablesort.DEBUG||this.settings.debug)&&console&&console.log&&console.log("[tablesort] "+t)},destroy:function(){return this.$table.find("th").unbind("click.tablesort"),this.$table.data("tablesort",null),null}},e.tablesort.DEBUG=!1,e.tablesort.defaults={debug:e.tablesort.DEBUG,asc:"sorted ascending",desc:"sorted descending"},e.fn.tablesort=function(t){var n,r,i;return this.each(function(){n=e(this),i=n.data("tablesort"),i&&i.destroy(),n.data("tablesort",new e.tablesort(n,t))})}});

0 comments on commit bf1d4ee

Please sign in to comment.
Something went wrong with that request. Please try again.