+++ /dev/null
-/*\r
- * \r
- * TableSorter 2.0 - Client-side table sorting with ease!\r
- * Version 2.0\r
- * @requires jQuery v1.1.3\r
- * \r
- * Copyright (c) 2007 Christian Bach\r
- * Examples and docs at: http://tablesorter.com\r
- * Dual licensed under the MIT and GPL licenses:\r
- * http://www.opensource.org/licenses/mit-license.php\r
- * http://www.gnu.org/licenses/gpl.html\r
- * \r
- */\r
-/**\r
- *\r
- * @description Create a sortable table with multi-column sorting capabilitys\r
- * \r
- * @example $('#table').tablesorter();\r
- * @desc Create a simple tablesorter interface.\r
- *\r
- * @example $('#table').tablesorter({ sortList:[[0,0],[1,0]] });\r
- * @desc Create a tablesorter interface and sort on the first and secound column in ascending order.\r
- * \r
- * @example $('#table').tablesorter({ headers: { 0: { sorter: false}, 1: {sorter: false} } });\r
- * @desc Create a tablesorter interface and disableing the first and secound column headers.\r
- * \r
- * @example $('#table').tablesorter({ 0: {sorter:"integer"}, 1: {sorter:"currency"} });\r
- * @desc Create a tablesorter interface and set a column parser for the first and secound column.\r
- * \r
- * \r
- * @param Object settings An object literal containing key/value pairs to provide optional settings.\r
- * \r
- * @option String cssHeader (optional) A string of the class name to be appended to sortable tr elements in the thead of the table. \r
- * Default value: "header"\r
- * \r
- * @option String cssAsc (optional) A string of the class name to be appended to sortable tr elements in the thead on a ascending sort. \r
- * Default value: "headerSortUp"\r
- * \r
- * @option String cssDesc (optional) A string of the class name to be appended to sortable tr elements in the thead on a descending sort. \r
- * Default value: "headerSortDown"\r
- * \r
- * @option String sortInitialOrder (optional) A string of the inital sorting order can be asc or desc. \r
- * Default value: "asc"\r
- * \r
- * @option String sortMultisortKey (optional) A string of the multi-column sort key. \r
- * Default value: "shiftKey"\r
- * \r
- * @option String textExtraction (optional) A string of the text-extraction method to use. \r
- * For complex html structures inside td cell set this option to "complex", \r
- * on large tables the complex option can be slow. \r
- * Default value: "simple"\r
- * \r
- * @option Object headers (optional) An array containing the forces sorting rules. \r
- * This option let's you specify a default sorting rule. \r
- * Default value: null\r
- * \r
- * @option Array sortList (optional) An array containing the forces sorting rules. \r
- * This option let's you specify a default sorting rule. \r
- * Default value: null\r
- * \r
- * @option Array sortForce (optional) An array containing the forces sorting rules. \r
- * This option let's you specify a default sorting rule. \r
- * Default value: null\r
- * \r
- * \r
- * @option Boolean widthFixed (optional) Boolean flag indicating if tablesorter should apply fixed widths to the table columns.\r
- * This is usefull when using the pager companion plugin.\r
- * This options requires the dimension jquery plugin.\r
- * Default value: false\r
- *\r
- * @option Boolean cancelSelection (optional) Boolean flag indicating if tablesorter should cancel selection of the table headers text.\r
- * Default value: true\r
- * \r
- * @type jQuery\r
- *\r
- * @name tablesorter\r
- * \r
- * @cat Plugins/Tablesorter\r
- * \r
- * @author Christian Bach/christian.bach@polyester.se\r
- */\r
-\r
-(function($) {\r
- $.extend({\r
- tablesorter: new function() {\r
- \r
- var parsers = [], widgets = [];\r
- \r
- this.defaults = {\r
- cssHeader: "header",\r
- cssAsc: "headerSortUp",\r
- cssDesc: "headerSortDown",\r
- sortInitialOrder: "asc",\r
- sortMultiSortKey: "shiftKey",\r
- sortForce: null,\r
- textExtraction: "simple",\r
- parsers: {}, \r
- widgets: [], \r
- widgetZebra: {css: ["even","odd"]},\r
- headers: {},\r
- widthFixed: false,\r
- cancelSelection: true,\r
- sortList: [],\r
- headerList: [],\r
- dateFormat: "us",\r
- debug: false\r
- };\r
- \r
- /* debuging utils */\r
- function benchmark(label,stamp) {\r
- log(label + "," + (new Date().getTime() - stamp.getTime()) + "ms");\r
- }\r
- \r
- function log(s) {\r
- if (typeof console != "undefined" && typeof console.debug != "undefined") {\r
- console.log(s);\r
- } else {\r
- alert(s);\r
- }
- }\r
- \r
- /* parsers utils */\r
- function buildParserCache(table,$headers) {\r
- \r
- if(table.config.debug) { var parsersDebug = ""; }\r
- \r
- var list = [], cells = table.tBodies[0].rows[0].cells, l = cells.length;\r
- \r
- for (var i=0;i < l; i++) {\r
- var p = false;\r
- \r
- if($.meta && ($($headers[i]).data() && $($headers[i]).data().sorter) ) {\r
- \r
- p = getParserById($($headers[i]).data().sorter); \r
- \r
- } else if((table.config.headers[i] && table.config.headers[i].sorter)) {\r
-\r
- p = getParserById(table.config.headers[i].sorter);\r
- }\r
- if(!p) {\r
- p = detectParserForColumn(table.config,cells[i]);\r
- }\r
-\r
- if(table.config.debug) { parsersDebug += "column:" + i + " parser:" +p.id + "\n"; }\r
-\r
- list.push(p);\r
- }\r
-\r
- if(table.config.debug) { log(parsersDebug); }\r
-\r
- return list;\r
- };\r
- \r
- function detectParserForColumn(config,node) {\r
- var l = parsers.length;\r
- for(var i=1; i < l; i++) {\r
- if(parsers[i].is($.trim(getElementText(config,node)))) {\r
- return parsers[i];\r
- }\r
- }\r
- \r
- // 0 is always the generic parser (text)\r
- return parsers[0];\r
- }\r
- \r
- function getParserById(name) {\r
- var l = parsers.length;\r
- for(var i=0; i < l; i++) {\r
- if(parsers[i].id.toLowerCase() == name.toLowerCase()) { \r
- return parsers[i];\r
- }\r
- }\r
- return false;\r
- }\r
- \r
- /* utils */\r
- function buildCache(table) {\r
- \r
- if(table.config.debug) { var cacheTime = new Date(); }\r
- \r
- var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0,\r
- totalCells = table.tBodies[0].rows[0].cells.length,\r
- parsers = table.config.parsers, \r
- cache = {row: [], normalized: []};\r
- \r
- for (var i=0;i < totalRows; ++i) {\r
- \r
- /** Add the table data to main data array */\r
- var c = table.tBodies[0].rows[i], cols = [];\r
- \r
- cache.row.push($(c));\r
- \r
- for(var j=0; j < totalCells; ++j) {\r
- cols.push(parsers[j].format(getElementText(table.config,c.cells[j]),table,c.cells[j])); \r
- }\r
- \r
- cols.push(i); // add position for rowCache\r
- cache.normalized.push(cols);\r
- cols = null;\r
- };\r
- \r
- if(table.config.debug) { benchmark("Building cache for " + totalRows + " rows:", cacheTime); }\r
- \r
- return cache;\r
- };\r
- \r
- function getElementText(config,node) {\r
- \r
- if(!node) return "";\r
- \r
- var t = "";\r
- \r
- \r
- if(typeof(config.textExtraction) == "function") {\r
- t = config.textExtraction(node);\r
- } else if(config.textExtraction == "complex") { \r
- t = $(node).text();\r
- } else {\r
- if(node.childNodes[0] && node.childNodes[0].hasChildNodes()) {\r
- t = node.childNodes[0].innerHTML;\r
- } else {\r
- t = node.innerHTML;\r
- }\r
- }\r
- return t;\r
- }\r
- \r
- function appendToTable(table,cache) {\r
- \r
- if(table.config.debug) {var appendTime = new Date()}\r
- \r
- var c = cache, \r
- r = c.row, \r
- n= c.normalized, \r
- totalRows = n.length, \r
- checkCell = (n[0].length-1), \r
- tableBody = $("tbody:first",table).empty();\r
- rows = [];\r
- \r
- for (var i=0;i < totalRows; i++) {\r
- rows.push(r[n[i][checkCell]]);\r
- if(table.config.appender == null) {\r
- tableBody.append(r[n[i][checkCell]]);\r
- }\r
- } \r
-\r
- if(table.config.appender != null) {\r
- table.config.appender(table,rows); \r
- }\r
- \r
- rows = null;\r
- \r
- //apply table widgets\r
- applyWidget(table);\r
- \r
- if(table.config.debug) { benchmark("Rebuilt table:", appendTime); }\r
- \r
- };\r
- \r
- function buildHeaders(table) {\r
- \r
- if(table.config.debug) { var time = new Date(); }\r
- \r
- var meta = ($.meta) ? true : false, tableHeadersRows = [];\r
- \r
- for(var i = 0; i < table.tHead.rows.length; i++) { tableHeadersRows[i]=0; };\r
- \r
- $tableHeaders = $(checkCellColSpan(table, tableHeadersRows, 0,table.tHead.rows[0].cells.length));\r
- \r
- $tableHeaders.each(function(index) {\r
- \r
- this.count = 0;\r
- this.column = index;\r
- this.order = formatSortingOrder(table.config.sortInitialOrder);\r
- \r
- if(checkHeaderMetadata(this) || checkHeaderOptions(table,index)) this.sortDisabled = true;\r
- \r
- if(!this.sortDisabled) {\r
- $(this).addClass(table.config.cssHeader);\r
- }\r
- \r
- // add cell to headerList\r
- table.config.headerList[index]= this;\r
- });\r
- \r
- if(table.config.debug) { benchmark("Built headers:", time); log($tableHeaders); }\r
- \r
- return $tableHeaders;\r
-
- };\r
- \r
- function checkCellColSpan(table, headerArr, row) {\r
- var arr = [], r = table.tHead.rows, c = r[row].cells;\r
- \r
- for(var i=headerArr[row]; i < c.length; i++) {\r
- var cell = c[i];\r
- \r
- if ( cell.colSpan > 1) { \r
- arr = arr.concat(checkCellColSpan(table, headerArr,row+cell.rowSpan));\r
- } else {\r
- if(table.tHead.length == 1 || (cell.rowSpan > 1 || !r[row+1])) {\r
- arr.push(cell);\r
- }\r
- headerArr[row] = (i+row);\r
- }\r
- }\r
- return arr;\r
- };\r
- \r
- function checkHeaderMetadata(cell) {\r
- if(($.meta) && ($(cell).data().sorter === false)) { return true; };\r
- return false;\r
- }\r
- \r
- function checkHeaderOptions(table,i) { \r
- if((table.config.headers[i]) && (table.config.headers[i].sorter === false)) { return true; };\r
- return false;\r
- }\r
- \r
- function applyWidget(table) {\r
- var c = table.config.widgets;\r
- var l = c.length;\r
- for(var i=0; i < l; i++) {\r
- \r
- getWidgetById(c[i]).format(table);\r
- }\r
- \r
- }\r
- \r
- function getWidgetById(name) {\r
- var l = widgets.length;\r
- for(var i=0; i < l; i++) {\r
- if(widgets[i].id.toLowerCase() == name.toLowerCase() ) {\r
- return widgets[i]; \r
- }\r
- }\r
- };\r
- \r
- function formatSortingOrder(v) {\r
- \r
- if(typeof(v) != "Number") {\r
- i = (v.toLowerCase() == "desc") ? 1 : 0;
- } else {\r
- i = (v == (0 || 1)) ? v : 0;
- }\r
- return i;
- }\r
- \r
- function isValueInArray(v, a) {\r
- var l = a.length;\r
- for(var i=0; i < l; i++) {\r
- if(a[i][0] == v) {\r
- return true;
- }
- }\r
- return false;
- }\r
- \r
- function setHeadersCss(table,$headers, list, css) {\r
- // remove all header information\r
- $headers.removeClass(css[0]).removeClass(css[1]);\r
- \r
- var h = [];\r
- $headers.each(function(offset) {\r
- if(!this.sortDisabled) {\r
- h[this.column] = $(this); \r
- }\r
- });\r
-\r
- var l = list.length; \r
- for(var i=0; i < l; i++) {\r
- h[list[i][0]].addClass(css[list[i][1]]);\r
- }\r
- }\r
- \r
- function fixColumnWidth(table,$headers) {\r
- var c = table.config;\r
- if(c.widthFixed) {\r
- var colgroup = $('<colgroup>');\r
- $("tbody:first tr:first td",table).each(function() {\r
- \r
- colgroup.append($('<col>').css('width',$(this).width()));\r
- \r
- });\r
- $(table).prepend(colgroup);\r
- };\r
- }\r
- \r
- function updateHeaderSortCount(table,sortList) {\r
- var c = table.config, l = sortList.length;\r
- for(var i=0; i < l; i++) {\r
- var s = sortList[i], o = c.headerList[s[0]];\r
- o.count = s[1];\r
- o.count++;\r
- }\r
- }\r
- \r
- /* sorting methods */\r
- function multisort(table,sortList,cache) {\r
- \r
- if(table.config.debug) { var sortTime = new Date(); }\r
- \r
- var dynamicExp = "var sortWrapper = function(a,b) {", l = sortList.length;\r
- \r
- for(var i=0; i < l; i++) {\r
- \r
- var c = sortList[i][0];\r
- var order = sortList[i][1];\r
- var s = (getCachedSortType(table.config.parsers,c) == "text") ? ((order == 0) ? "sortText" : "sortTextDesc") : ((order == 0) ? "sortNumeric" : "sortNumericDesc");\r
- \r
- var e = "e" + i;\r
- \r
- dynamicExp += "var " + e + " = " + s + "(a[" + c + "],b[" + c + "]); ";\r
- dynamicExp += "if(" + e + ") { return " + e + "; } ";\r
- dynamicExp += "else { ";\r
- }\r
- \r
- for(var i=0; i < l; i++) {\r
- dynamicExp += "}; ";\r
- }\r
- \r
- dynamicExp += "return 0; "; \r
- dynamicExp += "}; "; \r
- \r
- eval(dynamicExp);\r
- \r
- cache.normalized.sort(sortWrapper);\r
- \r
- if(table.config.debug) { benchmark("Sorting on " + sortList.toString() + " and dir " + order+ " time:", sortTime); }\r
- \r
- return cache;\r
- };\r
- \r
- function sortText(a,b) {\r
- return ((a < b) ? -1 : ((a > b) ? 1 : 0));\r
- };\r
- \r
- function sortTextDesc(a,b) {\r
- return ((b < a) ? -1 : ((b > a) ? 1 : 0));\r
- }; \r
- \r
- function sortNumeric(a,b) {\r
- return a-b;\r
- };\r
- \r
- function sortNumericDesc(a,b) {\r
- return b-a;\r
- };\r
- \r
- function getCachedSortType(parsers,i) {\r
- return parsers[i].type;\r
- };\r
- \r
- /* public methods */\r
- this.construct = function(settings) {\r
-\r
- return this.each(function() {\r
- \r
- \r
- \r
- \r
- var $this, $document,$headers, cache, config, shiftDown = 0, sortOrder;\r
- \r
- this.config = {};\r
- \r
- config = $.extend(this.config, $.tablesorter.defaults, settings);\r
- \r
- if(!this.tHead || !this.tBodies) return true;\r
- \r
- // store common expression for speed \r
- $this = $(this);\r
- \r
- // build headers\r
- $headers = buildHeaders(this);\r
- \r
- // try to auto detect column type, and store in tables config\r
- this.config.parsers = buildParserCache(this,$headers);\r
- \r
- \r
- // build the cache for the tbody cells\r
- cache = buildCache(this);\r
- \r
- // get the css class names, could be done else where.\r
- var sortCSS = [config.cssDesc,config.cssAsc];\r
- \r
- // fixate columns if the users supplies the fixedWidth option\r
- fixColumnWidth(this);\r
- \r
- // apply event handling to headers\r
- // this is to big, perhaps break it out?\r
- $headers.click(function(e) {\r
- if(!this.sortDisabled) {\r
- // store exp, for speed\r
- var $cell = $(this);\r
- \r
- // get current column index\r
- var i = this.column;\r
- \r
- // get current column sort order\r
- this.order = this.count++ % 2;\r
- \r
- \r
- \r
- // user only whants to sort on one column\r
- if(!e[config.sortMultiSortKey]) {\r
- \r
- // flush the sort list\r
- config.sortList = [];\r
- \r
- if(config.sortForce != null) {\r
- var a = config.sortForce; \r
- for(var j=0; j < a.length; j++) { \r
- config.sortList.push(a[j]); \r
- }\r
- }\r
- \r
- // add column to sort list\r
- config.sortList.push([i,this.order]);\r
- \r
- // multi column sorting \r
- } else {\r
- // the user has clicked on an all ready sortet column.\r
- if(isValueInArray(i,config.sortList)) { \r
- \r
- // revers the sorting direction for all tables.\r
- for(var j=0; j < config.sortList.length; j++) {\r
- var s = config.sortList[j], o = config.headerList[s[0]];\r
- if(s[0] == i) {\r
- o.count = s[1];\r
- o.count++;\r
- s[1] = o.count % 2;\r
- }\r
- } \r
- } else {\r
- // add column to sort list array\r
- config.sortList.push([i,this.order]);\r
- }\r
- };\r
- \r
- //set css for headers\r
- setHeadersCss($this[0],$headers,config.sortList,sortCSS);\r
- \r
- // sort the table and append it to the dom\r
- appendToTable($this[0],multisort($this[0],config.sortList,cache));\r
- \r
- // stop normal event by returning false\r
- return false;\r
- }\r
- // cancel selection
- }).mousedown(function() {\r
- if(config.cancelSelection) {\r
- this.onselectstart = function() {return false};\r
- //alert(this.onselectstart);\r
- return false;\r
- }\r
- });\r
- \r
- // apply easy methods that trigger binded events\r
- $this.bind("update",function() {\r
- \r
- // rebuild the cache map\r
- cache = buildCache(this);\r
- \r
- }).bind("sorton",function(e,list) {\r
- \r
- // update and store the sortlist\r
- var sortList = config.sortList = list;\r
- \r
- // update header count index\r
- updateHeaderSortCount(this,sortList);\r
- \r
- //set css for headers\r
- setHeadersCss(this,$headers,sortList,sortCSS);\r
- \r
- // sort the table and append it to the dom\r
- appendToTable(this,multisort(this,sortList,cache));\r
- \r
- }).bind("appendCache",function() {\r
- \r
- appendToTable(this,cache);\r
- \r
- }).bind("applyWidgetId",function(e,id) {\r
- \r
- getWidgetById(id).format(this);\r
- \r
- });\r
- \r
- if($.meta && ($(this).data() && $(this).data().sortlist)) {\r
- config.sortList = $(this).data().sortlist;\r
- }\r
- // if user has supplied a sort list to constructor.\r
- if(config.sortList.length > 0) {\r
- $this.trigger("sorton",[config.sortList]); \r
- }\r
- \r
- // apply widgets\r
- applyWidget(this);\r
- });\r
- };\r
- \r
- this.addParser = function(parser) {\r
- var l = parsers.length, a = true;\r
- for(var i=0; i < l; i++) {\r
- if(parsers[i].id.toLowerCase() == parser.id.toLowerCase()) {\r
- a = false;\r
- }\r
- }\r
- if(a) { parsers.push(parser); };\r
- };\r
- \r
- this.addWidget = function(widget) {\r
- widgets.push(widget);\r
- };\r
- \r
- this.formatFloat = function(s) {\r
-\r
- var i = parseFloat(s);\r
- return (isNaN(i)) ? 0 : i;\r
- };\r
- this.formatInt = function(s) {\r
- var i = parseInt(s);\r
- return (isNaN(i)) ? 0 : i;\r
- };\r
- \r
- }\r
- });\r
- \r
- // extend plugin scope\r
- $.fn.extend({\r
- tablesorter: $.tablesorter.construct\r
- });\r
- \r
- // add default parsers\r
- $.tablesorter.addParser({\r
- id: "text",\r
- is: function(s) {\r
- return true;\r
- },\r
- format: function(s) {\r
- return $.trim(s.toLowerCase());\r
- },\r
- type: "text"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "integer",\r
- is: function(s) {\r
- return s.match(new RegExp(/^\d+$/));\r
- },\r
- format: function(s) {\r
- return $.tablesorter.formatInt(s);\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "currency",\r
- is: function(s) {\r
- return /^[£$€?.]/.test(s);\r
- },\r
- format: function(s) {\r
- return $.tablesorter.formatFloat(s.replace(new RegExp(/[^0-9.]/g),""));\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "integer",\r
- is: function(s) {\r
- return /^\d+$/.test(s);\r
- },\r
- format: function(s) {\r
- return $.tablesorter.formatFloat(s);\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "floating",\r
- is: function(s) {\r
- return s.match(new RegExp(/^(\+|-)?[0-9]+\.[0-9]+((E|e)(\+|-)?[0-9]+)?$/));\r
- },\r
- format: function(s) {\r
- return $.tablesorter.formatFloat(s.replace(new RegExp(/,/),""));\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "ipAddress",\r
- is: function(s) {\r
- return /^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s);\r
- },\r
- format: function(s) {\r
- var a = s.split(".");\r
- var r = "";\r
- for (var i = 0, item; item = a[i]; i++) {\r
- if(item.length == 2) {\r
- r += "0" + item;\r
- } else {\r
- r += item;\r
- }\r
- }\r
- return $.tablesorter.formatFloat(s);\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "url",\r
- is: function(s) {\r
- return /^(https?|ftp|file):\/\/$/.test(s);\r
- },\r
- format: function(s) {\r
- return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//),''));\r
- },\r
- type: "text"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "isoDate",\r
- is: function(s) {\r
- return /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s);\r
- },\r
- format: function(s) {\r
- return $.tablesorter.formatFloat((s != "") ? new Date(s.replace(new RegExp(/-/g),"/")).getTime() : "0");\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "percent",\r
- is: function(s) {\r
- return /^\d{1,3}%$/.test(s);\r
- },\r
- format: function(s) {\r
- return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g),""));\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "usLongDate",\r
- is: function(s) {\r
- return /^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|\'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/.test(s);\r
- },\r
- format: function(s) {\r
- return $.tablesorter.formatFloat(new Date(s).getTime());\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "shortDate",\r
- is: function(s) {\r
- return /\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}/.test(s);\r
- },\r
- format: function(s,table) {\r
- var c = table.config;\r
- s = s.replace(new RegExp(/-/g),"/");\r
- if(c.dateFormat == "us") {\r
- /** reformat the string in ISO format */\r
- s = s.replace(new RegExp(/(\d{1,2})[\/-](\d{1,2})[\/-](\d{4})/), "$3/$1/$2");\r
- } else if(c.dateFormat == "uk") {\r
- /** reformat the string in ISO format */\r
- s = s.replace(new RegExp(/(\d{1,2})[\/-](\d{1,2})[\/-](\d{4})/), "$3/$2/$1");\r
- } else if(c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") {\r
- s = s.replace(new RegExp(/(\d{1,2})[\/-](\d{1,2})[\/-](\d{2})/), "$1/$2/$3"); \r
- }\r
- return $.tablesorter.formatFloat(new Date(s).getTime());\r
- },\r
- type: "numeric"\r
- });\r
- \r
- $.tablesorter.addParser({\r
- id: "time",\r
- is: function(s) {\r
- return /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s);\r
- },\r
- format: function(s) {\r
- return $.tablesorter.formatFloat(new Date("2000/01/01 " + s).getTime());\r
- },\r
- type: "numeric"\r
- });\r
- \r
- \r
- $.tablesorter.addParser({\r
- id: "metadata",\r
- is: function(s) {\r
- return false;\r
- },\r
- format: function(s,table,cell) {\r
- var c = table.config, p = (!c.parserMetadataName) ? 'sortValue' : c.parserMetadataName;\r
- return $(cell).data()[p];\r
- },\r
- type: "numeric"\r
- });\r
- \r
- // add default widgets\r
- $.tablesorter.addWidget({\r
- id: "zebra",\r
- format: function(table) {\r
- $("> tbody:first/tr:visible:even",table).removeClass(table.config.widgetZebra.css[1]).addClass(table.config.widgetZebra.css[0]);\r
- $("> tbody:first/tr:visible:odd",table).removeClass(table.config.widgetZebra.css[0]).addClass(table.config.widgetZebra.css[1]);\r
- }\r
- });\r
- \r
-})(jQuery);
\ No newline at end of file