Comparing version 1.4.0 to 1.4.1
{ | ||
"name": "tablesort", | ||
"description": "A sorting component for HTML tables", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"author": "tristen <@fallsemo>", | ||
@@ -11,3 +11,4 @@ "main": "./tablesort.js", | ||
"Olivier Vaillancourt <@ovaillancourt>", | ||
"Dmitry Kichenko <@imissmyjuno>" | ||
"Dmitry Kichenko <@imissmyjuno>", | ||
"Dong Liu <@dongliu>" | ||
], | ||
@@ -14,0 +15,0 @@ "licenses": [{ |
@@ -32,3 +32,3 @@ # tablesort.js | ||
__Exclude columns__ | ||
For columns that do not require sorting, you can add a class of `no-sort` | ||
For columns that do not require sorting, you can add a class of `no-sort` to a columns `th` element. | ||
``` html | ||
@@ -49,3 +49,3 @@ <th class='no-sort'>Name</th> | ||
[See homepage page for example](http://tristen.ca/tablesort/demo/#refresh) | ||
[See homepage for example](http://tristen.ca/tablesort/demo/#refresh) | ||
@@ -52,0 +52,0 @@ ## Ender support |
@@ -147,5 +147,3 @@ // tablesort.js | ||
for(i = 0; i < newRows.length; i++) { | ||
if(!newRows[i].className) { | ||
t.tBodies[0].appendChild(newRows[i]); | ||
} | ||
t.tBodies[0].appendChild(newRows[i]); | ||
} | ||
@@ -157,3 +155,3 @@ }, | ||
}; | ||
var week = /(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\.?\,?\s*/i, | ||
@@ -160,0 +158,0 @@ commonDate = /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/, |
// tablesort.js | ||
// tristen @fallsemo | ||
(function(){function a(a,b){a.tagName==="TABLE"?this.init(a,b||{}):console.error("Element must be a table")}a.prototype={init:function(a,b){var c=this,d;this.thead=!1,this.options=b,this.options.d=b.descending||!1,a.rows&&a.rows.length>0&&(a.tHead&&a.tHead.rows.length>0?(d=a.tHead.rows[a.tHead.rows.length-1],c.thead=!0):d=a.rows[0]);if(!d)return;for(var e=0;e<d.cells.length;e++){var f=d.cells[e];l(f,"no-sort")||(f.className+=" sort-header",m(f,"click",function(a){var b=g(f,"tr").getElementsByTagName("th");for(var d=0;d<b.length;d++)(l(b[d],"sort-up")||l(b[d],"sort-down"))&&b[d]!==this&&(b[d].className=b[d].className.replace(" sort-down","").replace(" sort-up",""));c.current=this,c.sortTable(this)}))}},sortTable:function(a,b){var c=this,d=a.cellIndex,m=g(a,"table");if(m.rows.length<=1)return;var n="",o=0;while(n===""&&o<m.tBodies[0].rows.length){n=h(m.tBodies[0].rows[o].cells[d]),n=j(n);if(n.substr(0,4)==="<!--"||n.length===0)n="";o++}if(n==="")return;var p,q=function(a,b){var d=h(a.cells[c.col]).toLowerCase(),e=h(b.cells[c.col]).toLowerCase();return d===e?0:d<e?1:-1},r=function(a,b){var d=h(a.cells[c.col]);d=k(d);var e=h(b.cells[c.col]);return e=k(e),i(e,d)},s=function(a,b){var d=h(a.cells[c.col]).toLowerCase(),e=h(b.cells[c.col]).toLowerCase();return f(e)-f(d)};n.match(/^-?[£$Û¢´]\d/)||n.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/)?p=r:e(n)?p=s:p=q,this.col=d;var t=[],u=[],v,w;for(v=0;v<m.tBodies.length;v++)for(o=0;o<m.tBodies[v].rows[0].length;o++)t[o]=m.tBodies[v].rows[0][o];for(v=0;v<m.tBodies.length;v++)if(!c.thead)for(w=1;w<m.tBodies[v].rows.length;w++)u[w-1]=m.tBodies[v].rows[w];else for(w=0;w<m.tBodies[v].rows.length;w++)u[w]=m.tBodies[v].rows[w];u.sort(p),b||(c.options.d?l(a,"sort-up")?(a.className=a.className.replace(/ sort-up/,""),a.className+=" sort-down"):(a.className=a.className.replace(/ sort-down/,""),a.className+=" sort-up"):l(a,"sort-down")?(a.className=a.className.replace(/ sort-down/,""),a.className+=" sort-up"):(a.className=a.className.replace(/ sort-up/,""),a.className+=" sort-down")),l(a,"sort-down")&&u.reverse();for(o=0;o<u.length;o++)u[o].className||m.tBodies[0].appendChild(u[o])},refresh:function(){this.current!==undefined&&this.sortTable(this.current,!0)}};var b=/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\.?\,?\s*/i,c=/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/,d=/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/i,e=function(a){return(a.search(b)!==-1||a.search(c)!==-1||a.search(d!==-1))!==-1},f=function(a){return a=a.replace(/\-/g,"/"),a=a.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3"),(new Date(a)).getTime()},g=function(a,b){return a===null?null:a.nodeType===1&&a.tagName.toLowerCase()===b.toLowerCase()?a:g(a.parentNode,b)},h=function(a){var b=this;if(typeof a=="string"||typeof a=="undefined")return a;if(a.innerText)return a.innerText;var c="",d=a.childNodes,e=d.length;for(var f=0;f<e;f++)switch(d[f].nodeType){case 1:c+=b.getInnerText(d[f]);break;case 3:c+=d[f].nodeValue}return c},i=function(a,b){var c=parseFloat(a);a=isNaN(c)?0:c;var d=parseFloat(b);return b=isNaN(d)?0:d,a-b},j=function(a){return a.replace(/^\s+|\s+$/g,"")},k=function(a){return a.replace(/[^\-?0-9.]/g,"")},l=function(a,b){return(" "+a.className+" ").indexOf(" "+b+" ")>-1},m=function(a,b,c){a.attachEvent?(a["e"+b+c]=c,a[b+c]=function(){a["e"+b+c](window.event)},a.attachEvent("on"+b,a[b+c])):a.addEventListener(b,c,!1)};window.Tablesort=a})(); | ||
(function(){function a(a,b){a.tagName==="TABLE"?this.init(a,b||{}):console.error("Element must be a table")}a.prototype={init:function(a,b){var c=this,d;this.thead=!1,this.options=b,this.options.d=b.descending||!1,a.rows&&a.rows.length>0&&(a.tHead&&a.tHead.rows.length>0?(d=a.tHead.rows[a.tHead.rows.length-1],c.thead=!0):d=a.rows[0]);if(!d)return;for(var e=0;e<d.cells.length;e++){var f=d.cells[e];l(f,"no-sort")||(f.className+=" sort-header",m(f,"click",function(a){var b=g(f,"tr").getElementsByTagName("th");for(var d=0;d<b.length;d++)(l(b[d],"sort-up")||l(b[d],"sort-down"))&&b[d]!==this&&(b[d].className=b[d].className.replace(" sort-down","").replace(" sort-up",""));c.current=this,c.sortTable(this)}))}},sortTable:function(a,b){var c=this,d=a.cellIndex,m=g(a,"table");if(m.rows.length<=1)return;var n="",o=0;while(n===""&&o<m.tBodies[0].rows.length){n=h(m.tBodies[0].rows[o].cells[d]),n=j(n);if(n.substr(0,4)==="<!--"||n.length===0)n="";o++}if(n==="")return;var p,q=function(a,b){var d=h(a.cells[c.col]).toLowerCase(),e=h(b.cells[c.col]).toLowerCase();return d===e?0:d<e?1:-1},r=function(a,b){var d=h(a.cells[c.col]);d=k(d);var e=h(b.cells[c.col]);return e=k(e),i(e,d)},s=function(a,b){var d=h(a.cells[c.col]).toLowerCase(),e=h(b.cells[c.col]).toLowerCase();return f(e)-f(d)};n.match(/^-?[£$Û¢´]\d/)||n.match(/^-?(\d+[,\.]?)+(E[-+][\d]+)?%?$/)?p=r:e(n)?p=s:p=q,this.col=d;var t=[],u=[],v,w;for(v=0;v<m.tBodies.length;v++)for(o=0;o<m.tBodies[v].rows[0].length;o++)t[o]=m.tBodies[v].rows[0][o];for(v=0;v<m.tBodies.length;v++)if(!c.thead)for(w=1;w<m.tBodies[v].rows.length;w++)u[w-1]=m.tBodies[v].rows[w];else for(w=0;w<m.tBodies[v].rows.length;w++)u[w]=m.tBodies[v].rows[w];u.sort(p),b||(c.options.d?l(a,"sort-up")?(a.className=a.className.replace(/ sort-up/,""),a.className+=" sort-down"):(a.className=a.className.replace(/ sort-down/,""),a.className+=" sort-up"):l(a,"sort-down")?(a.className=a.className.replace(/ sort-down/,""),a.className+=" sort-up"):(a.className=a.className.replace(/ sort-up/,""),a.className+=" sort-down")),l(a,"sort-down")&&u.reverse();for(o=0;o<u.length;o++)m.tBodies[0].appendChild(u[o])},refresh:function(){this.current!==undefined&&this.sortTable(this.current,!0)}};var b=/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\.?\,?\s*/i,c=/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/,d=/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/i,e=function(a){return(a.search(b)!==-1||a.search(c)!==-1||a.search(d!==-1))!==-1},f=function(a){return a=a.replace(/\-/g,"/"),a=a.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3"),(new Date(a)).getTime()},g=function(a,b){return a===null?null:a.nodeType===1&&a.tagName.toLowerCase()===b.toLowerCase()?a:g(a.parentNode,b)},h=function(a){var b=this;if(typeof a=="string"||typeof a=="undefined")return a;if(a.innerText)return a.innerText;var c="",d=a.childNodes,e=d.length;for(var f=0;f<e;f++)switch(d[f].nodeType){case 1:c+=b.getInnerText(d[f]);break;case 3:c+=d[f].nodeValue}return c},i=function(a,b){var c=parseFloat(a);a=isNaN(c)?0:c;var d=parseFloat(b);return b=isNaN(d)?0:d,a-b},j=function(a){return a.replace(/^\s+|\s+$/g,"")},k=function(a){return a.replace(/[^\-?0-9.]/g,"")},l=function(a,b){return(" "+a.className+" ").indexOf(" "+b+" ")>-1},m=function(a,b,c){a.attachEvent?(a["e"+b+c]=c,a[b+c]=function(){a["e"+b+c](window.event)},a.attachEvent("on"+b,a[b+c])):a.addEventListener(b,c,!1)};window.Tablesort=a})() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89498
1950