Core: include extraTables along with extraHeaders

Also replace instances of tagName with nodeName
This commit is contained in:
Mottie 2015-03-23 16:10:37 -05:00
parent 7f37b90ebd
commit fd693b6d87

View File

@ -1067,7 +1067,7 @@
// save initial settings // save initial settings
c.originalSettings = settings; c.originalSettings = settings;
// create a table from data (build table widget) // create a table from data (build table widget)
if (!table.hasInitialized && ts.buildTable && this.tagName !== 'TABLE') { if (!table.hasInitialized && ts.buildTable && this.nodeName !== 'TABLE') {
// return the table (in case the original target is the table's container) // return the table (in case the original target is the table's container)
ts.buildTable(table, c); ts.buildTable(table, c);
} else { } else {
@ -1334,10 +1334,14 @@
ts.bindEvents = function(table, $headers, core){ ts.bindEvents = function(table, $headers, core){
table = $(table)[0]; table = $(table)[0];
var downTarget = null, var t, downTarget = null,
c = table.config; c = table.config;
if (core !== true) { if (core !== true) {
c.$extraHeaders = c.$extraHeaders ? c.$extraHeaders.add($headers) : $headers; c.$extraHeaders = c.$extraHeaders ? c.$extraHeaders.add($headers) : $headers;
t = $.fn.closest ? $headers.closest('table')[0] : $headers.parents('table')[0];
if (t && t.nodeName === 'TABLE' && t !== table) {
c.$extraTables = c.$extraTables ? c.$extraTables.add(t) : $(t);
}
} }
// apply event handling to headers and/or additional headers (stickyheaders, scroller, etc) // apply event handling to headers and/or additional headers (stickyheaders, scroller, etc)
$headers $headers
@ -1365,7 +1369,7 @@
} }
downTarget = null; downTarget = null;
// prevent sort being triggered on form elements // prevent sort being triggered on form elements
if ( /(input|select|button|textarea)/i.test(e.target.tagName) || if ( /(input|select|button|textarea)/i.test(e.target.nodeName) ||
// nosort class name, or elements within a nosort container // nosort class name, or elements within a nosort container
$target.hasClass(c.cssNoSort) || $target.parents('.' + c.cssNoSort).length > 0 || $target.hasClass(c.cssNoSort) || $target.parents('.' + c.cssNoSort).length > 0 ||
// elements within a button // elements within a button
@ -1374,7 +1378,7 @@
} }
if (c.delayInit && isEmptyObject(c.cache)) { buildCache(table); } if (c.delayInit && isEmptyObject(c.cache)) { buildCache(table); }
// jQuery v1.2.6 doesn't have closest() // jQuery v1.2.6 doesn't have closest()
cell = $.fn.closest ? $(this).closest('th, td')[0] : /TH|TD/.test(this.tagName) ? this : $(this).parents('th, td')[0]; cell = $.fn.closest ? $(this).closest('th, td')[0] : /TH|TD/.test(this.nodeName) ? this : $(this).parents('th, td')[0];
// reference original table headers and find the same cell // reference original table headers and find the same cell
cell = c.$headers[ $headers.index( cell ) ]; cell = c.$headers[ $headers.index( cell ) ];
if (!cell.sortDisabled) { if (!cell.sortDisabled) {
@ -2052,8 +2056,8 @@
priority: 90, priority: 90,
format: function(table, c, wo) { format: function(table, c, wo) {
var $tb, $tv, $tr, row, even, time, k, var $tb, $tv, $tr, row, even, time, k,
child = new RegExp(c.cssChildRow, 'i'), child = new RegExp(c.cssChildRow, 'i'),
b = c.$tbodies; b = c.$tbodies.add( c.$extraTables && c.$extraTables.children( 'tbody' ) );
if (c.debug) { if (c.debug) {
time = new Date(); time = new Date();
} }