mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
changed the way clickProcessing of menu works
This commit is contained in:
parent
c72e6f0742
commit
78b8d01dd5
3 changed files with 26 additions and 82 deletions
|
|
@ -157,11 +157,11 @@ for reading.
|
|||
|
||||
* Fixed bug with getting showed menu in firefox.
|
||||
|
||||
* Commented e.stopImmediatePropagation() of function layerClick
|
||||
in contextmenu file, for correct work of context menu.
|
||||
|
||||
* Added temporary redirection for old no-js urls.
|
||||
|
||||
* Changed the way clickProcessing of menu works,
|
||||
for now it's much simplier.
|
||||
|
||||
|
||||
2012.12.12, Version 0.1.8
|
||||
|
||||
|
|
|
|||
|
|
@ -179,7 +179,10 @@ var CloudCommander, Util, DOM, $;
|
|||
},
|
||||
|
||||
// define the elements of the menu
|
||||
items: getAllItems(lMenuItems)
|
||||
items : getAllItems(lMenuItems),
|
||||
events :{
|
||||
hide: clickProcessing
|
||||
}
|
||||
};
|
||||
|
||||
return lRet;
|
||||
|
|
@ -207,97 +210,32 @@ 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
|
||||
* When menu shows up, it draws 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
|
||||
* how expected we remove invisible layer
|
||||
* so for observer it is nothing special
|
||||
* is not going on. All magic happening in
|
||||
* DOM tree
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function __clickProcessing(pEvent){
|
||||
function clickProcessing(){
|
||||
var lLayer = DOM.getById('context-menu-layer');
|
||||
if(lLayer){
|
||||
var lStyle,
|
||||
lParent;
|
||||
document.body.removeChild(lLayer);
|
||||
|
||||
if(lLayer)
|
||||
lStyle = lLayer.style.cssText;
|
||||
/* hide invisible menu layer */
|
||||
if(lStyle)
|
||||
lLayer.style.cssText = lStyle
|
||||
.replace('z-index: 1', 'z-index:-1');
|
||||
|
||||
var lElement;
|
||||
if(pEvent.$trigger)
|
||||
lElement = pEvent.$trigger[0];
|
||||
else
|
||||
lElement = document.elementFromPoint(pEvent.x, pEvent.y);
|
||||
|
||||
var lTag = lElement.tagName;
|
||||
var lElement = document.elementFromPoint(Position.x, Position.y),
|
||||
lTag = lElement.tagName;
|
||||
|
||||
if(lTag === 'A' || lTag === 'SPAN'){
|
||||
if (lElement.tagName === 'A')
|
||||
lParent = lElement.parentElement.parentElement;
|
||||
lElement = lElement.parentElement.parentElement;
|
||||
else if(lElement.tagName === 'SPAN')
|
||||
lParent = lElement.parentElement;
|
||||
lElement = lElement.parentElement;
|
||||
|
||||
if(lParent.className === '')
|
||||
DOM.setCurrentFile(lParent);
|
||||
if(lElement.className === '')
|
||||
DOM.setCurrentFile(lElement);
|
||||
}
|
||||
else
|
||||
DOM.setCurrentFile(lElement);
|
||||
|
||||
/* show invisible menu layer */
|
||||
if(lLayer && lStyle)
|
||||
lLayer.style.cssText = lStyle;
|
||||
|
||||
KeyBinding.set();
|
||||
}
|
||||
|
|
@ -308,7 +246,13 @@ var CloudCommander, Util, DOM, $;
|
|||
if(!MenuSeted){
|
||||
$.contextMenu(getConfig());
|
||||
MenuSeted = true;
|
||||
DOM.addListener('mousedown', clickProcessing);
|
||||
//DOM.addListener('mousedown', clickProcessing);
|
||||
DOM.addListener('mousemove', function(pEvent){
|
||||
Position = {
|
||||
x : pEvent.x,
|
||||
y : pEvent.y
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ var // currently active contextMenu trigger
|
|||
//selectors;
|
||||
|
||||
e.preventDefault();
|
||||
//e.stopImmediatePropagation();
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
setTimeout(function() {
|
||||
var $window;//, hideshow, possibleTarget;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue