mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
added ability to read storage modules information from menu module
This commit is contained in:
parent
f3612012c0
commit
a8d3da2dc3
2 changed files with 39 additions and 8 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue