From b7e979dae4ba5d9b50dc161c51821d73e0f60030 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 2 Dec 2014 03:47:13 -0500 Subject: [PATCH] feature(dom) showLoad, showError -> show.load, show.error --- lib/client.js | 4 ++-- lib/client/config.js | 8 ++++--- lib/client/contact.js | 2 +- lib/client/dom.js | 44 ++++++++++++++++++---------------- lib/client/edit.js | 2 +- lib/client/help.js | 3 ++- lib/client/key.js | 2 +- lib/client/konsole.js | 2 +- lib/client/load.js | 2 +- lib/client/markdown.js | 4 ++-- lib/client/menu.js | 2 +- lib/client/rest.js | 2 +- lib/client/storage/_dropbox.js | 2 +- lib/client/storage/_github.js | 2 +- lib/client/terminal.js | 2 +- lib/client/upload.js | 4 ++-- lib/client/view.js | 2 +- 17 files changed, 47 insertions(+), 42 deletions(-) diff --git a/lib/client.js b/lib/client.js index ffde50a7..e0319b88 100644 --- a/lib/client.js +++ b/lib/client.js @@ -58,7 +58,7 @@ var Util, DOM, CloudFunc, join; top: true }; - Images.showLoad(imgPosition); + Images.show.load(imgPosition); /* загружаем содержимое каталога */ ajaxLoad(link, { @@ -199,7 +199,7 @@ var Util, DOM, CloudFunc, join; Files.get('modules', function(error, modules) { var storageObj, mod, path, STORAGE = 'storage', - showLoad = Images.showLoad.bind(Images), + showLoad = Images.show.load, doBefore = { 'edit' : showLoad, diff --git a/lib/client/config.js b/lib/client/config.js index c46c9240..be3b30bb 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -10,9 +10,11 @@ var CloudCmd, Util, DOM, io; Key = CloudCmd.Key, Images = DOM.Images, Events = DOM.Events, - showLoad = Images.showLoad.bind(DOM, { - top: true - }), + showLoad = function() { + Images.show.load({ + top: true + }); + }, Element, INPUT = 'INPUT', CONFIG, diff --git a/lib/client/contact.js b/lib/client/contact.js index 759e2cd7..66e82de5 100644 --- a/lib/client/contact.js +++ b/lib/client/contact.js @@ -34,7 +34,7 @@ var CloudCmd, Util, DOM, olark; function load(callback) { var path = DIR + 'contact/olark.js'; - Images.showLoad({top: true}); + Images.show.load({top: true}); DOM.load.js(path, callback); } diff --git a/lib/client/dom.js b/lib/client/dom.js index 5c437012..411a2b7a 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -77,12 +77,17 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; }; - Images = new ImageElementProto(); + Images = new ImageElementProto(); + + this.show = load; + this.show.load = load; + this.show.error = error; + /** * Function shows loading spinner - * pPosition = {top: true}; + * position = {top: true}; */ - this.showLoad = function(position) { + function load(position) { var top = position && position.top, current, image = Images.loading(), @@ -101,20 +106,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; DOM.show(image); return image; - }; - - /** - * hide load image - */ - this.hide = function() { - var element = Images.get(); - DOM.hide(element); - }; - - /** - * show error image (usualy after error on ajax request) - */ - this.showError = function(jqXHR, isQuiet) { + } + + function error(jqXHR, isQuiet) { var isStr = Util.type.string(jqXHR), image = Images.error(), response = '', @@ -144,6 +138,14 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }, 100); return image; + } + + /** + * hide load image + */ + this.hide = function() { + var element = Images.get(); + DOM.hide(element); }; this.setProgress = function(value, title) { @@ -436,7 +438,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; name = file.name, path = dir + name; - Images.showLoad({top: true}); + Images.show.load({top: true}); Images.setProgress(0, name); DOM.RESTful.write(path, file, callback); @@ -524,7 +526,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; nameFile = Util.rmStrOnce(name, '.gz'); } - Images.showLoad(); + Images.show.load(); if (name && name !== '..') op(fileFrom, function() { @@ -781,7 +783,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; query = '?size', link = this.getCurrentPath(current); - Images.showLoad(); + Images.show.load(); if (name !== '..') RESTful.read(link + query, function(size) { @@ -1607,7 +1609,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (name === '..') { Dialog.alert('No files selected!'); } else { - Images.showLoad({ + Images.show.load({ top:true }); diff --git a/lib/client/edit.js b/lib/client/edit.js index b6e6d5e0..5a726599 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -123,7 +123,7 @@ var CloudCmd, Util, DOM, CloudFunc, io, ace, DiffProto, diff_match_patch, Zip, M var func = exec.ret(callback); if (!Loading) { - Images.showLoad(); + Images.show.load(); if (!Element) { Element = DOM.load({ diff --git a/lib/client/help.js b/lib/client/help.js index ccf8c594..fe6f589a 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -10,9 +10,10 @@ var CloudCmd, Util, DOM; Help = this; function init() { - Images.showLoad({ + Images.show.load({ top: true }); + Help.show(); } diff --git a/lib/client/key.js b/lib/client/key.js index 75164137..3fb19a12 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -288,7 +288,7 @@ var CloudCmd, Util, DOM; break; case Key.TRA: - DOM.Images.showLoad({top: true}); + DOM.Images.show.load({top: true}); if (shift) obj = CloudCmd.Terminal; diff --git a/lib/client/konsole.js b/lib/client/konsole.js index 6d00294c..741d57f7 100644 --- a/lib/client/konsole.js +++ b/lib/client/konsole.js @@ -15,7 +15,7 @@ var CloudCmd, Util, join, DOM, CloudFunc, Console; Konsole = this; function init() { - Images.showLoad({top:true}); + Images.show.load({top:true}); Util.exec.series([ DOM.loadJquery, diff --git a/lib/client/load.js b/lib/client/load.js index 5209165d..ad7efbe4 100644 --- a/lib/client/load.js +++ b/lib/client/load.js @@ -62,7 +62,7 @@ var Util, DOM; parent.removeChild(element); - Images.showError(msg, isQuit); + Images.show.error(msg, isQuit); Util.exec(callback, error); }; diff --git a/lib/client/markdown.js b/lib/client/markdown.js index e2f8d6cd..b8a31ad0 100644 --- a/lib/client/markdown.js +++ b/lib/client/markdown.js @@ -12,7 +12,7 @@ var CloudCmd, Util, DOM; MD = this; function init() { - Images.showLoad({ + Images.show.load({ top:true }); @@ -34,7 +34,7 @@ var CloudCmd, Util, DOM; options = optionsParam; if (options) { - Images.showLoad({ + Images.show.load({ top: o.topLoad }); diff --git a/lib/client/menu.js b/lib/client/menu.js index 4b7c5969..d54d545e 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -217,7 +217,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; } function getFromPicker() { - Images.showLoad({ + Images.show.load({ top: true }); diff --git a/lib/client/rest.js b/lib/client/rest.js index 2db7af18..a69f4894 100644 --- a/lib/client/rest.js +++ b/lib/client/rest.js @@ -187,7 +187,7 @@ var Util, DOM, CloudFunc, CloudCmd; url : p.url, data : p.data, dataType : p.dataType, - error : Images.showError, + error : Images.show.error, success : function(data) { Images.hide(); diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 20855ed8..868209c9 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -132,7 +132,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dropbox, cb, Client; if (!name) name = Util.getDate(); - DOM.Images.showLoad(); + DOM.Images.show.load(); Client.writeFile(name, data, function(error, data){ DOM.Images.hide(); diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index 1437a5b0..b3fd9678 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -127,7 +127,7 @@ var CloudCmd, Util, join, DOM, CloudFunc, Github, cb; name = params.name; if (content) { - DOM.Images.showLoad(); + DOM.Images.show.load(); if (!name) name = Util.getDate(); diff --git a/lib/client/terminal.js b/lib/client/terminal.js index 4801b9c8..679980d2 100644 --- a/lib/client/terminal.js +++ b/lib/client/terminal.js @@ -42,7 +42,7 @@ var CloudCmd, Util, DOM, CloudFunc, Terminal, io; function show(callback) { if (!Loading) { - Images.showLoad({top:true}); + Images.show.load({top:true}); if (!Element) { Element = DOM.load({ diff --git a/lib/client/upload.js b/lib/client/upload.js index bd291afc..aacfe3be 100644 --- a/lib/client/upload.js +++ b/lib/client/upload.js @@ -12,7 +12,7 @@ var CloudCmd, Util, DOM; Upload = this; function init() { - Images.showLoad({ + Images.show.load({ top: true }); @@ -23,7 +23,7 @@ var CloudCmd, Util, DOM; } this.show = function() { - Images.showLoad({ + Images.show.load({ top: true }); diff --git a/lib/client/view.js b/lib/client/view.js index 31b95b95..659650b0 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -124,7 +124,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; $.fancybox(element, config); } else { - Images.showLoad(); + Images.show.load(); path = CloudFunc.FS + Info.path; type = getType(path);