minor changes

This commit is contained in:
coderaiser 2013-02-08 11:21:32 -05:00
parent 0a7b095d99
commit 9309ba1d1b
5 changed files with 121 additions and 106 deletions

View file

@ -230,7 +230,7 @@ function initModules(pCallBack){
CloudCmd.getModules(function(pModules){
pModules = pModules || [];
DOM.addListener('contextmenu', function(pEvent){
DOM.addContextMenuListener(function(pEvent){
CloudCmd.Menu.ENABLED || DOM.preventDefault(pEvent);
}, document);

View file

@ -183,6 +183,10 @@ var CloudCommander, Util,
return DOM.addListener('click', pListener, pElement, pUseCapture);
};
DOM.addContextMenuListener = function(pListener, pElement, pUseCapture){
return DOM.addListener('contextmenu', pListener, pElement, pUseCapture);
};
/**
* safe add event click listener
* @param pListener

View file

@ -205,67 +205,72 @@ var CloudCommander, Util, DOM, $;
});
}
/*
* Menu works in some crazy way so need a
* little hack to get every thing work out.
* When menu shows up, it drawing invisible
* layer wich hides all elements of
* Cloud Commander so it could not handle
* onclick events. To get every thing work
* how expected we hide out invisible layer
* so for observer it is nothing special
* is not going on. All magic happening in
* DOM tree
*/
function clickProcessing(pEvent){
/* if clicked on menu item */
var lParent = pEvent.target.parentElement,
lClassName = lParent && lParent.className;
switch(lClassName){
case 'context-menu-item':
return;
case 'context-menu-list ':
return;
}
if(pEvent && pEvent.x){
var lLayer = DOM.getById('context-menu-layer');
if(lLayer){
var lStyle;
if(lLayer)
lStyle = lLayer.style.cssText;
/* hide invisible menu layer */
if(lStyle)
lLayer.style.cssText = lStyle
.replace('z-index: 1', 'z-index:-1');
/* get element by point */
var lElement = document.elementFromPoint(pEvent.x, pEvent.y),
lTag = lElement.tagName;
if(lTag === 'A' || lTag === 'SPAN'){
if (lElement.tagName === 'A')
lParent = lElement.parentElement.parentElement;
else if(lElement.tagName === 'SPAN')
lParent = lElement.parentElement;
if(lParent.className === '')
DOM.setCurrentFile(lParent);
}
/* show invisible menu layer */
if(lLayer && lStyle)
lLayer.style.cssText = lStyle;
KeyBinding.set();
//DOM.addListener('contextmenu', clickProcessing, lLayer);
}
}
}
function set(){
if(!MenuSeted){
$.contextMenu(getConfig());
/*
* Menu works in some crazy way so need a
* little hack to get every thing work out.
* When menu shows up, it drawing invisible
* layer wich hides all elements of
* Cloud Commander so it could not handle
* onclick events. To get every thing work
* how expected we hide out invisible layer
* so for observer it is nothing special
* is not going on. All magic happening in
* DOM tree
*/
DOM.addClickListener(function(pEvent){
/* if clicked on menu item */
var lParent = pEvent.target.parentElement,
lClassName = lParent && lParent.className;
switch(lClassName){
case 'context-menu-item':
return;
case 'context-menu-list ':
return;
}
if(pEvent && pEvent.x){
var lLayer = DOM.getById('context-menu-layer');
if(lLayer){
var lStyle;
if(lLayer)
lStyle = lLayer.style.cssText;
/* hide invisible menu layer */
if(lStyle)
lLayer.style.cssText = lStyle
.replace('z-index: 1', 'z-index:-1');
/* get element by point */
var lElement = document.elementFromPoint(pEvent.x, pEvent.y),
lTag = lElement.tagName,
lParent;
if(lTag === 'A' || lTag === 'SPAN'){
if (lElement.tagName === 'A')
lParent = lElement.parentElement.parentElement;
else if(lElement.tagName === 'SPAN')
lParent = lElement.parentElement;
if(lParent.className === '')
DOM.setCurrentFile(lParent);
}
/* show invisible menu layer */
if(lLayer && lStyle)
lLayer.style.cssText = lStyle;
KeyBinding.set();
}
}
});
DOM.addClickListener(clickProcessing);
MenuSeted = true;
}

View file

@ -21,8 +21,8 @@
querystring = main.querystring,
zlib = main.zlib,
FILE_NOT_FOUND = 404,
OK = 200,
FILE_NOT_FOUND = main.FILE_NOT_FOUND,
OK = main.OK,
FS = CloudFunc.FS,
NO_JS = CloudFunc.NOJS,
@ -125,7 +125,7 @@
}
else
sendResponse({
data : p.Error.toString(),
data : p.error.toString(),
name : lDirPath,
request : c.request,
response: c.response,

View file

@ -12,52 +12,58 @@
ext,
path, fs, zlib, url,
OK = 200,
FILE_NOT_FOUND = 404;
OK, FILE_NOT_FOUND;
/* Consts */
exports.OK = OK = 200;
exports.FILE_NOT_FOUND = 404;
exports.REQUEST = 'request';
exports.RESPONSE = 'response';
/* Native Modules*/
exports.crypto = require('crypto'),
exports.child_process = require('child_process'),
exports.fs = fs = require('fs'),
exports.http = require('http'),
exports.https = require('https'),
exports.path = path = require('path'),
exports.url = url = require('url'),
exports.querystring = require('querystring'),
exports.crypto = require('crypto'),
exports.child_process = require('child_process'),
exports.fs = fs = require('fs'),
exports.http = require('http'),
exports.https = require('https'),
exports.path = path = require('path'),
exports.url = url = require('url'),
exports.querystring = require('querystring'),
/* Constants */
/* current dir + 2 levels up */
exports.WIN32 = ISWIN32 = isWin32();
exports.SLASH = SLASH = ISWIN32 ? '\\' : '/',
exports.WIN32 = ISWIN32 = isWin32();
exports.SLASH = SLASH = ISWIN32 ? '\\' : '/',
exports.SRVDIR = SRVDIR = __dirname + SLASH,
exports.LIBDIR = LIBDIR = path.normalize(SRVDIR + '../'),
exports.DIR = DIR = path.normalize(LIBDIR + '../'),
exports.HTMLDIR = DIR + 'html' + SLASH,
exports.JSONDIR = JSONDIR = DIR + 'json' + SLASH,
exports.SRVDIR = SRVDIR = __dirname + SLASH,
exports.LIBDIR = LIBDIR = path.normalize(SRVDIR + '../'),
exports.DIR = DIR = path.normalize(LIBDIR + '../'),
exports.HTMLDIR = DIR + 'html' + SLASH,
exports.JSONDIR = JSONDIR = DIR + 'json' + SLASH,
/* Functions */
exports.require = mrequire,
exports.librequire = librequire,
exports.srvrequire = srvrequire,
exports.rootrequire = rootrequire,
exports.generateHeaders = generateHeaders,
exports.getQuery = getQuery,
exports.sendFile = sendFile,
exports.require = mrequire,
exports.librequire = librequire,
exports.srvrequire = srvrequire,
exports.rootrequire = rootrequire,
exports.generateHeaders = generateHeaders,
exports.getQuery = getQuery,
exports.sendFile = sendFile,
/* compitability with old versions of node */
exports.fs.exists = exports.fs.exists || exports.path.exists;
exports.fs.exists = exports.fs.exists || exports.path.exists;
/* Needed Modules */
exports.util = Util = require(LIBDIR + 'util'),
exports.util = Util = require(LIBDIR + 'util'),
exports.zlib = zlib = mrequire('zlib'),
exports.zlib = zlib = mrequire('zlib'),
/* Main Information */
exports.config = jsonrequire('config');
exports.modules = jsonrequire('modules');
exports.ext = ext = jsonrequire('ext');
exports.mainpackage = rootrequire('package');
exports.config = jsonrequire('config');
exports.modules = jsonrequire('modules');
exports.ext = ext = jsonrequire('ext');
exports.mainpackage = rootrequire('package');
/*
@ -66,21 +72,21 @@
* moudles do not depends on each other all needed information
* for all modules is initialized hear.
*/
global.cloudcmd.main = exports;
global.cloudcmd.main = exports;
exports.VOLUMES = getVolumes(),
exports.VOLUMES = getVolumes(),
/* Additional Modules */
exports.socket = srvrequire('socket'),
exports.auth = srvrequire('auth').auth,
exports.appcache = srvrequire('appcache'),
exports.cache = srvrequire('cache').Cache,
exports.cloudfunc = librequire('cloudfunc'),
exports.rest = srvrequire('rest').api,
exports.update = srvrequire('update'),
exports.ischanged = srvrequire('ischanged');
exports.commander = srvrequire('commander');
exports.minify = srvrequire('minify').Minify;
exports.socket = srvrequire('socket'),
exports.auth = srvrequire('auth').auth,
exports.appcache = srvrequire('appcache'),
exports.cache = srvrequire('cache').Cache,
exports.cloudfunc = librequire('cloudfunc'),
exports.rest = srvrequire('rest').api,
exports.update = srvrequire('update'),
exports.ischanged = srvrequire('ischanged');
exports.commander = srvrequire('commander');
exports.minify = srvrequire('minify').Minify;
/*
* second initializing after all modules load, so global var is
* totally filled of all information that should know all modules
@ -202,7 +208,7 @@
lReadStream = fs.createReadStream(lName, {
'bufferSize': 4 * 1024
});
});
lReadStream.on('error', function(pError){
lRes.writeHead(FILE_NOT_FOUND, 'OK');