diff --git a/lib/client/buffer.js b/lib/client/buffer.js index 3a830755..bb830056 100644 --- a/lib/client/buffer.js +++ b/lib/client/buffer.js @@ -29,11 +29,10 @@ }; function getNames() { - var name = Info.name, - names = DOM.getSelectedNames(), - n = names.length; + var files = DOM.getActiveFiles(), + names = DOM.getSelectedNames(files); - return n ? names : [name]; + return names; } function addCutClass() { @@ -130,13 +129,13 @@ data = json.parse(opData); data.to = path; - if (data.from === path) + if (data.from === path) { Dialog.alert(msg); - else + } else { Operation.show(opStr, data); + clear(); + } } - - clear(); }); } diff --git a/lib/client/dom.js b/lib/client/dom.js index bac549b4..c95efa55 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -9,9 +9,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; DOMProto, DialogProto = function() { - this.alert = alert.bind(window); - this.prompt = prompt.bind(window); - this.confirm = confirm.bind(window); + var self = this; + + this.alert = alert.bind(window); + this.prompt = prompt.bind(window); + this.confirm = confirm.bind(window); + + this.alert.noFiles = function() { + self.alert('No files selected!'); + }; }, ImagesProto = function() { @@ -475,7 +481,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Util.check(arguments, ['operation']); if (!names.length) { - Dialog.alert('No files selected!'); + Dialog.alert.noFiles(); } else { switch(operation) { case 'extract': @@ -755,6 +761,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.getCurrentData = function(callback, currentFile) { var hash, RESTful = DOM.RESTful, + Info = DOM.CurrentInfo, current = currentFile || DOM.getCurrentFile(), path = DOM.getCurrentPath(current), isDir = DOM.isCurrentIsDir(current), @@ -773,7 +780,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Util.exec(callback, null, data); }; - if (isDir) + if (Info.name === '..') + callback('No files selected!'); + else if (isDir) RESTful.read(path, func); else DOM.checkStorageHash(path, function(error, equal, hashNew) { @@ -1437,7 +1446,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; from = Cmd.getCurrentName(current); if (from === '..') { - Dialog.alert('No files selected!'); + Dialog.alert.noFiles(); } else { to = Dialog.prompt('Rename', from) || from; isExist = !!DOM.getCurrentByName(to); diff --git a/lib/client/edit.js b/lib/client/edit.js index 486b628d..772e9140 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -14,7 +14,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; Edit = this, Menu, - + Dialog = DOM.Dialog, Editor = 'edward', Images = DOM.Images, @@ -82,7 +82,8 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; name += '.json'; if (error) { - alert(error); + Images.hide(); + Dialog.alert(error); } else { edward.setValueFirst(path, data); @@ -126,7 +127,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; function getConfig(callback) { DOM.Files.get('config', function(error, config) { if (error) - alert(error); + Dialog.alert(error); else if (config.editor) Editor = config.editor; @@ -196,7 +197,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format, edward; }; if (error) { - alert(error); + Dialog.alert(error); } else if (!Menu && MenuIO) { Menu = new MenuIO(Element, options, menuData); Menu.show(position.x, position.y); diff --git a/lib/client/operation.js b/lib/client/operation.js index 1503a003..e29e7b23 100644 --- a/lib/client/operation.js +++ b/lib/client/operation.js @@ -208,7 +208,7 @@ if (name !== '..') ret = Dialog.confirm(msg); else - Dialog.alert('No files selected!'); + Dialog.alert.noFiles(); if (ret) deleteSilent(files); @@ -294,7 +294,7 @@ sameName = !!DOM.getCurrentByName(name, panel); if (name === '..') { - Dialog.alert('No files selected!'); + Dialog.alert.noFiles(); } else { if (shouldAsk) to = message(to, names); diff --git a/lib/client/view.js b/lib/client/view.js index 07dd0550..10ed736a 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -11,6 +11,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; var Name = 'View', Loading = false, Events = DOM.Events, + Dialog = DOM.Dialog, Info = DOM.CurrentInfo, Key = CloudCmd.Key, Images = DOM.Images, @@ -129,12 +130,18 @@ var CloudCmd, Util, DOM, CloudFunc, $; switch(type) { default: Info.getData(function(error, data) { - var element = document.createTextNode(data); + var element; + if (error) { + Images.hide(); + Dialog.alert(error); + } else { + element = document.createTextNode(data); /* add margin only for view text documents */ Element.css('margin', '2%'); $.fancybox(Element.append(element), Config); - }); + } + }); break; case 'image':