From 5b66f2240a68ff7cc5f82959757a9304e79a0460 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 28 Feb 2011 01:00:45 -0500 Subject: [PATCH] improve UI responsiveness with setTimeout --- .../staff_client/server/cat/volume_copy_creator.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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 ); -- 2.11.0