diff --git a/js/jquery/jquery.tablesorter.js b/js/jquery/jquery.tablesorter.js index e8e2323489..909d947425 100644 --- a/js/jquery/jquery.tablesorter.js +++ b/js/jquery/jquery.tablesorter.js @@ -826,9 +826,11 @@ // if user has supplied a sort list to constructor. if (config.sortList.length > 0) { $this.trigger("sorton", [config.sortList]); + } else { + // appendToTable used in sorton event already calls applyWidget + // apply widgets + applyWidget(this); } - // apply widgets - applyWidget(this); }); }; this.addParser = function (parser) { diff --git a/js/server_status.js b/js/server_status.js index 1d892e20e4..08d7679530 100644 --- a/js/server_status.js +++ b/js/server_status.js @@ -43,7 +43,24 @@ $(function() { }, type: "numeric" }); - + // faster zebra widget: no row visibility check, faster css class switching, no cssChildRow check + jQuery.tablesorter.addWidget({ + id: "fast-zebra", + format: function (table) { + if (table.config.debug) { + var time = new Date(); + } + $("tr:even", table.tBodies[0]) + .removeClass(table.config.widgetZebra.css[0]) + .addClass(table.config.widgetZebra.css[1]); + $("tr:odd", table.tBodies[0]) + .removeClass(table.config.widgetZebra.css[1]) + .addClass(table.config.widgetZebra.css[0]); + if (table.config.debug) { + $.tablesorter.benchmark("Applying Fast-Zebra widget", time); + } + } + }); // Popup behaviour $('a[rel="popupLink"]').click( function() { @@ -456,6 +473,7 @@ $(function() { } } }); + initTableSorter(tab.attr('id')); break; case 'statustabs_allvars': @@ -463,43 +481,40 @@ $(function() { tab.find('.tabInnerContent').html(data); filterVariables(); } + initTableSorter(tab.attr('id')); break; } - - initTableSorter(tab.attr('id')); } + // TODO: tablesorter shouldn't sort already sorted columns function initTableSorter(tabid) { + var $table, opts; switch(tabid) { case 'statustabs_queries': - $('#serverstatusqueriesdetails').tablesorter({ - sortList: [[3, 1]], - widgets: ['zebra'], - headers: { - 1: { sorter: 'fancyNumber' }, - 2: { sorter: 'fancyNumber' } - } - }); - - $('#serverstatusqueriesdetails tr:first th') - .append(''); - + $table = $('#serverstatusqueriesdetails'); + opts = { + sortList: [[3, 1]], + widgets: ['fast-zebra'], + headers: { + 1: { sorter: 'fancyNumber' }, + 2: { sorter: 'fancyNumber' } + } + }; break; - case 'statustabs_allvars': - $('#serverstatusvariables').tablesorter({ - sortList: [[0, 0]], - widgets: ['zebra'], - headers: { - 1: { sorter: 'fancyNumber' } - } - }); - - $('#serverstatusvariables tr:first th') - .append(''); - + $table = $('#serverstatusvariables'); + opts = { + sortList: [[0, 0]], + widgets: ['fast-zebra'], + headers: { + 1: { sorter: 'fancyNumber' } + } + }; break; } + $table.tablesorter(opts); + $table.find('tr:first th') + .append(''); } /* Filters the status variables by name/category/alert in the variables tab */ diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index 7ac2498810..fa0f28eb77 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -1680,7 +1680,7 @@ $(function() { $('div#logTable table').tablesorter({ sortList: [[cols.length - 1, 1]], - widgets: ['zebra'] + widgets: ['fast-zebra'] }); $('div#logTable table thead th')