return '#' + myid.replace(/(:|\.)/g,'\\$1');
}
+// Actions for opening the reading panel
+function node_dblclick_listener( evt ) {
+ // Open the reading dialogue for the given node.
+ // First get the reading info
+ var reading_id = $(this).attr('id');
+ var reading_info = readingdata[reading_id];
+ // and then populate the dialog box with it.
+ // Set the easy properties first
+ $('#reading-form').dialog( 'option', 'title', 'Reading information for "' + reading_info['text'] + '"' );
+ $('#reading_id').val( reading_id );
+ $('#reading_is_nonsense').val( reading_info['is_nonsense'] );
+ $('#reading_grammar_invalid').val( reading_info['grammar_invalid'] );
+ // Use .text as a backup for .normal_form
+ var normal_form = reading_info['normal_form'];
+ if( !normal_form ) {
+ normal_form = reading_info['text'];
+ }
+ var nfboxsize = 10;
+ if( normal_form.length > 9 ) {
+ nfboxsize = normal_form.length + 1;
+ }
+ $('#reading_normal_form').attr( 'size', nfboxsize )
+ $('#reading_normal_form').val( normal_form );
+ // Now do the morphological properties.
+ // and then open the dialog.
+ $('#morphology').empty();
+ $.each( reading_info['lexemes'], function( idx, lex ) {
+ var morphoptions = [];
+ $.each( lex['wordform_matchlist'], function( tdx, tag ) {
+ var tagstr = stringify_wordform( tag );
+ morphoptions.push( tagstr );
+ });
+ var formtag = 'morphology_' + idx;
+ //forminput.autocomplete('search', '');
+ var formstr = '';
+ if( lex['form'] ) {
+ formstr = stringify_wordform( lex['form'] );
+ }
+ var form_morph_elements = morph_elements(
+ formtag, lex['string'], formstr, morphoptions );
+ $.each( form_morph_elements, function( idx, el ) {
+ $('#morphology').append( el );
+ });
+ });
+ $('#reading-form').dialog("open");
+}
+
+function stringify_wordform ( tag ) {
+ return tag['lemma'] + ' // ' + tag['morphology'];
+}
+
+function morph_elements ( formtag, formtxt, currform, morphoptions ) {
+ var clicktag = '(Click to select)';
+ if ( !currform ) {
+ currform = clicktag;
+ }
+ var formlabel = $('<label/>').attr( 'id', 'label_' + formtag ).attr(
+ 'for', 'reading_' + formtag ).text( formtxt + ': ' );
+ var forminput = $('<input/>').attr( 'id', 'reading_' + formtag ).attr(
+ 'name', 'reading_' + formtag ).attr( 'size', '50' ).val( currform );
+ forminput.autocomplete({ source: morphoptions, minLength: 0 });
+ forminput.focus( function() {
+ if( $(this).val() == clicktag ) {
+ $(this).val('');
+ }
+ $(this).autocomplete('search', '')
+ });
+ var morphel = [ formlabel, forminput, $('<br/>') ];
+ return morphel;
+}
+
+function color_inactive ( el ) {
+ var reading_id = $(el).parent().attr('id');
+ var reading_info = readingdata[reading_id];
+ // If the reading info has any non-disambiguated lexemes, color it yellow;
+ // otherwise color it green.
+ $(el).attr( {stroke:'green', fill:'#b3f36d'} );
+ $.each( reading_info['lexemes'], function ( idx, lex ) {
+ if( !lex['is_disambiguated'] ) {
+ $(el).attr( {stroke:'orange', fill:'#fee233'} );
+ }
+ });
+}
+
+// Initialize the SVG once it exists
function svgEnlargementLoaded() {
//Give some visual evidence that we are working
$('#loading_overlay').show();
$('#update_workspace_button').data('locked', false);
$('#update_workspace_button').css('background-position', '0px 44px');
//This is essential to make sure zooming and panning works properly.
- $('#svgenlargement ellipse').attr( {stroke:'green', fill:'#b3f36d'} );
+ var rdgpath = getTextURL( 'readings' );
+ $.getJSON( rdgpath, function( data ) {
+ readingdata = data;
+ $('#svgenlargement ellipse').each( function( i, el ) { color_inactive( el ) });
+ });
+ $('#svgenlargement ellipse').parent().dblclick( node_dblclick_listener );
var graph_svg = $('#svgenlargement svg');
var svg_g = $('#svgenlargement svg g')[0];
if (!svg_g) return;
}
}
- // This might be a little application specific and should be pushed to the backend
- // but... This collapes corrector hands when they agree with the original
- // e.g., P46-*,P46-C becomes simply P46
- $(svg_root).find('text').each(function () {
- var t = $(this).text();
- var ws = t.split(',');
- for (i = 0; i < ws.length; ++i) {
- if (ws[i].indexOf('-*')> -1) {
- var collapse = false;
- var main = $.trim(ws[i].substring(0,ws[i].indexOf('-')));
- for (j = 0; j < ws.length; ++j) {
- if (i != j && ws[j].indexOf('-')> -1) {
- var pair = $.trim(ws[j].substring(0,ws[j].indexOf('-')));
- if (main == pair) {
- collapse = true;
- ws[j] = '';
- }
- }
- }
- if (collapse) ws[i] = main;
- }
- }
- t = '';
- for (i = 0; i < ws.length; ++i) {
- if (ws[i].length) {
- if (t.length>0) t+=', ';
- t+=ws[i];
- }
- }
- $(this).text(t);
- });
-
svg_root.viewBox.baseVal.width = graph_svg.attr( 'width' );
svg_root.viewBox.baseVal.height = graph_svg.attr( 'height' );
//Now set scale and translate so svg height is about 150px and vertically centered in viewbox.
var transform = 'rotate(0) scale(' + scale + ') translate(4 ' + translate + ')';
svg_g.setAttribute('transform', transform);
//used to calculate min and max zoom level:
- start_element_height = $('#__START__ ellipse')[0].getBBox().height;
+ start_element_height = $('#__START__').children('ellipse')[0].getBBox().height;
add_relations( function() { $('#loading_overlay').hide(); });
}
self.ellipse.siblings('text').attr('class', 'noselect draggable');
} else {
self.ellipse.siblings('text').attr('class', '');
- $(self.ellipse).parent().unbind('mouseenter').unbind('mouseleave').unbind('mousedown');
- $(self.ellipse).attr( {stroke:'green', fill:'#b3f36d'} );
+ $(self.ellipse).parent().unbind( 'mouseenter' ).unbind( 'mouseleave' ).unbind( 'mousedown' );
+ color_inactive( self.ellipse );
}
}
$(self.ellipse).parent().hover( self.enter_node, self.leave_node );
self.reset_elements();
}
-
+
this.cpos = function() {
return { x: self.ellipse.attr('cx'), y: self.ellipse.attr('cy') };
}
'cursor' : '-moz-grab'
});
- var rdgpath = getTextURL( 'readings' );
- $.getJSON( rdgpath, function( data ) {
- readingdata = data;
- });
$( "#dialog-form" ).dialog({
autoOpen: false,
$('#reading-form').dialog({
autoOpen: false,
height: 400,
- width: 200,
+ width: 600,
modal: true,
buttons: {
Cancel: function() {
}
},
create: function() {},
- open: function() {},
+ open: function() {
+ $(".ui-widget-overlay").css("background", "none");
+ $("#dialog_overlay").show();
+ $("#dialog_overlay").height( $("#enlargement_container").height() );
+ $("#dialog_overlay").width( $("#enlargement_container").innerWidth() );
+ $("#dialog_overlay").offset( $("#enlargement_container").offset() );
+ },
close: function() {
$("#dialog_overlay").hide();
}
});
+
+ $('#reading_relemmatize').button();
$('#update_workspace_button').click( function() {
var svg_enlargement = $('#svgenlargement').svg().svg('get').root();