@@ -106,10 +106,9 @@ require(['jquery', 'bootstrap.modal', 'svg-pan-zoom', 'hammerjs', 'jquery.svg'],
106
106
loadURL : $ ( "#graph" ) . attr ( "data-svgurl" ) ,
107
107
onLoad : enablePanZoom
108
108
} ) ;
109
- $ ( "#graphFullscreen" ) . svg ( {
110
- loadURL : $ ( "#graph" ) . attr ( "data-svgurl" ) ,
111
- onLoad : enablePanZoom
112
- } ) ;
109
+ /*$("#graphFullscreen").svg({
110
+ loadURL: $("#graph").attr("data-svgurl")
111
+ });*/
113
112
114
113
/**
115
114
* Enable svg-pan-zoom on the graph
@@ -288,7 +287,7 @@ require(['jquery', 'jquery.svg', 'jquery.svgdom'],
288
287
// Find corresponding table row and return
289
288
return $ ( "tr" ) . filter ( function ( ) {
290
289
return $ ( this ) . find ( "td:first" ) . html ( ) == elementTitle ;
291
- } ) . add ( ) ;
290
+ } ) ;
292
291
}
293
292
294
293
/**
@@ -312,6 +311,73 @@ require(['jquery', 'jquery.svg', 'jquery.svgdom'],
312
311
$ ( this ) . find ( "polygon" ) . removeClass ( "hover" ) ;
313
312
}
314
313
} , ".node" ) ;
314
+
315
+ /**
316
+ * Stores an in+outlist style graph structure
317
+ * Generated at time of first use
318
+ */
319
+ var graphModel = { } ;
320
+
321
+ /**
322
+ * Generates the graph model
323
+ */
324
+ function generateGraphModel ( ) {
325
+ var nodes = $ ( ".node" ) ;
326
+
327
+ // Add all node titles to the model
328
+ nodes . each ( function ( ) {
329
+ graphModel [ $ ( this ) . find ( "title" ) . parent ( ) . attr ( "id" ) ] = {
330
+ inList : [ ] ,
331
+ outList : [ ]
332
+ }
333
+ } ) ;
334
+
335
+ // Add all links to the model
336
+ $ ( ".edge" ) . each ( function ( ) {
337
+ var edgeText = $ ( this ) . find ( "title" ) . text ( ) ;
338
+ var toFrom = edgeText . split ( "->" ) ;
339
+ var to = nodes . filter ( function ( ) {
340
+ return $ ( this ) . find ( "title" ) . text ( ) === toFrom [ 0 ] ;
341
+ } ) . attr ( "id" ) ;
342
+ var from = nodes . filter ( function ( ) {
343
+ return $ ( this ) . find ( "title" ) . text ( ) === toFrom [ 1 ] ;
344
+ } ) . attr ( "id" ) ;
345
+ graphModel [ from ] . inList . push ( to ) ;
346
+ graphModel [ to ] . outList . push ( from ) ;
347
+ } ) ;
348
+ }
349
+
350
+ /**
351
+ * Recursively select all the parents or children of a node
352
+ */
353
+ function expandSelection ( root , listName ) {
354
+ var rootID = root . attr ( "id" ) ;
355
+ for ( var i = 0 ; i < graphModel [ rootID ] [ listName ] . length ; i ++ ) {
356
+ var next = $ ( "#" + graphModel [ rootID ] [ listName ] [ i ] ) ;
357
+ next . find ( "polygon" ) . addClass ( "selected" ) ;
358
+ getTableRow ( next ) . addClass ( "selected" ) ;
359
+ expandSelection ( next , listName ) ;
360
+ }
361
+ }
362
+
363
+ $ ( "#selectChildren" ) . click ( function ( ) {
364
+ if ( $ . isEmptyObject ( graphModel ) ) {
365
+ generateGraphModel ( ) ;
366
+ }
367
+ $ ( "polygon.selected" ) . each ( function ( ) {
368
+ expandSelection ( $ ( this ) . parent ( ) , "outList" ) ;
369
+ } ) ;
370
+ } ) ;
371
+
372
+ $ ( "#selectParents" ) . click ( function ( ) {
373
+ if ( $ . isEmptyObject ( graphModel ) ) {
374
+ generateGraphModel ( ) ;
375
+ }
376
+ $ ( "polygon.selected" ) . each ( function ( ) {
377
+ expandSelection ( $ ( this ) . parent ( ) , "inList" ) ;
378
+ } ) ;
379
+ } ) ;
380
+
315
381
} ) ;
316
382
317
383
require ( [ 'jquery' , 'bootstrap.tooltip' ] ,
0 commit comments