PHP Classes

File: docs/metrics/phpmetrics.html/js/sort-table.min.js

Recommend this page to a friend!
  Classes of Francesco Danti   ATK4 i18next PHP   docs/metrics/phpmetrics.html/js/sort-table.min.js   Download  
File: docs/metrics/phpmetrics.html/js/sort-table.min.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: ATK4 i18next PHP
Translate application texts like il8next-PHP
Author: By
Last change:
Date: 5 years ago
Size: 3,351 bytes
 

Contents

Class file image Download
/* Copyright (c) 2006-2013 Tyler Uebele * Released under the MIT license. * latest at https://github.com/tyleruebele/sort-table * minified by Google Closure Compiler */ function sortTable(a,b,d){var c;sortTable.sortCol=-1;c=a.className.match(/js-sort-\d+/);null!=c&&(sortTable.sortCol=c[0].replace(/js-sort-/,""),a.className=a.className.replace(RegExp(" ?"+c[0]+"\\b"),""));"undefined"===typeof b&&(b=sortTable.sortCol);"undefined"!==typeof d?sortTable.sortDir=-1==d||"desc"==d?-1:1:(c=a.className.match(/js-sort-(a|de)sc/),sortTable.sortDir=null!=c&&sortTable.sortCol==b?"js-sort-asc"==c[0]?-1:1:1);a.className=a.className.replace(/ ?js-sort-(a|de)sc/g,"");a.className+= " js-sort-"+b;sortTable.sortCol=b;a.className+=" js-sort-"+(-1==sortTable.sortDir?"desc":"asc");b<a.tHead.rows[a.tHead.rows.length-1].cells.length&&(c=a.tHead.rows[a.tHead.rows.length-1].cells[b].className.match(/js-sort-[-\w]+/));for(d=0;d<a.tHead.rows[a.tHead.rows.length-1].cells.length;d++)b==a.tHead.rows[a.tHead.rows.length-1].cells[d].getAttribute("data-js-sort-colNum")&&(c=a.tHead.rows[a.tHead.rows.length-1].cells[d].className.match(/js-sort-[-\w]+/));sortTable.sortFunc=null!=c?c[0].replace(/js-sort-/, ""):"string";b=[];a=a.tBodies[0];for(d=0;d<a.rows.length;d++)b[d]=a.rows[d];for(b.sort(sortTable.compareRow);a.firstChild;)a.removeChild(a.firstChild);for(d=0;d<b.length;d++)a.appendChild(b[d])}sortTable.compareRow=function(a,b){var d,c;"function"!=typeof sortTable[sortTable.sortFunc]&&(sortTable.sortFunc="string");d=sortTable[sortTable.sortFunc](a.cells[sortTable.sortCol]);c=sortTable[sortTable.sortFunc](b.cells[sortTable.sortCol]);return d==c?0:sortTable.sortDir*(d>c?1:-1)}; sortTable.stripTags=function(a){return a.replace(/<\/?[a-z][a-z0-9]*\b[^>]*>/gi,"")};sortTable.date=function(a){return new Date(sortTable.stripTags(a.innerHTML))};sortTable.number=function(a){return Number(sortTable.stripTags(a.innerHTML).replace(/[^-\d.]/g,""))};sortTable.string=function(a){return sortTable.stripTags(a.innerHTML).toLowerCase()};sortTable.last=function(a){return sortTable.stripTags(a.innerHTML).split(" ").pop().toLowerCase()}; sortTable.input=function(a){for(var b=0;b<a.children.length;b++)if("object"==typeof a.children[b]&&"undefined"!=typeof a.children[b].value)return a.children[b].value.toLowerCase();return sortTable.string(a)};sortTable.getClickHandler=function(a,b){return function(){sortTable(a,b)}}; sortTable.init=function(){var a,b,d;b=document.querySelectorAll?document.querySelectorAll("table.js-sort-table"):document.getElementsByTagName("table");for(var c=0;c<b.length;c++)if((document.querySelectorAll||null!==b[c].className.match(/\bjs-sort-table\b/))&&!b[c].attributes["data-js-sort-table"]){b[c].tHead?a=b[c].tHead:(a=document.createElement("thead"),a.appendChild(b[c].rows[0]),b[c].insertBefore(a,b[c].children[0]));for(var e=0;e<a.rows.length;e++)for(var f=0,g=0;f<a.rows[e].cells.length;f++)a.rows[e].cells[f].setAttribute("data-js-sort-colNum", g),d=sortTable.getClickHandler(b[c],g),window.addEventListener?a.rows[e].cells[f].addEventListener("click",d):window.attachEvent&&a.rows[e].cells[f].attachEvent("onclick",d),g+=a.rows[e].cells[f].colSpan;b[c].setAttribute("data-js-sort-table","true")}};window.addEventListener?window.addEventListener("load",sortTable.init,!1):window.attachEvent&&window.attachEvent("onload",sortTable.init);