From: Tara L Andrews Date: Wed, 5 Jun 2013 15:31:06 +0000 (+0200) Subject: re-merge the full and readonly versions of relationship.js X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=30d0ba1eb65182ce262cc2e67a20d70519b0a419;p=scpubgit%2Fstemmaweb.git re-merge the full and readonly versions of relationship.js --- diff --git a/root/js/relationship-readonly.js b/root/js/relationship-readonly.js deleted file mode 100644 index d6cf53d..0000000 --- a/root/js/relationship-readonly.js +++ /dev/null @@ -1,623 +0,0 @@ -var MARGIN=30; -var svg_root = null; -var svg_root_element = null; -var start_element_height = 0; -var reltypes = {}; -var readingdata = {}; - -function getTextURL( which ) { - return basepath + textid + '/' + which; -} - -function getReadingURL( reading_id ) { - return basepath + textid + '/reading/' + reading_id; -} - -// Make an XML ID into a valid selector -function jq(myid) { - 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 ); - toggle_checkbox( $('#reading_is_nonsense'), reading_info['is_nonsense'] ); - toggle_checkbox( $('#reading_grammar_invalid'), 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. - morphology_form( reading_info['lexemes'] ); - // and then open the dialog. - $('#reading-form').dialog("open"); -} - -function toggle_checkbox( box, value ) { - if( value == null ) { - value = false; - } - box.attr('checked', value ); -} - -function morphology_form ( lexlist ) { - if( lexlist.length ) { - $('#morph_outer').show(); - $('#morphology').empty(); - $.each( lexlist, function( idx, lex ) { - var morphoptions = []; - if( 'wordform_matchlist' in lex ) { - $.each( lex['wordform_matchlist'], function( tdx, tag ) { - var tagstr = stringify_wordform( tag ); - morphoptions.push( tagstr ); - }); - } - var formtag = 'morphology_' + idx; - var formstr = ''; - if( 'form' in lex ) { - 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 ); - }); - }); - } else { - $('#morph_outer').hide(); - } -} - -function stringify_wordform ( tag ) { - if( tag ) { - var elements = tag.split(' // '); - return elements[1] + ' // ' + elements[2]; - } - return '' -} - -function morph_elements ( formtag, formtxt, currform, morphoptions ) { - var clicktag = '(Click to select)'; - if ( !currform ) { - currform = clicktag; - } - var formlabel = $('