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 () {
|
|
|
|
// Work around for WebKit bug 55740
|
|
|
|
var info = $('div.info');
|
|
|
|
|
2013-12-19 15:04:14 +01:00
|
|
|
if ( info.height() < 158 ) {
|
|
|
|
info.css( 'height', '11em' );
|
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]);
|
|
|
|
|
|
|
|
// json
|
|
|
|
var ajaxTab = $('ul.tabs li').eq(3).css('display', 'none');
|
|
|
|
|
2013-11-18 12:46:27 +01:00
|
|
|
$(document).on( 'init.dt', function ( e, settings ) {
|
2013-10-16 13:13:30 +02:00
|
|
|
var api = new $.fn.dataTable.Api( settings );
|
|
|
|
|
|
|
|
var show = function ( str ) {
|
|
|
|
ajaxTab.css( 'display', 'block' );
|
2013-12-19 15:03:24 +01:00
|
|
|
$('div.tabs div.ajax code').remove();
|
2013-10-16 13:13:30 +02:00
|
|
|
|
|
|
|
// Old IE :-|
|
|
|
|
try {
|
|
|
|
str = JSON.stringify( str, null, 2 );
|
|
|
|
} catch ( e ) {}
|
|
|
|
|
|
|
|
$('div.tabs div.ajax').append(
|
2013-12-19 15:03:24 +01:00
|
|
|
'<code class="multiline brush: js;">'+str+'</code>'
|
2013-10-16 13:13:30 +02:00
|
|
|
);
|
2013-12-19 15:03:24 +01:00
|
|
|
SyntaxHighlighter.highlight( {}, $('div.tabs div.ajax code')[0] );
|
2013-10-16 13:13:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// First draw
|
|
|
|
var json = api.ajax.json();
|
|
|
|
if ( json ) {
|
|
|
|
show( json );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Subsequent draws
|
2013-11-18 12:46:27 +01:00
|
|
|
api.on( 'xhr.dt', function ( e, settings, json ) {
|
2013-10-16 13:13:30 +02:00
|
|
|
show( json );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
|
|
|