From: tla Date: Tue, 10 Jun 2014 14:49:17 +0000 (+0200) Subject: Rationalize button disabling/enabling throughout UI X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=932277e1ee255147e7bb3f864b917d96bdbf857d;p=scpubgit%2Fstemmaweb.git Rationalize button disabling/enabling throughout UI --- diff --git a/root/js/componentload.js b/root/js/componentload.js index 06a2991..3abf1a2 100644 --- a/root/js/componentload.js +++ b/root/js/componentload.js @@ -437,7 +437,8 @@ $(document).ready( function() { buttons: { Save: function (evt) { $("#edit_textinfo_status").empty(); - $(evt.target).closest('button').button("disable"); + var mybuttons = $(evt.target).closest('button').parent().find('button'); + mybuttons.button( 'disable' ); var requrl = _get_url([ "textinfo", selectedTextID ]); var reqparam = $('#edit_textinfo').serialize(); $.post( requrl, reqparam, function (data) { @@ -445,7 +446,7 @@ $(document).ready( function() { selectedTextInfo = data; load_textinfo(); // Reenable the button and close the form - $(evt.target).closest('button').button("enable"); + mybuttons.button("enable"); $('#textinfo-edit-dialog').dialog('close'); }, 'json' ); }, @@ -490,7 +491,8 @@ $(document).ready( function() { buttons: { Save: function (evt) { $("#edit_stemma_status").empty(); - $(evt.target).closest('button').button("disable"); + var mybuttons = $(evt.target).closest('button').parent().find('button'); + mybuttons.button( 'disable' ); var stemmaseq = $('#stemmaseq').val(); var requrl = _get_url([ "stemma", selectedTextID, stemmaseq ]); var reqparam = { 'dot': $('#dot_field').val() }; @@ -507,7 +509,7 @@ $(document).ready( function() { // Display the new stemma load_stemma( selectedStemmaID, true ); // Reenable the button and close the form - $(evt.target).closest('button').button("enable"); + mybuttons.button("enable"); $('#stemma-edit-dialog').dialog('close'); }, 'json' ); }, @@ -552,14 +554,15 @@ $(document).ready( function() { buttons: { Run: function (evt) { $("#stemweb_run_status").empty(); - $(evt.target).closest('button').button("disable"); + var mybuttons = $(evt.target).closest('button').parent().find('button'); + mybuttons.button( 'disable' ); var requrl = _get_url([ "stemweb", "request" ]); var reqparam = $('#call_stemweb').serialize(); // TODO We need to stash the literal SVG string in stemmata // somehow. Implement accept header on server side to decide // whether to send application/json or application/xml? $.getJSON( requrl, reqparam, function (data) { - $(evt.target).closest('button').button("enable"); + mybuttons.button("enable"); $('#stemweb-ui-dialog').dialog('close'); if( 'jobid' in data ) { // There is a pending job. diff --git a/root/js/relationship.js b/root/js/relationship.js index 0e253d8..8cb73d4 100644 --- a/root/js/relationship.js +++ b/root/js/relationship.js @@ -1063,18 +1063,20 @@ $(document).ready(function () { modal: true, buttons: { 'Merge readings': function( evt ) { - $( evt.target ).button( 'disable' ); + var mybuttons = $(evt.target).closest('button').parent().find('button'); + mybuttons.button( 'disable' ); $( '#status' ).empty(); form_values = $( '#collapse_node_form' ).serialize(); ncpath = getTextURL( 'merge' ); var jqjson = $.post( ncpath, form_values, function( data ) { merge_nodes( $( '#source_node_id' ).val(), $( '#target_node_id' ).val(), data ); - $(evt.target).button( 'enable' ); + mybuttons.button( 'enable' ); $( '#dialog-form' ).dialog( 'close' ); } ); }, OK: function( evt ) { - $( evt.target ).button( 'disable' ); + var mybuttons = $(evt.target).closest('button').parent().find('button'); + mybuttons.button( 'disable' ); $( '#status' ).empty(); form_values = $( '#collapse_node_form' ).serialize(); ncpath = getTextURL( 'relationships' ); @@ -1090,7 +1092,7 @@ $(document).ready(function () { relation.data( k.name, k.value ); }); } - $(evt.target).button( 'enable' ); + mybuttons.button( 'enable' ); }); $( '#dialog-form' ).dialog( 'close' ); }, 'json' ); @@ -1221,12 +1223,13 @@ $(document).ready(function () { Cancel: function() { $( this ).dialog( "close" ); }, Detach: function ( evt ) { var self = $(this); - $( evt.target ).button( "disable" ); + var mybuttons = $(evt.target).closest('button').parent().find('button'); + mybuttons.button( 'disable' ); var form_values = $('#detach_collated_form').serialize(); ncpath = getTextURL( 'duplicate' ); var jqjson = $.post( ncpath, form_values, function(data) { detach_node( data ); - $(evt.target).button("enable"); + mybuttons.button("enable"); self.dialog( "close" ); } ); } @@ -1308,7 +1311,8 @@ $(document).ready(function () { }, Update: function( evt ) { // Disable the button - $(evt.target).button("disable"); + var mybuttons = $(evt.target).closest('button').parent().find('button'); + mybuttons.button( 'disable' ); $('#reading_status').empty(); var reading_id = $('#reading_id').val() form_values = { @@ -1335,7 +1339,7 @@ $(document).ready(function () { if( $('#update_workspace_button').data('locked') == false ) { color_inactive( get_ellipse( reading_id ) ); } - $(evt.target).button("enable"); + mybuttons.button("enable"); $( "#reading-form" ).dialog( "close" ); }); // Re-color the node if necessary