mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
added hide method to view module
This commit is contained in:
parent
fb0aa4d55c
commit
bb8013c818
2 changed files with 127 additions and 126 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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('<div id=view tabindex=0>' +
|
||||
pParams.data + '</div>', Config);
|
||||
});
|
||||
|
||||
Util.exec(pCallBack);
|
||||
};
|
||||
|
||||
CloudCmd.View.init = function(pCallBack){
|
||||
Util.loadOnLoad([
|
||||
pCallBack,
|
||||
FancyBox.show,
|
||||
FancyBox.load,
|
||||
DOM.jqueryLoad
|
||||
]);
|
||||
|
||||
DOM.Events.addKey(lListener);
|
||||
DOM.setButtonKey('f3', lView);
|
||||
|
||||
function lView(){
|
||||
this.showHelp = function(){
|
||||
DOM.Images.showLoad();
|
||||
FancyBox.show( DOM.getCurrentFile() );
|
||||
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);
|
||||
},
|
||||
|
||||
error: DOM.Images.showError
|
||||
});
|
||||
},
|
||||
|
||||
error:DOM.Images.showError
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* function shows FancyBox
|
||||
*/
|
||||
this.show = function(pCallBack){
|
||||
var lPath = CloudFunc.FS + DOM.getCurrentPath();
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
this.hide = function(){
|
||||
$.fancybox.close();
|
||||
};
|
||||
|
||||
/**
|
||||
* function loads css and js of FancyBox
|
||||
* @pParent - this
|
||||
* @pCallBack - executes, when everything loaded
|
||||
*/
|
||||
function load(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;' +
|
||||
'}'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function lListener(pEvent){
|
||||
function view(){
|
||||
DOM.Images.showLoad();
|
||||
FancyBox.show( DOM.getCurrentFile() );
|
||||
}
|
||||
|
||||
function listener(pEvent){
|
||||
var lF3 = Key.F3,
|
||||
lF1 = Key.F1,
|
||||
lIsBind = Key.isBind(),
|
||||
|
|
@ -141,7 +140,7 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
if (lIsBind) {
|
||||
switch(lKey){
|
||||
case lF3:
|
||||
lView();
|
||||
view();
|
||||
DOM.preventDefault(pEvent);
|
||||
break;
|
||||
|
||||
|
|
@ -151,8 +150,6 @@ var CloudCmd, Util, DOM, CloudFunc, $;
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CloudCmd.View.FancyBox = FancyBox;
|
||||
}
|
||||
|
||||
})(CloudCmd, Util, DOM, CloudFunc);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue