@@ -43,7 +43,7 @@ requirejs.config({
43
43
* Make the graph pannable and zoomable
44
44
*/
45
45
require ( [ 'jquery' , 'bootstrap.modal' , 'svg-pan-zoom' , 'hammerjs' , 'jquery.svg' ] ,
46
- function ( $ , modal , svgPanZoom , hammerjs ) {
46
+ function ( $ , modal , svgPanZoom , Hammer ) {
47
47
/**
48
48
* Custom hammer event handler to add mobile support
49
49
* Based on example in svg-pan-zoom/demo/mobile.html
@@ -106,9 +106,6 @@ 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
- });*/
112
109
113
110
/**
114
111
* Enable svg-pan-zoom on the graph
@@ -117,8 +114,12 @@ require(['jquery', 'bootstrap.modal', 'svg-pan-zoom', 'hammerjs', 'jquery.svg'],
117
114
var graph = svgPanZoom ( '#graph svg' , {
118
115
zoomEnabled : true ,
119
116
controlIconsEnabled : true ,
120
- customEventsHandler : eventHandler ,
121
- preventMouseEventsDefault : false
117
+ customEventsHandler : eventHandler
118
+ } ) ;
119
+
120
+ // Add deselect to reset control
121
+ $ ( "#svg-pan-zoom-reset-pan-zoom" ) . click ( function ( ) {
122
+ $ ( "polygon.selected, tr.selected" ) . removeClass ( "selected" ) ;
122
123
} ) ;
123
124
124
125
// Resizing window also resizes the graph
@@ -132,7 +133,7 @@ require(['jquery', 'bootstrap.modal', 'svg-pan-zoom', 'hammerjs', 'jquery.svg'],
132
133
$ ( '#fullScreenGraphModal' ) . on ( 'shown.bs.modal' , function ( e ) {
133
134
// Timeout allows for modal to show
134
135
setTimeout ( function ( ) {
135
- var fullGraph = svgPanZoom ( '#graphFullscreen svg ' , {
136
+ var fullGraph = svgPanZoom ( '#graphFullscreen' , {
136
137
zoomEnabled : true ,
137
138
controlIconsEnabled : true ,
138
139
customEventsHandler : eventHandler
@@ -261,10 +262,12 @@ require(['jquery', 'jquery.svg', 'jquery.svgdom'],
261
262
*/
262
263
$ ( "tr" ) . not ( 'thead tr' ) . on ( {
263
264
click : function ( event ) {
265
+ var matchingGraphBox = getGraphBox ( this ) ;
264
266
if ( ! event . ctrlKey ) {
265
- $ ( "polygon.selected, tr.selected" ) . not ( $ ( this ) ) . removeClass ( "selected" ) ;
267
+ $ ( "polygon.selected, tr.selected" ) . not ( $ ( this ) )
268
+ . not ( matchingGraphBox ) . removeClass ( "selected" ) ;
266
269
}
267
- getGraphBox ( this ) . toggleClass ( "selected" ) ;
270
+ matchingGraphBox . toggleClass ( "selected" ) ;
268
271
$ ( this ) . toggleClass ( "selected" ) ;
269
272
} ,
270
273
mouseenter : function ( ) {
@@ -290,17 +293,35 @@ require(['jquery', 'jquery.svg', 'jquery.svgdom'],
290
293
} ) ;
291
294
}
292
295
296
+ /**
297
+ * Keep track of whether the graph is being dragged to
298
+ * be able to disable click events during pan
299
+ */
300
+ var draggingGraph = false ;
301
+ $ ( document ) . on ( {
302
+ mousedown : function ( ) {
303
+ draggingGraph = false ;
304
+ } ,
305
+ mousemove : function ( ) {
306
+ draggingGraph = true ;
307
+ }
308
+ } , "#graph" ) ;
309
+
293
310
/**
294
311
* When a graph box is hovered over/clicked, highlight
295
312
*/
296
313
$ ( document ) . on ( {
297
314
click : function ( event ) {
298
- var thisPolygon = $ ( this ) . find ( "polygon" ) ;
299
- if ( ! event . ctrlKey ) {
300
- $ ( "polygon.selected, tr.selected" ) . not ( thisPolygon ) . removeClass ( "selected" ) ;
315
+ if ( ! draggingGraph ) {
316
+ var thisPolygon = $ ( this ) . find ( "polygon" ) ;
317
+ var matchingTableRow = getTableRow ( this ) ;
318
+ if ( ! event . ctrlKey ) {
319
+ $ ( "polygon.selected, tr.selected" ) . not ( thisPolygon )
320
+ . not ( matchingTableRow ) . removeClass ( "selected" ) ;
321
+ }
322
+ matchingTableRow . toggleClass ( "selected" ) ;
323
+ thisPolygon . toggleClass ( "selected" ) ;
301
324
}
302
- getTableRow ( this ) . toggleClass ( "selected" ) ;
303
- thisPolygon . toggleClass ( "selected" ) ;
304
325
} ,
305
326
mouseenter : function ( ) {
306
327
getTableRow ( this ) . addClass ( "hover" ) ;
0 commit comments