blob: d2d704dc4dcdf2d33b9607675625a1d29f66e3db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
( function( $, undefined ) {
var gistStylesheetLoaded = false,
gistEmbed = function() {
$( '.gist-oembed' ).each( function( i, el ) {
var url = 'https://gist.github.com/' + $( el ).data( 'gist' ),
ts = Number.parseInt( $( el ).data( 'ts' ), 10 );
$.ajax( {
url: url,
dataType: 'jsonp',
} ).done( function( response ) {
if ( ts && 8 !== ts ) {
$( el ).replaceWith( $( response.div ).css( 'tab-size', ts.toString() ) );
} else {
$( el ).replaceWith( response.div );
}
if ( ! gistStylesheetLoaded ) {
var stylesheet =
'<link rel="stylesheet" href="' + response.stylesheet + '" type="text/css" />';
$( 'head' ).append( stylesheet );
gistStylesheetLoaded = true;
}
} );
} );
};
$( document ).ready( gistEmbed );
$( 'body' ).on( 'post-load', gistEmbed );
} )( jQuery );
|