mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
129 lines
4.3 KiB
JavaScript
129 lines
4.3 KiB
JavaScript
var CloudCmd, Util, DOM, CloudFunc, $;
|
|
|
|
(function(CloudCmd, Util, DOM, CloudFunc){
|
|
'use strict';
|
|
|
|
CloudCmd.View = new ViewProto(CloudCmd, Util, DOM, CloudFunc);
|
|
|
|
function ViewProto(CloudCmd, Util, DOM, CloudFunc){
|
|
var Key = CloudCmd.Key,
|
|
Images = DOM.Images,
|
|
View = this,
|
|
|
|
Config = {
|
|
beforeShow : Key.unsetBind,
|
|
|
|
afterShow : function(){
|
|
var lEditor = DOM.getById('View');
|
|
if(lEditor)
|
|
lEditor.focus();
|
|
},
|
|
|
|
beforeClose : 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 || Util.retExec(View.show, null),
|
|
load,
|
|
DOM.jqueryLoad
|
|
]);
|
|
|
|
DOM.Events.addKey(listener);
|
|
DOM.setButtonKey('f3', view);
|
|
|
|
delete View.init;
|
|
};
|
|
|
|
/**
|
|
* function shows FancyBox
|
|
*/
|
|
this.show = function(pData){
|
|
var lPath;
|
|
|
|
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('<div id=view tabindex=0>' +
|
|
pParams.data + '</div>', Config);
|
|
});
|
|
}
|
|
};
|
|
|
|
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 );
|
|
Images.hideLoad();
|
|
})
|
|
.cssSet({id:'view-css',
|
|
inner : '#view{' +
|
|
'font-size: 16px;' +
|
|
'white-space :pre' +
|
|
'}' +
|
|
'#view::selection{' +
|
|
/*
|
|
'background: #fe57a1;'
|
|
'color: #fff;'
|
|
*/
|
|
'background: #b3d4fc;' +
|
|
'text-shadow: none;' +
|
|
'}'
|
|
});
|
|
|
|
}
|
|
|
|
function view(){
|
|
Images.showLoad();
|
|
View.show();
|
|
}
|
|
|
|
function listener(pEvent){
|
|
var lF3 = Key.F3,
|
|
lIsBind = Key.isBind(),
|
|
lKey = pEvent.keyCode;
|
|
|
|
/* если клавиши можно обрабатывать */
|
|
if (lIsBind && lKey === lF3) {
|
|
view();
|
|
DOM.preventDefault(pEvent);
|
|
}
|
|
}
|
|
}
|
|
|
|
})(CloudCmd, Util, DOM, CloudFunc);
|