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