From: Tara L Andrews Date: Sat, 5 May 2012 10:29:14 +0000 (+0200) Subject: better autoselect logic; encapsulate creation of morphology elements X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d11323067803a7f40e4aa9712fb74e28df6c232f;p=scpubgit%2Fstemmaweb.git better autoselect logic; encapsulate creation of morphology elements --- diff --git a/root/js/relationship.js b/root/js/relationship.js index 7f6ed87..ac621f2 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -75,17 +75,13 @@ function node_dblclick_listener( evt ) { morphoptions.push( tagstr ); }); var formtag = 'morphology_' + idx; - var form_morph_elements = morph_elements( formtag ); - form_morph_elements[0].text( lex['string'] + ': ' ); - form_morph_elements[1].autocomplete({ - source: morphoptions, - minLength: 0 - }); //forminput.autocomplete('search', ''); + var formstr = ''; if( lex['form'] ) { - var formstr = stringify_wordform( lex['form'] ); - form_morph_elements[1].val( formstr ); + 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 ); }); @@ -97,11 +93,22 @@ function stringify_wordform ( tag ) { return tag['lemma'] + ' // ' + tag['morphology']; } -function morph_elements ( formtag ) { +function morph_elements ( formtag, formtxt, currform, morphoptions ) { + var clicktag = '(Click to select)'; + if ( !currform ) { + currform = clicktag; + } var formlabel = $('