Release 1.2

* use jQuery and data-sortt attribute if available
This commit is contained in:
6543 2019-09-18 00:36:09 +00:00 committed by Gitea
commit f630cb10e3

View File

@ -4,10 +4,26 @@
@License MIT @License MIT
@Author 6543 @Author 6543
@Repository https://gitea.com/6543/gitea_sortt @Repository https://gitea.com/6543/gitea_sortt
@Version 1.1 @Version 1.2


*/ */



// test if jQuery is available
if(!window.jQuery) {
console.log("sortt.js: ERROR no jQuery found!");
} else {

//use JQuery to bind event on each <th> with a "data-sortt" attribute
$('th').each(function() {
if ($(this)[0].dataset.sortt) $(this).on('click', function(e) {
var data = $(this)[0].dataset.sortt
data = data.split(",");
sortt(data[0],data[1],data[2]);
});
});
}

//create global function with main routine //create global function with main routine
window.sortt=function(normsort,revsort,isdefault){ window.sortt=function(normsort,revsort,isdefault){
//sortTable [normsort] (revsort) (isdefault) //sortTable [normsort] (revsort) (isdefault)