mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +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
|
|
@ -24,6 +24,8 @@ started.
|
|||
|
||||
* Fixed bug with error code of program execution in terminal.
|
||||
|
||||
* Fixed bug with menu itmes edit and view.
|
||||
|
||||
|
||||
2012.10.01, Version 0.1.7
|
||||
|
||||
|
|
|
|||
50
client.js
50
client.js
|
|
@ -728,19 +728,35 @@ CloudClient.Util = (function(){
|
|||
};
|
||||
|
||||
/**
|
||||
* functions check is pObject is object
|
||||
* @param pObject
|
||||
* functions check is pVarible is boolean
|
||||
* @param pVarible
|
||||
*/
|
||||
this.isObject = function(pObject){
|
||||
return typeof pObject === 'object';
|
||||
this.isBoolean = function(pVarible){
|
||||
return this.isType(pVarible, 'boolean');
|
||||
};
|
||||
|
||||
/**
|
||||
* functions check is pFunction is function
|
||||
* @param pFunction
|
||||
* functions check is pVarible is object
|
||||
* @param pVarible
|
||||
*/
|
||||
this.isFunction = function(pFunction){
|
||||
return typeof pFunction === 'function';
|
||||
this.isObject = function(pVarible){
|
||||
return this.isType(pVarible, 'object');
|
||||
};
|
||||
|
||||
/**
|
||||
* functions check is pVarible is function
|
||||
* @param pVarible
|
||||
*/
|
||||
this.isFunction = function(pVarible){
|
||||
return this.isType(pVarible, 'function');
|
||||
};
|
||||
/**
|
||||
* functions check is pVarible is pType
|
||||
* @param pVarible
|
||||
* @param pType
|
||||
*/
|
||||
this.isType = function(pVarible, pType){
|
||||
return typeof pVarible === pType;
|
||||
};
|
||||
|
||||
this.getCurrentLink = function(pCurrentFile){
|
||||
|
|
@ -901,13 +917,13 @@ CloudClient.KeyBinding = (function(){
|
|||
});
|
||||
|
||||
/* function loads and shows editor */
|
||||
CloudClient.Editor = (function(pCurrentFile, pIsReadOnly) {
|
||||
CloudClient.Editor = (function(pIsReadOnly) {
|
||||
/* loading CloudMirror plagin */
|
||||
Util.jsload(CloudClient.LIBDIRCLIENT +
|
||||
'editor/_codemirror.js',{
|
||||
//'editor/_ace.js',{
|
||||
onload:(function(){
|
||||
cloudcmd.Editor.Keys(pCurrentFile, pIsReadOnly);
|
||||
cloudcmd.Editor.Keys(pIsReadOnly);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
@ -931,7 +947,7 @@ CloudClient.GoogleAnalytics = (function(){
|
|||
Util.jsload('lib/client/google_analytics.js');
|
||||
},5000);
|
||||
|
||||
if(typeof lFunc === 'function')
|
||||
if( Util.isFunction(lFunc) )
|
||||
lFunc();
|
||||
|
||||
document.onmousemove = lFunc;
|
||||
|
|
@ -1056,7 +1072,7 @@ CloudClient._editFileName = (function(pParent){
|
|||
* setted up earlier
|
||||
*/
|
||||
document.onclick = lDocumentOnclick;
|
||||
if(typeof lDocumentOnclick === 'function')
|
||||
if( Util.isFunction(lDocumentOnclick) )
|
||||
lDocumentOnclick();
|
||||
|
||||
});
|
||||
|
|
@ -1098,12 +1114,12 @@ CloudClient._setCurrent=(function(){
|
|||
}
|
||||
/* если мы попали сюда с энтера*/
|
||||
if(pFromEnter===true){
|
||||
if(typeof this.ondblclick === 'function')
|
||||
if( Util.isFunction(this.ondblclick) )
|
||||
this.ondblclick(this);
|
||||
/* enter pressed on file */
|
||||
else{
|
||||
var lA = this.getElementsByTagName('a')[0];
|
||||
if(typeof lA.ondblclick === 'function')
|
||||
if( Util.isFunction(lA.ondblclick) )
|
||||
lA.ondblclick(this);
|
||||
}
|
||||
}/* если мы попали сюда от клика мышки */
|
||||
|
|
@ -1169,7 +1185,7 @@ CloudClient.baseInit = (function(){
|
|||
applicationCache.onupdateready = function(){
|
||||
console.log('app cacheed');
|
||||
location.reload();
|
||||
if(typeof lFunc === 'function')
|
||||
if( Util.isFunction(lFunc) )
|
||||
lFunc();
|
||||
};
|
||||
}
|
||||
|
|
@ -1266,8 +1282,8 @@ CloudClient._changeLinks = function(pPanelID){
|
|||
var lTarget = pEvent.currentTarget || pEvent.target;
|
||||
Util.setCurrentFile(lTarget);
|
||||
|
||||
if(typeof CloudCommander.Menu === 'function'){
|
||||
CloudCommander.Menu({
|
||||
if(Util.isFunction(cloudcmd.Menu) ){
|
||||
cloudcmd.Menu({
|
||||
x: pEvent.x,
|
||||
y: pEvent.y
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ CloudServer.start = function (pConfig) {
|
|||
|
||||
|
||||
console.log(process.argv);
|
||||
console.log(this.Config);
|
||||
|
||||
/* server mode or testing mode */
|
||||
if (this.Config.server) {
|
||||
var http = require('http');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue