Debug: update debug logging

pager, columnSelector & filter
This commit is contained in:
Mottie 2015-02-27 17:37:14 -06:00
parent a69a746fdf
commit c17aa829e6
13 changed files with 100 additions and 35 deletions

View File

@ -216,6 +216,9 @@
pagerArrows(p); pagerArrows(p);
fixHeight(table, p); fixHeight(table, p);
if (p.initialized && completed !== false) { if (p.initialized && completed !== false) {
if (c.debug) {
ts.log('Pager: Triggering pagerComplete');
}
c.$table.trigger('pagerComplete', p); c.$table.trigger('pagerComplete', p);
// save pager info to storage // save pager info to storage
if (p.savePages && ts.storage) { if (p.savePages && ts.storage) {
@ -386,7 +389,7 @@
if ( exception ) { if ( exception ) {
if (c.debug) { if (c.debug) {
ts.log('Ajax Error', xhr, exception); ts.log('Pager: >> Ajax Error', xhr, exception);
} }
ts.showError(table, ts.showError(table,
xhr.status === 0 ? 'Not connected, verify Network' : xhr.status === 0 ? 'Not connected, verify Network' :
@ -481,6 +484,9 @@
// apply widgets after table has rendered & after a delay to prevent // apply widgets after table has rendered & after a delay to prevent
// multiple applyWidget blocking code from blocking this trigger // multiple applyWidget blocking code from blocking this trigger
setTimeout(function(){ setTimeout(function(){
if (c.debug) {
ts.log('Pager: Triggering pagerChange');
}
$t $t
.trigger('applyWidgets') .trigger('applyWidgets')
.trigger('pagerChange', p); .trigger('pagerChange', p);
@ -493,6 +499,9 @@
if (!p.initialized) { if (!p.initialized) {
p.initialized = true; p.initialized = true;
p.initializing = false; p.initializing = false;
if (table.config.debug) {
ts.log('Pager: Triggering pagerInitialized');
}
$(table) $(table)
.trigger('applyWidgets') .trigger('applyWidgets')
.trigger('pagerInitialized', p); .trigger('pagerInitialized', p);
@ -530,7 +539,7 @@
} }
}; };
if (c.debug) { if (c.debug) {
ts.log('ajax initialized', p.ajaxObject); ts.log('Pager: Ajax initialized', p.ajaxObject);
} }
$.ajax(p.ajaxObject); $.ajax(p.ajaxObject);
} }
@ -574,7 +583,7 @@
url = p.customAjaxUrl(table, url); url = p.customAjaxUrl(table, url);
} }
if (c.debug) { if (c.debug) {
ts.log('Pager ajax url: ' + url); ts.log('Pager: Ajax url = ' + url);
} }
return url; return url;
}, },
@ -589,7 +598,7 @@
e = p.size; e = p.size;
if ( l < 1 ) { if ( l < 1 ) {
if (c.debug) { if (c.debug) {
ts.log('Pager: no rows for pager to render'); ts.log('Pager: >> No rows for pager to render');
} }
// empty table, abort! // empty table, abort!
return; return;
@ -600,7 +609,12 @@
} }
p.cacheIndex = []; p.cacheIndex = [];
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
if (p.initialized) { $t.trigger('pagerChange', p); } if (p.initialized) {
if (c.debug) {
ts.log('Pager: Triggering pagerChange');
}
$t.trigger('pagerChange', p);
}
if ( !p.removeRows ) { if ( !p.removeRows ) {
hideRows(table, p); hideRows(table, p);
@ -627,6 +641,9 @@
} }
updatePageDisplay(table, p); updatePageDisplay(table, p);
if (table.isUpdating) { if (table.isUpdating) {
if (c.debug) {
ts.log('Pager: Triggering updateComplete');
}
$t.trigger('updateComplete', [ table, true ]); $t.trigger('updateComplete', [ table, true ]);
} }
}, },
@ -648,7 +665,7 @@
renderTable(table, table.config.rowsCopy, p); renderTable(table, table.config.rowsCopy, p);
$(table).trigger('applyWidgets'); $(table).trigger('applyWidgets');
if (table.config.debug) { if (table.config.debug) {
ts.log('pager disabled'); ts.log('Pager: Disabled');
} }
} }
// disable size selector // disable size selector
@ -702,7 +719,7 @@
(l.optAjaxUrl || '') === (p.ajaxUrl || '') && (l.optAjaxUrl || '') === (p.ajaxUrl || '') &&
l.sortList === (c.sortList || []).join(',') ) { return; } l.sortList === (c.sortList || []).join(',') ) { return; }
if (c.debug) { if (c.debug) {
ts.log('Pager changing to page ' + p.page); ts.log('Pager: Changing to page ' + p.page);
} }
p.last = { p.last = {
page : p.page, page : p.page,
@ -721,10 +738,16 @@
} }
$.data(table, 'pagerLastPage', p.page); $.data(table, 'pagerLastPage', p.page);
if (p.initialized && pageMoved !== false) { if (p.initialized && pageMoved !== false) {
if (c.debug) {
ts.log('Pager: Triggering pageMoved');
}
$t $t
.trigger('pageMoved', p) .trigger('pageMoved', p)
.trigger('applyWidgets'); .trigger('applyWidgets');
if (table.isUpdating) { if (table.isUpdating) {
if (c.debug) {
ts.log('Pager: Triggering updateComplete');
}
$t.trigger('updateComplete', [ table, true ]); $t.trigger('updateComplete', [ table, true ]);
} }
} }
@ -802,7 +825,7 @@
setPageSize(table, p.size, p); setPageSize(table, p.size, p);
hideRowsSetup(table, p); hideRowsSetup(table, p);
if (c.debug) { if (c.debug) {
ts.log('pager enabled'); ts.log('Pager: Enabled');
} }
} }
}; };
@ -836,7 +859,7 @@
// save a copy of the original settings // save a copy of the original settings
p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings ); p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
if (c.debug) { if (c.debug) {
ts.log('Pager initializing'); ts.log('Pager: Initializing');
} }
p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success; p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
c.appender = $this.appender; c.appender = $this.appender;
@ -929,6 +952,9 @@
// clicked controls // clicked controls
ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ]; ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ]; fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
if (c.debug && !pager.length) {
ts.log('Pager: >> Container not found');
}
pager.find(ctrls.join(',')) pager.find(ctrls.join(','))
.attr("tabindex", 0) .attr("tabindex", 0)
.unbind('click.pager') .unbind('click.pager')
@ -955,6 +981,8 @@
moveToPage(table, p, true); moveToPage(table, p, true);
updatePageDisplay(table, p, false); updatePageDisplay(table, p, false);
}); });
} else if (c.debug) {
ts.log('Pager: >> Goto selector not found');
} }
// page size selector // page size selector
@ -970,6 +998,8 @@
} }
return false; return false;
}); });
} else if (c.debug) {
ts.log('Pager: >> Size selector not found');
} }
// clear initialized flag // clear initialized flag
@ -997,7 +1027,10 @@
p.initializing = false; p.initializing = false;
p.initialized = true; p.initialized = true;
moveToPage(table, p); moveToPage(table, p);
$(table).trigger('pagerInitialized', p); if (c.debug) {
ts.log('Pager: Triggering pagerInitialized');
}
c.$table.trigger('pagerInitialized', p);
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) { if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
updatePageDisplay(table, p, false); updatePageDisplay(table, p, false);
} }

File diff suppressed because one or more lines are too long

View File

@ -1139,7 +1139,7 @@ ts.filter = {
}).get(); }).get();
if (c.debug) { if (c.debug) {
ts.log('Starting filter widget search', filters); ts.log('Filter: Starting filter widget search', filters);
time = new Date(); time = new Date();
} }
// filtered rows count // filtered rows count
@ -1217,7 +1217,7 @@ ts.filter = {
// can't search when all rows are hidden - this happens when looking for exact matches // can't search when all rows are hidden - this happens when looking for exact matches
if (searchFiltered && notFiltered === 0) { searchFiltered = false; } if (searchFiltered && notFiltered === 0) { searchFiltered = false; }
if (c.debug) { if (c.debug) {
ts.log( "Searching through " + ( searchFiltered && notFiltered < len ? notFiltered : "all" ) + " rows" ); ts.log( 'Filter: Searching through ' + ( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
} }
if (data.anyMatchFlag) { if (data.anyMatchFlag) {
if (c.sortLocaleCompare) { if (c.sortLocaleCompare) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -147,7 +147,7 @@
prev : '.prev', // previous page arrow prev : '.prev', // previous page arrow
next : '.next', // next page arrow next : '.next', // next page arrow
last : '.last', // go to last page arrow last : '.last', // go to last page arrow
goto : '.gotoPage', // go to page selector - select dropdown that sets the current page gotoPage : '.gotoPage', // go to page selector - select dropdown that sets the current page
pageDisplay : '.pagedisplay', // location of where the "output" is displayed pageDisplay : '.pagedisplay', // location of where the "output" is displayed
pageSize : '.pagesize' // page size selector - select dropdown that sets the "size" option pageSize : '.pagesize' // page size selector - select dropdown that sets the "size" option

View File

@ -105,7 +105,7 @@
prev : '.prev', // previous page arrow prev : '.prev', // previous page arrow
next : '.next', // next page arrow next : '.next', // next page arrow
last : '.last', // go to last page arrow last : '.last', // go to last page arrow
goto : '.gotoPage', // go to page selector - select dropdown that sets the current page gotoPage : '.gotoPage', // go to page selector - select dropdown that sets the current page
pageDisplay : '.pagedisplay', // location of where the "output" is displayed pageDisplay : '.pagedisplay', // location of where the "output" is displayed
pageSize : '.pagesize' // page size selector - select dropdown that sets the "size" option pageSize : '.pagesize' // page size selector - select dropdown that sets the "size" option
} }

View File

@ -1145,7 +1145,7 @@ ts.filter = {
}).get(); }).get();
if (c.debug) { if (c.debug) {
ts.log('Starting filter widget search', filters); ts.log('Filter: Starting filter widget search', filters);
time = new Date(); time = new Date();
} }
// filtered rows count // filtered rows count
@ -1223,7 +1223,7 @@ ts.filter = {
// can't search when all rows are hidden - this happens when looking for exact matches // can't search when all rows are hidden - this happens when looking for exact matches
if (searchFiltered && notFiltered === 0) { searchFiltered = false; } if (searchFiltered && notFiltered === 0) { searchFiltered = false; }
if (c.debug) { if (c.debug) {
ts.log( "Searching through " + ( searchFiltered && notFiltered < len ? notFiltered : "all" ) + " rows" ); ts.log( 'Filter: Searching through ' + ( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
} }
if (data.anyMatchFlag) { if (data.anyMatchFlag) {
if (c.sortLocaleCompare) { if (c.sortLocaleCompare) {

View File

@ -21,7 +21,7 @@ tsColSel = ts.columnSelector = {
$t = $(wo.columnSelector_layout); $t = $(wo.columnSelector_layout);
if (!$t.find('input').add( $t.filter('input') ).length) { if (!$t.find('input').add( $t.filter('input') ).length) {
if (c.debug) { if (c.debug) {
ts.log('*** ERROR: Column Selector aborting, no input found in the layout! ***'); ts.log('ColumnSelector: >> ERROR: Column Selector aborting, no input found in the layout! ***');
} }
return; return;
} }
@ -45,6 +45,8 @@ tsColSel = ts.columnSelector = {
colSel.isInitializing = false; colSel.isInitializing = false;
if (colSel.$container.length) { if (colSel.$container.length) {
tsColSel.updateCols(c, wo); tsColSel.updateCols(c, wo);
} else if (c.debug) {
ts.log('ColumnSelector: >> container not found');
} }
c.$table c.$table

View File

@ -796,7 +796,7 @@ ts.filter = {
}).get(); }).get();
if (c.debug) { if (c.debug) {
ts.log('Starting filter widget search', filters); ts.log('Filter: Starting filter widget search', filters);
time = new Date(); time = new Date();
} }
// filtered rows count // filtered rows count
@ -874,7 +874,7 @@ ts.filter = {
// can't search when all rows are hidden - this happens when looking for exact matches // can't search when all rows are hidden - this happens when looking for exact matches
if (searchFiltered && notFiltered === 0) { searchFiltered = false; } if (searchFiltered && notFiltered === 0) { searchFiltered = false; }
if (c.debug) { if (c.debug) {
ts.log( "Searching through " + ( searchFiltered && notFiltered < len ? notFiltered : "all" ) + " rows" ); ts.log( 'Filter: Searching through ' + ( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
} }
if (data.anyMatchFlag) { if (data.anyMatchFlag) {
if (c.sortLocaleCompare) { if (c.sortLocaleCompare) {

View File

@ -151,7 +151,7 @@ tsp = ts.pager = {
p.isInitializing = true; p.isInitializing = true;
if (c.debug) { if (c.debug) {
ts.log('Pager initializing'); ts.log('Pager: Initializing');
} }
p.size = $.data(table, 'pagerLastSize') || wo.pager_size; p.size = $.data(table, 'pagerLastSize') || wo.pager_size;
@ -196,7 +196,7 @@ tsp = ts.pager = {
} else { } else {
p.ajax = false; p.ajax = false;
// Regular pager; all rows stored in memory // Regular pager; all rows stored in memory
c.$table.trigger("appendCache", [{}, true]); c.$table.trigger('appendCache', [{}, true]);
} }
}, },
@ -214,6 +214,9 @@ tsp = ts.pager = {
p.initialized = true; p.initialized = true;
p.initializing = false; p.initializing = false;
p.isInitializing = false; p.isInitializing = false;
if (c.debug) {
ts.log('Pager: Triggering pagerInitialized');
}
c.$table.trigger('pagerInitialized', c); c.$table.trigger('pagerInitialized', c);
// filter widget not initialized; it will update the output display & fire off the pagerComplete event // filter widget not initialized; it will update the output display & fire off the pagerComplete event
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) { if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
@ -310,6 +313,9 @@ tsp = ts.pager = {
// clicked controls // clicked controls
ctrls = [ s.first, s.prev, s.next, s.last ]; ctrls = [ s.first, s.prev, s.next, s.last ];
fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ]; fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ];
if (c.debug && !p.$container.length) {
ts.log('Pager: >> Container not found');
}
p.$container.find(ctrls.join(',')) p.$container.find(ctrls.join(','))
.attr("tabindex", 0) .attr("tabindex", 0)
.off('click.pager') .off('click.pager')
@ -336,6 +342,8 @@ tsp = ts.pager = {
tsp.moveToPage(table, p, true); tsp.moveToPage(table, p, true);
tsp.updatePageDisplay(table, c, false); tsp.updatePageDisplay(table, c, false);
}); });
} else if (c.debug) {
ts.log('Pager: >> Goto selector not found');
} }
if ( p.$size.length ) { if ( p.$size.length ) {
@ -351,6 +359,8 @@ tsp = ts.pager = {
} }
return false; return false;
}); });
} else if (c.debug) {
ts.log('Pager: >> Size selector not found');
} }
}, },
@ -455,6 +465,9 @@ tsp = ts.pager = {
tsp.pagerArrows(c); tsp.pagerArrows(c);
tsp.fixHeight(table, c); tsp.fixHeight(table, c);
if (p.initialized && completed !== false) { if (p.initialized && completed !== false) {
if (c.debug) {
ts.log('Pager: Triggering pagerComplete');
}
c.$table.trigger('pagerComplete', c); c.$table.trigger('pagerComplete', c);
// save pager info to storage // save pager info to storage
if (wo.pager_savePages && ts.storage) { if (wo.pager_savePages && ts.storage) {
@ -629,7 +642,7 @@ tsp = ts.pager = {
if ( exception ) { if ( exception ) {
if (c.debug) { if (c.debug) {
ts.log('Ajax Error', xhr, exception); ts.log('Pager: >> Ajax Error', xhr, exception);
} }
ts.showError(table, exception.message + ' (' + xhr.status + ')'); ts.showError(table, exception.message + ' (' + xhr.status + ')');
c.$tbodies.eq(0).children('tr').detach(); c.$tbodies.eq(0).children('tr').detach();
@ -719,6 +732,9 @@ tsp = ts.pager = {
// apply widgets after table has rendered & after a delay to prevent // apply widgets after table has rendered & after a delay to prevent
// multiple applyWidget blocking code from blocking this trigger // multiple applyWidget blocking code from blocking this trigger
setTimeout(function(){ setTimeout(function(){
if (c.debug) {
ts.log('Pager: Triggering pagerChange');
}
$t $t
.trigger('applyWidgets') .trigger('applyWidgets')
.trigger('pagerChange', p); .trigger('pagerChange', p);
@ -760,7 +776,7 @@ tsp = ts.pager = {
} }
}; };
if (c.debug) { if (c.debug) {
ts.log('ajax initialized', p.ajaxObject); ts.log('Pager: Ajax initialized', p.ajaxObject);
} }
$.ajax(p.ajaxObject); $.ajax(p.ajaxObject);
} }
@ -805,7 +821,7 @@ tsp = ts.pager = {
url = wo.pager_customAjaxUrl(table, url); url = wo.pager_customAjaxUrl(table, url);
} }
if (c.debug) { if (c.debug) {
ts.log('Pager ajax url: ' + url); ts.log('Pager: Ajax url = ' + url);
} }
return url; return url;
}, },
@ -821,7 +837,7 @@ tsp = ts.pager = {
e = p.size; e = p.size;
if ( l < 1 ) { if ( l < 1 ) {
if (c.debug) { if (c.debug) {
ts.log('Pager: no rows for pager to render'); ts.log('Pager: >> No rows for pager to render');
} }
// empty table, abort! // empty table, abort!
return; return;
@ -832,7 +848,12 @@ tsp = ts.pager = {
} }
p.cacheIndex = []; p.cacheIndex = [];
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
if (p.initialized) { c.$table.trigger('pagerChange', c); } if (p.initialized) {
if (c.debug) {
ts.log('Pager: Triggering pagerChange');
}
c.$table.trigger('pagerChange', c);
}
if ( !wo.pager_removeRows ) { if ( !wo.pager_removeRows ) {
tsp.hideRows(table, c); tsp.hideRows(table, c);
} else { } else {
@ -861,6 +882,9 @@ tsp = ts.pager = {
wo.pager_startPage = p.page; wo.pager_startPage = p.page;
wo.pager_size = p.size; wo.pager_size = p.size;
if (table.isUpdating) { if (table.isUpdating) {
if (c.debug) {
ts.log('Pager: Triggering updateComplete');
}
c.$table.trigger('updateComplete', [ table, true ]); c.$table.trigger('updateComplete', [ table, true ]);
} }
@ -885,7 +909,7 @@ tsp = ts.pager = {
tsp.renderTable(table, c.rowsCopy); tsp.renderTable(table, c.rowsCopy);
c.$table.trigger('applyWidgets'); c.$table.trigger('applyWidgets');
if (c.debug) { if (c.debug) {
ts.log('pager disabled'); ts.log('Pager: Disabled');
} }
} }
// disable size selector // disable size selector
@ -948,7 +972,7 @@ tsp = ts.pager = {
return; return;
} }
if (c.debug) { if (c.debug) {
ts.log('Pager changing to page ' + p.page); ts.log('Pager: Changing to page ' + p.page);
} }
p.last = { p.last = {
page : p.page, page : p.page,
@ -967,10 +991,16 @@ tsp = ts.pager = {
} }
$.data(table, 'pagerLastPage', p.page); $.data(table, 'pagerLastPage', p.page);
if (p.initialized && pageMoved !== false) { if (p.initialized && pageMoved !== false) {
if (c.debug) {
ts.log('Pager: Triggering pageMoved');
}
c.$table c.$table
.trigger('pageMoved', c) .trigger('pageMoved', c)
.trigger('applyWidgets'); .trigger('applyWidgets');
if (!p.ajax && table.isUpdating) { if (!p.ajax && table.isUpdating) {
if (c.debug) {
ts.log('Pager: Triggering updateComplete');
}
c.$table.trigger('updateComplete', [ table, true ]); c.$table.trigger('updateComplete', [ table, true ]);
} }
} }
@ -1047,7 +1077,7 @@ tsp = ts.pager = {
tsp.setPageSize(table, p.size, c); tsp.setPageSize(table, p.size, c);
tsp.hideRowsSetup(table, c); tsp.hideRowsSetup(table, c);
if (c.debug) { if (c.debug) {
ts.log('pager enabled'); ts.log('Pager: Enabled');
} }
} }
}, },