d6761d41364746ab09deadfabf24c2b4b2ddd21a
[scpubgit/stemmaweb.git] / root / js / relationship-readonly.js
1 var MARGIN=30;
2 var svg_root = null;
3 var svg_root_element = null;
4 var start_element_height = 0;
5 var reltypes = {};
6 var readingdata = {};
7
8 function getTextURL( which ) {
9         return basepath + textid + '/' + which;
10 }
11
12 function getReadingURL( reading_id ) {
13         return basepath + textid + '/reading/' + reading_id;
14 }
15
16 // Make an XML ID into a valid selector
17 function jq(myid) { 
18         return '#' + myid.replace(/(:|\.)/g,'\\$1');
19 }
20
21 // Actions for opening the reading panel
22 function 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
50 function toggle_checkbox( box, value ) {
51         if( value == null ) {
52                 value = false;
53         }
54         box.attr('checked', value );
55 }
56
57 function morphology_form ( lexlist ) {
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 );
78                         });
79                 });
80         } else {
81                 $('#morph_outer').hide();
82         }
83 }
84
85 function stringify_wordform ( tag ) {
86         if( tag ) {
87                 var elements = tag.split(' // ');
88                 return elements[1] + ' // ' + elements[2];
89         }
90         return ''
91 }
92
93 function 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
114 function 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
129 function 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
152 function 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
201 function add_relations( callback_fn ) {
202         var textrelpath = getTextURL( 'relationships' );
203         var typedefpath = getTextURL( 'definitions' );
204     $.getJSON( typedefpath, function(data) {
205                 var rel_types = data.types.sort();
206                 $.each( rel_types, function(index, value) {   
207                          $('#keymaplist').append( $('<li>').css( "border-color", relation_manager.relation_colors[index] ).text(value) ); 
208                 });
209         $.getJSON( textrelpath, function(data) {
210             $.each(data, function( index, rel_info ) {
211                 var type_index = $.inArray(rel_info.type, rel_types);
212                 var source_found = get_ellipse( rel_info.source );
213                 var target_found = get_ellipse( rel_info.target );
214                 if( type_index != -1 && source_found.size() && target_found.size() ) {
215                     var relation = relation_manager.create( rel_info.source, rel_info.target, type_index );
216                     relation.data( 'type', rel_info.type );
217                     relation.data( 'scope', rel_info.scope );
218                     relation.data( 'note', rel_info.note );
219                     var node_obj = get_node_obj(rel_info.source);
220                     node_obj.ellipse.data( 'node_obj', null );
221                     node_obj = get_node_obj(rel_info.target);
222                     node_obj.ellipse.data( 'node_obj', null );
223                 }
224             });
225             callback_fn.call();
226         });
227     });
228 }
229
230 function get_ellipse( node_id ) {
231         return $( jq( node_id ) + ' ellipse');
232 }
233
234 function get_node_obj( node_id ) {
235     var node_ellipse = get_ellipse( node_id );
236     if( node_ellipse.data( 'node_obj' ) == null ) {
237         node_ellipse.data( 'node_obj', new node_obj(node_ellipse) );
238     };
239     return node_ellipse.data( 'node_obj' );
240 }
241
242 function node_obj(ellipse) {
243   this.ellipse = ellipse;
244   var self = this;
245   
246   this.x = 0;
247   this.y = 0;
248   this.dx = 0;
249   this.dy = 0;
250   this.node_elements = node_elements_for(self.ellipse);
251
252   this.update_elements = function() {
253       self.node_elements = node_elements_for(self.ellipse);
254   }
255 }
256
257 function svgshape( shape_element ) {
258   this.shape = shape_element;
259   this.move = function(dx,dy) {
260     this.shape.attr( "transform", "translate(" + dx + " " + dy + ")" );
261   }
262   this.reset = function() {
263     this.shape.attr( "transform", "translate( 0, 0 )" );
264   }
265   this.grey_out = function(filter) {
266       if( this.shape.parent(filter).size() != 0 ) {
267           this.shape.attr({'stroke':'#e5e5e5', 'fill':'#e5e5e5'});
268       }
269   }
270   this.un_grey_out = function(filter) {
271       if( this.shape.parent(filter).size() != 0 ) {
272         this.shape.attr({'stroke':'#000000', 'fill':'#000000'});
273       }
274   }
275 }
276
277 function svgpath( path_element, svg_element ) {
278   this.svg_element = svg_element;
279   this.path = path_element;
280   this.x = this.path.x;
281   this.y = this.path.y;
282   this.move = function(dx,dy) {
283     this.path.x = this.x + dx;
284     this.path.y = this.y + dy;
285   }
286   this.reset = function() {
287     this.path.x = this.x;
288     this.path.y = this.y;
289   }
290   this.grey_out = function(filter) {
291       if( this.svg_element.parent(filter).size() != 0 ) {
292           this.svg_element.attr('stroke', '#e5e5e5');
293           this.svg_element.siblings('text').attr('fill', '#e5e5e5');
294           this.svg_element.siblings('text').attr('class', 'noselect');
295       }
296   }
297   this.un_grey_out = function(filter) {
298       if( this.svg_element.parent(filter).size() != 0 ) {
299           this.svg_element.attr('stroke', '#000000');
300           this.svg_element.siblings('text').attr('fill', '#000000');
301           this.svg_element.siblings('text').attr('class', '');
302       }
303   }
304 }
305
306 function node_elements_for( ellipse ) {
307   node_elements = get_edge_elements_for( ellipse );
308   node_elements.push( new svgshape( ellipse.siblings('text') ) );
309   node_elements.push( new svgshape( ellipse ) );
310   return node_elements;
311 }
312
313 function get_edge_elements_for( ellipse ) {
314   edge_elements = new Array();
315   node_id = ellipse.parent().attr('id');
316   edge_in_pattern = new RegExp( node_id + '$' );
317   edge_out_pattern = new RegExp( '^' + node_id );
318   $.each( $('#svgenlargement .edge,#svgenlargement .relation').children('title'), function(index) {
319     title = $(this).text();
320     if( edge_in_pattern.test(title) ) {
321         polygon = $(this).siblings('polygon');
322         if( polygon.size() > 0 ) {
323             edge_elements.push( new svgshape( polygon ) );
324         }
325         path_segments = $(this).siblings('path')[0].pathSegList;
326         edge_elements.push( new svgpath( path_segments.getItem(path_segments.numberOfItems - 1), $(this).siblings('path') ) );
327     }
328     if( edge_out_pattern.test(title) ) {
329       path_segments = $(this).siblings('path')[0].pathSegList;
330       edge_elements.push( new svgpath( path_segments.getItem(0), $(this).siblings('path') ) );
331     }
332   });
333   return edge_elements;
334
335
336 function relation_factory() {
337     var self = this;
338     this.color_memo = null;
339     //TODO: colors hard coded for now
340     this.relation_colors = [ "#5CCCCC", "#67E667", "#F9FE72", "#6B90D4", "#FF7673", "#E467B3", "#AA67D5", "#8370D8", "#FFC173" ];
341
342     this.create = function( source_node_id, target_node_id, color_index ) {
343         //TODO: Protect from (color_)index out of bound..
344         var relation_color = self.relation_colors[ color_index ];
345         var relation = draw_relation( source_node_id, target_node_id, relation_color );
346         var relation_id = get_relation_id( source_node_id, target_node_id );
347         get_node_obj( source_node_id ).update_elements();
348         get_node_obj( target_node_id ).update_elements();
349         // Set it active by default. May need to restore toggling if having all
350         // relationships active is too much of a performance hit.
351         var relation_path = relation.children('path');
352         // All relations active in order to allow hover information?
353         // Else we will have to deactivate them when they go off-screen.
354                 relation_path.css( {'cursor':'pointer'} );
355                 relation_path.mouseenter( function(event) { 
356                         outerTimer = setTimeout( function() { 
357                                 timer = setTimeout( function() { 
358                                         var related_nodes = get_related_nodes( relation_id );
359                                         var source_node_id = related_nodes[0];
360                                         var target_node_id = related_nodes[1];
361                                         $('#delete_source_node_id').val( source_node_id );
362                                         $('#delete_target_node_id').val( target_node_id );
363                                         self.showinfo(relation); 
364                                 }, 500 ) 
365                         }, 1000 );
366                 });
367                 relation_path.mouseleave( function(event) {
368                         clearTimeout(outerTimer); 
369                         if( timer != null ) { clearTimeout(timer); } 
370                 });
371         
372         return relation;
373     }
374
375     this.showinfo = function(relation) {
376         var htmlstr = 'type: ' + relation.data( 'type' ) + '<br/>scope: ' + relation.data( 'scope' );
377         if( relation.data( 'note' ) ) {
378                 htmlstr = htmlstr + '<br/>note: ' + relation.data( 'note' );
379         }
380         $('#delete-form-text').html( htmlstr );
381         var points = relation.children('path').attr('d').slice(1).replace('C',' ').split(' ');
382         var xs = parseFloat( points[0].split(',')[0] );
383         var xe = parseFloat( points[1].split(',')[0] );
384         var ys = parseFloat( points[0].split(',')[1] );
385         var ye = parseFloat( points[3].split(',')[1] );
386         var p = svg_root.createSVGPoint();
387         p.x = xs + ((xe-xs)*1.1);
388         p.y = ye - ((ye-ys)/2);
389         var ctm = svg_root_element.getScreenCTM();
390         var nx = p.matrixTransform(ctm).x;
391         var ny = p.matrixTransform(ctm).y;
392         var dialog_aria = $ ("div[aria-labelledby='ui-dialog-title-delete-form']");
393         $('#delete-form').dialog( 'open' );
394         dialog_aria.offset({ left: nx, top: ny });
395     }
396     /* Do we need this in readonly mode?
397     this.remove = function( relation_id ) {
398         var relation = $( jq( relation_id ) );
399         relation.remove();
400     }
401     */
402 }
403
404 // Utility function to create/return the ID of a relation link between
405 // a source and target.
406 function get_relation_id( source_id, target_id ) {
407         var idlist = [ source_id, target_id ];
408         idlist.sort();
409         return 'relation-' + idlist[0] + '-...-' + idlist[1];
410 }
411
412 function get_related_nodes( relation_id ) {
413         var srctotarg = relation_id.substr( 9 );
414         return srctotarg.split('-...-');
415 }
416
417 function draw_relation( source_id, target_id, relation_color ) {
418     var source_ellipse = get_ellipse( source_id );
419     var target_ellipse = get_ellipse( target_id );
420     var relation_id = get_relation_id( source_id, target_id );
421     var svg = $('#svgenlargement').children('svg').svg().svg('get');
422     var path = svg.createPath(); 
423     var sx = parseInt( source_ellipse.attr('cx') );
424     var rx = parseInt( source_ellipse.attr('rx') );
425     var sy = parseInt( source_ellipse.attr('cy') );
426     var ex = parseInt( target_ellipse.attr('cx') );
427     var ey = parseInt( target_ellipse.attr('cy') );
428     var relation = svg.group( $("#svgenlargement svg g"), 
429         { 'class':'relation', 'id':relation_id } );
430     svg.title( relation, source_id + '->' + target_id );
431     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});
432     var relation_element = $('#svgenlargement .relation').filter( ':last' );
433     relation_element.insertBefore( $('#svgenlargement g g').filter(':first') );
434     return relation_element;
435 }
436
437 $(document).ready(function () {
438     
439   timer = null;
440   relation_manager = new relation_factory();
441   
442   $('#enlargement').mousedown(function (event) {
443     $(this)
444         .data('down', true)
445         .data('x', event.clientX)
446         .data('y', event.clientY)
447         .data('scrollLeft', this.scrollLeft)
448         stateTf = svg_root_element.getCTM().inverse();
449         var p = svg_root.createSVGPoint();
450         p.x = event.clientX;
451         p.y = event.clientY;
452         stateOrigin = p.matrixTransform(stateTf);
453         event.returnValue = false;
454         event.preventDefault();
455         return false;
456   }).mouseup(function (event) {
457         $(this).data('down', false);
458   }).mousemove(function (event) {
459     if( timer != null ) { clearTimeout(timer); } 
460     if ( ($(this).data('down') == true) ) {
461         var p = svg_root.createSVGPoint();
462         p.x = event.clientX;
463         p.y = event.clientY;
464         p = p.matrixTransform(stateTf);
465         var matrix = stateTf.inverse().translate(p.x - stateOrigin.x, p.y - stateOrigin.y);
466         var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
467         svg_root_element.setAttribute("transform", s);
468     }
469     event.returnValue = false;
470     event.preventDefault();
471   }).mousewheel(function (event, delta) {
472     event.returnValue = false;
473     event.preventDefault();
474         if (!delta || delta == null || delta == 0) delta = event.originalEvent.wheelDelta;
475         if (!delta || delta == null || delta == 0) delta = -1 * event.originalEvent.detail;
476         if( delta < -9 ) { delta = -9 }; 
477         var z = 1 + delta/10;
478         z = delta > 0 ? 1 : -1;
479         var g = svg_root_element;
480         if (g && ((z<1 && (g.getScreenCTM().a * start_element_height) > 4.0) || (z>=1 && (g.getScreenCTM().a * start_element_height) < 100))) {
481                 var root = svg_root;
482                 var p = root.createSVGPoint();
483                 p.x = event.originalEvent.clientX;
484                 p.y = event.originalEvent.clientY;
485                 p = p.matrixTransform(g.getCTM().inverse());
486                 var scaleLevel = 1+(z/20);
487                 var k = root.createSVGMatrix().translate(p.x, p.y).scale(scaleLevel).translate(-p.x, -p.y);
488                 var matrix = g.getCTM().multiply(k);
489                 var s = "matrix(" + matrix.a + "," + matrix.b + "," + matrix.c + "," + matrix.d + "," + matrix.e + "," + matrix.f + ")";
490                 g.setAttribute("transform", s);
491         }
492   }).css({
493     'overflow' : 'hidden',
494     'cursor' : '-moz-grab'
495   });
496   
497   $( "#delete-form" ).dialog({
498     autoOpen: false,
499     height: 135,
500     width: 160,
501     modal: false,
502     buttons: {
503         OK: function() {
504             $( this ).dialog( "close" );
505         }
506     },
507     create: function(event, ui) {
508         var buttonset = $(this).parent().find( '.ui-dialog-buttonset' ).css( 'width', '100%' );
509         buttonset.find( "button:contains('Cancel')" ).css( 'float', 'right' );
510         var dialog_aria = $("div[aria-labelledby='ui-dialog-title-delete-form']");  
511         dialog_aria.mouseenter( function() {
512             if( mouseWait != null ) { clearTimeout(mouseWait) };
513         })
514         dialog_aria.mouseleave( function() {
515             mouseWait = setTimeout( function() { $("#delete-form").dialog( "close" ) }, 2000 );
516         })
517     },
518     open: function() {
519         mouseWait = setTimeout( function() { $("#delete-form").dialog( "close" ) }, 2000 );
520     },
521     close: function() {
522     }
523   });
524
525   // function for reading form dialog should go here; 
526   // just hide the element for now if we don't have morphology
527   if( can_morphologize ) {
528           $('#reading-form').dialog({
529                 autoOpen: false,
530                 width: 450,
531                 modal: true,
532                 buttons: {
533                         OK: function() {
534                                 $( this ).dialog( "close" );
535                         }
536                 },
537                 create: function() {
538                         // Hide the relemmatize button since it is not allowed
539                         $('#reading_relemmatize').hide();
540                 },
541                 open: function() {
542                         $(".ui-widget-overlay").css("background", "none");
543                         $("#dialog_overlay").show();
544                         $('#reading_status').empty();
545                         $("#dialog_overlay").height( $("#enlargement_container").height() );
546                         $("#dialog_overlay").width( $("#enlargement_container").innerWidth() );
547                         $("#dialog_overlay").offset( $("#enlargement_container").offset() );
548                 },
549                 close: function() {
550                         $("#dialog_overlay").hide();
551                 }
552           }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) {
553                   if( ajaxSettings.url.lastIndexOf( getReadingURL('') ) > -1
554                         && ajaxSettings.type == 'POST' && jqXHR.status == 403 ) {
555                           var errobj = jQuery.parseJSON( jqXHR.responseText );
556                           $('#reading_status').append( '<p class="error">Error: ' + errobj.error + '</p>' );
557                   }
558                   $(event.target).parent().find('.ui-button').button("enable");
559           });
560   } else {
561         $('#reading-form').hide();
562   }
563   
564   // Hide the unused elements
565   $('#dialog-form').hide();
566   $('#update_workspace_button').hide();
567   
568   $('.helptag').popupWindow({ 
569           height:500, 
570           width:800, 
571           top:50, 
572           left:50,
573           scrollbars:1 
574   }); 
575
576   
577   expandFillPageClients();
578   $(window).resize(function() {
579     expandFillPageClients();
580   });
581
582 });
583
584
585 function expandFillPageClients() {
586         $('.fillPage').each(function () {
587                 $(this).height($(window).height() - $(this).offset().top - MARGIN);
588         });
589 }
590
591 function loadSVG(svgData) {
592         var svgElement = $('#svgenlargement');
593
594         $(svgElement).svg('destroy');
595
596         $(svgElement).svg({
597                 loadURL: svgData,
598                 onLoad : svgEnlargementLoaded
599         });
600 }
601
602
603 /*      OS Gadget stuff
604
605 function svg_select_callback(topic, data, subscriberData) {
606         svgData = data;
607         loadSVG(svgData);
608 }
609
610 function loaded() {
611         var prefs = new gadgets.Prefs();
612         var preferredHeight = parseInt(prefs.getString('height'));
613         if (gadgets.util.hasFeature('dynamic-height')) gadgets.window.adjustHeight(preferredHeight);
614         expandFillPageClients();
615 }
616
617 if (gadgets.util.hasFeature('pubsub-2')) {
618         gadgets.HubSettings.onConnect = function(hum, suc, err) {
619                 subId = gadgets.Hub.subscribe("interedition.svg.selected", svg_select_callback);
620                 loaded();
621         };
622 }
623 else gadgets.util.registerOnLoadHandler(loaded);
624 */