X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=stemmaweb%2Froot%2Fjs%2Frelationship.js;h=72f83b2a0f415a6d7c1ed57847b5962641027e84;hb=f52467de2be0f8d7de9da735d717a016cbc23aac;hp=ed43d5dcb395365fb576ef5872eb62ee10b8a5ca;hpb=397f3cf456fe5baf57f53a1d352c19dde8a3dac4;p=scpubgit%2Fstemmatology.git diff --git a/stemmaweb/root/js/relationship.js b/stemmaweb/root/js/relationship.js index ed43d5d..72f83b2 100644 --- a/stemmaweb/root/js/relationship.js +++ b/stemmaweb/root/js/relationship.js @@ -136,15 +136,18 @@ function color_inactive ( el ) { // 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'} ); - } - }); + if( reading_info ) { + $.each( reading_info['lexemes'], function ( idx, lex ) { + if( !lex['is_disambiguated'] || lex['is_disambiguated'] == 0 ) { + $(el).attr( {stroke:'orange', fill:'#fee233'} ); + } + }); + } } function relemmatize () { // Send the reading for a new lemmatization and reopen the form. + $('#relemmatize_pending').show(); var reading_id = $('#reading_id').val() ncpath = getReadingURL( reading_id ); form_values = { @@ -160,6 +163,7 @@ function relemmatize () { } else { alert("Could not relemmatize as requested: " + data['error']); } + $('#relemmatize_pending').hide(); }); } @@ -645,11 +649,11 @@ $(document).ready(function () { width: 290, modal: true, buttons: { - "Ok": function() { + "Ok": function( evt ) { + $(evt.target).button("disable"); $('#status').empty(); form_values = $('#collapse_node_form').serialize(); ncpath = getTextURL( 'relationships' ); - $(':button :contains("Ok")').attr("disabled", true); var jqjson = $.post( ncpath, form_values, function(data) { $.each( data, function(item, source_target) { var source_found = get_ellipse( source_target[0] ); @@ -661,7 +665,8 @@ $(document).ready(function () { relation.data( 'note', $('#note').val() ); relation_manager.toggle_active( relation.attr('id') ); } - }); + $(evt.target).button("enable"); + }); $( "#dialog-form" ).dialog( "close" ); }, 'json' ); }, @@ -703,6 +708,7 @@ $(document).ready(function () { && ajaxSettings.type == 'POST' && jqXHR.status == 403 ) { var errobj = jQuery.parseJSON( jqXHR.responseText ); $('#status').append( '

Error: ' + errobj.error + '
The relationship cannot be made.

' ); + $(event.target).parent().find('.ui-button').button("enable"); } } ); @@ -754,7 +760,9 @@ $(document).ready(function () { Cancel: function() { $( this ).dialog( "close" ); }, - Update: function() { + Update: function( evt ) { + // Disable the button + $(evt.target).button("disable"); $('#reading_status').empty(); var reading_id = $('#reading_id').val() form_values = { @@ -771,7 +779,7 @@ $(document).ready(function () { // Make the JSON call ncpath = getReadingURL( reading_id ); var reading_element = readingdata[reading_id]; - $(':button :contains("Update")').attr("disabled", true); + // $(':button :contains("Update")').attr("disabled", true); var jqjson = $.post( ncpath, form_values, function(data) { $.each( data, function(key, value) { reading_element[key] = value; @@ -779,6 +787,7 @@ $(document).ready(function () { if( $('#update_workspace_button').data('locked') == false ) { color_inactive( get_ellipse( reading_id ) ); } + $(evt.target).button("enable"); $( "#reading-form" ).dialog( "close" ); }); // Re-color the node if necessary @@ -803,6 +812,7 @@ $(document).ready(function () { && ajaxSettings.type == 'POST' && jqXHR.status == 403 ) { var errobj = jQuery.parseJSON( jqXHR.responseText ); $('#reading_status').append( '

Error: ' + errobj.error + '

' ); + $(event.target).parent().find('.ui-button').button("enable"); } });