8
8
*/
9
9
10
10
/* Provide console simulation for firebug-less environments */
11
+ /*
11
12
if (!("console" in window) || !("firebug" in console)) {
12
13
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
13
14
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
@@ -16,41 +17,35 @@ if (!("console" in window) || !("firebug" in console)) {
16
17
for (var i = 0; i < names.length; ++i)
17
18
window.console[names[i]] = function() {};
18
19
};
19
-
20
-
21
- /**
22
- * Unwrap the first element that matches the given @expr@ from the targets and return them.
23
20
*/
24
- $ . fn . unwrap = function ( expr ) {
25
- return this . each ( function ( ) {
26
- $ ( this ) . parents ( expr ) . eq ( 0 ) . after ( this ) . remove ( ) ;
27
- } ) ;
28
- } ;
29
21
30
22
31
23
function showSource ( e ) {
32
24
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
+ }
41
34
} ;
42
35
43
36
function hookSourceViews ( ) {
44
- $ ( '.method-heading' ) . click ( showSource ) ;
37
+ document . querySelectorAll ( '.method-heading' ) . forEach ( function ( codeObject ) {
38
+ codeObject . addEventListener ( 'click' , showSource ) ;
39
+ } ) ;
45
40
} ;
46
41
47
42
function 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" ) ;
51
46
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" ) ;
54
49
55
50
var search = new Search ( search_data , input , result ) ;
56
51
@@ -77,85 +72,14 @@ function hookSearch() {
77
72
}
78
73
79
74
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 ;
82
77
}
83
78
84
79
search . scrollIntoView = search . scrollInWindow ;
85
80
} ;
86
81
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 ( ) {
134
83
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
84
hookSearch ( ) ;
154
85
} ) ;
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 ) ;
161
- } ) ;
0 commit comments