added ability to put callback to view

This commit is contained in:
coderaiaser 2013-06-12 05:47:05 -07:00
parent cda360ac2e
commit b241775e21
2 changed files with 30 additions and 24 deletions

View file

@ -56,6 +56,8 @@ getJSONfromFileTable.
* FilePicker gets key from modules.json.
* Added ability to put callback to view.
2012.04.22, v0.2.0

View file

@ -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('<div id=view tabindex=0>' +
pParams.data + '</div>', Config);
});
Util.exec(pCallBack);
if(pData)
$.fancybox('<div id=view tabindex=0>' + pData + '</div>', 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('<div id=view tabindex=0>' +
pParams.data + '</div>', 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){