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
|
|
|
|
2015-08-12 20:48:50 +02:00
|
|
|
if ( window.$ ) {
|
|
|
|
$(document).ready( function () {
|
|
|
|
if ( ! $.fn.dataTable ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var dt110 = $.fn.dataTable.Api ? true : false;
|
|
|
|
|
|
|
|
// Work around for WebKit bug 55740
|
|
|
|
var info = $('div.info');
|
|
|
|
|
|
|
|
if ( info.height() < 115 ) {
|
|
|
|
info.css( 'min-height', '8em' );
|
|
|
|
}
|
|
|
|
|
|
|
|
var escapeHtml = function ( str ) {
|
|
|
|
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
|
|
};
|
|
|
|
|
|
|
|
// css
|
|
|
|
var cssContainer = $('div.tabs div.css');
|
|
|
|
if ( $.trim( cssContainer.find('code').text() ) === '' ) {
|
|
|
|
cssContainer.find('code, p:eq(0), div').css('display', 'none');
|
|
|
|
}
|
|
|
|
|
|
|
|
// init html
|
|
|
|
var table = $('<p/>').append( $('table').clone() ).html();
|
2020-05-21 11:29:10 +02:00
|
|
|
|
2016-12-02 18:58:11 +01:00
|
|
|
var demoHtml = $.trim( $('div.demo-html').html() );
|
|
|
|
|
|
|
|
if ( demoHtml ) {
|
|
|
|
demoHtml = demoHtml+'\n\n';
|
|
|
|
}
|
|
|
|
|
2015-08-12 20:48:50 +02:00
|
|
|
$('div.tabs div.table').append(
|
|
|
|
'<code class="multiline language-html">\t\t\t'+
|
2016-12-02 18:58:11 +01:00
|
|
|
escapeHtml( demoHtml + table )+
|
2015-08-12 20:48:50 +02:00
|
|
|
'</code>'
|
|
|
|
);
|
|
|
|
//SyntaxHighlighter.highlight({}, $('#display-init-html')[0]);
|
|
|
|
|
|
|
|
// 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 ) {
|
|
|
|
if ( e.namespace !== 'dt' ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var api = new $.fn.dataTable.Api( settings );
|
|
|
|
|
|
|
|
var show = function ( str ) {
|
|
|
|
ajaxTab.css( 'display', 'block' );
|
|
|
|
$('div.tabs div.ajax code').remove();
|
|
|
|
$('div.tabs div.ajax div.syntaxhighlighter').remove();
|
|
|
|
|
|
|
|
// Old IE :-|
|
|
|
|
try {
|
|
|
|
str = JSON.stringify( str, null, 2 );
|
|
|
|
} catch ( e ) {}
|
|
|
|
|
2020-05-21 11:29:10 +02:00
|
|
|
var strArr = str.split('\n');
|
|
|
|
|
|
|
|
if(strArr.length > 1000){
|
|
|
|
strArr.splice(999);
|
|
|
|
strArr.push('...');
|
|
|
|
str = strArr.join('\n');
|
|
|
|
}
|
|
|
|
|
2015-08-12 20:48:50 +02:00
|
|
|
$('div.tabs div.ajax').append(
|
2015-11-06 11:40:22 +01:00
|
|
|
$('<code class="multiline language-js"/>').text( str )
|
2015-08-12 20:48:50 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// This can be really slow for large builds
|
|
|
|
setTimeout( function () {
|
|
|
|
SyntaxHighlighter.highlight( {}, $('div.tabs div.ajax code')[0] );
|
|
|
|
}, 500 );
|
|
|
|
};
|
2013-10-16 13:13:30 +02:00
|
|
|
|
2015-08-12 20:48:50 +02:00
|
|
|
// First draw
|
|
|
|
var json = api.ajax.json();
|
|
|
|
if ( json ) {
|
|
|
|
show( json );
|
|
|
|
}
|
2014-01-17 17:45:14 +01:00
|
|
|
|
2015-08-12 20:48:50 +02:00
|
|
|
// Subsequent draws
|
|
|
|
api.on( 'xhr.dt', function ( e, settings, json ) {
|
|
|
|
show( json );
|
|
|
|
} );
|
|
|
|
} );
|
2015-04-03 13:22:10 +02:00
|
|
|
|
2015-08-12 20:48:50 +02:00
|
|
|
// php
|
|
|
|
var phpTab = $('ul.tabs li').eq(4).css('display', 'none');
|
|
|
|
|
|
|
|
$(document).on( 'init.dt.demoSSP', function ( e, settings ) {
|
|
|
|
if ( e.namespace !== 'dt' ) {
|
2014-01-31 14:27:42 +01:00
|
|
|
return;
|
|
|
|
}
|
2015-08-12 20:48:50 +02:00
|
|
|
|
|
|
|
if ( settings.oFeatures.bServerSide ) {
|
2020-05-21 11:25:40 +02:00
|
|
|
if ( typeof settings.ajax === 'function' ) {
|
2015-08-12 20:48:50 +02:00
|
|
|
return;
|
2014-01-31 14:27:42 +01:00
|
|
|
}
|
2015-08-12 20:48:50 +02:00
|
|
|
$.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 language-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
|
|
|
|
$('ul.tabs').on( 'click', 'li', function () {
|
|
|
|
$('ul.tabs li.active').removeClass('active');
|
|
|
|
$(this).addClass('active');
|
|
|
|
|
|
|
|
$('div.tabs>div')
|
|
|
|
.css('display', 'none')
|
|
|
|
.eq( $(this).index() ).css('display', 'block');
|
2014-01-31 14:27:42 +01:00
|
|
|
} );
|
2015-08-12 20:48:50 +02:00
|
|
|
$('ul.tabs li.active').click();
|
2013-10-16 13:13:30 +02:00
|
|
|
} );
|
2015-08-12 20:48:50 +02:00
|
|
|
}
|
2013-10-16 13:13:30 +02:00
|
|
|
|
|
|
|
|