From 28b2aa1823b5f4353b10febb2e0b886b5870b9dd Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 27 Aug 2012 03:42:30 -0400 Subject: [PATCH] minor changes --- lib/client/menu.js | 50 ++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/lib/client/menu.js b/lib/client/menu.js index 4322129a..2eae0e36 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -14,9 +14,24 @@ var CloudCommander, $; /* enable and disable menu constant */ CloudCommander.Menu.ENABLED = false; - /* function return configureation - * for menu - */ + + CloudCommander.Menu.showEditor = (function(pReadOnly){ + Util.Images.showLoad(); + var lCloudcmd = CloudCommander; + var lEditor = pReadOnly ? lCloudcmd.Viewer:lCloudcmd.Editor; + var lCurrent = Util.getCurrentFile(); + if(lCurrent){ + if(typeof lEditor === 'function') + lEditor(lCurrent); + else{ + lEditor = lEditor.get(); + if(lEditor && lEditor.show) + lEditor.show(lCurrent); + } + } + }); + + /* function return configureation for menu */ CloudCommander.Menu.getConfig = (function(){ return{ // define which elements trigger this menu @@ -30,32 +45,12 @@ var CloudCommander, $; }, // define the elements of the menu items: { - view: {name: 'View', callback: function(key, opt){ - var lCurrent = Util.getCurrentFile(); - if(lCurrent){ - if(typeof CloudCommander.Viewer === 'function') - CloudCommander.Viewer(lCurrent); - else{ - var lViewer = CloudCommander.Viewer.get(); - if(lViewer && lViewer.show) - lViewer.show(lCurrent); - } + view: {name: 'View', callback: function(key, opt){ + CloudCommander.showEditor(true); }}, edit: {name: 'Edit', callback: function(key, opt){ - Util.Images.showLoad(); - - if(typeof CloudCommander.Editor === 'function') - CloudCommander.Editor(); - else{ - var lEditor = CloudCommander.Editor.get(); - if(lEditor && lEditor.show){ - var lCurrent = Util.getCurrentFile(); - if(lCurrent) - lEditor.show(lCurrent); - } - } - + CloudCommander.showEditor(false); }}, 'delete': {name: 'Delete', @@ -90,11 +85,10 @@ var CloudCommander, $; document.body.removeChild(lDownload); }, 10000); } - else{ + else Util.Images.showError({ responseText: 'Error: You trying to' + 'download same file to often'}); - } }} } };