mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 01:17:18 +00:00
minor changes
This commit is contained in:
parent
a1993927ef
commit
811a86d459
4 changed files with 231 additions and 224 deletions
|
|
@ -672,12 +672,12 @@ CloudClient.keyBinding=(function(){
|
|||
});
|
||||
|
||||
/* function loads and shows editor */
|
||||
CloudClient.Editor = (function(pIsReadOnly) {
|
||||
CloudClient.Editor = (function(pCurrentFile, pIsReadOnly) {
|
||||
/* loading CloudMirror plagin */
|
||||
Util.jsload(CloudClient.LIBDIRCLIENT +
|
||||
'editor.js',{
|
||||
onload:(function(){
|
||||
CloudCommander.Editor.Keys(pIsReadOnly);
|
||||
CloudCommander.Editor.Keys(pCurrentFile, pIsReadOnly);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
@ -698,11 +698,11 @@ CloudClient.GoogleAnalytics = (function(){
|
|||
});
|
||||
|
||||
/* function loads and shows viewer */
|
||||
CloudClient.Viewer = (function(){
|
||||
CloudClient.Viewer = (function(pCurrentFile){
|
||||
Util.jsload(CloudClient.LIBDIRCLIENT +
|
||||
'viewer.js',{
|
||||
onload: (function(){
|
||||
CloudCommander.Viewer.Keys();
|
||||
CloudCommander.Viewer.Keys(pCurrentFile);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,14 +10,15 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
return this.CodeMirror;
|
||||
})
|
||||
};
|
||||
CloudCommander.Editor.CodeMirror = new CloudCommander.Utils();
|
||||
CloudCommander.Editor.CodeMirror = {};
|
||||
|
||||
/* indicator says CodeMirror still loads */
|
||||
CloudCommander.Editor.CodeMirror.loading = false;
|
||||
|
||||
/* function loads CodeMirror js and css files */
|
||||
CloudCommander.Editor.CodeMirror.load = (function(pThis){
|
||||
CloudCommander.Editor.CodeMirror.load = (function(pCurrentFile, pIsReadOnly){
|
||||
/* function shows editor */
|
||||
var lThis = this;
|
||||
var createEditorDiv = function(){
|
||||
if (!Util.getById('CloudEditor')) {
|
||||
var lFM = Util.getById('fm');
|
||||
|
|
@ -30,7 +31,7 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
else
|
||||
console.log('Error. Something went wrong FM not found');
|
||||
|
||||
pThis.show(pThis);
|
||||
lThis.show(pCurrentFile, pIsReadOnly);
|
||||
}
|
||||
};
|
||||
/* function loads css files
|
||||
|
|
@ -65,10 +66,10 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
});
|
||||
|
||||
/* function shows CodeMirror editor */
|
||||
CloudCommander.Editor.CodeMirror.show = (function(pIsReadOnly){
|
||||
CloudCommander.Editor.CodeMirror.show = (function(pCurrentFile, pIsReadOnly){
|
||||
/* if CloudEditor is not loaded - loading him */
|
||||
if(!Util.getById('CloudEditor'))
|
||||
return this.load(this);
|
||||
return this.load(pCurrentFile, pIsReadOnly);
|
||||
|
||||
/* if CodeMirror function show already
|
||||
* called do not call it again
|
||||
|
|
@ -104,11 +105,10 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
|
||||
var lCloudEditor = Util.getById('CloudEditor');
|
||||
|
||||
var lCurrent = Util.getCurrentFile();
|
||||
var lA;
|
||||
|
||||
/* getting link */
|
||||
lA = Util.getByTag('a', lCurrent);
|
||||
lA = Util.getByTag('a', pCurrentFile);
|
||||
|
||||
lA = lA[0].href;
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
lA = '/' + lA.replace(document.location.href,'');
|
||||
|
||||
/* checking is this link is to directory */
|
||||
var lSize = Util.getByClass('size', lCurrent);
|
||||
var lSize = Util.getByClass('size', pCurrentFile);
|
||||
if(lSize){
|
||||
lSize = lSize[0].textContent;
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
error: (function(jqXHR, textStatus, errorThrown){
|
||||
lThis.loading = false;
|
||||
|
||||
return lThis.Images.showError(jqXHR);
|
||||
return Util.Images.showError(jqXHR);
|
||||
}),
|
||||
|
||||
success:function(data, textStatus, jqXHR){
|
||||
|
|
@ -159,7 +159,7 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
Util.hidePanel();
|
||||
Util.Images.hideLoad();
|
||||
|
||||
lThis.loading = false;
|
||||
lThis.loading = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -179,12 +179,12 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
};
|
||||
});
|
||||
|
||||
CloudCommander.Editor.Keys = (function(pIsReadOnly){
|
||||
CloudCommander.Editor.Keys = (function(pCurrentFile, pIsReadOnly){
|
||||
"use strict";
|
||||
|
||||
var lThis = this.CodeMirror;
|
||||
/* loading js and css of CodeMirror */
|
||||
this.CodeMirror.show(pIsReadOnly);
|
||||
this.CodeMirror.show(pCurrentFile, pIsReadOnly);
|
||||
|
||||
var key_event = function(pEvent){
|
||||
|
||||
|
|
@ -195,11 +195,13 @@ var CloudCommander, CloudFunc, CodeMirror;
|
|||
var lF4 = CloudCommander.KEY.F4;
|
||||
var lShow = lThis.show.bind(lThis);
|
||||
|
||||
var lCurrentFile = Util.getCurrentFile();
|
||||
|
||||
if(!pEvent.shiftKey){
|
||||
if(pEvent.keyCode === lF4)
|
||||
lShow();
|
||||
lShow(lCurrentFile);
|
||||
else if(pEvent.keyCode === lF3){
|
||||
lShow(true);
|
||||
lShow(lCurrentFile, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,12 +84,13 @@ CloudCommander.keyBinding = (function(){
|
|||
|
||||
/* if f3 or shift+f3 pressed */
|
||||
else if(event.keyCode === lKEY.F3){
|
||||
Util.Images.showLoad();
|
||||
if(event.shiftKey &&
|
||||
typeof CloudCommander.Viewer === 'function')
|
||||
CloudCommander.Viewer();
|
||||
CloudCommander.Viewer(lCurrentFile);
|
||||
|
||||
else if (typeof CloudCommander.Editor === 'function')
|
||||
CloudCommander.Editor(true);
|
||||
CloudCommander.Editor(lCurrentFile, true);
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
|
|
@ -97,6 +98,7 @@ CloudCommander.keyBinding = (function(){
|
|||
/* if alt+f3 pressed */
|
||||
else if(event.keyCode === lKEY.F3 &&
|
||||
event.altKey){
|
||||
Util.Images.showLoad();
|
||||
if (typeof CloudCommander.Terminal === 'function')
|
||||
CloudCommander.Terminal();
|
||||
|
||||
|
|
@ -108,7 +110,7 @@ CloudCommander.keyBinding = (function(){
|
|||
Util.Images.showLoad();
|
||||
|
||||
if (typeof CloudCommander.Editor === 'function')
|
||||
CloudCommander.Editor();
|
||||
CloudCommander.Editor(lCurrentFile);
|
||||
|
||||
event.preventDefault();//запрет на дальнейшее действие
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,219 +2,222 @@ var CloudCommander, CloudFunc, $;
|
|||
/* object contains viewer FancyBox
|
||||
* https://github.com/fancyapps/fancyBox
|
||||
*/
|
||||
CloudCommander.Viewer = {
|
||||
get: (function(){
|
||||
return this.FancyBox;
|
||||
})
|
||||
};
|
||||
|
||||
CloudCommander.Viewer.FancyBox = new CloudCommander.Utils();
|
||||
|
||||
CloudCommander.Viewer.dir = './lib/client/viewer/';
|
||||
CloudCommander.Viewer.FancyBox.dir = CloudCommander.Viewer.dir +
|
||||
'fancybox/';
|
||||
|
||||
/* function return configureation
|
||||
* for FancyBox open and
|
||||
* onclick (it shoud be
|
||||
* different objects)
|
||||
*/
|
||||
CloudCommander.Viewer.FancyBox.getConfig = (function(){
|
||||
var lThis = this;
|
||||
return{
|
||||
/* function do her work
|
||||
* before FauncyBox shows
|
||||
*/
|
||||
beforeShow : function(){
|
||||
CloudCommander.keyBinded = false;
|
||||
},
|
||||
|
||||
afterShow : function(){
|
||||
var lEditor = lThis.getById('CloudViewer');
|
||||
if(lEditor)
|
||||
lEditor.focus();
|
||||
},
|
||||
|
||||
beforeClose : function(){
|
||||
CloudCommander.keyBinded = true;
|
||||
},
|
||||
|
||||
openEffect : 'none',
|
||||
closeEffect : 'none',
|
||||
autoSize : false,
|
||||
height : window.innerHeight,
|
||||
helpers : {
|
||||
overlay : {
|
||||
opacity: 0.1,
|
||||
css : {
|
||||
'background-color' : '#fff'
|
||||
}
|
||||
}
|
||||
},
|
||||
padding : 0
|
||||
};
|
||||
});
|
||||
|
||||
/* function loads css and js of FancyBox
|
||||
* @pParent - this
|
||||
* @pCallBack - executes, when everything loaded
|
||||
*/
|
||||
CloudCommander.Viewer.FancyBox.load = (function(pThis, pCallBack){
|
||||
var ljsLoad_f = function(){
|
||||
var lSrc = pThis.dir + 'jquery.fancybox.pack.js';
|
||||
pThis.jsload(lSrc,{
|
||||
onload: pCallBack
|
||||
});
|
||||
(function(){
|
||||
CloudCommander.Viewer = {
|
||||
get: (function(){
|
||||
return this.FancyBox;
|
||||
})
|
||||
};
|
||||
|
||||
pThis.cssSet({id:'viewer',
|
||||
inner : '#CloudViewer{' +
|
||||
'font-size: 16px;' +
|
||||
'white-space :pre' +
|
||||
'}' +
|
||||
'#CloudViewer::selection{' +
|
||||
'background: #fe57a1;' +
|
||||
'color: #fff;' +
|
||||
'text-shadow: none;' +
|
||||
'}'
|
||||
});
|
||||
CloudCommander.Viewer.FancyBox = {};
|
||||
var Util = CloudCommander.Util;
|
||||
|
||||
var lSrc = pThis.dir +'jquery.fancybox.pack.css';
|
||||
pThis.cssLoad({
|
||||
src : lSrc,
|
||||
func : {
|
||||
onload: ljsLoad_f
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
CloudCommander.Viewer.FancyBox.loadData = (function(pA){
|
||||
var lThis = this;
|
||||
var lConfig = this.getConfig();
|
||||
|
||||
this.Images.showLoad();
|
||||
|
||||
var lLink = pA.href;
|
||||
|
||||
/* убираем адрес хоста*/
|
||||
lLink = '/' + lLink.replace(document.location.href,'');
|
||||
|
||||
if (lLink.indexOf(CloudFunc.NOJS) === CloudFunc.FS.length)
|
||||
lLink = lLink.replace(CloudFunc.NOJS, '');
|
||||
|
||||
$.ajax({
|
||||
url : lLink,
|
||||
error : (function(jqXHR, textStatus, errorThrown){
|
||||
lThis.loading = false;
|
||||
return lThis.Images.showError(jqXHR, textStatus, errorThrown);
|
||||
}),
|
||||
|
||||
success:function(data, textStatus, jqXHR){
|
||||
/* if we got json - show it */
|
||||
if(typeof data === 'object')
|
||||
data = JSON.stringify(data, null, 4);
|
||||
|
||||
$.fancybox('<div id=CloudViewer tabindex=0>' + data + '</div>', lConfig);
|
||||
|
||||
lThis.Images.hideLoad();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
CloudCommander.Viewer.FancyBox.set = (function(){
|
||||
if(this.getByClass('fancybox').length)
|
||||
return;
|
||||
try{
|
||||
/* get current panel (left or right) */
|
||||
var lPanel = this.getPanel();
|
||||
|
||||
/* get all file links */
|
||||
var lA = this.getByTag('a', lPanel);
|
||||
CloudCommander.Viewer.dir = './lib/client/viewer/';
|
||||
CloudCommander.Viewer.FancyBox.dir = CloudCommander.Viewer.dir +
|
||||
'fancybox/';
|
||||
|
||||
/* function return configureation
|
||||
* for FancyBox open and
|
||||
* onclick (it shoud be
|
||||
* different objects)
|
||||
*/
|
||||
CloudCommander.Viewer.FancyBox.getConfig = (function(){
|
||||
var lThis = this;
|
||||
|
||||
var lDblClick_f = function(pA){
|
||||
return function(){
|
||||
var lConfig = lThis.getConfig();
|
||||
lConfig.href = pA.href;
|
||||
if(pA.rel)
|
||||
$.fancybox(lConfig);
|
||||
else
|
||||
lThis.loadData(pA);
|
||||
};
|
||||
return{
|
||||
/* function do her work
|
||||
* before FauncyBox shows
|
||||
*/
|
||||
beforeShow : function(){
|
||||
CloudCommander.keyBinded = false;
|
||||
},
|
||||
|
||||
afterShow : function(){
|
||||
var lEditor = Util.getById('CloudViewer');
|
||||
if(lEditor)
|
||||
lEditor.focus();
|
||||
},
|
||||
|
||||
beforeClose : function(){
|
||||
CloudCommander.keyBinded = true;
|
||||
},
|
||||
|
||||
openEffect : 'none',
|
||||
closeEffect : 'none',
|
||||
autoSize : false,
|
||||
height : window.innerHeight,
|
||||
helpers : {
|
||||
overlay : {
|
||||
opacity: 0.1,
|
||||
css : {
|
||||
'background-color' : '#fff'
|
||||
}
|
||||
}
|
||||
},
|
||||
padding : 0
|
||||
};
|
||||
});
|
||||
|
||||
/* function loads css and js of FancyBox
|
||||
* @pParent - this
|
||||
* @pCallBack - executes, when everything loaded
|
||||
*/
|
||||
CloudCommander.Viewer.FancyBox.load = (function(pThis, pCallBack){
|
||||
var ljsLoad_f = function(){
|
||||
var lSrc = pThis.dir + 'jquery.fancybox.pack.js';
|
||||
Util.jsload(lSrc,{
|
||||
onload: pCallBack
|
||||
});
|
||||
};
|
||||
|
||||
/* first two is not files nor folders*/
|
||||
for (var i=2; i < lA.length; i++) {
|
||||
var lName = lA[i].title || lA[i].textContent;
|
||||
Util.cssSet({id:'viewer',
|
||||
inner : '#CloudViewer{' +
|
||||
'font-size: 16px;' +
|
||||
'white-space :pre' +
|
||||
'}' +
|
||||
'#CloudViewer::selection{' +
|
||||
'background: #fe57a1;' +
|
||||
'color: #fff;' +
|
||||
'text-shadow: none;' +
|
||||
'}'
|
||||
});
|
||||
|
||||
var lSrc = pThis.dir +'jquery.fancybox.pack.css';
|
||||
Util.cssLoad({
|
||||
src : lSrc,
|
||||
func : {
|
||||
onload: ljsLoad_f
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
CloudCommander.Viewer.FancyBox.loadData = (function(pA){
|
||||
var lThis = this;
|
||||
var lConfig = this.getConfig();
|
||||
|
||||
Util.Images.showLoad();
|
||||
|
||||
lA[i].className = 'fancybox';
|
||||
if(CloudFunc.checkExtension(lName, ['png','jpg', 'gif','ico'])){
|
||||
lA[i].rel = 'gallery';
|
||||
var lLink = pA.href;
|
||||
|
||||
/* убираем адрес хоста*/
|
||||
lLink = '/' + lLink.replace(document.location.href,'');
|
||||
|
||||
if (lLink.indexOf(CloudFunc.NOJS) === CloudFunc.FS.length)
|
||||
lLink = lLink.replace(CloudFunc.NOJS, '');
|
||||
|
||||
$.ajax({
|
||||
url : lLink,
|
||||
error : (function(jqXHR, textStatus, errorThrown){
|
||||
lThis.loading = false;
|
||||
return Util.Images.showError(jqXHR, textStatus, errorThrown);
|
||||
}),
|
||||
|
||||
success:function(data, textStatus, jqXHR){
|
||||
/* if we got json - show it */
|
||||
if(typeof data === 'object')
|
||||
data = JSON.stringify(data, null, 4);
|
||||
|
||||
$.fancybox('<div id=CloudViewer tabindex=0>' + data + '</div>', lConfig);
|
||||
|
||||
Util.Images.hideLoad();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
CloudCommander.Viewer.FancyBox.set = (function(){
|
||||
if(Util.getByClass('fancybox').length)
|
||||
return;
|
||||
try{
|
||||
/* get current panel (left or right) */
|
||||
var lPanel = Util.getPanel();
|
||||
|
||||
/* get all file links */
|
||||
var lA = Util.getByTag('a', lPanel);
|
||||
|
||||
var lThis = this;
|
||||
|
||||
var lDblClick_f = function(pA){
|
||||
return function(){
|
||||
var lConfig = lThis.getConfig();
|
||||
lConfig.href = pA.href;
|
||||
if(pA.rel)
|
||||
$.fancybox(lConfig);
|
||||
else
|
||||
lThis.loadData(pA);
|
||||
};
|
||||
};
|
||||
|
||||
/* first two is not files nor folders*/
|
||||
for (var i=2; i < lA.length; i++) {
|
||||
var lName = lA[i].title || lA[i].textContent;
|
||||
|
||||
lA[i].className = 'fancybox';
|
||||
if(CloudFunc.checkExtension(lName, ['png','jpg', 'gif','ico'])){
|
||||
lA[i].rel = 'gallery';
|
||||
}
|
||||
|
||||
lA[i].ondblclick = lDblClick_f(lA[i]);
|
||||
}
|
||||
|
||||
}catch(pError){
|
||||
console.log(pError);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
CloudCommander.Viewer.FancyBox.show = (function(pCurrentFile){
|
||||
CloudCommander.Viewer.FancyBox.set();
|
||||
|
||||
var lA = Util.getByClass('fancybox', pCurrentFile)[0];
|
||||
var lConfig = this.getConfig();
|
||||
|
||||
if(lA){
|
||||
if(lA.rel)
|
||||
$.fancybox.open({ href : lA[0].href },
|
||||
lConfig);
|
||||
else this.loadData(lA);
|
||||
}
|
||||
});
|
||||
|
||||
CloudCommander.Viewer.Keys = (function(pCurrentFile){
|
||||
"use strict";
|
||||
|
||||
var lCallBack_f = (function(){
|
||||
var key_event = (function(pEvent){
|
||||
/* если клавиши можно обрабатывать */
|
||||
if(CloudCommander.keyBinded)
|
||||
/* if f3 pressed */
|
||||
if(pEvent.keyCode === CloudCommander.KEY.F3 &&
|
||||
pEvent.shiftKey){
|
||||
var lCurrentFile = Util.getCurrentFile();
|
||||
CloudCommander.Viewer.FancyBox.show(lCurrentFile);
|
||||
|
||||
pEvent.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
if (document.addEventListener)
|
||||
document.addEventListener('keydown', key_event, false);
|
||||
|
||||
else{
|
||||
var lFunc;
|
||||
if(typeof document.onkeydown === 'function')
|
||||
lFunc = document.onkeydown;
|
||||
|
||||
document.onkeydown = function(){
|
||||
if(lFunc)
|
||||
lFunc();
|
||||
|
||||
key_event();
|
||||
};
|
||||
}
|
||||
|
||||
lA[i].ondblclick = lDblClick_f(lA[i]);
|
||||
}
|
||||
|
||||
}catch(pError){
|
||||
console.log(pError);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
CloudCommander.Viewer.FancyBox.show = (function(pParent){
|
||||
CloudCommander.Viewer.FancyBox.set();
|
||||
|
||||
var lCurrent = this.getCurrentFile();
|
||||
var lA = this.getByClass('fancybox', lCurrent)[0];
|
||||
var lConfig = this.getConfig();
|
||||
|
||||
if(lA){
|
||||
if(lA.rel)
|
||||
$.fancybox.open({ href : lA[0].href },
|
||||
lConfig);
|
||||
else this.loadData(lA);
|
||||
}
|
||||
});
|
||||
|
||||
CloudCommander.Viewer.Keys = (function(){
|
||||
"use strict";
|
||||
|
||||
var lCallBack_f = (function(){
|
||||
var key_event = (function(pEvent){
|
||||
/* если клавиши можно обрабатывать */
|
||||
if(CloudCommander.keyBinded)
|
||||
/* if f3 pressed */
|
||||
if(pEvent.keyCode === CloudCommander.KEY.F3 &&
|
||||
pEvent.shiftKey){
|
||||
CloudCommander.Viewer.FancyBox.show();
|
||||
|
||||
pEvent.preventDefault();
|
||||
}
|
||||
/* showing images preview*/
|
||||
CloudCommander.Viewer.FancyBox.show(pCurrentFile);
|
||||
});
|
||||
|
||||
/* добавляем обработчик клавишь */
|
||||
if (document.addEventListener)
|
||||
document.addEventListener('keydown', key_event, false);
|
||||
|
||||
else{
|
||||
var lFunc;
|
||||
if(typeof document.onkeydown === 'function')
|
||||
lFunc = document.onkeydown;
|
||||
|
||||
document.onkeydown = function(){
|
||||
if(lFunc)
|
||||
lFunc();
|
||||
|
||||
key_event();
|
||||
};
|
||||
}
|
||||
|
||||
/* showing images preview*/
|
||||
CloudCommander.Viewer.FancyBox.show();
|
||||
CloudCommander.Viewer.FancyBox.load(this.FancyBox, lCallBack_f);
|
||||
});
|
||||
|
||||
CloudCommander.Viewer.FancyBox.load(this.FancyBox, lCallBack_f);
|
||||
});
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue