2013-10-16 13:13:30 +02:00
|
|
|
|
|
|
|
/*global SyntaxHighlighter*/
|
2013-12-19 15:03:24 +01:00
|
|
|
SyntaxHighlighter.config.tagName = 'code';
|
2013-10-16 13:13:30 +02:00
|
|
|
|
|
|
|
$(document).ready( function () {
|
2014-01-31 14:27:42 +01:00
|
|
|
var dt110 = $.fn.dataTable.Api ? true : false;
|
|
|
|
|
2013-10-16 13:13:30 +02:00
|
|
|
// Work around for WebKit bug 55740
|
|
|
|
var info = $('div.info');
|
|
|
|
|
2014-01-17 17:45:14 +01:00
|
|
|
if ( info.height() < 115 ) {
|
|
|
|
info.css( 'height', '8em' );
|
2013-10-16 13:13:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var escapeHtml = function ( str ) {
|
|
|
|
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
|
|
};
|
|
|
|
|
|
|
|
// css
|
|
|
|
var cssContainer = $('div.tabs div.css');
|
2013-12-19 15:03:24 +01:00
|
|
|
if ( $.trim( cssContainer.find('code').text() ) === '' ) {
|
|
|
|
cssContainer.find('code, p:eq(0), div').css('display', 'none');
|
2013-10-16 13:13:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// init html
|
|
|
|
var table = $('<p/>').append( $('table').clone() ).html();
|
|
|
|
$('div.tabs div.table').append(
|
2013-12-19 15:03:24 +01:00
|
|
|
'<code class="multiline brush: html;">\t\t\t'+
|
2013-10-16 13:13:30 +02:00
|
|
|
escapeHtml( table )+
|
2013-12-19 15:03:24 +01:00
|
|
|
'</code>'
|
2013-10-16 13:13:30 +02:00
|
|
|
);
|
|
|
|
//SyntaxHighlighter.highlight({}, $('#display-init-html')[0]);
|
|
|
|
|
2014-01-31 14:27:42 +01:00
|
|
|
// Allow the demo code to run if DT 1.9 is used
|
|
|
|
if ( dt110 ) {
|
|
|
|
// json
|
|
|
|
var ajaxTab = $('ul.tabs li').eq(3).css('display', 'none');
|
|
|
|
|
|
|
|
$(document).on( 'init.dt', function ( e, settings ) {
|
|
|
|
var api = new $.fn.dataTable.Api( settings );
|
|
|
|
|
|
|
|
var show = function ( str ) {
|
|
|
|
ajaxTab.css( 'display', 'block' );
|
|
|
|
$('div.tabs div.ajax code').remove();
|
|
|
|
|
|
|
|
// Old IE :-|
|
|
|
|
try {
|
|
|
|
str = JSON.stringify( str, null, 2 );
|
|
|
|
} catch ( e ) {}
|
|
|
|
|
|
|
|
$('div.tabs div.ajax').append(
|
|
|
|
'<code class="multiline brush: js;">'+str+'</code>'
|
|
|
|
);
|
|
|
|
SyntaxHighlighter.highlight( {}, $('div.tabs div.ajax code')[0] );
|
|
|
|
};
|
|
|
|
|
|
|
|
// First draw
|
|
|
|
var json = api.ajax.json();
|
|
|
|
if ( json ) {
|
|
|
|
show( json );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subsequent draws
|
|
|
|
api.on( 'xhr.dt', function ( e, settings, json ) {
|
|
|
|
show( json );
|
|
|
|
} );
|
2013-10-16 13:13:30 +02:00
|
|
|
} );
|
|
|
|
|
2014-01-31 14:27:42 +01:00
|
|
|
// php
|
|
|
|
var phpTab = $('ul.tabs li').eq(4).css('display', 'none');
|
2014-01-17 17:45:14 +01:00
|
|
|
|
2014-01-31 14:27:42 +01:00
|
|
|
$(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');
|
|
|
|
}
|
2014-01-17 17:45:14 +01:00
|
|
|
|
2013-10-16 13:13:30 +02:00
|
|
|
// Tabs
|
|
|
|
$('ul.tabs li').click( function () {
|
|
|
|
$('ul.tabs li.active').removeClass('active');
|
|
|
|
$(this).addClass('active');
|
|
|
|
|
|
|
|
$('div.tabs>div')
|
|
|
|
.css('display', 'none')
|
|
|
|
.eq( $(this).index() ).css('display', 'block');
|
|
|
|
} );
|
|
|
|
$('ul.tabs li.active').click();
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
|
|
|