mirror of
https://github.com/DataTables/DataTables.git
synced 2025-02-27 00:54:15 +01:00
Dev: Demo JS can now run with DataTables 1.9
This commit is contained in:
parent
d50902791c
commit
5449eaebf3
@ -1 +1 @@
|
|||||||
d28cee9a04217d60958fb456fa0ea44ca9c7f33a
|
8238b3057f27bff04a3aa2e1e4ef73013b1936a8
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
SyntaxHighlighter.config.tagName = 'code';
|
SyntaxHighlighter.config.tagName = 'code';
|
||||||
|
|
||||||
$(document).ready( function () {
|
$(document).ready( function () {
|
||||||
|
var dt110 = $.fn.dataTable.Api ? true : false;
|
||||||
|
|
||||||
// Work around for WebKit bug 55740
|
// Work around for WebKit bug 55740
|
||||||
var info = $('div.info');
|
var info = $('div.info');
|
||||||
|
|
||||||
@ -29,62 +31,71 @@ $(document).ready( function () {
|
|||||||
);
|
);
|
||||||
//SyntaxHighlighter.highlight({}, $('#display-init-html')[0]);
|
//SyntaxHighlighter.highlight({}, $('#display-init-html')[0]);
|
||||||
|
|
||||||
// json
|
// Allow the demo code to run if DT 1.9 is used
|
||||||
var ajaxTab = $('ul.tabs li').eq(3).css('display', 'none');
|
if ( dt110 ) {
|
||||||
|
// json
|
||||||
|
var ajaxTab = $('ul.tabs li').eq(3).css('display', 'none');
|
||||||
|
|
||||||
$(document).on( 'init.dt', function ( e, settings ) {
|
$(document).on( 'init.dt', function ( e, settings ) {
|
||||||
var api = new $.fn.dataTable.Api( settings );
|
var api = new $.fn.dataTable.Api( settings );
|
||||||
|
|
||||||
var show = function ( str ) {
|
var show = function ( str ) {
|
||||||
ajaxTab.css( 'display', 'block' );
|
ajaxTab.css( 'display', 'block' );
|
||||||
$('div.tabs div.ajax code').remove();
|
$('div.tabs div.ajax code').remove();
|
||||||
|
|
||||||
// Old IE :-|
|
// Old IE :-|
|
||||||
try {
|
try {
|
||||||
str = JSON.stringify( str, null, 2 );
|
str = JSON.stringify( str, null, 2 );
|
||||||
} catch ( e ) {}
|
} catch ( e ) {}
|
||||||
|
|
||||||
$('div.tabs div.ajax').append(
|
$('div.tabs div.ajax').append(
|
||||||
'<code class="multiline brush: js;">'+str+'</code>'
|
'<code class="multiline brush: js;">'+str+'</code>'
|
||||||
);
|
);
|
||||||
SyntaxHighlighter.highlight( {}, $('div.tabs div.ajax code')[0] );
|
SyntaxHighlighter.highlight( {}, $('div.tabs div.ajax code')[0] );
|
||||||
};
|
};
|
||||||
|
|
||||||
// First draw
|
// First draw
|
||||||
var json = api.ajax.json();
|
var json = api.ajax.json();
|
||||||
if ( json ) {
|
if ( json ) {
|
||||||
show( json );
|
show( json );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Subsequent draws
|
// Subsequent draws
|
||||||
api.on( 'xhr.dt', function ( e, settings, json ) {
|
api.on( 'xhr.dt', function ( e, settings, json ) {
|
||||||
show( json );
|
show( json );
|
||||||
} );
|
|
||||||
} );
|
|
||||||
|
|
||||||
// php
|
|
||||||
var phpTab = $('ul.tabs li').eq(4).css('display', 'none');
|
|
||||||
|
|
||||||
$(document).on( 'init.dt', function ( e, settings ) {
|
|
||||||
if ( settings.oFeatures.bServerSide ) {
|
|
||||||
$.ajax( {
|
|
||||||
url: '../resources/examples.php',
|
|
||||||
data: {
|
|
||||||
src: settings.sAjaxSource || settings.ajax.url || settings.ajax
|
|
||||||
},
|
|
||||||
dataType: 'text',
|
|
||||||
type: 'post',
|
|
||||||
success: function ( txt ) {
|
|
||||||
phpTab.css( 'display', 'block' );
|
|
||||||
$('div.tabs div.php').append(
|
|
||||||
'<code class="multiline brush: php;">'+txt+'</code>'
|
|
||||||
);
|
|
||||||
SyntaxHighlighter.highlight( {}, $('div.tabs div.php code')[0] );
|
|
||||||
}
|
|
||||||
} );
|
} );
|
||||||
}
|
} );
|
||||||
} );
|
|
||||||
|
|
||||||
|
// php
|
||||||
|
var phpTab = $('ul.tabs li').eq(4).css('display', 'none');
|
||||||
|
|
||||||
|
$(document).on( 'init.dt', function ( e, settings ) {
|
||||||
|
if ( settings.oFeatures.bServerSide ) {
|
||||||
|
if ( $.isFunction( settings.ajax ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$.ajax( {
|
||||||
|
url: '../resources/examples.php',
|
||||||
|
data: {
|
||||||
|
src: settings.sAjaxSource || settings.ajax.url || settings.ajax
|
||||||
|
},
|
||||||
|
dataType: 'text',
|
||||||
|
type: 'post',
|
||||||
|
success: function ( txt ) {
|
||||||
|
phpTab.css( 'display', 'block' );
|
||||||
|
$('div.tabs div.php').append(
|
||||||
|
'<code class="multiline brush: php;">'+txt+'</code>'
|
||||||
|
);
|
||||||
|
SyntaxHighlighter.highlight( {}, $('div.tabs div.php code')[0] );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('ul.tabs li').eq(3).css('display', 'none');
|
||||||
|
$('ul.tabs li').eq(4).css('display', 'none');
|
||||||
|
}
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
$('ul.tabs li').click( function () {
|
$('ul.tabs li').click( function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user