| 9 |
lars |
1 |
|
|
|
2 |
/*global SyntaxHighlighter*/
|
|
|
3 |
SyntaxHighlighter.config.tagName = 'code';
|
|
|
4 |
|
|
|
5 |
if ( window.$ ) {
|
|
|
6 |
$(document).ready( function () {
|
|
|
7 |
if ( ! $.fn.dataTable ) {
|
|
|
8 |
return;
|
|
|
9 |
}
|
|
|
10 |
var dt110 = $.fn.dataTable.Api ? true : false;
|
|
|
11 |
|
|
|
12 |
// Work around for WebKit bug 55740
|
|
|
13 |
var info = $('div.info');
|
|
|
14 |
|
|
|
15 |
if ( info.height() < 115 ) {
|
|
|
16 |
info.css( 'min-height', '8em' );
|
|
|
17 |
}
|
|
|
18 |
|
|
|
19 |
var escapeHtml = function ( str ) {
|
|
|
20 |
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
|
21 |
};
|
|
|
22 |
|
|
|
23 |
// css
|
|
|
24 |
var cssContainer = $('div.tabs div.css');
|
|
|
25 |
if ( $.trim( cssContainer.find('code').text() ) === '' ) {
|
|
|
26 |
cssContainer.find('code, p:eq(0), div').css('display', 'none');
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
// init html
|
|
|
30 |
var table = $('<p/>').append( $('table').clone() ).html();
|
|
|
31 |
$('div.tabs div.table').append(
|
|
|
32 |
'<code class="multiline language-html">\t\t\t'+
|
|
|
33 |
escapeHtml( table )+
|
|
|
34 |
'</code>'
|
|
|
35 |
);
|
|
|
36 |
//SyntaxHighlighter.highlight({}, $('#display-init-html')[0]);
|
|
|
37 |
|
|
|
38 |
// Allow the demo code to run if DT 1.9 is used
|
|
|
39 |
if ( dt110 ) {
|
|
|
40 |
// json
|
|
|
41 |
var ajaxTab = $('ul.tabs li').eq(3).css('display', 'none');
|
|
|
42 |
|
|
|
43 |
$(document).on( 'init.dt', function ( e, settings ) {
|
|
|
44 |
if ( e.namespace !== 'dt' ) {
|
|
|
45 |
return;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
var api = new $.fn.dataTable.Api( settings );
|
|
|
49 |
|
|
|
50 |
var show = function ( str ) {
|
|
|
51 |
ajaxTab.css( 'display', 'block' );
|
|
|
52 |
$('div.tabs div.ajax code').remove();
|
|
|
53 |
$('div.tabs div.ajax div.syntaxhighlighter').remove();
|
|
|
54 |
|
|
|
55 |
// Old IE :-|
|
|
|
56 |
try {
|
|
|
57 |
str = JSON.stringify( str, null, 2 );
|
|
|
58 |
} catch ( e ) {}
|
|
|
59 |
|
|
|
60 |
$('div.tabs div.ajax').append(
|
|
|
61 |
'<code class="multiline language-js">'+str+'</code>'
|
|
|
62 |
);
|
|
|
63 |
|
|
|
64 |
// This can be really slow for large builds
|
|
|
65 |
setTimeout( function () {
|
|
|
66 |
SyntaxHighlighter.highlight( {}, $('div.tabs div.ajax code')[0] );
|
|
|
67 |
}, 500 );
|
|
|
68 |
};
|
|
|
69 |
|
|
|
70 |
// First draw
|
|
|
71 |
var json = api.ajax.json();
|
|
|
72 |
if ( json ) {
|
|
|
73 |
show( json );
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
// Subsequent draws
|
|
|
77 |
api.on( 'xhr.dt', function ( e, settings, json ) {
|
|
|
78 |
show( json );
|
|
|
79 |
} );
|
|
|
80 |
} );
|
|
|
81 |
|
|
|
82 |
// php
|
|
|
83 |
var phpTab = $('ul.tabs li').eq(4).css('display', 'none');
|
|
|
84 |
|
|
|
85 |
$(document).on( 'init.dt.demoSSP', function ( e, settings ) {
|
|
|
86 |
if ( e.namespace !== 'dt' ) {
|
|
|
87 |
return;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
if ( settings.oFeatures.bServerSide ) {
|
|
|
91 |
if ( $.isFunction( settings.ajax ) ) {
|
|
|
92 |
return;
|
|
|
93 |
}
|
|
|
94 |
$.ajax( {
|
|
|
95 |
url: '../resources/examples.php',
|
|
|
96 |
data: {
|
|
|
97 |
src: settings.sAjaxSource || settings.ajax.url || settings.ajax
|
|
|
98 |
},
|
|
|
99 |
dataType: 'text',
|
|
|
100 |
type: 'post',
|
|
|
101 |
success: function ( txt ) {
|
|
|
102 |
phpTab.css( 'display', 'block' );
|
|
|
103 |
$('div.tabs div.php').append(
|
|
|
104 |
'<code class="multiline language-php">'+txt+'</code>'
|
|
|
105 |
);
|
|
|
106 |
SyntaxHighlighter.highlight( {}, $('div.tabs div.php code')[0] );
|
|
|
107 |
}
|
|
|
108 |
} );
|
|
|
109 |
}
|
|
|
110 |
} );
|
|
|
111 |
}
|
|
|
112 |
else {
|
|
|
113 |
$('ul.tabs li').eq(3).css('display', 'none');
|
|
|
114 |
$('ul.tabs li').eq(4).css('display', 'none');
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
// Tabs
|
|
|
118 |
$('ul.tabs').on( 'click', 'li', function () {
|
|
|
119 |
$('ul.tabs li.active').removeClass('active');
|
|
|
120 |
$(this).addClass('active');
|
|
|
121 |
|
|
|
122 |
$('div.tabs>div')
|
|
|
123 |
.css('display', 'none')
|
|
|
124 |
.eq( $(this).index() ).css('display', 'block');
|
|
|
125 |
} );
|
|
|
126 |
$('ul.tabs li.active').click();
|
|
|
127 |
} );
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
|