mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
added api for getting curent file, getting active and passive panels and show/hide any of panels
This commit is contained in:
parent
46950f261f
commit
dd6560efa3
2 changed files with 93 additions and 56 deletions
68
client.js
68
client.js
|
|
@ -47,7 +47,8 @@ var CloudClient = {
|
|||
/* height of Cloud Commander
|
||||
* seting up in init()
|
||||
*/
|
||||
HEIGHT :0
|
||||
HEIGHT :0,
|
||||
MIN_ONE_PANEL_WIDTH :1155
|
||||
};
|
||||
|
||||
/* short names used all the time functions */
|
||||
|
|
@ -321,14 +322,13 @@ CloudClient.Util = (function(){
|
|||
return lE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Function shows loading spinner
|
||||
* @pElem - top element of screen
|
||||
*/
|
||||
|
||||
var lThis = this;
|
||||
this.Images = {
|
||||
/*
|
||||
* Function shows loading spinner
|
||||
* @pElem - top element of screen
|
||||
*/
|
||||
showLoad : function(pElem){
|
||||
if(!lLoadingImage)
|
||||
lLoadingImage = LImages_o.loading();
|
||||
|
|
@ -358,7 +358,9 @@ CloudClient.Util = (function(){
|
|||
},
|
||||
|
||||
hideLoad : function(){
|
||||
if(lLoadingImage)
|
||||
if(!lLoadingImage)
|
||||
lLoadingImage = LImages_o.loading();
|
||||
|
||||
lLoadingImage.className ='hidden';
|
||||
},
|
||||
|
||||
|
|
@ -390,6 +392,56 @@ CloudClient.Util = (function(){
|
|||
console.log(lText);
|
||||
}
|
||||
};
|
||||
|
||||
this.getCurrentFile = function(){
|
||||
var lCurrent = lThis.getByClass(CloudCommander.CURRENT_FILE)[0];
|
||||
if(!lCurrent)
|
||||
console.log('Error: Can not find Current File');
|
||||
|
||||
return lCurrent;
|
||||
};
|
||||
|
||||
/* function getting panel active, or passive
|
||||
* @pPanel_o = {active: true}
|
||||
*/
|
||||
this.getPanel = function(pActive){
|
||||
var lPanel;
|
||||
|
||||
lPanel = lThis.getCurrentFile().parentElement;
|
||||
|
||||
/* if two panels showed
|
||||
* then always work with passive
|
||||
* panel
|
||||
*/
|
||||
if(window.innerWidth > CloudCommander.MIN_ONE_PANEL_WIDTH)
|
||||
pActive = {active: false};
|
||||
|
||||
/* if {active : false} getting passive panel */
|
||||
if(pActive && !pActive.active){
|
||||
var lId = lPanel.id === 'left' ? 'right' : 'left';
|
||||
lPanel = lThis.getById(lId);
|
||||
}
|
||||
|
||||
|
||||
if(!lPanel)
|
||||
console.log('Error can not find Active Panel');
|
||||
|
||||
return lPanel;
|
||||
};
|
||||
|
||||
this.showPanel = function(pActive){
|
||||
var lPanel = lThis.getPanel(pActive);
|
||||
|
||||
if(lPanel)
|
||||
lPanel.className = 'panel';
|
||||
};
|
||||
|
||||
this.hidePanel = function(pActive){
|
||||
var lPanel = lThis.getPanel(pActive);
|
||||
|
||||
if(lPanel)
|
||||
lPanel.className = 'panel hidden';
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -99,44 +99,38 @@ CloudCommander.Editor.CodeMirror.show = (function(){
|
|||
});
|
||||
};
|
||||
|
||||
var lLeft = this.getById('left');
|
||||
var lCloudEditor = this.getById('CloudEditor');
|
||||
var lCURRENTFILE = CloudCommander.CURRENT_FILE;
|
||||
|
||||
|
||||
var lCurrent = this.getByClass(lCURRENTFILE);
|
||||
|
||||
var lCurrent = this.getCurrentFile();
|
||||
var lA;
|
||||
if(lCurrent.length){
|
||||
lCurrent = lCurrent[0];
|
||||
|
||||
/* getting link */
|
||||
lA = lCurrent.getElementsByTagName('a');
|
||||
if(!lA.length)
|
||||
return console.log('Error:' +
|
||||
'can not find links in current file');
|
||||
|
||||
lA = lA[0].href;
|
||||
|
||||
/* убираем адрес хоста*/
|
||||
lA = '/' + lA.replace(document.location.href,'');
|
||||
|
||||
/* checking is this link is to directory */
|
||||
var lSize = lCurrent.getElementsByClassName('size');
|
||||
if(lSize){
|
||||
lSize = lSize[0].textContent;
|
||||
|
||||
/* getting link */
|
||||
lA = lCurrent.getElementsByTagName('a');
|
||||
if(!lA.length)
|
||||
return console.log('Error:' +
|
||||
'can not find links in current file');
|
||||
|
||||
lA = lA[0].href;
|
||||
/* if directory - load json
|
||||
* not html data
|
||||
*/
|
||||
if (lSize === '<dir>'){
|
||||
if (lA.indexOf(CloudFunc.NOJS) ===
|
||||
CloudFunc.FS.length) {
|
||||
|
||||
/* убираем адрес хоста*/
|
||||
lA = '/' + lA.replace(document.location.href,'');
|
||||
|
||||
/* checking is this link is to directory */
|
||||
var lSize = lCurrent.getElementsByClassName('size');
|
||||
if(lSize){
|
||||
lSize = lSize[0].textContent;
|
||||
|
||||
/* if directory - load json
|
||||
* not html data
|
||||
*/
|
||||
if (lSize === '<dir>'){
|
||||
if (lA.indexOf(CloudFunc.NOJS) ===
|
||||
CloudFunc.FS.length) {
|
||||
|
||||
lA = lA.replace(CloudFunc.NOJS, '');
|
||||
lReadOnly = true;
|
||||
}
|
||||
lA = lA.replace(CloudFunc.NOJS, '');
|
||||
lReadOnly = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
|
|
@ -157,10 +151,8 @@ CloudCommander.Editor.CodeMirror.show = (function(){
|
|||
|
||||
/* removing keyBinding if set */
|
||||
CloudCommander.keyBinded = false;
|
||||
|
||||
lLeft &&
|
||||
(lLeft.className = 'panel hidden');
|
||||
|
||||
|
||||
lParent.hidePanel();
|
||||
lParent.Images.hideLoad();
|
||||
|
||||
lParent.loading = false;
|
||||
|
|
@ -171,19 +163,12 @@ CloudCommander.Editor.CodeMirror.show = (function(){
|
|||
/* function hides CodeMirror editor */
|
||||
CloudCommander.Editor.CodeMirror.hide = (function(pParent) {
|
||||
return function(){
|
||||
CloudCommander.keyBinded = true;
|
||||
CloudCommander.keyBinded = true;
|
||||
pParent.showPanel();
|
||||
|
||||
var lLeft = pParent.getById('left');
|
||||
var lCloudEditor = pParent.getById('CloudEditor');
|
||||
|
||||
/*
|
||||
lCloudEditor &&
|
||||
(lCloudEditor.className = 'hidden');
|
||||
*/
|
||||
lLeft &&
|
||||
(lLeft.className = 'panel');
|
||||
|
||||
var lCloudEditor = pParent.getById('CloudEditor');
|
||||
var lCodeMirror = pParent.getByClass('CodeMirror');
|
||||
|
||||
if(lCodeMirror.length)
|
||||
lCloudEditor
|
||||
.removeChild(lCodeMirror[0]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue