1
- let observer = null ;
2
-
3
- function attachAllListeners ( ) {
4
- if ( observer ) {
5
- observer . disconnect ( )
1
+ window . addEventListener ( "DOMContentLoaded" , ( ) => {
2
+ var toggler = document . getElementById ( "leftToggler" ) ;
3
+ if ( toggler ) {
4
+ toggler . onclick = function ( ) {
5
+ document . getElementById ( "leftColumn" ) . classList . toggle ( "open" ) ;
6
+ } ;
6
7
}
7
8
8
9
var scrollPosition = sessionStorage . getItem ( "scroll_value" ) ;
@@ -53,89 +54,24 @@ function attachAllListeners() {
53
54
}
54
55
}
55
56
}
56
- $ ( ".side-menu span" ) . on ( "click" , function ( ) {
57
- $ ( this ) . parent ( ) . toggleClass ( "expanded" ) ;
58
- } ) ;
59
- document . querySelectorAll ( 'a' ) . forEach ( el => {
60
- const href = el . href
61
- if ( href === "" ) { return }
62
- const url = new URL ( href )
63
- el . addEventListener ( 'click' , e => {
64
- if ( url . href . replace ( "#" , "" ) === window . location . href . replace ( "#" , "" ) ) { return }
65
- if ( url . origin !== window . location . origin ) { return }
66
- if ( e . metaKey || e . ctrlKey || e . shiftKey || e . altKey || e . button !== 0 ) { return }
67
- e . preventDefault ( )
68
- e . stopPropagation ( )
69
- $ . get ( href , function ( data ) {
70
- const html = $ . parseHTML ( data )
71
- const title = html . find ( node => node . nodeName === "TITLE" ) . innerText
72
- const bodyDiv = html . find ( node => node . nodeName === "DIV" )
73
- const { children } = document . body . firstChild
74
- if ( window . history . state === null ) {
75
- window . history . replaceState ( {
76
- leftColumn : children [ 3 ] . innerHTML ,
77
- mainDiv : children [ 6 ] . innerHTML ,
78
- title : document . title ,
79
- } , '' )
80
- }
81
- document . title = title
82
- const leftColumn = bodyDiv . children [ 3 ] . innerHTML
83
- const mainDiv = bodyDiv . children [ 6 ] . innerHTML
84
- window . history . pushState ( { leftColumn, mainDiv, title } , '' , href )
85
- children [ 3 ] . innerHTML = leftColumn
86
- children [ 6 ] . innerHTML = mainDiv
87
- attachAllListeners ( )
88
- } )
89
- } )
90
- } )
91
-
92
- document . querySelectorAll ( 'a' ) . forEach ( el => {
93
- const href = el . href
94
- if ( href === "" ) { return }
95
- const url = new URL ( href )
96
- el . addEventListener ( 'click' , e => {
97
- if ( url . href . replace ( "#" , "" ) === window . location . href . replace ( "#" , "" ) ) { return }
98
- if ( url . origin !== window . location . origin ) { return }
99
- if ( e . metaKey || e . ctrlKey || e . shiftKey || e . altKey || e . button !== 0 ) { return }
100
- e . preventDefault ( )
101
- e . stopPropagation ( )
102
- $ . get ( href , function ( data ) {
103
- const html = $ . parseHTML ( data )
104
- const title = html . find ( node => node . nodeName === "TITLE" ) . innerText
105
- const bodyDiv = html . find ( node => node . nodeName === "DIV" )
106
- const { children } = document . body . firstChild
107
- if ( window . history . state === null ) {
108
- window . history . replaceState ( {
109
- leftColumn : children [ 3 ] . innerHTML ,
110
- mainDiv : children [ 6 ] . innerHTML ,
111
- title : document . title ,
112
- } , '' )
113
- }
114
- document . title = title
115
- const leftColumn = bodyDiv . children [ 3 ] . innerHTML
116
- const mainDiv = bodyDiv . children [ 6 ] . innerHTML
117
- window . history . pushState ( { leftColumn, mainDiv, title } , '' , href )
118
- children [ 3 ] . innerHTML = leftColumn
119
- children [ 6 ] . innerHTML = mainDiv
120
- attachAllListeners ( )
121
- } )
122
- } )
123
- } )
57
+
58
+ $ ( ".side-menu span" ) . on ( "click" , function ( ) {
59
+ $ ( this ) . parent ( ) . toggleClass ( "expanded" ) ;
60
+ } ) ;
124
61
125
62
$ ( ".ar" ) . on ( "click" , function ( e ) {
126
63
$ ( this ) . parent ( ) . parent ( ) . toggleClass ( "expanded" ) ;
127
64
$ ( this ) . toggleClass ( "expanded" ) ;
128
65
e . stopPropagation ( ) ;
129
66
} ) ;
130
67
131
- document . querySelectorAll ( ".nh" ) . forEach ( el => el . addEventListener ( 'click' , ( ) => {
132
- if ( el . lastChild . href . replace ( "#" , "" ) === window . location . href . replace ( "#" , "" ) ) {
133
- el . parentElement . classList . toggle ( "expanded" )
134
- el . firstChild . classList . toggle ( "expanded" )
135
- } else {
136
- el . lastChild . click ( )
137
- }
138
- } ) )
68
+ document . querySelectorAll ( ".nh" ) . forEach ( ( el ) =>
69
+ el . addEventListener ( "click" , ( ) => {
70
+ el . lastChild . click ( ) ;
71
+ el . first . addClass ( "expanded" ) ;
72
+ el . parent . addClass ( "expanded" ) ;
73
+ } ) ,
74
+ ) ;
139
75
140
76
document . querySelectorAll ( ".supertypes" ) . forEach ( ( el ) =>
141
77
el . firstChild . addEventListener ( "click" , ( ) => {
@@ -168,128 +104,154 @@ function attachAllListeners() {
168
104
} ) ,
169
105
) ;
170
106
171
- const observer = new IntersectionObserver ( entries => {
172
- entries . forEach ( entry => {
173
- const id = entry . target . getAttribute ( 'id' ) ;
107
+ const observer = new IntersectionObserver ( ( entries ) => {
108
+ entries . forEach ( ( entry ) => {
109
+ const id = entry . target . getAttribute ( "id" ) ;
174
110
if ( entry . intersectionRatio > 0 ) {
175
- document . querySelector ( `#toc li a[href="#${ id } "]` ) . parentElement . classList . add ( 'active' ) ;
111
+ document
112
+ . querySelector ( `#toc li a[href="#${ id } "]` )
113
+ . parentElement . classList . add ( "active" ) ;
176
114
} else {
177
- document . querySelector ( `#toc li a[href="#${ id } "]` ) . parentElement . classList . remove ( 'active' ) ;
115
+ document
116
+ . querySelector ( `#toc li a[href="#${ id } "]` )
117
+ . parentElement . classList . remove ( "active" ) ;
178
118
}
179
119
} ) ;
180
120
} ) ;
181
121
182
- document . querySelectorAll ( ' #content section[id]' ) . forEach ( ( section ) => {
122
+ document . querySelectorAll ( " #content section[id]" ) . forEach ( ( section ) => {
183
123
observer . observe ( section ) ;
184
124
} ) ;
185
125
126
+ document
127
+ . querySelectorAll ( ".side-menu a" )
128
+ . forEach ( ( elem ) =>
129
+ elem . addEventListener ( "click" , ( e ) => e . stopPropagation ( ) ) ,
130
+ ) ;
131
+
186
132
if ( location . hash ) {
187
133
var target = location . hash . substring ( 1 ) ;
188
134
// setting the 'expand' class on the top-level container causes undesireable styles
189
135
// to apply to the top-level docs, so we avoid this logic for that element.
190
- if ( target != ' container' ) {
136
+ if ( target != " container" ) {
191
137
var selected = document . getElementById ( location . hash . substring ( 1 ) ) ;
192
138
if ( selected ) {
193
139
selected . classList . toggle ( "expand" ) ;
194
140
}
195
141
}
196
142
}
197
143
198
- document . querySelectorAll ( 'pre code' ) . forEach ( el => {
199
- hljs . highlightBlock ( el ) ;
144
+ var logo = document . getElementById ( "logo" ) ;
145
+ if ( logo ) {
146
+ logo . onclick = function ( ) {
147
+ window . location = pathToRoot ; // global variable pathToRoot is created by the html renderer
148
+ } ;
149
+ }
150
+
151
+ document . querySelectorAll ( ".documentableAnchor" ) . forEach ( ( elem ) => {
152
+ elem . addEventListener ( "click" , ( event ) => {
153
+ var $temp = $ ( "<input>" ) ;
154
+ $ ( "body" ) . append ( $temp ) ;
155
+ var a = document . createElement ( "a" ) ;
156
+ a . href = $ ( elem ) . attr ( "link" ) ;
157
+ $temp . val ( a . href ) . select ( ) ;
158
+ document . execCommand ( "copy" ) ;
159
+ $temp . remove ( ) ;
160
+ } ) ;
200
161
} ) ;
201
162
163
+ hljs . registerLanguage ( "scala" , highlightDotty ) ;
164
+ hljs . registerAliases ( [ "dotty" , "scala3" ] , "scala" ) ;
165
+ hljs . initHighlighting ( ) ;
166
+
202
167
/* listen for the `F` key to be pressed, to focus on the member filter input (if it's present) */
203
- document . body . addEventListener ( ' keydown' , e => {
168
+ document . body . addEventListener ( " keydown" , ( e ) => {
204
169
if ( e . key == "f" ) {
205
170
const tag = e . target . tagName ;
206
171
if ( tag != "INPUT" && tag != "TEXTAREA" ) {
207
- const filterInput = findRef ( '.documentableFilter input.filterableInput' ) ;
172
+ const filterInput = findRef (
173
+ ".documentableFilter input.filterableInput" ,
174
+ ) ;
208
175
if ( filterInput != null ) {
209
176
// if we focus during this event handler, the `f` key gets typed into the input
210
177
setTimeout ( ( ) => filterInput . focus ( ) , 1 ) ;
211
178
}
212
179
}
213
180
}
214
- } )
181
+ } ) ;
215
182
216
- // when document is loaded graph needs to be shown
217
- }
183
+ // show/hide side menu on mobile view
184
+ const sideMenuToggler = document . getElementById ( "mobile-sidebar-toggle" ) ;
185
+ sideMenuToggler . addEventListener ( "click" , ( _e ) => {
186
+ document . getElementById ( "leftColumn" ) . classList . toggle ( "show" ) ;
187
+ document . getElementById ( "content" ) . classList . toggle ( "sidebar-shown" ) ;
188
+ const toc = document . getElementById ( "toc" ) ;
189
+ if ( toc ) {
190
+ toc . classList . toggle ( "sidebar-shown" ) ;
191
+ }
192
+ sideMenuToggler . classList . toggle ( "menu-shown" ) ;
193
+ } ) ;
218
194
219
- window . addEventListener ( "DOMContentLoaded" , ( ) => {
220
- hljs . registerLanguage ( "scala" , highlightDotty ) ;
221
- hljs . registerAliases ( [ "dotty" , "scala3" ] , "scala" ) ;
222
- attachAllListeners ( )
223
- } ) ;
195
+ // show/hide mobile menu on mobile view
196
+ const mobileMenuOpenIcon = document . getElementById ( "mobile-menu-toggle" ) ;
197
+ const mobileMenuCloseIcon = document . getElementById ( "mobile-menu-close" ) ;
198
+ mobileMenuOpenIcon . addEventListener ( "click" , ( _e ) => {
199
+ document . getElementById ( "mobile-menu" ) . classList . add ( "show" ) ;
200
+ } ) ;
201
+ mobileMenuCloseIcon . addEventListener ( "click" , ( _e ) => {
202
+ document . getElementById ( "mobile-menu" ) . classList . remove ( "show" ) ;
203
+ } ) ;
224
204
225
- // show/hide side menu on mobile view
226
- const sideMenuToggler = document . getElementById ( "mobile-sidebar-toggle" )
227
- sideMenuToggler . addEventListener ( 'click' , _e => {
228
- document . getElementById ( "leftColumn" ) . classList . toggle ( "show" )
229
- document . getElementById ( "content" ) . classList . toggle ( "sidebar-shown" )
230
- const toc = document . getElementById ( "toc" ) ;
231
- if ( toc && toc . childElementCount > 0 ) {
232
- toc . classList . toggle ( "sidebar-shown" )
233
- }
234
- sideMenuToggler . classList . toggle ( "menu-shown" )
235
- } )
236
-
237
- // show/hide mobile menu on mobile view
238
- document . getElementById ( "mobile-menu-toggle" ) . addEventListener ( 'click' , _e => {
239
- document . getElementById ( "mobile-menu" ) . classList . add ( "show" )
240
- } )
241
- document . getElementById ( "mobile-menu-close" ) . addEventListener ( 'click' , _e => {
242
- document . getElementById ( "mobile-menu" ) . classList . remove ( "show" )
243
- } )
244
-
245
- window . addEventListener ( 'popstate' , e => {
246
- const { leftColumn, mainDiv, title } = e . state
247
- document . title = title
248
- const { children } = document . body . firstChild
249
- children [ 3 ] . innerHTML = leftColumn
250
- children [ 6 ] . innerHTML = mainDiv
251
- attachAllListeners ( )
252
- } )
205
+ // when document is loaded graph needs to be shown
206
+ } ) ;
253
207
254
208
var zoom ;
255
209
var transform ;
256
210
257
211
function showGraph ( ) {
258
- document . getElementById ( "inheritance-diagram" ) . classList . add ( "shown" )
212
+ document . getElementById ( "inheritance-diagram" ) . classList . add ( "shown" ) ;
259
213
if ( $ ( "svg#graph" ) . children ( ) . length == 0 ) {
260
- var dotNode = document . querySelector ( "#dot" )
214
+ var dotNode = document . querySelector ( "#dot" ) ;
261
215
262
216
if ( dotNode ) {
263
217
var svg = d3 . select ( "#graph" ) ;
264
- var radialGradient = svg . append ( "defs" ) . append ( "radialGradient" ) . attr ( "id" , "Gradient" ) ;
265
- radialGradient . append ( "stop" ) . attr ( "stop-color" , "var(--yellow9)" ) . attr ( "offset" , "30%" ) ;
266
- radialGradient . append ( "stop" ) . attr ( "stop-color" , "var(--background-default)" ) . attr ( "offset" , "100%" ) ;
218
+ var radialGradient = svg
219
+ . append ( "defs" )
220
+ . append ( "radialGradient" )
221
+ . attr ( "id" , "Gradient" ) ;
222
+ radialGradient
223
+ . append ( "stop" )
224
+ . attr ( "stop-color" , "var(--yellow9)" )
225
+ . attr ( "offset" , "30%" ) ;
226
+ radialGradient
227
+ . append ( "stop" )
228
+ . attr ( "stop-color" , "var(--background-default)" )
229
+ . attr ( "offset" , "100%" ) ;
267
230
268
231
var inner = svg . append ( "g" ) ;
269
232
270
233
// Set up zoom support
271
- zoom = d3 . zoom ( )
272
- . on ( "zoom" , function ( { transform } ) {
273
- inner . attr ( "transform" , transform ) ;
274
- } ) ;
234
+ zoom = d3 . zoom ( ) . on ( "zoom" , function ( { transform } ) {
235
+ inner . attr ( "transform" , transform ) ;
236
+ } ) ;
275
237
svg . call ( zoom ) ;
276
238
277
239
var render = new dagreD3 . render ( ) ;
278
240
var g = graphlibDot . read ( dotNode . text ) ;
279
- g . graph ( ) . rankDir = 'BT' ;
241
+ g . graph ( ) . rankDir = "BT" ;
280
242
g . nodes ( ) . forEach ( function ( v ) {
281
243
g . setNode ( v , {
282
244
labelType : "html" ,
283
245
label : g . node ( v ) . label ,
284
246
class : g . node ( v ) . class ,
285
247
id : g . node ( v ) . id ,
286
248
rx : "4px" ,
287
- ry : "4px"
249
+ ry : "4px" ,
288
250
} ) ;
289
251
} ) ;
290
252
g . setNode ( "node0Cluster" , {
291
253
style : "fill: url(#Gradient);" ,
292
- id : "node0Cluster"
254
+ id : "node0Cluster" ,
293
255
} ) ;
294
256
g . setParent ( "node0" , "node0Cluster" ) ;
295
257
@@ -300,7 +262,8 @@ function showGraph() {
300
262
} ) ;
301
263
302
264
render . arrows ( ) . hollowPoint = function normal ( parent , id , edge , type ) {
303
- var marker = parent . append ( "marker" )
265
+ var marker = parent
266
+ . append ( "marker" )
304
267
. attr ( "id" , id )
305
268
. attr ( "viewBox" , "0 0 10 10" )
306
269
. attr ( "refX" , 9 )
@@ -310,7 +273,8 @@ function showGraph() {
310
273
. attr ( "markerHeight" , 12 )
311
274
. attr ( "orient" , "auto" ) ;
312
275
313
- var path = marker . append ( "path" )
276
+ var path = marker
277
+ . append ( "path" )
314
278
. attr ( "d" , "M 0 0 L 10 5 L 0 10 z" )
315
279
. style ( "stroke-width" , 1 )
316
280
. style ( "stroke-dasharray" , "1,0" )
@@ -332,7 +296,10 @@ function showGraph() {
332
296
midY = bounds . y + height / 2 ;
333
297
if ( width == 0 || height == 0 ) return ; // nothing to fit
334
298
var scale = Math . min ( fullWidth / width , fullHeight / height ) * 0.99 ; // 0.99 to make a little padding
335
- var translate = [ fullWidth / 2 - scale * midX , fullHeight / 2 - scale * midY ] ;
299
+ var translate = [
300
+ fullWidth / 2 - scale * midX ,
301
+ fullHeight / 2 - scale * midY ,
302
+ ] ;
336
303
337
304
transform = d3 . zoomIdentity
338
305
. translate ( translate [ 0 ] , translate [ 1 ] )
@@ -346,22 +313,25 @@ function showGraph() {
346
313
var node0Cluster = d3 . select ( "g#node0Cluster" ) . _groups [ 0 ] [ 0 ] ;
347
314
var node0ClusterRect = node0Cluster . children [ 0 ] ;
348
315
node0Cluster . setAttribute ( "transform" , node0 . getAttribute ( "transform" ) ) ;
349
- node0ClusterRect . setAttribute ( "width" , + node0Rect . getAttribute ( "width" ) + 80 ) ;
350
- node0ClusterRect . setAttribute ( "height" , + node0Rect . getAttribute ( "height" ) + 80 ) ;
316
+ node0ClusterRect . setAttribute (
317
+ "width" ,
318
+ + node0Rect . getAttribute ( "width" ) + 80 ,
319
+ ) ;
320
+ node0ClusterRect . setAttribute (
321
+ "height" ,
322
+ + node0Rect . getAttribute ( "height" ) + 80 ,
323
+ ) ;
351
324
node0ClusterRect . setAttribute ( "x" , node0Rect . getAttribute ( "x" ) - 40 ) ;
352
325
node0ClusterRect . setAttribute ( "y" , node0Rect . getAttribute ( "y" ) - 40 ) ;
353
326
}
354
327
}
355
328
}
356
329
357
330
function hideGraph ( ) {
358
- document . getElementById ( "inheritance-diagram" ) . classList . remove ( "shown" )
331
+ document . getElementById ( "inheritance-diagram" ) . classList . remove ( "shown" ) ;
359
332
}
360
333
361
334
function zoomOut ( ) {
362
335
var svg = d3 . select ( "#graph" ) ;
363
- svg
364
- . transition ( )
365
- . duration ( 2000 )
366
- . call ( zoom . transform , transform ) ;
336
+ svg . transition ( ) . duration ( 2000 ) . call ( zoom . transform , transform ) ;
367
337
}
0 commit comments