Merge branch 'master' of github.com:tla/stemmatology
[scpubgit/stemmatology.git] / stemmaweb / root / js / relationship.js
CommitLineData
7fd1d97a 1function getTextPath() {
2 var currpath = window.location.pathname
3 if( currpath.lastIndexOf('/') == currpath.length - 1 ) {
4 currpath = currpath.slice( 0, currpath.length - 1)
5 };
6 var path_elements = currpath.split('/');
7 var textid = path_elements.pop();
8 var basepath = path_elements.join( '/' );
9 var path_parts = [ basepath, textid ];
10 return path_parts;
581aee24 11}
12
72874569 13function getRelativePath() {
14 var path_parts = getTextPath();
15 return path_parts[0];
16}
17
18function getRelationshipURL() {
19 var path_parts = getTextPath();
20 return path_parts[0] + '/' + path_parts[1] + '/relationships';
581aee24 21}
22
23function svgEnlargementLoaded() {
72874569 24 //Set viewbox widht and height to widht and height of $('#svgenlargement svg').
25 //This is essential to make sure zooming and panning works properly.
26 $('#svgenlargement ellipse').attr( {stroke:'green', fill:'#b3f36d'} );
27 var graph_svg = $('#svgenlargement svg');
28 var svg_g = $('#svgenlargement svg g')[0];
29 svg_root = graph_svg.svg().svg('get').root();
30 svg_root.viewBox.baseVal.width = graph_svg.attr( 'width' );
31 svg_root.viewBox.baseVal.height = graph_svg.attr( 'height' );
32 //Now set scale and translate so svg height is about 150px and vertically centered in viewbox.
33 //This is just to create a nice starting enlargement.
34 var initial_svg_height = 250;
35 var scale = initial_svg_height/graph_svg.attr( 'height' );
36 var additional_translate = (graph_svg.attr( 'height' ) - initial_svg_height)/(2*scale);
37 var transform = svg_g.getAttribute('transform');
38 var translate = parseFloat( transform.match( /translate\([^\)]*\)/ )[0].split('(')[1].split(' ')[1].split(')')[0] );
39 translate += additional_translate;
40 var transform = 'rotate(0) scale(' + scale + ') translate(4 ' + translate + ')';
41 svg_g.setAttribute('transform', transform);
42 //used to calculate min and max zoom level:
43 start_element_height = $("#svgenlargement .node title:contains('#START#')").siblings('ellipse')[0].getBBox().height;
7fd1d97a 44 add_relations();
45}
46
47function add_relations() {
72874569 48 var basepath = getRelativePath();
49 var textrelpath = getRelationshipURL();
50 $.getJSON( basepath + '/definitions', function(data) {
7fd1d97a 51 var rel_types = data.types.sort();
72874569 52 $.getJSON( textrelpath,
7fd1d97a 53 function(data) {
54 $.each(data, function( index, rel_info ) {
55 var type_index = $.inArray(rel_info.type, rel_types);
56 if( type_index != -1 ) {
72874569 57 var relation = relation_manager.create( rel_info.source, rel_info.target, type_index );
58 relation.data( 'type', rel_info.type );
59 relation.data( 'scope', rel_info.scope );
31aaf446 60 relation.data( 'note', rel_info.note );
72874569 61 var node_obj = get_node_obj(rel_info.source);
62 node_obj.set_draggable( false );
63 node_obj.ellipse.data( 'node_obj', null );
64 node_obj = get_node_obj(rel_info.target);
65 node_obj.set_draggable( false );
66 node_obj.ellipse.data( 'node_obj', null );
7fd1d97a 67 }
68 })
72874569 69 });
7fd1d97a 70 });
581aee24 71}
72
73function get_ellipse( node_id ) {
74 return $('#svgenlargement .node').children('title').filter( function(index) {
75 return $(this).text() == node_id;
76 }).siblings('ellipse');
77}
78
79function get_node_obj( node_id ) {
72874569 80 var node_ellipse = get_ellipse( node_id );
81 if( node_ellipse.data( 'node_obj' ) == null ) {
82 node_ellipse.data( 'node_obj', new node_obj(node_ellipse) );
83 };
84 return node_ellipse.data( 'node_obj' );
581aee24 85}
86
87function get_edge( edge_id ) {
88 return $('#svgenlargement .edge').filter( function(index) {
89 return $(this).children( 'title' ).text() == $('<div/>').html(edge_id).text() ;
90 });
91}
92
93function node_obj(ellipse) {
94 this.ellipse = ellipse;
95 var self = this;
96
97 this.x = 0;
98 this.y = 0;
99 this.dx = 0;
100 this.dy = 0;
101 this.node_elements = node_elements_for(self.ellipse);
102
103 this.get_id = function() {
104 return self.ellipse.siblings('title').text()
105 }
106
107 this.set_draggable = function( draggable ) {
108 if( draggable ) {
109 self.ellipse.attr( {stroke:'black', fill:'#fff'} );
110 self.ellipse.mousedown( this.mousedown_listener );
111 self.ellipse.hover( this.enter_node, this.leave_node );
112 } else {
113 self.ellipse.unbind('mouseenter').unbind('mouseleave').unbind('mousedown');
114 self.ellipse.attr( {stroke:'green', fill:'#b3f36d'} );
115 }
116 }
117
118 this.mousedown_listener = function(evt) {
119 evt.stopPropagation();
120 self.x = evt.clientX;
121 self.y = evt.clientY;
122 $('body').mousemove( self.mousemove_listener );
123 $('body').mouseup( self.mouseup_listener );
124 self.ellipse.unbind('mouseenter').unbind('mouseleave')
125 self.ellipse.attr( 'fill', '#ff66ff' );
126 first_node_g_element = $("#svgenlargement g .node" ).filter( ":first" );
127 if( first_node_g_element.attr('id') !== self.get_g().attr('id') ) { self.get_g().insertBefore( first_node_g_element ) };
128 }
129
130 this.mousemove_listener = function(evt) {
72874569 131 self.dx = (evt.clientX - self.x) / mouse_scale;
132 self.dy = (evt.clientY - self.y) / mouse_scale;
581aee24 133 self.move_elements();
134 }
135
136 this.mouseup_listener = function(evt) {
137 if( $('ellipse[fill="#ffccff"]').size() > 0 ) {
138 var source_node_id = self.ellipse.siblings('title').text();
139 var target_node_id = $('ellipse[fill="#ffccff"]').siblings("title").text();
140 $('#source_node_id').val( source_node_id );
141 $('#target_node_id').val( target_node_id );
142 $('#dialog-form').dialog( 'open' );
143 };
144 $('body').unbind('mousemove');
145 $('body').unbind('mouseup');
146 self.ellipse.attr( 'fill', '#fff' );
147 self.ellipse.hover( self.enter_node, self.leave_node );
72874569 148 self.reset_elements();
581aee24 149 }
150
151 this.cpos = function() {
152 return { x: self.ellipse.attr('cx'), y: self.ellipse.attr('cy') };
153 }
154
155 this.get_g = function() {
156 return self.ellipse.parent('g');
157 }
158
159 this.enter_node = function(evt) {
160 self.ellipse.attr( 'fill', '#ffccff' );
161 }
162
163 this.leave_node = function(evt) {
164 self.ellipse.attr( 'fill', '#fff' );
165 }
166
167 this.greyout_edges = function() {
168 $.each( self.node_elements, function(index, value) {
169 value.grey_out('.edge');
170 });
171 }
172
173 this.ungreyout_edges = function() {
174 $.each( self.node_elements, function(index, value) {
175 value.un_grey_out('.edge');
176 });
177 }
178
179 this.move_elements = function() {
180 $.each( self.node_elements, function(index, value) {
181 value.move(self.dx,self.dy);
182 });
183 }
184
185 this.reset_elements = function() {
186 $.each( self.node_elements, function(index, value) {
187 value.reset();
188 });
189 }
190
191 this.update_elements = function() {
192 self.node_elements = node_elements_for(self.ellipse);
193 }
194
195 self.set_draggable( true );
196}
197
198function svgshape( shape_element ) {
199 this.shape = shape_element;
200 this.move = function(dx,dy) {
201 this.shape.attr( "transform", "translate(" + dx + " " + dy + ")" );
202 }
203 this.reset = function() {
204 this.shape.attr( "transform", "translate( 0, 0 )" );
205 }
206 this.grey_out = function(filter) {
207 if( this.shape.parent(filter).size() != 0 ) {
208 this.shape.attr({'stroke':'#e5e5e5', 'fill':'#e5e5e5'});
209 }
210 }
211 this.un_grey_out = function(filter) {
212 if( this.shape.parent(filter).size() != 0 ) {
213 this.shape.attr({'stroke':'#000000', 'fill':'#000000'});
214 }
215 }
216}
217
218function svgpath( path_element, svg_element ) {
219 this.svg_element = svg_element;
220 this.path = path_element;
221 this.x = this.path.x;
222 this.y = this.path.y;
223 this.move = function(dx,dy) {
224 this.path.x = this.x + dx;
225 this.path.y = this.y + dy;
226 }
227 this.reset = function() {
228 this.path.x = this.x;
229 this.path.y = this.y;
230 }
231 this.grey_out = function(filter) {
232 if( this.svg_element.parent(filter).size() != 0 ) {
233 this.svg_element.attr('stroke', '#e5e5e5');
234 this.svg_element.siblings('text').attr('fill', '#e5e5e5');
235 }
236 }
237 this.un_grey_out = function(filter) {
238 if( this.svg_element.parent(filter).size() != 0 ) {
239 this.svg_element.attr('stroke', '#000000');
240 this.svg_element.siblings('text').attr('fill', '#000000');
241 }
242 }
243}
244
245function node_elements_for( ellipse ) {
246 node_elements = get_edge_elements_for( ellipse );
247 node_elements.push( new svgshape( ellipse.siblings('text') ) );
248 node_elements.push( new svgshape( ellipse ) );
249 return node_elements;
250}
251
252function get_edge_elements_for( ellipse ) {
253 edge_elements = new Array();
254 node_id = ellipse.siblings('title').text();
255 edge_in_pattern = new RegExp( node_id + '$' );
256 edge_out_pattern = new RegExp( '^' + node_id );
257 $.each( $('#svgenlargement .edge,#svgenlargement .relation').children('title'), function(index) {
258 title = $(this).text();
259 if( edge_in_pattern.test(title) ) {
260 polygon = $(this).siblings('polygon');
261 if( polygon.size() > 0 ) {
262 edge_elements.push( new svgshape( polygon ) );
263 }
264 path_segments = $(this).siblings('path')[0].pathSegList;
265 edge_elements.push( new svgpath( path_segments.getItem(path_segments.numberOfItems - 1), $(this).siblings('path') ) );
266 }
267 if( edge_out_pattern.test(title) ) {
268 path_segments = $(this).siblings('path')[0].pathSegList;
269 edge_elements.push( new svgpath( path_segments.getItem(0), $(this).siblings('path') ) );
270 }
271 });
272 return edge_elements;
273}
274
275function relation_factory() {
276 var self = this;
277 this.color_memo = null;
278 //TODO: colors hard coded for now
279 this.temp_color = '#FFA14F';
280 this.relation_colors = [ "#5CCCCC", "#67E667", "#F9FE72", "#6B90D4", "#FF7673", "#E467B3", "#AA67D5", "#8370D8", "#FFC173" ];
281
282 this.create_temporary = function( source_node_id, target_node_id ) {
72874569 283 var relation = $('#svgenlargement .relation').filter( function(index) {
284 var relation_id = $(this).children('title').text();
581aee24 285 if( ( relation_id == ( source_node_id + '->' + target_node_id ) ) || ( relation_id == ( target_node_id + '->' + source_node_id ) ) ) {
72874569 286 return true;
287 }
288 } );
289 if( relation.size() == 0 ) {
581aee24 290 draw_relation( source_node_id, target_node_id, self.temp_color );
291 } else {
292 self.color_memo = relation.children('path').attr( 'stroke' );
293 relation.children('path').attr( 'stroke', self.temp_color );
294 }
295 }
296 this.remove_temporary = function() {
297 var path_element = $('#svgenlargement .relation').children('path[stroke="' + self.temp_color + '"]');
298 if( self.color_memo != null ) {
299 path_element.attr( 'stroke', self.color_memo );
300 self.color_memo = null;
301 } else {
72874569 302 var temporary = path_element.parent('g').remove();
303 temporary.empty();
304 temporary = null;
581aee24 305 }
306 }
307 this.create = function( source_node_id, target_node_id, color_index ) {
308 //TODO: Protect from (color_)index out of bound..
309 var relation_color = self.relation_colors[ color_index ];
72874569 310 var relation = draw_relation( source_node_id, target_node_id, relation_color );
311 get_node_obj( source_node_id ).update_elements();
312 get_node_obj( target_node_id ).update_elements();
313 return relation;
581aee24 314 }
72874569 315 this.toggle_active = function( relation_id ) {
316 var relation = $("#svgenlargement .relation:has(title:contains('" + relation_id + "'))");
317 var relation_path = relation.children('path');
318 if( !relation.data( 'active' ) ) {
319 relation_path.css( {'cursor':'pointer'} );
320 relation_path.mouseenter( function(event) {
321 outerTimer = setTimeout( function() {
322 timer = setTimeout( function() {
323 var title = relation.children('title').text();
324 var source_node_id = title.substring( 0, title.indexOf( "->" ) );
325 var target_node_id = title.substring( (title.indexOf( "->" ) + 2) );
326 $('#delete_source_node_id').val( source_node_id );
327 $('#delete_target_node_id').val( target_node_id );
328 self.showinfo(relation);
329 }, 500 )
330 }, 1000 );
331 });
332 relation_path.mouseleave( function(event) {
333 clearTimeout(outerTimer);
334 if( timer != null ) { clearTimeout(timer); }
335 });
336 relation.data( 'active', true );
337 } else {
338 relation_path.unbind( 'mouseenter' );
339 relation_path.unbind( 'mouseleave' );
340 relation_path.css( {'cursor':'inherit'} );
341 relation.data( 'active', false );
342 }
343 }
344 this.showinfo = function(relation) {
31aaf446 345 var htmlstr = 'type: ' + relation.data( 'type' ) + '<br/>scope: ' + relation.data( 'scope' );
346 if( relation.data( 'note' ) ) {
347 htmlstr = htmlstr + '<br/>note: ' + relation.data( 'note' );
348 }
349 $('#delete-form-text').html( htmlstr );
72874569 350 var points = relation.children('path').attr('d').slice(1).replace('C',' ').split(' ');
351 var xs = parseFloat( points[0].split(',')[0] );
352 var xe = parseFloat( points[1].split(',')[0] );
353 var ys = parseFloat( points[0].split(',')[1] );
354 var ye = parseFloat( points[3].split(',')[1] );
355 var p = svg_root.createSVGPoint();
356 p.x = xs + ((xe-xs)*1.1);
357 p.y = ye - ((ye-ys)/2);
358 var ctm = svg_root.children[0].getScreenCTM();
359 var nx = p.matrixTransform(ctm).x;
360 var ny = p.matrixTransform(ctm).y;
361 var dialog_aria = $ ("div[aria-labelledby='ui-dialog-title-delete-form']");
362 $('#delete-form').dialog( 'open' );
363 dialog_aria.offset({ left: nx, top: ny });
364 }
365 this.remove = function( relation_id ) {
366 var relation = $("#svgenlargement .relation:has(title:contains('" + relation_id + "'))");
367 relation.remove();
581aee24 368 }
369}
370
371function draw_relation( source_id, target_id, relation_color ) {
72874569 372 var source_ellipse = get_ellipse( source_id );
373 var target_ellipse = get_ellipse( target_id );
374 var svg = $('#svgenlargement').children('svg').svg().svg('get');
375 var path = svg.createPath();
376 var sx = parseInt( source_ellipse.attr('cx') );
377 var rx = parseInt( source_ellipse.attr('rx') );
378 var sy = parseInt( source_ellipse.attr('cy') );
379 var ex = parseInt( target_ellipse.attr('cx') );
380 var ey = parseInt( target_ellipse.attr('cy') );
381 var relation = svg.group( $("#svgenlargement svg g"), {'class':'relation'} );
382 svg.title( relation, source_id + '->' + target_id );
383 svg.path( relation, path.move( sx, sy ).curveC( sx + (2*rx), sy, ex + (2*rx), ey, ex, ey ), {fill: 'none', stroke: relation_color, strokeWidth: 4});
581aee24 384 var relation_element = $('#svgenlargement .relation').filter( ':last' );
385 relation_element.insertBefore( $('#svgenlargement g g').filter(':first') );
72874569 386 return relation_element;
581aee24 387}
388
72874569 389
581aee24 390$(document).ready(function () {
72874569 391
392 timer = null;
581aee24 393 relation_manager = new relation_factory();
72874569 394 $('#update_workspace_button').data('locked', false);
581aee24 395
72874569 396 $('#enlargement').mousedown(function (event) {
581aee24 397 $(this)
72874569 398 .data('down', true)
399 .data('x', event.clientX)
400 .data('y', event.clientY)
401 .data('scrollLeft', this.scrollLeft)
402 stateTf = svg_root.children[0].getCTM().inverse();
403 var p = svg_root.createSVGPoint();
404 p.x = event.clientX;
405 p.y = event.clientY;
406 stateOrigin = p.matrixTransform(stateTf);
407 return false;
581aee24 408 }).mouseup(function (event) {
72874569 409 $(this).data('down', false);
581aee24 410 }).mousemove(function (event) {
72874569 411 if( timer != null ) { clearTimeout(timer); }
412 if ( ($(this).data('down') == true) && ($('#update_workspace_button').data('locked') == false) ) {
413 var p = svg_root.createSVGPoint();
414 p.x = event.clientX;
415 p.y = event.clientY;
416 p = p.matrixTransform(stateTf);
417 var matrix = stateTf.inverse().translate(p.x - stateOrigin.x, p.y - stateOrigin.y);
418 var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
419 svg_root.children[0].setAttribute("transform", s);
581aee24 420 }
421 }).mousewheel(function (event, delta) {
72874569 422 event.returnValue = false;
423 event.preventDefault();
424 if ( $('#update_workspace_button').data('locked') == false ) {
425 if( delta < -9 ) { delta = -9 };
426 var z = 1 + delta/10;
427 var g = svg_root.children[0];
428 if( (z<1 && (g.getScreenCTM().a * start_element_height) > 4.0) || (z>1 && (g.getScreenCTM().a * start_element_height) < 100) ) {
429 var root = svg_root;
430 var p = root.createSVGPoint();
431 p.x = event.clientX;
432 p.y = event.clientY;
433 p = p.matrixTransform(g.getCTM().inverse());
434 var k = root.createSVGMatrix().translate(p.x, p.y).scale(z).translate(-p.x, -p.y);
435 var matrix = g.getCTM().multiply(k);
436 var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
437 g.setAttribute("transform", s);
438 }
439 }
581aee24 440 }).css({
441 'overflow' : 'hidden',
442 'cursor' : '-moz-grab'
443 });
444
445
446 $( "#dialog-form" ).dialog({
447 autoOpen: false,
448 height: 270,
449 width: 290,
450 modal: true,
451 buttons: {
452 "Ok": function() {
453 $('#status').empty();
454 form_values = $('#collapse_node_form').serialize()
72874569 455 ncpath = getRelationshipURL();
456 $(':button :contains("Ok")').attr("disabled", true);
581aee24 457 var jqjson = $.post( ncpath, form_values, function(data) {
458 $.each( data, function(item, source_target) {
72874569 459 var relation = relation_manager.create( source_target[0], source_target[1], $('#rel_type').attr('selectedIndex') );
460 relation.data( 'type', $('#rel_type :selected').text() );
461 relation.data( 'scope', $('#scope :selected').text() );
31aaf446 462 relation.data( 'note', $('#note').val() );
72874569 463 relation_manager.toggle_active( relation.children('title').text() );
581aee24 464 });
581aee24 465 $( "#dialog-form" ).dialog( "close" );
72874569 466 }, 'json' );
581aee24 467 },
468 Cancel: function() {
581aee24 469 $( this ).dialog( "close" );
470 }
471 },
472 create: function(event, ui) {
473 $(this).data( 'relation_drawn', false );
474 //TODO? Err handling?
72874569 475 var basepath = getRelativePath();
476 var jqjson = $.getJSON( basepath + '/definitions', function(data) {
581aee24 477 var types = data.types.sort();
478 $.each( types, function(index, value) {
479 $('#rel_type').append( $('<option>').attr( "value", value ).text(value) );
480 $('#keymaplist').append( $('<li>').css( "border-color", relation_manager.relation_colors[index] ).text(value) );
481 });
482 var scopes = data.scopes;
483 $.each( scopes, function(index, value) {
484 $('#scope').append( $('<option>').attr( "value", value ).text(value) );
485 });
486 });
487 },
488 open: function() {
489 relation_manager.create_temporary( $('#source_node_id').val(), $('#target_node_id').val() );
72874569 490 $(".ui-widget-overlay").css("background", "none");
491 $("#dialog_overlay").show();
492 $("#dialog_overlay").height( $("#enlargement_container").height() );
493 $("#dialog_overlay").width( $("#enlargement_container").width() );
494 $("#dialog_overlay").offset( $("#enlargement_container").offset() );
581aee24 495 },
496 close: function() {
72874569 497 relation_manager.remove_temporary();
581aee24 498 $( '#status' ).empty();
499 $("#dialog_overlay").hide();
500 }
501 }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) {
72874569 502 if( ( ajaxSettings.type == 'POST' ) && jqXHR.status == 403 ) {
503 var errobj = jQuery.parseJSON( jqXHR.responseText );
504 $('#status').append( '<p class="error">Error: ' + errobj.error + '</br>The relationship cannot be made.</p>' );
581aee24 505 }
506 } );
507
72874569 508 $( "#delete-form" ).dialog({
509 autoOpen: false,
31aaf446 510 height: 135,
72874569 511 width: 160,
512 modal: false,
513 buttons: {
514 Cancel: function() {
515 $( this ).dialog( "close" );
516 },
517 Delete: function() {
518 form_values = $('#delete_relation_form').serialize()
519 ncpath = getRelationshipURL()
520 var jqjson = $.ajax({ url: ncpath, data: form_values, success: function(data) {
521 $.each( data, function(item, source_target) {
522 relation_manager.remove( source_target[0] + '->' + source_target[1] );
523 });
524 $( "#delete-form" ).dialog( "close" );
525 }, dataType: 'json', type: 'DELETE' });
526 }
527 },
528 create: function(event, ui) {
529 var buttonset = $(this).parent().find( '.ui-dialog-buttonset' ).css( 'width', '100%' );
530 buttonset.find( "button:contains('Cancel')" ).css( 'float', 'right' );
531 var dialog_aria = $("div[aria-labelledby='ui-dialog-title-delete-form']");
532 dialog_aria.mouseenter( function() {
533 if( mouseWait != null ) { clearTimeout(mouseWait) };
534 })
535 dialog_aria.mouseleave( function() {
536 mouseWait = setTimeout( function() { $("#delete-form").dialog( "close" ) }, 2000 );
537 })
538 },
539 open: function() {
540 mouseWait = setTimeout( function() { $("#delete-form").dialog( "close" ) }, 2000 );
541 },
542 close: function() {
543 }
544 });
545
581aee24 546 $('#update_workspace_button').click( function() {
547 var svg_enlargement = $('#svgenlargement').svg().svg('get').root();
72874569 548 mouse_scale = svg_root.children[0].getScreenCTM().a;
549 if( $(this).data('locked') == true ) {
550 $('#svgenlargement ellipse' ).each( function( index ) {
551 if( $(this).data( 'node_obj' ) != null ) {
552 $(this).data( 'node_obj' ).ungreyout_edges();
553 $(this).data( 'node_obj' ).set_draggable( false );
554 var node_id = $(this).data( 'node_obj' ).get_id();
555 toggle_relation_active( node_id );
556 $(this).data( 'node_obj', null );
557 }
581aee24 558 })
581aee24 559 $(this).data('locked', false);
72874569 560 $(this).css('background-position', '0px 44px');
581aee24 561 } else {
72874569 562 var left = $('#enlargement').offset().left;
563 var right = left + $('#enlargement').width();
564 var tf = svg_root.children[0].getScreenCTM().inverse();
565 var p = svg_root.createSVGPoint();
566 p.x=left;
567 p.y=100;
568 var cx_min = p.matrixTransform(tf).x;
569 p.x=right;
570 var cx_max = p.matrixTransform(tf).x;
571 $('#svgenlargement ellipse').each( function( index ) {
572 var cx = parseInt( $(this).attr('cx') );
573 if( cx > cx_min && cx < cx_max) {
574 if( $(this).data( 'node_obj' ) == null ) {
575 $(this).data( 'node_obj', new node_obj( $(this) ) );
576 } else {
577 $(this).data( 'node_obj' ).set_draggable( true );
578 }
579 $(this).data( 'node_obj' ).greyout_edges();
580 var node_id = $(this).data( 'node_obj' ).get_id();
581 toggle_relation_active( node_id );
581aee24 582 }
72874569 583 });
584 $(this).css('background-position', '0px 0px');
581aee24 585 $(this).data('locked', true );
581aee24 586 }
587 });
588
9ca77245 589 $('.helptag').popupWindow({
590 height:500,
591 width:800,
592 top:50,
593 left:50,
594 scrollbars:1
595 });
596
597
72874569 598 function toggle_relation_active( node_id ) {
599 $('#svgenlargement .relation').find( "title:contains('" + node_id + "')" ).each( function(index) {
600 matchid = new RegExp( "^" + node_id );
601 if( $(this).text().match( matchid ) != null ) {
602 relation_manager.toggle_active( $(this).text() );
603 };
604 });
581aee24 605 }
581aee24 606
72874569 607});
581aee24 608
609