From 2a6a1c63cb21015009fe4fd13f62cdac64e1fe36 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 23 May 2013 17:44:45 +0200 Subject: upload_history: Allow column sorting (jquery.tablesorter) Signed-off-by: Florian Pritz --- data/css/style.css | 24 ++++++++++++ data/img/asc.gif | Bin 0 -> 54 bytes data/img/bg.gif | Bin 0 -> 64 bytes data/img/desc.gif | Bin 0 -> 54 bytes data/js/jquery.tablesorter.min.js | 4 ++ data/js/script.js | 77 +++++++++++++++++++++++++++++++++++++- 6 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 data/img/asc.gif create mode 100644 data/img/bg.gif create mode 100644 data/img/desc.gif create mode 100644 data/js/jquery.tablesorter.min.js (limited to 'data') diff --git a/data/css/style.css b/data/css/style.css index 625ab7a06..1808836d8 100644 --- a/data/css/style.css +++ b/data/css/style.css @@ -285,3 +285,27 @@ code, pre, textarea { margin: 0 auto 0 0; color: #999; } + +/* tables */ +table.tablesorter thead tr th, table.tablesorter tfoot tr th { + background-color: #e6EEEE; +} +table.tablesorter thead tr .header { + background-image: url(../img/bg.gif); + background-repeat: no-repeat; + background-position: center right; + cursor: pointer; +} +table.tablesorter tbody td { + color: #3D3D3D; + vertical-align: top; +} +table.tablesorter thead tr .headerSortUp { + background-image: url(../img/asc.gif); +} +table.tablesorter thead tr .headerSortDown { + background-image: url(../img/desc.gif); +} +table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp { + background-color: #8dbdd8; +} diff --git a/data/img/asc.gif b/data/img/asc.gif new file mode 100644 index 000000000..74157867f Binary files /dev/null and b/data/img/asc.gif differ diff --git a/data/img/bg.gif b/data/img/bg.gif new file mode 100644 index 000000000..fac668fcf Binary files /dev/null and b/data/img/bg.gif differ diff --git a/data/img/desc.gif b/data/img/desc.gif new file mode 100644 index 000000000..3b30b3c58 Binary files /dev/null and b/data/img/desc.gif differ diff --git a/data/js/jquery.tablesorter.min.js b/data/js/jquery.tablesorter.min.js new file mode 100644 index 000000000..b8605df1e --- /dev/null +++ b/data/js/jquery.tablesorter.min.js @@ -0,0 +1,4 @@ + +(function($){$.extend({tablesorter:new +function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',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="";}if(table.tBodies.length==0)return;var rows=table.tBodies[0].rows;if(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(($.metadata)&&($(cell).metadata().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 checkHeaderOptionsSortingLocked(table,i){if((table.config.headers[i])&&(table.config.headers[i].lockedOrder))return table.config.headers[i].lockedOrder;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;i b["+i+"]) ? 1 : 0));";};function makeSortTextDesc(i){return"((b["+i+"] < a["+i+"]) ? -1 : ((b["+i+"] > a["+i+"]) ? 1 : 0));";};function makeSortNumeric(i){return"a["+i+"]-b["+i+"];";};function makeSortNumericDesc(i){return"b["+i+"]-a["+i+"];";};function sortText(a,b){if(table.config.sortLocaleCompare)return a.localeCompare(b);return((ab)?1:0));};function sortTextDesc(a,b){if(table.config.sortLocaleCompare)return b.localeCompare(a);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);$.data(this,"tablesorter",config);$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){$this.trigger("sortStart");var $cell=$(this);var i=this.column;this.order=this.count++%2;if(this.lockedOrder)this.order=this.lockedOrder;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