mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-07 05:54:15 +01:00
New: Static API method - fnVersionCheck same as the version check that is already available as an instance method, but here available as a static API method attached to $.fn.dataTable
New: Static API method - fnIsDataTable - check if a TABLE node is a DataTable or not New: Static API method - fnTables - get the DataTables that are initialised on the table (optionally limit to just the visible tables) Examples update - Tabs and scrolling updated to use the new static fnTables method Fix: Settings object model was missing the nScrollHead and nScrollFoot properties from the documentation
This commit is contained in:
parent
0518525f59
commit
2a60a96177
@ -18,9 +18,9 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#tabs").tabs( {
|
$("#tabs").tabs( {
|
||||||
"show": function(event, ui) {
|
"show": function(event, ui) {
|
||||||
var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
|
var table = $.fn.dataTable.fnTables(true);
|
||||||
if ( oTable.length > 0 ) {
|
if ( table.length > 0 ) {
|
||||||
oTable.fnAdjustColumnSizing();
|
$(table).dataTable().fnAdjustColumnSizing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
@ -300,9 +300,9 @@
|
|||||||
<pre class="brush: js;">$(document).ready(function() {
|
<pre class="brush: js;">$(document).ready(function() {
|
||||||
$("#tabs").tabs( {
|
$("#tabs").tabs( {
|
||||||
"show": function(event, ui) {
|
"show": function(event, ui) {
|
||||||
var oTable = $('div.dataTables_scrollBody>table.display', ui.panel).dataTable();
|
var table = $.fn.dataTable.fnTables(true);
|
||||||
if ( oTable.length > 0 ) {
|
if ( table.length > 0 ) {
|
||||||
oTable.fnAdjustColumnSizing();
|
$(table).dataTable().fnAdjustColumnSizing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
134
media/js/jquery.dataTables.js
vendored
134
media/js/jquery.dataTables.js
vendored
@ -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<iLen ; i++ )
|
||||||
|
{
|
||||||
|
sThis += fnZPad( aThis[i], 3 );
|
||||||
|
sThat += fnZPad( aThat[i], 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseInt(sThis, 10) >= 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<o.length ; i++ )
|
||||||
|
{
|
||||||
|
if ( o[i].nTable === nTable || o[i].nScrollHead === nTable || o[i].nScrollFoot === nTable )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all DataTable tables that have been initialised - optionally you can select to
|
||||||
|
* get only currently visible tables.
|
||||||
|
* @param {boolean} [bVisible=false] Flag to indicate if you want all (default) or
|
||||||
|
* visible tables only.
|
||||||
|
* @returns {array} Array of TABLE nodes (not DataTable instances) which are DataTables
|
||||||
|
* @static
|
||||||
|
* @dtopt API-Static
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* var table = $.fn.dataTable.fnTables(true);
|
||||||
|
* if ( table.length > 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
|
* 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
|
* 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' ) );
|
* alert( oTable.fnVersionCheck( '1.9.0' ) );
|
||||||
* } );
|
* } );
|
||||||
*/
|
*/
|
||||||
"fnVersionCheck": function( sVersion )
|
"fnVersionCheck": DataTable.fnVersionCheck,
|
||||||
{
|
|
||||||
/* 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<iLen ; i++ )
|
|
||||||
{
|
|
||||||
sThis += fnZPad( aThis[i], 3 );
|
|
||||||
sThat += fnZPad( aThat[i], 3 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return parseInt(sThis, 10) >= parseInt(sThat, 10);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11032,7 +11110,17 @@
|
|||||||
* tabindex attribute value that is added to DataTables control elements, allowing
|
* tabindex attribute value that is added to DataTables control elements, allowing
|
||||||
* keyboard navigation of the table and its controls.
|
* 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
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,6 +83,8 @@
|
|||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
require('api.static.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version string for plug-ins to check compatibility. Allowed format is
|
* 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
|
* a.b.c.d.e where: a:int, b:int, c:int, d:string(dev|beta), e:int. d and
|
||||||
|
98
media/src/api/api.static.js
Normal file
98
media/src/api/api.static.js
Normal file
@ -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<iLen ; i++ )
|
||||||
|
{
|
||||||
|
sThis += fnZPad( aThis[i], 3 );
|
||||||
|
sThat += fnZPad( aThat[i], 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return parseInt(sThis, 10) >= 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<o.length ; i++ )
|
||||||
|
{
|
||||||
|
if ( o[i].nTable === nTable || o[i].nScrollHead === nTable || o[i].nScrollFoot === nTable )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all DataTable tables that have been initialised - optionally you can select to
|
||||||
|
* get only currently visible tables.
|
||||||
|
* @param {boolean} [bVisible=false] Flag to indicate if you want all (default) or
|
||||||
|
* visible tables only.
|
||||||
|
* @returns {array} Array of TABLE nodes (not DataTable instances) which are DataTables
|
||||||
|
* @static
|
||||||
|
* @dtopt API-Static
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* var table = $.fn.dataTable.fnTables(true);
|
||||||
|
* if ( table.length > 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;
|
||||||
|
};
|
||||||
|
|
@ -224,28 +224,7 @@ DataTable.models.ext = {
|
|||||||
* alert( oTable.fnVersionCheck( '1.9.0' ) );
|
* alert( oTable.fnVersionCheck( '1.9.0' ) );
|
||||||
* } );
|
* } );
|
||||||
*/
|
*/
|
||||||
"fnVersionCheck": function( sVersion )
|
"fnVersionCheck": DataTable.fnVersionCheck,
|
||||||
{
|
|
||||||
/* 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<iLen ; i++ )
|
|
||||||
{
|
|
||||||
sThis += fnZPad( aThis[i], 3 );
|
|
||||||
sThat += fnZPad( aThat[i], 3 );
|
|
||||||
}
|
|
||||||
|
|
||||||
return parseInt(sThis, 10) >= parseInt(sThat, 10);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -854,5 +854,15 @@ DataTable.models.oSettings = {
|
|||||||
* tabindex attribute value that is added to DataTables control elements, allowing
|
* tabindex attribute value that is added to DataTables control elements, allowing
|
||||||
* keyboard navigation of the table and its controls.
|
* 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
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user