draggability logic doesn't apply to readonly view
[scpubgit/stemmaweb.git] / root / js / relationship-readonly.js
CommitLineData
20198e59 1var MARGIN=30;
2var svg_root = null;
3var svg_root_element = null;
4var start_element_height = 0;
5var reltypes = {};
6var readingdata = {};
7
20198e59 8function getTextURL( which ) {
3f9d7ae5 9 return basepath + textid + '/' + which;
20198e59 10}
11
12function getReadingURL( reading_id ) {
3f9d7ae5 13 return basepath + textid + '/reading/' + reading_id;
20198e59 14}
15
16// Make an XML ID into a valid selector
17function jq(myid) {
18 return '#' + myid.replace(/(:|\.)/g,'\\$1');
19}
20
21// Actions for opening the reading panel
22function node_dblclick_listener( evt ) {
23 // Open the reading dialogue for the given node.
24 // First get the reading info
25 var reading_id = $(this).attr('id');
26 var reading_info = readingdata[reading_id];
27 // and then populate the dialog box with it.
28 // Set the easy properties first
29 $('#reading-form').dialog( 'option', 'title', 'Reading information for "' + reading_info['text'] + '"' );
30 $('#reading_id').val( reading_id );
31 toggle_checkbox( $('#reading_is_nonsense'), reading_info['is_nonsense'] );
32 toggle_checkbox( $('#reading_grammar_invalid'), reading_info['grammar_invalid'] );
33 // Use .text as a backup for .normal_form
34 var normal_form = reading_info['normal_form'];
35 if( !normal_form ) {
36 normal_form = reading_info['text'];
37 }
38 var nfboxsize = 10;
39 if( normal_form.length > 9 ) {
40 nfboxsize = normal_form.length + 1;
41 }
42 $('#reading_normal_form').attr( 'size', nfboxsize )
43 $('#reading_normal_form').val( normal_form );
44 // Now do the morphological properties.
45 morphology_form( reading_info['lexemes'] );
46 // and then open the dialog.
47 $('#reading-form').dialog("open");
48}
49
50function toggle_checkbox( box, value ) {
51 if( value == null ) {
52 value = false;
53 }
54 box.attr('checked', value );
55}
56
57function morphology_form ( lexlist ) {
487674b9 58 if( lexlist.length ) {
59 $('#morph_outer').show();
60 $('#morphology').empty();
61 $.each( lexlist, function( idx, lex ) {
62 var morphoptions = [];
63 if( 'wordform_matchlist' in lex ) {
64 $.each( lex['wordform_matchlist'], function( tdx, tag ) {
65 var tagstr = stringify_wordform( tag );
66 morphoptions.push( tagstr );
67 });
68 }
69 var formtag = 'morphology_' + idx;
70 var formstr = '';
71 if( 'form' in lex ) {
72 formstr = stringify_wordform( lex['form'] );
73 }
74 var form_morph_elements = morph_elements(
75 formtag, lex['string'], formstr, morphoptions );
76 $.each( form_morph_elements, function( idx, el ) {
77 $('#morphology').append( el );
20198e59 78 });
20198e59 79 });
487674b9 80 } else {
81 $('#morph_outer').hide();
82 }
20198e59 83}
84
85function stringify_wordform ( tag ) {
86 if( tag ) {
87 var elements = tag.split(' // ');
88 return elements[1] + ' // ' + elements[2];
89 }
90 return ''
91}
92
93function morph_elements ( formtag, formtxt, currform, morphoptions ) {
94 var clicktag = '(Click to select)';
95 if ( !currform ) {
96 currform = clicktag;
97 }
98 var formlabel = $('<label/>').attr( 'id', 'label_' + formtag ).attr(
99 'for', 'reading_' + formtag ).text( formtxt + ': ' );
100 var forminput = $('<input/>').attr( 'id', 'reading_' + formtag ).attr(
101 'name', 'reading_' + formtag ).attr( 'size', '50' ).attr(
102 'class', 'reading_morphology' ).val( currform );
103 forminput.autocomplete({ source: morphoptions, minLength: 0 });
104 forminput.focus( function() {
105 if( $(this).val() == clicktag ) {
106 $(this).val('');
107 }
108 $(this).autocomplete('search', '')
109 });
110 var morphel = [ formlabel, forminput, $('<br/>') ];
111 return morphel;
112}
113
114function color_inactive ( el ) {
115 var reading_id = $(el).parent().attr('id');
116 var reading_info = readingdata[reading_id];
117 // If the reading info has any non-disambiguated lexemes, color it yellow;
118 // otherwise color it green.
119 $(el).attr( {stroke:'green', fill:'#b3f36d'} );
120 if( reading_info ) {
121 $.each( reading_info['lexemes'], function ( idx, lex ) {
122 if( !lex['is_disambiguated'] || lex['is_disambiguated'] == 0 ) {
123 $(el).attr( {stroke:'orange', fill:'#fee233'} );
124 }
125 });
126 }
127}
128
129function relemmatize () {
130 // Send the reading for a new lemmatization and reopen the form.
131 $('#relemmatize_pending').show();
132 var reading_id = $('#reading_id').val()
133 ncpath = getReadingURL( reading_id );
134 form_values = {
135 'normal_form': $('#reading_normal_form').val(),
136 'relemmatize': 1 };
137 var jqjson = $.post( ncpath, form_values, function( data ) {
138 // Update the form with the return
139 if( 'id' in data ) {
140 // We got back a good answer. Stash it
141 readingdata[reading_id] = data;
142 // and regenerate the morphology form.
143 morphology_form( data['lexemes'] );
144 } else {
145 alert("Could not relemmatize as requested: " + data['error']);
146 }
147 $('#relemmatize_pending').hide();
148 });
149}
150
151// Initialize the SVG once it exists
152function svgEnlargementLoaded() {
153 //Give some visual evidence that we are working
154 $('#loading_overlay').show();
155 lo_height = $("#enlargement_container").outerHeight();
156 lo_width = $("#enlargement_container").outerWidth();
157 $("#loading_overlay").height( lo_height );
158 $("#loading_overlay").width( lo_width );
159 $("#loading_overlay").offset( $("#enlargement_container").offset() );
160 $("#loading_message").offset(
161 { 'top': lo_height / 2 - $("#loading_message").height() / 2,
162 'left': lo_width / 2 - $("#loading_message").width() / 2 });
163 //Set viewbox widht and height to widht and height of $('#svgenlargement svg').
164 //This is essential to make sure zooming and panning works properly.
165 var rdgpath = getTextURL( 'readings' );
166 $.getJSON( rdgpath, function( data ) {
167 readingdata = data;
168 $('#svgenlargement ellipse').each( function( i, el ) { color_inactive( el ) });
169 });
170 $('#svgenlargement ellipse').parent().dblclick( node_dblclick_listener );
171 var graph_svg = $('#svgenlargement svg');
172 var svg_g = $('#svgenlargement svg g')[0];
173 if (!svg_g) return;
174 svg_root = graph_svg.svg().svg('get').root();
175
176 // Find the real root and ignore any text nodes
177 for (i = 0; i < svg_root.childNodes.length; ++i) {
178 if (svg_root.childNodes[i].nodeName != '#text') {
179 svg_root_element = svg_root.childNodes[i];
180 break;
181 }
182 }
183
184 svg_root.viewBox.baseVal.width = graph_svg.attr( 'width' );
185 svg_root.viewBox.baseVal.height = graph_svg.attr( 'height' );
186 //Now set scale and translate so svg height is about 150px and vertically centered in viewbox.
187 //This is just to create a nice starting enlargement.
188 var initial_svg_height = 250;
189 var scale = initial_svg_height/graph_svg.attr( 'height' );
190 var additional_translate = (graph_svg.attr( 'height' ) - initial_svg_height)/(2*scale);
191 var transform = svg_g.getAttribute('transform');
192 var translate = parseFloat( transform.match( /translate\([^\)]*\)/ )[0].split('(')[1].split(' ')[1].split(')')[0] );
193 translate += additional_translate;
194 var transform = 'rotate(0) scale(' + scale + ') translate(4 ' + translate + ')';
195 svg_g.setAttribute('transform', transform);
196 //used to calculate min and max zoom level:
197 start_element_height = $('#__START__').children('ellipse')[0].getBBox().height;
198 add_relations( function() { $('#loading_overlay').hide(); });
199}
200
201function add_relations( callback_fn ) {
56e3972e 202 // Add the relationship types to the keymap list
203 $.each( relationship_types, function(index, typedef) {
671c04b1 204 li_elm = $('<li class="key">').css( "border-color",
205 relation_manager.relation_colors[index] ).text(typedef.name);
206 li_elm.append( $('<div>').attr('class', 'key_tip_container').append(
207 $('<div>').attr('class', 'key_tip').text(typedef.description) ) );
208 $('#keymaplist').append( li_elm );
56e3972e 209 });
210 // Now fetch the relationships themselves and add them to the graph
211 var rel_types = $.map( relationship_types, function(t) { return t.name });
20198e59 212 var textrelpath = getTextURL( 'relationships' );
56e3972e 213 $.getJSON( textrelpath, function(data) {
214 $.each(data, function( index, rel_info ) {
215 var type_index = $.inArray(rel_info.type, rel_types);
216 var source_found = get_ellipse( rel_info.source );
217 var target_found = get_ellipse( rel_info.target );
218 if( type_index != -1 && source_found.size() && target_found.size() ) {
219 var relation = relation_manager.create( rel_info.source, rel_info.target, type_index );
220 relation.data( 'type', rel_info.type );
221 relation.data( 'scope', rel_info.scope );
222 relation.data( 'note', rel_info.note );
56e3972e 223 }
20198e59 224 });
56e3972e 225 callback_fn.call();
226 });
20198e59 227}
228
229function get_ellipse( node_id ) {
230 return $( jq( node_id ) + ' ellipse');
231}
232
233function get_node_obj( node_id ) {
234 var node_ellipse = get_ellipse( node_id );
235 if( node_ellipse.data( 'node_obj' ) == null ) {
236 node_ellipse.data( 'node_obj', new node_obj(node_ellipse) );
237 };
238 return node_ellipse.data( 'node_obj' );
239}
240
241function node_obj(ellipse) {
242 this.ellipse = ellipse;
243 var self = this;
244
245 this.x = 0;
246 this.y = 0;
247 this.dx = 0;
248 this.dy = 0;
249 this.node_elements = node_elements_for(self.ellipse);
250
251 this.update_elements = function() {
252 self.node_elements = node_elements_for(self.ellipse);
253 }
254}
255
256function svgshape( shape_element ) {
257 this.shape = shape_element;
258 this.move = function(dx,dy) {
259 this.shape.attr( "transform", "translate(" + dx + " " + dy + ")" );
260 }
261 this.reset = function() {
262 this.shape.attr( "transform", "translate( 0, 0 )" );
263 }
264 this.grey_out = function(filter) {
265 if( this.shape.parent(filter).size() != 0 ) {
266 this.shape.attr({'stroke':'#e5e5e5', 'fill':'#e5e5e5'});
267 }
268 }
269 this.un_grey_out = function(filter) {
270 if( this.shape.parent(filter).size() != 0 ) {
271 this.shape.attr({'stroke':'#000000', 'fill':'#000000'});
272 }
273 }
274}
275
276function svgpath( path_element, svg_element ) {
277 this.svg_element = svg_element;
278 this.path = path_element;
279 this.x = this.path.x;
280 this.y = this.path.y;
281 this.move = function(dx,dy) {
282 this.path.x = this.x + dx;
283 this.path.y = this.y + dy;
284 }
285 this.reset = function() {
286 this.path.x = this.x;
287 this.path.y = this.y;
288 }
289 this.grey_out = function(filter) {
290 if( this.svg_element.parent(filter).size() != 0 ) {
291 this.svg_element.attr('stroke', '#e5e5e5');
292 this.svg_element.siblings('text').attr('fill', '#e5e5e5');
293 this.svg_element.siblings('text').attr('class', 'noselect');
294 }
295 }
296 this.un_grey_out = function(filter) {
297 if( this.svg_element.parent(filter).size() != 0 ) {
298 this.svg_element.attr('stroke', '#000000');
299 this.svg_element.siblings('text').attr('fill', '#000000');
300 this.svg_element.siblings('text').attr('class', '');
301 }
302 }
303}
304
305function node_elements_for( ellipse ) {
306 node_elements = get_edge_elements_for( ellipse );
307 node_elements.push( new svgshape( ellipse.siblings('text') ) );
308 node_elements.push( new svgshape( ellipse ) );
309 return node_elements;
310}
311
312function get_edge_elements_for( ellipse ) {
313 edge_elements = new Array();
314 node_id = ellipse.parent().attr('id');
315 edge_in_pattern = new RegExp( node_id + '$' );
316 edge_out_pattern = new RegExp( '^' + node_id );
317 $.each( $('#svgenlargement .edge,#svgenlargement .relation').children('title'), function(index) {
318 title = $(this).text();
319 if( edge_in_pattern.test(title) ) {
320 polygon = $(this).siblings('polygon');
321 if( polygon.size() > 0 ) {
322 edge_elements.push( new svgshape( polygon ) );
323 }
324 path_segments = $(this).siblings('path')[0].pathSegList;
325 edge_elements.push( new svgpath( path_segments.getItem(path_segments.numberOfItems - 1), $(this).siblings('path') ) );
326 }
327 if( edge_out_pattern.test(title) ) {
328 path_segments = $(this).siblings('path')[0].pathSegList;
329 edge_elements.push( new svgpath( path_segments.getItem(0), $(this).siblings('path') ) );
330 }
331 });
332 return edge_elements;
333}
334
335function relation_factory() {
336 var self = this;
337 this.color_memo = null;
338 //TODO: colors hard coded for now
339 this.relation_colors = [ "#5CCCCC", "#67E667", "#F9FE72", "#6B90D4", "#FF7673", "#E467B3", "#AA67D5", "#8370D8", "#FFC173" ];
340
341 this.create = function( source_node_id, target_node_id, color_index ) {
342 //TODO: Protect from (color_)index out of bound..
343 var relation_color = self.relation_colors[ color_index ];
344 var relation = draw_relation( source_node_id, target_node_id, relation_color );
345 var relation_id = get_relation_id( source_node_id, target_node_id );
346 get_node_obj( source_node_id ).update_elements();
347 get_node_obj( target_node_id ).update_elements();
348 // Set it active by default. May need to restore toggling if having all
349 // relationships active is too much of a performance hit.
350 var relation_path = relation.children('path');
351 // All relations active in order to allow hover information?
352 // Else we will have to deactivate them when they go off-screen.
353 relation_path.css( {'cursor':'pointer'} );
354 relation_path.mouseenter( function(event) {
355 outerTimer = setTimeout( function() {
356 timer = setTimeout( function() {
357 var related_nodes = get_related_nodes( relation_id );
358 var source_node_id = related_nodes[0];
359 var target_node_id = related_nodes[1];
360 $('#delete_source_node_id').val( source_node_id );
361 $('#delete_target_node_id').val( target_node_id );
362 self.showinfo(relation);
363 }, 500 )
364 }, 1000 );
365 });
366 relation_path.mouseleave( function(event) {
367 clearTimeout(outerTimer);
368 if( timer != null ) { clearTimeout(timer); }
369 });
370
371 return relation;
372 }
373
374 this.showinfo = function(relation) {
375 var htmlstr = 'type: ' + relation.data( 'type' ) + '<br/>scope: ' + relation.data( 'scope' );
376 if( relation.data( 'note' ) ) {
377 htmlstr = htmlstr + '<br/>note: ' + relation.data( 'note' );
378 }
379 $('#delete-form-text').html( htmlstr );
380 var points = relation.children('path').attr('d').slice(1).replace('C',' ').split(' ');
381 var xs = parseFloat( points[0].split(',')[0] );
382 var xe = parseFloat( points[1].split(',')[0] );
383 var ys = parseFloat( points[0].split(',')[1] );
384 var ye = parseFloat( points[3].split(',')[1] );
385 var p = svg_root.createSVGPoint();
386 p.x = xs + ((xe-xs)*1.1);
387 p.y = ye - ((ye-ys)/2);
388 var ctm = svg_root_element.getScreenCTM();
389 var nx = p.matrixTransform(ctm).x;
390 var ny = p.matrixTransform(ctm).y;
391 var dialog_aria = $ ("div[aria-labelledby='ui-dialog-title-delete-form']");
392 $('#delete-form').dialog( 'open' );
393 dialog_aria.offset({ left: nx, top: ny });
394 }
395 /* Do we need this in readonly mode?
396 this.remove = function( relation_id ) {
397 var relation = $( jq( relation_id ) );
398 relation.remove();
399 }
400 */
401}
402
403// Utility function to create/return the ID of a relation link between
404// a source and target.
405function get_relation_id( source_id, target_id ) {
406 var idlist = [ source_id, target_id ];
407 idlist.sort();
408 return 'relation-' + idlist[0] + '-...-' + idlist[1];
409}
410
411function get_related_nodes( relation_id ) {
412 var srctotarg = relation_id.substr( 9 );
413 return srctotarg.split('-...-');
414}
415
416function draw_relation( source_id, target_id, relation_color ) {
417 var source_ellipse = get_ellipse( source_id );
418 var target_ellipse = get_ellipse( target_id );
419 var relation_id = get_relation_id( source_id, target_id );
420 var svg = $('#svgenlargement').children('svg').svg().svg('get');
421 var path = svg.createPath();
422 var sx = parseInt( source_ellipse.attr('cx') );
423 var rx = parseInt( source_ellipse.attr('rx') );
424 var sy = parseInt( source_ellipse.attr('cy') );
425 var ex = parseInt( target_ellipse.attr('cx') );
426 var ey = parseInt( target_ellipse.attr('cy') );
427 var relation = svg.group( $("#svgenlargement svg g"),
428 { 'class':'relation', 'id':relation_id } );
429 svg.title( relation, source_id + '->' + target_id );
430 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});
431 var relation_element = $('#svgenlargement .relation').filter( ':last' );
432 relation_element.insertBefore( $('#svgenlargement g g').filter(':first') );
433 return relation_element;
434}
435
436$(document).ready(function () {
437
438 timer = null;
439 relation_manager = new relation_factory();
440
441 $('#enlargement').mousedown(function (event) {
442 $(this)
443 .data('down', true)
444 .data('x', event.clientX)
445 .data('y', event.clientY)
446 .data('scrollLeft', this.scrollLeft)
447 stateTf = svg_root_element.getCTM().inverse();
448 var p = svg_root.createSVGPoint();
449 p.x = event.clientX;
450 p.y = event.clientY;
451 stateOrigin = p.matrixTransform(stateTf);
452 event.returnValue = false;
453 event.preventDefault();
454 return false;
455 }).mouseup(function (event) {
456 $(this).data('down', false);
457 }).mousemove(function (event) {
458 if( timer != null ) { clearTimeout(timer); }
459 if ( ($(this).data('down') == true) ) {
460 var p = svg_root.createSVGPoint();
461 p.x = event.clientX;
462 p.y = event.clientY;
463 p = p.matrixTransform(stateTf);
464 var matrix = stateTf.inverse().translate(p.x - stateOrigin.x, p.y - stateOrigin.y);
465 var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
466 svg_root_element.setAttribute("transform", s);
467 }
468 event.returnValue = false;
469 event.preventDefault();
470 }).mousewheel(function (event, delta) {
471 event.returnValue = false;
472 event.preventDefault();
473 if (!delta || delta == null || delta == 0) delta = event.originalEvent.wheelDelta;
474 if (!delta || delta == null || delta == 0) delta = -1 * event.originalEvent.detail;
475 if( delta < -9 ) { delta = -9 };
476 var z = 1 + delta/10;
477 z = delta > 0 ? 1 : -1;
478 var g = svg_root_element;
479 if (g && ((z<1 && (g.getScreenCTM().a * start_element_height) > 4.0) || (z>=1 && (g.getScreenCTM().a * start_element_height) < 100))) {
480 var root = svg_root;
481 var p = root.createSVGPoint();
482 p.x = event.originalEvent.clientX;
483 p.y = event.originalEvent.clientY;
484 p = p.matrixTransform(g.getCTM().inverse());
485 var scaleLevel = 1+(z/20);
486 var k = root.createSVGMatrix().translate(p.x, p.y).scale(scaleLevel).translate(-p.x, -p.y);
487 var matrix = g.getCTM().multiply(k);
488 var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
489 g.setAttribute("transform", s);
490 }
491 }).css({
492 'overflow' : 'hidden',
493 'cursor' : '-moz-grab'
494 });
495
496 $( "#delete-form" ).dialog({
497 autoOpen: false,
498 height: 135,
499 width: 160,
500 modal: false,
501 buttons: {
502 OK: function() {
503 $( this ).dialog( "close" );
504 }
505 },
506 create: function(event, ui) {
507 var buttonset = $(this).parent().find( '.ui-dialog-buttonset' ).css( 'width', '100%' );
508 buttonset.find( "button:contains('Cancel')" ).css( 'float', 'right' );
509 var dialog_aria = $("div[aria-labelledby='ui-dialog-title-delete-form']");
510 dialog_aria.mouseenter( function() {
511 if( mouseWait != null ) { clearTimeout(mouseWait) };
512 })
513 dialog_aria.mouseleave( function() {
514 mouseWait = setTimeout( function() { $("#delete-form").dialog( "close" ) }, 2000 );
515 })
516 },
517 open: function() {
518 mouseWait = setTimeout( function() { $("#delete-form").dialog( "close" ) }, 2000 );
519 },
520 close: function() {
521 }
522 });
523
487674b9 524 // function for reading form dialog should go here;
525 // just hide the element for now if we don't have morphology
526 if( can_morphologize ) {
527 $('#reading-form').dialog({
528 autoOpen: false,
529 width: 450,
530 modal: true,
531 buttons: {
532 OK: function() {
533 $( this ).dialog( "close" );
534 }
535 },
536 create: function() {
537 // Hide the relemmatize button since it is not allowed
538 $('#reading_relemmatize').hide();
539 },
540 open: function() {
541 $(".ui-widget-overlay").css("background", "none");
542 $("#dialog_overlay").show();
543 $('#reading_status').empty();
544 $("#dialog_overlay").height( $("#enlargement_container").height() );
545 $("#dialog_overlay").width( $("#enlargement_container").innerWidth() );
546 $("#dialog_overlay").offset( $("#enlargement_container").offset() );
547 },
548 close: function() {
549 $("#dialog_overlay").hide();
550 }
551 }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) {
552 if( ajaxSettings.url.lastIndexOf( getReadingURL('') ) > -1
553 && ajaxSettings.type == 'POST' && jqXHR.status == 403 ) {
554 var errobj = jQuery.parseJSON( jqXHR.responseText );
555 $('#reading_status').append( '<p class="error">Error: ' + errobj.error + '</p>' );
556 }
557 $(event.target).parent().find('.ui-button').button("enable");
558 });
559 } else {
560 $('#reading-form').hide();
561 }
20198e59 562
69ac99fc 563 // Hide the unused elements
564 $('#dialog-form').hide();
20198e59 565 $('#update_workspace_button').hide();
566
567 $('.helptag').popupWindow({
568 height:500,
569 width:800,
570 top:50,
571 left:50,
572 scrollbars:1
573 });
574
575
576 expandFillPageClients();
577 $(window).resize(function() {
578 expandFillPageClients();
579 });
580
581});
582
583
584function expandFillPageClients() {
585 $('.fillPage').each(function () {
586 $(this).height($(window).height() - $(this).offset().top - MARGIN);
587 });
588}
589
590function loadSVG(svgData) {
591 var svgElement = $('#svgenlargement');
592
593 $(svgElement).svg('destroy');
594
595 $(svgElement).svg({
596 loadURL: svgData,
597 onLoad : svgEnlargementLoaded
598 });
599}
600
601
602/* OS Gadget stuff
603
604function svg_select_callback(topic, data, subscriberData) {
605 svgData = data;
606 loadSVG(svgData);
607}
608
609function loaded() {
610 var prefs = new gadgets.Prefs();
611 var preferredHeight = parseInt(prefs.getString('height'));
612 if (gadgets.util.hasFeature('dynamic-height')) gadgets.window.adjustHeight(preferredHeight);
613 expandFillPageClients();
614}
615
616if (gadgets.util.hasFeature('pubsub-2')) {
617 gadgets.HubSettings.onConnect = function(hum, suc, err) {
618 subId = gadgets.Hub.subscribe("interedition.svg.selected", svg_select_callback);
619 loaded();
620 };
621}
622else gadgets.util.registerOnLoadHandler(loaded);
623*/