diff --git a/lib/client/operation.js b/lib/client/operation.js index d14c9109..1503a003 100644 --- a/lib/client/operation.js +++ b/lib/client/operation.js @@ -22,6 +22,8 @@ Images = DOM.Images, Dialog = DOM.Dialog, + showLoad = Images.show.load.bind(null, 'top'), + Operation = this; function rmLastSlash(str) { @@ -29,7 +31,7 @@ } function init() { - Images.show.load(); + showLoad(); Util.exec.series([ DOM.loadSocket, @@ -88,27 +90,36 @@ } function setListeners(emitter, callback) { - var listeners = { - progress: function(value) { - Images.setProgress(value); - }, - - end: function() { - callback(); - events.forEach(function(name) { - emitter.removeListener(name, listeners[name]); - }); - }, - - error: function(data) { - var msg = data + '\n Continue?', - is = confirm(msg); + var wasError, + listeners = { + progress: function(value) { + Images.setProgress(value); + }, - if (is) - spero.continue(); - else - spero.abort(); - } + end: function() { + if (!wasError) + callback(); + + Images + .hide() + .clearProgress(); + + events.forEach(function(name) { + emitter.removeListener(name, listeners[name]); + }); + }, + + error: function(error) { + var msg = error + '\n Continue?', + is = confirm(msg); + + if (is) { + emitter.continue(); + } else { + wasError = true; + emitter.abort(); + } + } }, events = Object.keys(listeners); @@ -217,7 +228,7 @@ path = Info.dirPath, current = Info.element; - Images.show(); + showLoad(); if (!files) files = DOM.getSelectedFiles(); @@ -296,7 +307,7 @@ })); if (ok) { - Images.show.load('top'); + showLoad(); files = { from : from,