diff --git a/client.js b/client.js index b4f602b8..da11b595 100644 --- a/client.js +++ b/client.js @@ -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); }) }); }); diff --git a/lib/client/editor.js b/lib/client/editor.js index 6c6438df..bfff9196 100644 --- a/lib/client/editor.js +++ b/lib/client/editor.js @@ -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); } } } diff --git a/lib/client/keyBinding.js b/lib/client/keyBinding.js index 81a6001f..7620d967 100644 --- a/lib/client/keyBinding.js +++ b/lib/client/keyBinding.js @@ -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();//запрет на дальнейшее действие } diff --git a/lib/client/viewer.js b/lib/client/viewer.js index 853ca603..5214f3c4 100644 --- a/lib/client/viewer.js +++ b/lib/client/viewer.js @@ -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('