diff --git a/ChangeLog b/ChangeLog index 1e4ff7f6..efc5195b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -87,6 +87,8 @@ clicked on menu item. * Improved modules.json format and parsing. +* Added ability to read storage modules information from menu module. + 2012.12.12, Version 0.1.8 diff --git a/lib/client/menu.js b/lib/client/menu.js index 727a27e7..1ffa55fd 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -8,8 +8,9 @@ var CloudCommander, Util, DOM, $; var KeyBinding = CloudCmd.KeyBinding, MenuSeted = false, Menu = {}, - Position; - + Position, + UploadToItemNames; + Menu.dir = '/lib/client/menu/'; /* enable and disable menu constant */ @@ -33,17 +34,43 @@ var CloudCommander, Util, DOM, $; } } + /* function read data from modules.json + * and build array of menu items of "upload to" + * menu + */ + function setUploadToItemNames(pCallBack){ + CloudCmd.getModules(function(pModules){ + var lStorage = 'storage', + lItems = pModules[lStorage]; + + for(var i = 0, n = pModules.length; i < n; i++ ){ + lItems = pModules[i][lStorage]; + + if(lItems) + break; + } + + lItems = lItems || []; + UploadToItemNames = []; + + for(i = 0, n = lItems.length; i < n; i++) + UploadToItemNames[i] = lItems[i].name; + + Util.exec(pCallBack); + }); + } + /** * function get menu item object for Upload To */ - function getUploadToItem(pObjectName){ + function getUploadToItems(pObjectName){ var lObj = {}; if( Util.isArray(pObjectName) ){ var n = pObjectName.length; for(var i = 0; i < n; i++){ var lStr = pObjectName[i]; - lObj[lStr] = getUploadToItem( lStr ); + lObj[lStr] = getUploadToItems( lStr ); } } else if( Util.isString(pObjectName) ){ @@ -123,13 +150,14 @@ var CloudCommander, Util, DOM, $; 'View' : Util.retExec(showEditor, true), 'Edit' : Util.retExec(showEditor, false), 'Delete' : Util.retExec(DOM.promptRemoveCurrent), - 'Upload to' : getUploadToItem( + 'Upload to' : getUploadToItems(UploadToItemNames) + /* [ 'DropBox', 'GDrive', 'GitHub', 'VK' - ]), + ])*/, 'Download' : function(key, opt){ DOM.Images.showLoad(); @@ -225,8 +253,8 @@ var CloudCommander, Util, DOM, $; var lElement = document.elementFromPoint(pEvent.x, pEvent.y), lTag = lElement.tagName, lParent; - - if(lTag === 'A' || lTag === 'SPAN'){ + + if(lTag === 'A' || lTag === 'SPAN'){ if (lElement.tagName === 'A') lParent = lElement.parentElement.parentElement; else if(lElement.tagName === 'SPAN') @@ -275,6 +303,7 @@ var CloudCommander, Util, DOM, $; Util.loadOnLoad([ Menu.show, + setUploadToItemNames, load, DOM.jqueryLoad ]);