Include text direction as editable attribute of a tradition
[scpubgit/stemmaweb.git] / root / js / componentload.js
index 5c9412d..60757c6 100644 (file)
@@ -185,7 +185,6 @@ function query_stemweb_progress() {
        $.getJSON( requrl, function (data) {
                process_stemweb_result( data );
        });
-       // TODO need an error handler
 }
 
 function process_stemweb_result(data) {
@@ -203,6 +202,9 @@ function process_stemweb_result(data) {
                                var newIdx = stemmata.length - data.stemmata.length;
                                load_stemma( newIdx, true );
                        } 
+                       // Hide the call dialog no matter how we got here
+                       $('#call_stemweb').hide()
+                       $('#stemweb_run_button').hide();
                        $('#stemweb_run_status').empty().append( 
                                _make_message( 'notification', 'You have one or more new stemmata!' ) );
                } else {
@@ -212,7 +214,7 @@ function process_stemweb_result(data) {
        } else if( data.status === 'running' ) {
                // Just tell the user.
                $('#stemweb_run_status').empty().append( 
-                               _make_message( 'notification', 'Your Stemweb query is still running!' ) );
+                               _make_message( 'warning', 'Your Stemweb query is still running!' ) );
        } else if( data.status === 'notfound' ) {
                // Ask the user to refresh, for now.
                $('#stemweb_run_status').empty().append( 
@@ -272,6 +274,11 @@ function loadSVG(svgData) {
 
 function set_stemma_interactive( svg_element ) {
        if( selectedTextEditable ) {
+         // unbind is needed as this set_stemma_interactive is called each time
+         // the stemma is re-rooted, and each time jquery adds an 
+         // onclick handler to the root_tree_dialog_button_ok
+         // that all re-root the stemma, that all add an onclick, etc..
+         $( "#root_tree_dialog_button_ok" ).unbind();
                $( "#root_tree_dialog_button_ok" ).click( function() {
                        var requrl = _get_url([ "stemmaroot", selectedTextID, selectedStemmaID ]);
                        var targetnode = $('#root_tree_dialog').data( 'selectedNode' );
@@ -496,7 +503,7 @@ $(document).ready( function() {
                        $("#edit_textinfo_status").empty();
                        // Populate the form fields with the current values
                        // edit_(name, language, public, owner)
-                       $.each([ 'name', 'language', 'owner' ], function( idx, k ) {
+                       $.each([ 'name', 'language', 'owner', 'direction' ], function( idx, k ) {
                                var fname = '#edit_' + k;
                                // Special case: language Default is basically language null
                                if( k == 'language' && selectedTextInfo[k] == 'Default' ) {
@@ -604,13 +611,13 @@ $(document).ready( function() {
                                // whether to send application/json or application/xml?
                                $.getJSON( requrl, reqparam, function (data) {
                                        mybuttons.button("enable");
-                                       $('#stemweb-ui-dialog').dialog('close');
                                        if( 'jobid' in data ) {
                                                // There is a pending job.
                                                selectedTextInfo.stemweb_jobid = data.jobid;
-                                               alert("Your request has been submitted to Stemweb.\nThe resulting tree will appear in due course.");
+                                               $('#stemweb_run_status').empty().append( 
+                                                       _make_message( 'notification', "Your request has been submitted to Stemweb.\nThe resulting tree will appear in due course." ) );
                                                // Reload the current stemma to rejigger the buttons
-                                               load_stemma( selectedStemmaID, true );
+                                               switch_stemweb_ui();
                                        } else {
                                                // We appear to have an answer; process it.
                                                process_stemweb_result( data );