diff --git a/ChangeLog b/ChangeLog index 96b4eae6..bd9889d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -46,6 +46,10 @@ getJSONfromFileTable. * Simpified plugins id's. +* Rewrited _codemirror and view modules with prototypes. + +* Added hide method to view module. + 2012.04.22, v0.2.0 diff --git a/lib/client/view.js b/lib/client/view.js index d8bfd558..94d0979e 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -1,137 +1,136 @@ var CloudCmd, Util, DOM, CloudFunc, $; -/* object contains viewer FancyBox - * https://github.com/fancyapps/fancyBox - */ + (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; - var Key = CloudCmd.Key, - FancyBox = {}, + CloudCmd.View = new ViewProto(CloudCmd, Util, DOM, CloudFunc); - Config = { - beforeShow : function(){ - DOM.Images.hideLoad(); - Key.unsetBind(); - }, + function ViewProto(CloudCmd, Util, DOM, CloudFunc){ + var Key = CloudCmd.Key, + FancyBox = this, - afterShow : function(){ - var lEditor = DOM.getById('View'); - if(lEditor) - lEditor.focus(); - }, - - beforeClose : Util.retFunc( Key.setBind ), - - openEffect : 'none', - closeEffect : 'none', - autoSize : false, - height : window.innerHeight, - helpers : { - overlay : { - css : { - 'background' : 'rgba(255, 255, 255, 0.1)' - } - } - }, - padding : 0 - }; - - CloudCmd.View = { - get: function(){ - return this.FancyBox; - } - }; - - /** - * function loads css and js of FancyBox - * @pParent - this - * @pCallBack - executes, when everything loaded - */ - FancyBox.load = function(pCallBack){ - Util.time('fancybox load'); - var lDir = CloudCmd.LIBDIRCLIENT + 'view/fancyBox/source/', - lFiles = [ lDir + 'jquery.fancybox.css', - lDir + 'jquery.fancybox.js' ]; - - DOM.anyLoadOnLoad([lFiles], function(){ - Util.timeEnd('fancybox load'); - Util.exec( pCallBack ); - }) - .cssSet({id:'view-css', - inner : '#view{' + - 'font-size: 16px;' + - 'white-space :pre' + - '}' + - '#view::selection{' + - /* - 'background: #fe57a1;' - 'color: #fff;' - */ - 'background: #b3d4fc;' + - 'text-shadow: none;' + - '}' - }); - - }; - - - FancyBox.showHelp = function(){ - DOM.Images.showLoad(); - DOM.ajax({ - url: '/README.md', - success: function (pData){ - var lData = {text: pData}; - DOM.ajax({ - method : 'post', - url : 'https://api.github.com/markdown', - data : Util.stringifyJSON(lData), - success:function(pResult){ - DOM.Images.hideLoad(); - $.fancybox(pResult, Config); - }, + Config = { + beforeShow : function(){ + DOM.Images.hideLoad(); + Key.unsetBind(); + }, - error: DOM.Images.showError - }); - }, + afterShow : function(){ + var lEditor = DOM.getById('View'); + if(lEditor) + lEditor.focus(); + }, + + beforeClose : Util.retFunc( Key.setBind ), + + openEffect : 'none', + closeEffect : 'none', + autoSize : false, + height : window.innerHeight, + helpers : { + overlay : { + css : { + 'background' : 'rgba(255, 255, 255, 0.1)' + } + } + }, + padding : 0 + }; + + this.init = function(pCallBack){ + Util.loadOnLoad([ + pCallBack, + FancyBox.show, + load, + DOM.jqueryLoad + ]); - error:DOM.Images.showError - }); - }; - - /** - * function shows FancyBox - */ - FancyBox.show = function(pCallBack){ - var lPath = CloudFunc.FS + DOM.getCurrentPath(); + DOM.Events.addKey(listener); + DOM.setButtonKey('f3', view); + }; - if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) - $.fancybox.open({ href : lPath }, Config); - else - DOM.getCurrentData(function(pParams){ - $.fancybox('