1+ ( function ( ) {
2+ var cx = '003552815484763729059:feruzu5o53s' ;
3+ var gcse = document . createElement ( 'script' ) ;
4+ gcse . type = 'text/javascript' ;
5+ gcse . async = true ;
6+ gcse . src = 'https://cse.google.com/cse.js?cx=' + cx ;
7+ var s = document . getElementsByTagName ( 'script' ) [ 0 ] ;
8+ s . parentNode . insertBefore ( gcse , s ) ;
9+ } ) ( ) ;
10+ window . onload = function ( ) {
11+ document . getElementById ( 'gsc-i-id1' ) . placeholder = 'Search Bonsai Docs' ;
12+
13+ $ ( "td.gsc-search-button" ) . empty ( ) . html ( '<input type="image" src="https://dl.dropboxusercontent.com/s/l4e4aa6s5t9m4xx/search.svg?dl=0" class="gsc-search-button gsc-search-button-v2 svg" title="search">' ) ;
14+
15+ } ;
16+
17+ $ ( function ( ) {
18+ jQuery ( 'img.svg' ) . each ( function ( ) {
19+ var $img = jQuery ( this ) ;
20+ var imgID = $img . attr ( 'id' ) ;
21+ var imgClass = $img . attr ( 'class' ) ;
22+ var imgURL = $img . attr ( 'src' ) ;
23+
24+ jQuery . get ( imgURL , function ( data ) {
25+ // Get the SVG tag, ignore the rest
26+ var $svg = jQuery ( data ) . find ( 'svg' ) ;
27+
28+ // Add replaced image's ID to the new SVG
29+ if ( typeof imgID !== 'undefined' ) {
30+ $svg = $svg . attr ( 'id' , imgID ) ;
31+ }
32+ // Add replaced image's classes to the new SVG
33+ if ( typeof imgClass !== 'undefined' ) {
34+ $svg = $svg . attr ( 'class' , imgClass + ' replaced-svg' ) ;
35+ }
36+
37+ // Remove any invalid XML tags as per http://validator.w3.org
38+ $svg = $svg . removeAttr ( 'xmlns:a' ) ;
39+
40+ // Check if the viewport is set, else we gonna set it if we can.
41+ if ( ! $svg . attr ( 'viewBox' ) && $svg . attr ( 'height' ) && $svg . attr ( 'width' ) ) {
42+ $svg . attr ( 'viewBox' , '0 0 ' + $svg . attr ( 'height' ) + ' ' + $svg . attr ( 'width' ) )
43+ }
44+
45+ // Replace image with new SVG
46+ $img . replaceWith ( $svg ) ;
47+
48+ } , 'xml' ) ;
49+
50+ } ) ;
51+ } ) ;
52+
0 commit comments