mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
fixed bug with menu items sshow and view
This commit is contained in:
parent
b26be35ef6
commit
d5ea30d4e9
7 changed files with 126 additions and 102 deletions
|
|
@ -98,7 +98,10 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
/**
|
||||
* function shows CodeMirror editor
|
||||
*/
|
||||
CodeMirrorEditor.show = function(){
|
||||
CodeMirrorEditor.show = function(pReadOnly){
|
||||
if( Util.isBoolean(pReadOnly) )
|
||||
ReadOnly = pReadOnly;
|
||||
|
||||
/* if CodeMirrorEditor is not loaded - loading him */
|
||||
if(!CodeMirrorLoaded)
|
||||
return load();
|
||||
|
|
@ -189,12 +192,11 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
/**
|
||||
* function bind keys
|
||||
*/
|
||||
cloudcmd.Editor.Keys = function(pIsReadOnly){
|
||||
ReadOnly = pIsReadOnly;
|
||||
cloudcmd.Editor.Keys = function(pReadOnly){
|
||||
ReadOnly = pReadOnly;
|
||||
|
||||
var lThis = this.CodeMirror;
|
||||
/* loading js and css of CodeMirror */
|
||||
lThis.show();
|
||||
CodeMirrorEditor.show();
|
||||
|
||||
var key_event = function(pEvent){
|
||||
|
||||
|
|
@ -203,8 +205,7 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
/* if f4 or f3 pressed */
|
||||
var lF3 = cloudcmd.KEY.F3;
|
||||
var lF4 = cloudcmd.KEY.F4;
|
||||
//var lShow = lThis.show.bind(lThis);
|
||||
var lShow = Util.bind(lThis.show, lThis);
|
||||
var lShow = Util.bind( CodeMirrorEditor.show, CodeMirrorEditor );
|
||||
|
||||
if(!pEvent.shiftKey){
|
||||
switch(pEvent.keyCode)
|
||||
|
|
@ -228,7 +229,7 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
|
||||
else{
|
||||
var lFunc;
|
||||
if(typeof document.onkeydown === 'function')
|
||||
if( Util.isFunction(document.onkeydown) )
|
||||
lFunc = document.onkeydown;
|
||||
|
||||
document.onkeydown = function(){
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ var CloudCommander;
|
|||
console.log('openning config window...');
|
||||
|
||||
Util.Images.showLoad();
|
||||
if (typeof cloudcmd.Config === 'function')
|
||||
if ( Util.isFunction(cloudcmd.Config) )
|
||||
cloudcmd.Config();
|
||||
|
||||
}
|
||||
|
|
@ -121,11 +121,11 @@ var CloudCommander;
|
|||
|
||||
var lViewer = cloudcmd.Viewer;
|
||||
var lEditor = cloudcmd.Editor;
|
||||
|
||||
if(event.shiftKey && typeof lViewer === 'function')
|
||||
lViewer(lCurrentFile);
|
||||
|
||||
else if (typeof lEditor === 'function')
|
||||
if(event.shiftKey && Util.isFunction(lViewer) )
|
||||
lViewer(lCurrentFile);
|
||||
|
||||
else if ( Util.isFunction(lEditor) )
|
||||
lEditor(true);
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
|
|
@ -135,14 +135,14 @@ var CloudCommander;
|
|||
else if(event.keyCode === KEY.F4) {
|
||||
Util.Images.showLoad();
|
||||
|
||||
if (typeof cloudcmd.Editor === 'function')
|
||||
if ( Util.isFunction(cloudcmd.Editor) )
|
||||
cloudcmd.Editor();
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
else if(event.keyCode === KEY.F10 &&
|
||||
event.shiftKey){
|
||||
if (typeof cloudcmd.Menu === 'function')
|
||||
if ( Util.isFunction(cloudcmd.Menu) )
|
||||
cloudcmd.Menu();
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
|
|
@ -150,7 +150,7 @@ var CloudCommander;
|
|||
|
||||
else if (event.keyCode === KEY.TRA){
|
||||
Util.Images.showLoad({top: true});
|
||||
if(typeof cloudcmd.Terminal === 'function')
|
||||
if( Util.isFunction(cloudcmd.Terminal) )
|
||||
cloudcmd.Terminal();
|
||||
}
|
||||
/* навигация по таблице файлов*/
|
||||
|
|
@ -270,10 +270,13 @@ var CloudCommander;
|
|||
|
||||
/* из него достаём спан с именем файла*/
|
||||
lName = Util.getByClass('name', lCurrentFile);
|
||||
|
||||
/* если нету (что вряд ли) - выходим*/
|
||||
if(!lName)return false;
|
||||
|
||||
/* достаём все ссылки*/
|
||||
var lATag = Util.getByTag('a', lName[0]);
|
||||
|
||||
/* если нету - выходим */
|
||||
if(!lATag)return false;
|
||||
|
||||
|
|
@ -282,7 +285,8 @@ var CloudCommander;
|
|||
* (opera, ie), вызываем событие onclick,
|
||||
*/
|
||||
|
||||
if(lCurrentFile.onclick)lCurrentFile.onclick(true);
|
||||
if(lCurrentFile.onclick)
|
||||
lCurrentFile.onclick(true);
|
||||
else try{
|
||||
lATag[0].click();
|
||||
}
|
||||
|
|
@ -311,8 +315,7 @@ var CloudCommander;
|
|||
var lRefreshIcon = Util.getRefreshButton();
|
||||
if(lRefreshIcon){
|
||||
/* получаем название файла*/
|
||||
var lSelectedName = Util
|
||||
.getByTag('a', lCurrentFile)[0].textContent;
|
||||
var lSelectedName = Util.getCurrentName();
|
||||
|
||||
/* если нашли элемент нажимаем него
|
||||
* а если не можем - нажимаем на
|
||||
|
|
|
|||
|
|
@ -5,36 +5,38 @@ var CloudCommander, $;
|
|||
(function(){
|
||||
"use strict";
|
||||
|
||||
var cloudcmd = CloudCommander;
|
||||
var KeyBinding = cloudcmd.KeyBinding;
|
||||
|
||||
cloudcmd.Menu = {};
|
||||
|
||||
var Util = CloudCommander.Util;
|
||||
|
||||
CloudCommander.Menu.dir = './lib/client/menu/';
|
||||
var cloudcmd = CloudCommander,
|
||||
KeyBinding = cloudcmd.KeyBinding,
|
||||
Util = cloudcmd.Util,
|
||||
MenuSeted = false,
|
||||
Menu = {},
|
||||
Position;
|
||||
|
||||
Menu.dir = './lib/client/menu/';
|
||||
|
||||
/* enable and disable menu constant */
|
||||
CloudCommander.Menu.ENABLED = false;
|
||||
|
||||
Menu.ENABLED = false;
|
||||
|
||||
CloudCommander.Menu.showEditor = (function(pReadOnly){
|
||||
/* PRIVATE FUNCTIONS */
|
||||
|
||||
/** function shows editor
|
||||
* @param pReadOnly
|
||||
*/
|
||||
function showEditor(pReadOnly){
|
||||
Util.Images.showLoad();
|
||||
var lEditor = pReadOnly ? cloudcmd.Viewer : cloudcmd.Editor;
|
||||
var lCurrent = Util.getCurrentFile();
|
||||
if(lCurrent){
|
||||
if(typeof lEditor === 'function')
|
||||
lEditor(lCurrent);
|
||||
else{
|
||||
lEditor = lEditor.get();
|
||||
if(lEditor && lEditor.show)
|
||||
lEditor.show(lCurrent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if( Util.isFunction(lEditor) )
|
||||
lEditor(pReadOnly);
|
||||
else{
|
||||
lEditor = lEditor.get();
|
||||
if(lEditor && lEditor.show)
|
||||
lEditor.show();
|
||||
}
|
||||
}
|
||||
|
||||
/* function return configureation for menu */
|
||||
CloudCommander.Menu.getConfig = (function(){
|
||||
/** function return configureation for menu */
|
||||
function getConfig (){
|
||||
return{
|
||||
// define which elements trigger this menu
|
||||
selector: 'li',
|
||||
|
|
@ -48,11 +50,11 @@ var CloudCommander, $;
|
|||
// define the elements of the menu
|
||||
items: {
|
||||
view: {name: 'View', callback: function(key, opt){
|
||||
CloudCommander.showEditor(true);
|
||||
showEditor(true);
|
||||
}},
|
||||
|
||||
edit: {name: 'Edit', callback: function(key, opt){
|
||||
CloudCommander.showEditor(false);
|
||||
showEditor();
|
||||
}},
|
||||
|
||||
'delete': {name: 'Delete',
|
||||
|
|
@ -94,24 +96,23 @@ var CloudCommander, $;
|
|||
}}
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/* function loads css and js of Menu
|
||||
* @pParent - this
|
||||
* @pPosition - position of menu
|
||||
/** function loads css and js of Menu
|
||||
* @param pParent - this
|
||||
* @param pPosition - position of menu
|
||||
*/
|
||||
CloudCommander.Menu.load = (function(pPosition){
|
||||
var lThis = this;
|
||||
function load(){
|
||||
var ljsLoad_f = function(){
|
||||
var lUISrc = lThis.dir + 'ui.position.js';
|
||||
var lMenuSrc = lThis.dir + 'contextMenu.js';
|
||||
var lUISrc = Menu.dir + 'ui.position.js';
|
||||
var lMenuSrc = Menu.dir + 'contextMenu.js';
|
||||
|
||||
Util.jsload(lUISrc, function(){
|
||||
Util.jsload(lMenuSrc, lThis.show(lThis, pPosition));
|
||||
Util.jsload(lMenuSrc, Menu.show());
|
||||
});
|
||||
};
|
||||
|
||||
var lSrc = this.dir + 'contextMenu.css';
|
||||
var lSrc = Menu.dir + 'contextMenu.css';
|
||||
|
||||
Util.cssLoad({
|
||||
src : lSrc,
|
||||
|
|
@ -121,11 +122,11 @@ var CloudCommander, $;
|
|||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
CloudCommander.Menu.set = (function(){
|
||||
if(!this.seted){
|
||||
$.contextMenu(this.getConfig());
|
||||
function set(){
|
||||
if(!MenuSeted){
|
||||
$.contextMenu(getConfig());
|
||||
|
||||
var lFunc_f = document.onclick;
|
||||
/*
|
||||
|
|
@ -183,44 +184,43 @@ var CloudCommander, $;
|
|||
}
|
||||
};
|
||||
|
||||
this.seted = true;
|
||||
MenuSeted = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
CloudCommander.Menu.seted = false;
|
||||
|
||||
/* function shows menu for the first time
|
||||
/** function shows menu for the first time
|
||||
* right away after loading
|
||||
*/
|
||||
CloudCommander.Menu.show = (function(pThis, pPosition){
|
||||
Menu.show = function(){
|
||||
return function(){
|
||||
pThis.set();
|
||||
set();
|
||||
|
||||
Util.Images.hideLoad();
|
||||
|
||||
if(pPosition && pPosition.x && pPosition.y)
|
||||
$('li').contextMenu(pPosition);
|
||||
if(Position && Position.x && Position.y)
|
||||
$('li').contextMenu(Position);
|
||||
else
|
||||
$('li').contextMenu();
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
/* key binding function */
|
||||
CloudCommander.Menu.Keys = (function(pPosition){
|
||||
"use strict";
|
||||
|
||||
var lFunc = document.oncontextmenu;
|
||||
Menu.Keys = function(pPosition){
|
||||
Position = pPosition;
|
||||
|
||||
var lFunc = document.oncontextmenu;
|
||||
document.oncontextmenu = function(){
|
||||
if(typeof lFunc === 'function')
|
||||
lFunc();
|
||||
return CloudCommander.Menu.ENABLED;
|
||||
return Menu.ENABLED;
|
||||
};
|
||||
|
||||
var key_event = (function(pEvent){
|
||||
/* если клавиши можно обрабатывать */
|
||||
if( KeyBinding.get() )
|
||||
/* if shift + F10 pressed */
|
||||
if(pEvent.keyCode === CloudCommander.KEY.F10 &&
|
||||
if(pEvent.keyCode === cloudcmd.KEY.F10 &&
|
||||
pEvent.shiftKey){
|
||||
var lCurrent = Util.getCurrentFile();
|
||||
if(lCurrent)
|
||||
|
|
@ -247,9 +247,11 @@ var CloudCommander, $;
|
|||
};
|
||||
|
||||
/* showing context menu preview*/
|
||||
CloudCommander.Menu.show();
|
||||
Menu.show();
|
||||
}
|
||||
|
||||
CloudCommander.Menu.load(pPosition);
|
||||
});
|
||||
load();
|
||||
};
|
||||
|
||||
cloudcmd.Menu = Menu;
|
||||
})();
|
||||
|
|
@ -182,13 +182,17 @@ var CloudCommander, CloudFunc, $;
|
|||
/**
|
||||
* function shows FancyBox
|
||||
*/
|
||||
FancyBox.show = function(pCurrentFile){
|
||||
FancyBox.show = function(pCallBack){
|
||||
FancyBox.set();
|
||||
|
||||
var lConfig = this.getConfig();
|
||||
|
||||
if(typeof pCurrentFile !== 'function'){
|
||||
var lA = Util.getByClass('fancybox', pCurrentFile)[0];
|
||||
if( Util.isFunction(pCallBack) )
|
||||
pCallBack();
|
||||
else{
|
||||
var lCurrentFile = Util.getCurrentFile();
|
||||
|
||||
var lA = Util.getByClass('fancybox', lCurrentFile)[0];
|
||||
if(lA){
|
||||
if(lA.rel)
|
||||
$.fancybox.open({ href : lA.href },
|
||||
|
|
@ -196,10 +200,6 @@ var CloudCommander, CloudFunc, $;
|
|||
else this.loadData(lA, this.onDataLoaded);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var lFunc_f = pCurrentFile;
|
||||
lFunc_f();
|
||||
}
|
||||
|
||||
Util.Images.hideLoad();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue