From 480f9c4600dfbb235e10b3c04661bd1f95810f7d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 29 Jan 2013 06:43:47 -0500 Subject: [PATCH] added ability to hide "Upload To" menu item --- ChangeLog | 3 ++ lib/client/menu.js | 94 ++++++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index a89eb006..d77d4631 100644 --- a/ChangeLog +++ b/ChangeLog @@ -112,6 +112,9 @@ with clicks on files. * Removed allowed from cache property in config. +* Added ability to hide "Upload To" menu item if +no storage modules setted up in modules.json. + 2012.12.12, Version 0.1.8 diff --git a/lib/client/menu.js b/lib/client/menu.js index cdd65227..5e8de2c5 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -112,18 +112,63 @@ var CloudCommander, Util, DOM, $; if(pItems) for(lName in pItems){ - lFunc = pItems[lName]; + lFunc = pItems[lName]; lRet[lName] = getItem(lName, lFunc); } return lRet; } + /** + * download menu item callback + */ + function downloadFromMenu(key, opt){ + DOM.Images.showLoad(); + + var lPath = DOM.getCurrentPath(), + lId = DOM.getIdBySrc(lPath); + + Util.log('downloading file ' + lPath +'...'); + + lPath = lPath + '?download'; + + if(!DOM.getById(lId)){ + var lDownload = DOM.anyload({ + name : 'iframe', + async : false, + className : 'hidden', + src : lPath, + func : Util.retFunc(DOM.Images.hideLoad) + }); + + DOM.Images.hideLoad(); + setTimeout(function() { + document.body.removeChild(lDownload); + }, 10000); + } + else + DOM.Images.showError({ + responseText: 'Error: You trying to' + + 'download same file to often'}); + } + /** * function return configureation for menu */ function getConfig (){ - return{ + var lRet, + lMenuItems = { + 'View' : Util.retExec(showEditor, true), + 'Edit' : Util.retExec(showEditor, false), + 'Delete' : Util.retExec(DOM.promptRemoveCurrent), + }; + + if(UploadToItemNames.length) + lMenuItems['Upload to'] = getUploadToItems(UploadToItemNames); + + lMenuItems.Download = Util.retExec(downloadFromMenu); + + lRet = { // define which elements trigger this menu selector: 'li', @@ -135,49 +180,10 @@ var CloudCommander, Util, DOM, $; }, // define the elements of the menu - items: getAllItems({ - 'View' : Util.retExec(showEditor, true), - 'Edit' : Util.retExec(showEditor, false), - 'Delete' : Util.retExec(DOM.promptRemoveCurrent), - 'Upload to' : getUploadToItems(UploadToItemNames) - /* - [ - 'DropBox', - 'GDrive', - 'GitHub', - 'VK' - ])*/, - 'Download' : function(key, opt){ - DOM.Images.showLoad(); - - var lPath = DOM.getCurrentPath(), - lId = DOM.getIdBySrc(lPath); - - Util.log('downloading file ' + lPath +'...'); - - lPath = lPath + '?download'; - - if(!DOM.getById(lId)){ - var lDownload = DOM.anyload({ - name : 'iframe', - async : false, - className : 'hidden', - src : lPath, - func : Util.retFunc(DOM.Images.hideLoad) - }); - - DOM.Images.hideLoad(); - setTimeout(function() { - document.body.removeChild(lDownload); - }, 10000); - } - else - DOM.Images.showError({ - responseText: 'Error: You trying to' + - 'download same file to often'}); - } - }) + items: getAllItems(lMenuItems) }; + + return lRet; } /** function loads css and js of Menu