diff --git a/ChangeLog b/ChangeLog index c7760eac..44c31fc2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -56,6 +56,8 @@ getJSONfromFileTable. * FilePicker gets key from modules.json. +* Added ability to put callback to view. + 2012.04.22, v0.2.0 diff --git a/lib/client/view.js b/lib/client/view.js index 8fb02e20..2979d2af 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -7,15 +7,13 @@ var CloudCmd, Util, DOM, CloudFunc, $; function ViewProto(CloudCmd, Util, DOM, CloudFunc){ var Key = CloudCmd.Key, + Images = DOM.Images, View = this, Config = { - beforeShow : function(){ - DOM.Images.hideLoad(); - Key.unsetBind(); - }, + beforeShow : Key.unsetBind, - afterShow : function(){ + afterShow : function(){ var lEditor = DOM.getById('View'); if(lEditor) lEditor.focus(); @@ -39,8 +37,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; this.init = function(pCallBack){ Util.loadOnLoad([ - pCallBack, - View.show, + pCallBack || View.show, load, DOM.jqueryLoad ]); @@ -52,7 +49,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; }; this.showHelp = function(){ - DOM.Images.showLoad(); + Images.showLoad(); DOM.ajax({ url: '/README.md', success: function (pData){ @@ -62,33 +59,39 @@ var CloudCmd, Util, DOM, CloudFunc, $; url : 'https://api.github.com/markdown', data : Util.stringifyJSON(lData), success:function(pResult){ - DOM.Images.hideLoad(); + Images.hideLoad(); $.fancybox(pResult, Config); }, - error: DOM.Images.showError + error: Images.showError }); }, - error:DOM.Images.showError + error:Images.showError }); }; /** * function shows FancyBox */ - this.show = function(pCallBack){ - var lPath = CloudFunc.FS + DOM.getCurrentPath(); + this.show = function(pData){ + var lPath; - if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) - $.fancybox.open({ href : lPath }, Config); - else - DOM.getCurrentData(function(pParams){ - $.fancybox('
' + - pParams.data + '
', Config); - }); - - Util.exec(pCallBack); + if(pData) + $.fancybox('
' + pData + '
', Config); + else { + lPath = CloudFunc.FS + DOM.getCurrentPath(); + if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) ) { + Images.hideLoad(); + $.fancybox.open({ href : lPath }, Config); + } + else + DOM.getCurrentData(function(pParams){ + Images.hideLoad(); + $.fancybox('
' + + pParams.data + '
', Config); + }); + } }; this.hide = function(){ @@ -109,6 +112,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.anyLoadOnLoad([lFiles], function(){ Util.timeEnd('fancybox load'); Util.exec( pCallBack ); + Images.hideLoad(); }) .cssSet({id:'view-css', inner : '#view{' + @@ -128,8 +132,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; } function view(){ - DOM.Images.showLoad(); - View.show( DOM.getCurrentFile() ); + Images.showLoad(); + View.show(); } function listener(pEvent){