88 */
99
1010/* Provide console simulation for firebug-less environments */
11+ /*
1112if (!("console" in window) || !("firebug" in console)) {
1213 var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
1314 "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
@@ -16,41 +17,35 @@ if (!("console" in window) || !("firebug" in console)) {
1617 for (var i = 0; i < names.length; ++i)
1718 window.console[names[i]] = function() {};
1819};
19-
20-
21- /**
22- * Unwrap the first element that matches the given @expr@ from the targets and return them.
23- */
24- $ . fn . unwrap = function ( expr ) {
25- return this . each ( function ( ) {
26- $ ( this ) . parents ( expr ) . eq ( 0 ) . after ( this ) . remove ( ) ;
27- } ) ;
28- } ;
20+ */
2921
3022
3123function showSource ( e ) {
3224 var target = e . target ;
33- var codeSections = $ ( target ) .
34- parents ( '.method-detail' ) .
35- find ( '.method-source-code' ) ;
36-
37- $ ( target ) .
38- parents ( '.method-detail' ) .
39- find ( '.method-source-code' ) .
40- slideToggle ( ) ;
25+ while ( ! target . classList . contains ( 'method-detail' ) ) {
26+ target = target . parentNode ;
27+ }
28+ if ( typeof target !== "undefined" && target !== null ) {
29+ target = target . querySelector ( '.method-source-code' ) ;
30+ }
31+ if ( typeof target !== "undefined" && target !== null ) {
32+ target . classList . toggle ( 'active-menu' )
33+ }
4134} ;
4235
4336function hookSourceViews ( ) {
44- $ ( '.method-heading' ) . click ( showSource ) ;
37+ document . querySelectorAll ( '.method-heading' ) . forEach ( function ( codeObject ) {
38+ codeObject . addEventListener ( 'click' , showSource ) ;
39+ } ) ;
4540} ;
4641
4742function hookSearch ( ) {
48- var input = $ ( '#search-field' ) . eq ( 0 ) ;
49- var result = $ ( '#search-results' ) . eq ( 0 ) ;
50- $ ( result ) . show ( ) ;
43+ var input = document . querySelector ( '#search-field' ) ;
44+ var result = document . querySelector ( '#search-results' ) ;
45+ result . classList . remove ( "initially-hidden" ) ;
5146
52- var search_section = $ ( '#search-section' ) . get ( 0 ) ;
53- $ ( search_section ) . show ( ) ;
47+ var search_section = document . querySelector ( '#search-section' ) ;
48+ search_section . classList . remove ( "initially-hidden" ) ;
5449
5550 var search = new Search ( search_data , input , result ) ;
5651
@@ -77,85 +72,14 @@ function hookSearch() {
7772 }
7873
7974 search . select = function ( result ) {
80- var result_element = result . get ( 0 ) ;
81- window . location . href = result_element . firstChild . firstChild . href ;
75+ console . log ( result ) ;
76+ window . location . href = result . firstChild . firstChild . href ;
8277 }
8378
8479 search . scrollIntoView = search . scrollInWindow ;
8580} ;
8681
87- function highlightTarget ( anchor ) {
88- console . debug ( "Highlighting target '%s'." , anchor ) ;
89-
90- $ ( "a[name]" ) . each ( function ( ) {
91- if ( $ ( this ) . attr ( "name" ) == anchor ) {
92- if ( ! $ ( this ) . parent ( ) . parent ( ) . hasClass ( 'target-section' ) ) {
93- console . debug ( "Wrapping the target-section" ) ;
94- $ ( 'div.method-detail' ) . unwrap ( 'div.target-section' ) ;
95- $ ( this ) . parent ( ) . wrap ( '<div class="target-section"></div>' ) ;
96- } else {
97- console . debug ( "Already wrapped." ) ;
98- }
99- }
100- } ) ;
101- } ;
102-
103- function highlightLocationTarget ( ) {
104- console . debug ( "Location hash: %s" , window . location . hash ) ;
105- if ( ! window . location . hash || window . location . hash . length == 0 ) return ;
106-
107- var anchor = window . location . hash . substring ( 1 ) ;
108- console . debug ( "Found anchor: %s; matching %s" , anchor , "a[name=" + anchor + "]" ) ;
109-
110- highlightTarget ( anchor ) ;
111- } ;
112-
113- function highlightClickTarget ( event ) {
114- console . debug ( "Highlighting click target for event %o" , event . target ) ;
115- try {
116- var anchor = $ ( event . target ) . attr ( 'href' ) . substring ( 1 ) ;
117- console . debug ( "Found target anchor: %s" , anchor ) ;
118- highlightTarget ( anchor ) ;
119- } catch ( err ) {
120- console . error ( "Exception while highlighting: %o" , err ) ;
121- } ;
122- } ;
123-
124- function loadAsync ( path , success , prefix ) {
125- $ . ajax ( {
126- url : prefix + path ,
127- dataType : 'script' ,
128- success : success ,
129- cache : true
130- } ) ;
131- } ;
132-
133- $ ( document ) . ready ( function ( ) {
82+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
13483 hookSourceViews ( ) ;
135- highlightLocationTarget ( ) ;
136- $ ( 'ul.link-list a' ) . bind ( "click" , highlightClickTarget ) ;
137-
138- var search_scripts_loaded = {
139- navigation_loaded : false ,
140- search_loaded : false ,
141- search_index_loaded : false ,
142- searcher_loaded : false ,
143- }
144-
145- var search_success_function = function ( variable ) {
146- return ( function ( data , status , xhr ) {
147- search_scripts_loaded [ variable ] = true ;
148-
149- if ( search_scripts_loaded [ 'navigation_loaded' ] == true &&
150- search_scripts_loaded [ 'search_loaded' ] == true &&
151- search_scripts_loaded [ 'search_index_loaded' ] == true &&
152- search_scripts_loaded [ 'searcher_loaded' ] == true )
153- hookSearch ( ) ;
154- } ) ;
155- }
156-
157- loadAsync ( 'js/navigation.js' , search_success_function ( 'navigation_loaded' ) , rdoc_rel_prefix ) ;
158- loadAsync ( 'js/search.js' , search_success_function ( 'search_loaded' ) , rdoc_rel_prefix ) ;
159- loadAsync ( 'js/search_index.js' , search_success_function ( 'search_index_loaded' ) , index_rel_prefix ) ;
160- loadAsync ( 'js/searcher.js' , search_success_function ( 'searcher_loaded' ) , rdoc_rel_prefix ) ;
84+ hookSearch ( ) ;
16185} ) ;
0 commit comments