From 08bc8ceae570fa7b0ce2d0b3f7807e6cbea6f702 Mon Sep 17 00:00:00 2001 From: Ozh Date: Tue, 19 Feb 2013 20:17:42 +0000 Subject: [PATCH] Table sorter: update script, fix broken stuff. See Issue 1286. git-svn-id: http://yourls.googlecode.com/svn/trunk@890 12232710-3e20-11de-b438-597f59cd7555 --- css/tablesorter.css | 31 +++++++++++++++++++++---------- images/bg.gif | Bin 64 -> 1124 bytes js/jquery.tablesorter.min.js | 20 +++++++++++++++----- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/css/tablesorter.css b/css/tablesorter.css index 43b1d98..e56e95c 100644 --- a/css/tablesorter.css +++ b/css/tablesorter.css @@ -16,15 +16,16 @@ table.tblSorter thead tr th, table.tblSorter tfoot tr th, table.tblSorter th.hea table.tblSorter tfoot tr th { background-color: #E3F3FF; } -table.tblSorter thead tr .header { +table.tblSorter thead tr .tablesorter-header { background-image: url('../images/bg.gif'); background-repeat: no-repeat; background-position: center right; cursor: pointer; padding-right:10px; } -table.tblSorter tbody tr:hover td { - background-color:#F3FAFD; +table.tblSorter thead tr .sorter-false { + background-image: none; + cursor:default; } table.tblSorter tbody td { color: #3D3D3D; @@ -32,20 +33,30 @@ table.tblSorter tbody td { background-color: #FFF; vertical-align: top; } -table.tblSorter tbody tr.even td { - +table.tblSorter tbody tr.normal-row td { + background: #F1F9FF; } -table.tblSorter tbody tr.odd td { +table.tblSorter tbody tr.alt-row td { } -table.tblSorter thead tr .headerSortUp { +table.tblSorter tbody tr.normal-row:hover td { + background-color:#F1FFF6; +} +table.tblSorter tbody tr.alt-row:hover td { + background-color:#F1FFF6; +} +table.tblSorter thead tr .tablesorter-headerDesc { background-image: url('../images/desc.gif'); + background-repeat: no-repeat; + background-position: center right; } -table.tblSorter thead tr .headerSortDown { +table.tblSorter thead tr .tablesorter-headerAsc { background-image: url('../images/asc.gif'); + background-repeat: no-repeat; + background-position: center right; } -table.tblSorter thead tr .headerSortDown, table.tblSorter thead tr .headerSortUp { - background-color: #88c0eb; +table.tblSorter thead tr .tablesorter-headerAsc, table.tblSorter thead tr .tablesorter-headerDesc { + background-color: #91C7F2; } table.tblSorter tfoot tr { background-color: #BCD9E8; diff --git a/images/bg.gif b/images/bg.gif index fac668fcf42af844a3af0a239fa638ddbc08443c..bf9446ba548a49cc3a849543fee963158506d9d5 100644 GIT binary patch literal 1124 zcmZ?wbhEHb6lLIKn8?JiV8Mdr%a{NE|DS<@LGeF#gl~X?OJYePkhZa}C`e4sPAySL zN=?tqvsHS(d%u!GW{Ry+xT&v!Z-H}aMy5wqQEG6NUr2IQcCuxPlD(aRO@&oOZb5Ep zNuokUZcbjYRfVlmVoH8esuhq864qBz04piUwpDTjNhpBqbj~kIRWQ{v&`mZlGgL4$ z(K9qLur#sMQ7|$vG|)FR(l;>IH8ij?HMcS_RDc2{plwAdX;wilZcw{`JX@uVl9B=| zef{$Ca=mh6z5JqdeM3u2OML?)eIp}XpbFjM%Dj@q3f;V7Wta&rsl~}fnFS@8`FRQ; z6BCp2OG|8(fG&l2A-4c-Y+kV**gJa3`MLTPi3R$GdIlgb!4&%X;#ZoR3s+rS5|oN? zFIIz#Ln;eW^@CE2^Gl18Q-R8rK~@!5ITxiSmgEx(xwAm%KD6=dz#jPkmR{`v0 zt4!Q(amHyLRBsAyx47Wcs}FRHJ}6?5A{r(HOg$hbJlO&{@Pwb52Tbinz+}z%|KHy~ zzkmJw@%`J^FP}es{P6zW+c&RYy?pWf+0!SFA3c0<|K8m@w{P9NasArWE0-@_ym0>9 z*)yk4ojh^;*wG`04;?(Pf8X9cyLau}v3=XtEt@xO+^~M#+BK_Jtz5Bu+0rG87cE>c zf8N|VvuDkmF@4(9DU&BnoY3Fb+tc0E+0owC+S1(A*ic_rTT@+CSy5hAT2fq8SdgEW zo0FZDnUS8Bnv$H9m=GTq8xtKB84(^98WJ277~t>c>*MX^>EZ6?>f-F==wNSWYh!I? zX<=?=YGP~z%u;%~I@(&A8tQ7QD#}WV3i5KYGSX6#65?W_BEmv~0{ncuJltHI9PDhY zEX+)dz_Q^d3y@@D&;gbc44|@ufk|>of5U0Xi;EcFd%CUOyQh0iWw1tHK&3_yBZD;n DDM5|* literal 64 zcmZ?wbhEHb6lLIKXkcJa);0M5|G(l-7DfgJMg|=QAOOiQFp2l{H=O3Yl~fU8)V1~= QTew|n!uOuePzDBT00piR0RR91 diff --git a/js/jquery.tablesorter.min.js b/js/jquery.tablesorter.min.js index 9aff216..bbeedfe 100644 --- a/js/jquery.tablesorter.min.js +++ b/js/jquery.tablesorter.min.js @@ -1,5 +1,11 @@ -/* jQuery Tablesorter */ -(function($){$.extend({tablesorter:new function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}var rows=table.tBodies[0].rows;if(table.tBodies[0].rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i1){arr=arr.concat(checkCellColSpan(table,headerArr,row++));}else{if(table.tHead.length==1||(cell.rowSpan>1||!r[row+1])){arr.push(cell);}}}return arr;};function checkHeaderMetadata(cell){if(($.meta)&&($(cell).data().sorter===false)){return true;};return false;}function checkHeaderOptions(table,i){if((table.config.headers[i])&&(table.config.headers[i].sorter===false)){return true;};return false;}function applyWidget(table){var c=table.config.widgets;var l=c.length;for(var i=0;i');$("tr:first td",table.tBodies[0]).each(function(){colgroup.append($('').css('width',$(this).width()));});$(table).prepend(colgroup);};}function updateHeaderSortCount(table,sortList){var c=table.config,l=sortList.length;for(var i=0;ib)?1:0));};function sortTextDesc(a,b){return((ba)?1:0));};function sortNumeric(a,b){return a-b;};function sortNumericDesc(a,b){return b-a;};function getCachedSortType(parsers,i){return parsers[i].type;};this.construct=function(settings){return this.each(function(){if(!this.tHead||!this.tBodies)return;var $this,$document,$headers,cache,config,shiftDown=0,sortOrder;this.config={};config=$.extend(this.config,$.tablesorter.defaults,settings);$this=$(this);$headers=buildHeaders(this);this.config.parsers=buildParserCache(this,$headers);cache=buildCache(this);var sortCSS=[config.cssDesc,config.cssAsc];fixColumnWidth(this);$headers.click(function(e){var totalRows=($this[0].tBodies[0]&&$this[0].tBodies[0].rows.length)||0;if(!this.sortDisabled&&totalRows>0){var $cell=$(this);var i=this.column;this.order=this.count++%2;if(!e[config.sortMultiSortKey]){config.sortList=[];if(config.sortForce!=null){var a=config.sortForce;for(var j=0;j0){$this.trigger("sorton",[config.sortList]);}applyWidget(this);});};this.addParser=function(parser){var l=parsers.length,a=true;for(var i=0;i thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:!1,headerList:[],empties:{},strings:{},parsers:[]};g.benchmark=v;g.construct=function(d){return this.each(function(){if(!this.tHead||0===this.tBodies.length||!0===this.hasInitialized)return this.config&&this.config.debug?e("stopping initialization! No thead, tbody or tablesorter has already been initialized"):"";var c=j(this),a=this,b,q,f,l="",u,n,k,C,x=j.metadata; a.hasInitialized=!1;a.config={};b=j.extend(!0,a.config,g.defaults,d);j.data(a,"tablesorter",b);b.debug&&j.data(a,"startoveralltimer",new Date);b.supportsTextContent="x"===j("x")[0].textContent;b.supportsDataObject=1.4<=parseFloat(j.fn.jquery);b.string={max:1,min:-1,"max+":1,"max-":-1,zero:0,none:0,"null":0,top:!0,bottom:!1};/tablesorter\-/.test(c.attr("class"))||(l=""!==b.theme?" tablesorter-"+b.theme:"");b.$table=c.addClass(b.tableClass+l);b.$tbodies=c.children("tbody:not(."+b.cssInfoBlock+ ")");var t=[],y={},Q=0,V=j(a).find("thead:eq(0), tfoot").children("tr"),E,L,z,A,R,D,M,W,X,H;for(E=0;E':"";t=j(a).find(w.selectorHeaders).each(function(a){B=j(this);N=w.headers[a];w.headerContent[a]=this.innerHTML;O=w.headerTemplate.replace(/\{content\}/g,this.innerHTML).replace(/\{icon\}/g,Y);w.onRenderTemplate&&(S=w.onRenderTemplate.apply(B,[a,O]))&&"string"===typeof S&&(O=S);this.innerHTML='
'+O+"
";w.onRenderHeader&&w.onRenderHeader.apply(B, [a]);this.column=y[this.parentNode.rowIndex+"-"+this.cellIndex];var b=g.getData(B,N,"sortInitialOrder")||w.sortInitialOrder;this.order=/^d/i.test(b)||1===b?[1,0,2]:[0,1,2];this.count=-1;"false"===g.getData(B,N,"sorter")?(this.sortDisabled=!0,B.addClass("sorter-false")):B.removeClass("sorter-false");this.lockedOrder=!1;J=g.getData(B,N,"lockedOrder")||!1;"undefined"!==typeof J&&!1!==J&&(this.order=this.lockedOrder=/^d/i.test(J)||1===J?[1,1,1]:[0,0,0]);B.addClass((this.sortDisabled?"sorter-false ":" ")+ w.cssHeader);w.headerList[a]=this;B.parent().addClass(w.cssHeaderRow)});a.config.debug&&(v("Built headers:",K),e(t));b.$headers=t;var T,P=a.config,U=j("");K=P.$table.find("colgroup");var Z=P.$table.width();j("tr:first td",a.tBodies[0]).each(function(){T=j("");P.widthFixed&&T.css("width",parseInt(1E3*(j(this).width()/Z),10)/10+"%");U.append(T)});K.length?K.html(U.html()):P.$table.prepend(U);b.parsers=h(a);b.delayInit||s(a);b.$headers.find("*").andSelf().filter(b.selectorSort).unbind("mousedown.tablesorter mouseup.tablesorter").bind("mousedown.tablesorter mouseup.tablesorter", function(d,e){var h=(this.tagName.match("TH|TD")?j(this):j(this).parents("th, td").filter(":last"))[0];if(1!==(d.which||d.button))return!1;if("mousedown"===d.type)return C=(new Date).getTime(),"INPUT"===d.target.tagName?"":!b.cancelSelection;if(!0!==e&&250<(new Date).getTime()-C)return!1;b.delayInit&&!b.cache&&s(a);if(!h.sortDisabled){c.trigger("sortStart",a);l=!d[b.sortMultiSortKey];h.count=d[b.sortResetKey]?2:(h.count+1)%(b.sortReset?3:2);b.sortRestart&&(q=h,b.$headers.each(function(){if(this!== q&&(l||!j(this).is("."+b.cssDesc+",."+b.cssAsc)))this.count=-1}));q=h.column;if(l){b.sortList=[];if(null!==b.sortForce){u=b.sortForce;for(f=0;fk&&(b.sortList.push([q,k]),1k&&(b.sortList.push([q,k]),1'), d=j.fn.detach?c.detach():c.remove();d=j(d).find("span.tablesorter-savemyplace");c.insertAfter(d);d.remove()};g.clearTableBody=function(d){d.config.$tbodies.empty()};g.destroy=function(d,c,a){if(d.hasInitialized){g.refreshWidgets(d,!0,!0);var b=j(d),e=d.config,f=b.find("thead:first"),l=f.find("tr."+e.cssHeaderRow).removeClass(e.cssHeaderRow),h=b.find("tfoot:first > tr").children("th, td");f.find("tr").not(l).remove();b.removeData("tablesorter").unbind("sortReset update updateCell addRows sorton appendCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave"); e.$headers.add(h).removeClass(e.cssHeader+" "+e.cssAsc+" "+e.cssDesc).removeAttr("data-column");l.find(e.selectorSort).unbind("mousedown.tablesorter mouseup.tablesorter");l.children().each(function(a){j(this).html(e.headerContent[a])});!1!==c&&b.removeClass(e.tableClass+" tablesorter-"+e.theme);d.hasInitialized=!1;"function"===typeof a&&a(d)}};g.regex=[/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, /^0x[0-9a-f]+$/i];g.sortText=function(d,c,a,b){if(c===a)return 0;var e=d.config,f=e.string[e.empties[b]||e.emptyTo],h=g.regex;if(""===c&&0!==f)return"boolean"===typeof f?f?-1:1:-f||-1;if(""===a&&0!==f)return"boolean"===typeof f?f?1:-1:f||1;if("function"===typeof e.textSorter)return e.textSorter(c,a,d,b);d=c.replace(h[0],"\\0$1\\0").replace(/\\0$/,"").replace(/^\\0/,"").split("\\0");b=a.replace(h[0],"\\0$1\\0").replace(/\\0$/,"").replace(/^\\0/,"").split("\\0");c=parseInt(c.match(h[2]),16)||1!==d.length&& c.match(h[1])&&Date.parse(c);if(a=parseInt(a.match(h[2]),16)||c&&a.match(h[1])&&Date.parse(a)||null){if(ca)return 1}e=Math.max(d.length,b.length);for(c=0;ch)return 1}return 0};g.sortTextDesc=function(d,c,a,b){if(c===a)return 0;var e=d.config,f=e.string[e.empties[b]||e.emptyTo];return""===c&& 0!==f?"boolean"===typeof f?f?-1:1:f||1:""===a&&0!==f?"boolean"===typeof f?f?1:-1:-f||-1:"function"===typeof e.textSorter?e.textSorter(a,c,d,b):g.sortText(d,a,c)};g.getTextValue=function(d,c,a){if(c){var b=d.length,e=c+a;for(c=0;cj.inArray(l[b].id,f)))h.debug&&e("Refeshing widgets: Removing "+l[b].id),l[b].hasOwnProperty("remove")&&l[b].remove(d,h,h.widgetOptions);!0!==a&&g.applyWidget(d,c)};g.getData=function(d,c,a){var b="";d=j(d); var e,f;if(!d.length)return"";e=j.metadata?d.metadata():!1;f=" "+(d.attr("class")||"");"undefined"!==typeof d.data(a)||"undefined"!==typeof d.data(a.toLowerCase())?b+=d.data(a)||d.data(a.toLowerCase()):e&&"undefined"!==typeof e[a]?b+=e[a]:c&&"undefined"!==typeof c[a]?b+=c[a]:" "!==f&&f.match(" "+a+"-")&&(b=f.match(RegExp(" "+a+"-(\\w+)"))[1]||"");return j.trim(b)};g.formatFloat=function(d,c){if("string"!==typeof d||""===d)return d;var a;d=(c&&c.config?!1!==c.config.usNumberFormat:"undefined"!==typeof c? c:1)?d.replace(/,/g,""):d.replace(/[\s|\.]/g,"").replace(/,/g,".");/^\s*\([.\d]+\)/.test(d)&&(d=d.replace(/^\s*\(/,"-").replace(/\)/,""));a=parseFloat(d);return isNaN(a)?j.trim(d):a};g.isDigit=function(d){return isNaN(d)?/^[\-+(]?\d+[)]?$/.test(d.toString().replace(/[,.'"\s]/g,"")):!0}}});var h=j.tablesorter;j.fn.extend({tablesorter:h.construct});h.addParser({id:"text",is:function(){return!0},format:function(e,v){var p=v.config;e=j.trim(p.ignoreCase?e.toLocaleLowerCase():e);return p.sortLocaleCompare? h.replaceAccents(e):e},type:"text"});h.addParser({id:"currency",is:function(e){return/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/.test(e)},format:function(e,j){return h.formatFloat(e.replace(/[^\w,. \-()]/g,""),j)},type:"numeric"});h.addParser({id:"ipAddress",is:function(e){return/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(e)},format:function(e,j){var p,r=e.split("."),s="",m=r.length;for(p=0;p