diff --git a/examples/api/tabs_and_scrolling.html b/examples/api/tabs_and_scrolling.html index f528ec2e..c370ad85 100644 --- a/examples/api/tabs_and_scrolling.html +++ b/examples/api/tabs_and_scrolling.html @@ -18,9 +18,9 @@ $(document).ready(function() { $("#tabs").tabs( { "show": function(event, ui) { - var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable(); - if ( oTable.length > 0 ) { - oTable.fnAdjustColumnSizing(); + var table = $.fn.dataTable.fnTables(true); + if ( table.length > 0 ) { + $(table).dataTable().fnAdjustColumnSizing(); } } } ); @@ -300,9 +300,9 @@
$(document).ready(function() { $("#tabs").tabs( { "show": function(event, ui) { - var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable(); - if ( oTable.length > 0 ) { - oTable.fnAdjustColumnSizing(); + var table = $.fn.dataTable.fnTables(true); + if ( table.length > 0 ) { + $(table).dataTable().fnAdjustColumnSizing(); } } } ); diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 6fb37ac7..17328d24 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -6587,6 +6587,105 @@ } ); }; + + + /** + * Provide a common method for plug-ins to check the version of DataTables being used, in order + * to ensure compatibility. + * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the + * formats "X" and "X.Y" are also acceptable. + * @returns {boolean} true if this version of DataTables is greater or equal to the required + * version, or false if this version of DataTales is not suitable + * @static + * @dtopt API-Static + * + * @example + * alert( $.fn.dataTable.fnVersionCheck( '1.9.0' ) ); + */ + DataTable.fnVersionCheck = function( sVersion ) + { + /* This is cheap, but effective */ + var fnZPad = function (Zpad, count) + { + while(Zpad.length < count) { + Zpad += '0'; + } + return Zpad; + }; + var aThis = DataTable.ext.sVersion.split('.'); + var aThat = sVersion.split('.'); + var sThis = '', sThat = ''; + + for ( var i=0, iLen=aThat.length ; i= parseInt(sThat, 10); + }; + + + /** + * Check if a TABLE node is a DataTable table already or not. + * @param {node} nTable The TABLE node to check if it is a DataTable or not (note that other + * node types can be passed in, but will always return false). + * @returns {boolean} true the table given is a DataTable, or false otherwise + * @static + * @dtopt API-Static + * + * @example + * var ex = document.getElementById('example'); + * if ( ! $.fn.DataTable.fnIsDataTable( ex ) ) { + * $(ex).dataTable(); + * } + */ + DataTable.fnIsDataTable = function ( nTable ) + { + var o = DataTable.settings; + + for ( var i=0 ; i 0 ) { + * $(table).dataTable().fnAdjustColumnSizing(); + * } + */ + DataTable.fnTables = function ( bVisible ) + { + var out = []; + + jQuery.each( DataTable.settings, function (i, o) { + if ( !bVisible || (bVisible === true && $(o.nTable).is(':visible')) ) + { + out.push( o.nTable ); + } + } ); + + return out; + }; + + /** * Version string for plug-ins to check compatibility. Allowed format is * a.b.c.d.e where: a:int, b:int, c:int, d:string(dev|beta), e:int. d and @@ -6843,28 +6942,7 @@ * alert( oTable.fnVersionCheck( '1.9.0' ) ); * } ); */ - "fnVersionCheck": function( sVersion ) - { - /* This is cheap, but very effective */ - var fnZPad = function (Zpad, count) - { - while(Zpad.length < count) { - Zpad += '0'; - } - return Zpad; - }; - var aThis = DataTable.ext.sVersion.split('.'); - var aThat = sVersion.split('.'); - var sThis = '', sThat = ''; - - for ( var i=0, iLen=aThat.length ; i = parseInt(sThat, 10); - }, + "fnVersionCheck": DataTable.fnVersionCheck, /** @@ -11032,7 +11110,17 @@ * tabindex attribute value that is added to DataTables control elements, allowing * keyboard navigation of the table and its controls. */ - "iTabIndex": 0 + "iTabIndex": 0, + + /** + * DIV container for the footer scrolling table if scrolling + */ + "nScrollHead": null, + + /** + * DIV container for the footer scrolling table if scrolling + */ + "nScrollFoot": null }; /** diff --git a/media/src/DataTables.js b/media/src/DataTables.js index 83fa90e6..37b7c115 100644 --- a/media/src/DataTables.js +++ b/media/src/DataTables.js @@ -83,6 +83,8 @@ } ); }; + require('api.static.js'); + /** * Version string for plug-ins to check compatibility. Allowed format is * a.b.c.d.e where: a:int, b:int, c:int, d:string(dev|beta), e:int. d and diff --git a/media/src/api/api.static.js b/media/src/api/api.static.js new file mode 100644 index 00000000..5000dce4 --- /dev/null +++ b/media/src/api/api.static.js @@ -0,0 +1,98 @@ + + +/** + * Provide a common method for plug-ins to check the version of DataTables being used, in order + * to ensure compatibility. + * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the + * formats "X" and "X.Y" are also acceptable. + * @returns {boolean} true if this version of DataTables is greater or equal to the required + * version, or false if this version of DataTales is not suitable + * @static + * @dtopt API-Static + * + * @example + * alert( $.fn.dataTable.fnVersionCheck( '1.9.0' ) ); + */ +DataTable.fnVersionCheck = function( sVersion ) +{ + /* This is cheap, but effective */ + var fnZPad = function (Zpad, count) + { + while(Zpad.length < count) { + Zpad += '0'; + } + return Zpad; + }; + var aThis = DataTable.ext.sVersion.split('.'); + var aThat = sVersion.split('.'); + var sThis = '', sThat = ''; + + for ( var i=0, iLen=aThat.length ; i = parseInt(sThat, 10); +}; + + +/** + * Check if a TABLE node is a DataTable table already or not. + * @param {node} nTable The TABLE node to check if it is a DataTable or not (note that other + * node types can be passed in, but will always return false). + * @returns {boolean} true the table given is a DataTable, or false otherwise + * @static + * @dtopt API-Static + * + * @example + * var ex = document.getElementById('example'); + * if ( ! $.fn.DataTable.fnIsDataTable( ex ) ) { + * $(ex).dataTable(); + * } + */ +DataTable.fnIsDataTable = function ( nTable ) +{ + var o = DataTable.settings; + + for ( var i=0 ; i 0 ) { + * $(table).dataTable().fnAdjustColumnSizing(); + * } + */ +DataTable.fnTables = function ( bVisible ) +{ + var out = []; + + jQuery.each( DataTable.settings, function (i, o) { + if ( !bVisible || (bVisible === true && $(o.nTable).is(':visible')) ) + { + out.push( o.nTable ); + } + } ); + + return out; +}; + diff --git a/media/src/model/model.ext.js b/media/src/model/model.ext.js index 590eeb23..7483984d 100644 --- a/media/src/model/model.ext.js +++ b/media/src/model/model.ext.js @@ -224,28 +224,7 @@ DataTable.models.ext = { * alert( oTable.fnVersionCheck( '1.9.0' ) ); * } ); */ - "fnVersionCheck": function( sVersion ) - { - /* This is cheap, but very effective */ - var fnZPad = function (Zpad, count) - { - while(Zpad.length < count) { - Zpad += '0'; - } - return Zpad; - }; - var aThis = DataTable.ext.sVersion.split('.'); - var aThat = sVersion.split('.'); - var sThis = '', sThat = ''; - - for ( var i=0, iLen=aThat.length ; i = parseInt(sThat, 10); - }, + "fnVersionCheck": DataTable.fnVersionCheck, /** diff --git a/media/src/model/model.settings.js b/media/src/model/model.settings.js index 95c0e81b..6d66e9e6 100644 --- a/media/src/model/model.settings.js +++ b/media/src/model/model.settings.js @@ -854,5 +854,15 @@ DataTable.models.oSettings = { * tabindex attribute value that is added to DataTables control elements, allowing * keyboard navigation of the table and its controls. */ - "iTabIndex": 0 + "iTabIndex": 0, + + /** + * DIV container for the footer scrolling table if scrolling + */ + "nScrollHead": null, + + /** + * DIV container for the footer scrolling table if scrolling + */ + "nScrollFoot": null };