From: Jason Etheridge Date: Mon, 28 Feb 2011 06:00:45 +0000 (-0500) Subject: improve UI responsiveness with setTimeout X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=5b66f2240a68ff7cc5f82959757a9304e79a0460;p=evergreen%2Fequinox.git improve UI responsiveness with setTimeout --- diff --git a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js index 07398b2b86..37d1500ced 100644 --- a/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js +++ b/Open-ILS/xul/staff_client/server/cat/volume_copy_creator.js @@ -359,12 +359,21 @@ g.render_barcode_entry = function(node,callnumber,count,ou_id) { setTimeout( function() { ev.target.select(); ev.target.focus(); }, 0); } if (xulG.unified_interface) { - g.gather_copies(); - try { - xulG.refresh_copy_editor(); - } catch(E) { - alert('Error in volume_copy_editor.js trying to call xulG.refresh_copy_editor(): ' + E); + if (g.update_copy_editor_timeoutID) { + clearTimeout(g.update_copy_editor_timeoutID); } + // This function is expensive when it comes to keeping the UI responsive, so let's give it a delay + // that quick entry of consecutive barcodes can override + g.update_copy_editor_timeoutID = setTimeout( + function() { + g.gather_copies(); + try { + xulG.refresh_copy_editor(); + } catch(E) { + alert('Error in volume_copy_editor.js trying to call xulG.refresh_copy_editor(): ' + E); + } + }, 2000 + ); } }, false); tb.addEventListener( 'focus', function(ev) { g.last_focus = ev.target; }, false );