added help screen (on F1 after viewer loads)

This commit is contained in:
coderaiser 2013-02-28 03:54:11 -05:00
parent fd3838f5ec
commit eeec5ffdec
7 changed files with 165 additions and 128 deletions

View file

@ -189,6 +189,8 @@ generation of json of directory listing.
* Added RESTfull object to DOM for easy work with
CloudCmd REST API.
* Added help screen (on F1 after viewer loads).
2012.12.12, Version 0.1.8

View file

@ -2,7 +2,7 @@
"api_url" : "/api/v1",
"appcache" : false,
"minification" : {
"js" : true,
"js" : false,
"css" : true,
"html" : true,
"img" : true

View file

@ -281,7 +281,7 @@ function initKeysPanel(pCallBack){
lFuncs =[
null,
null, /* f1 */
null, /* f2 */
DOM.renameCurrentFile, /* f2 */
CloudCmd.Viewer, /* f3 */
CloudCmd.Editor, /* f4 */
null, /* f5 */

View file

@ -1400,7 +1400,7 @@ var CloudCommander, Util,
* @pCurrent
*/
DOM.renameCurrentFile = function(pCurrentFile){
if( Util.isString(pCurrentFile) )
if( !DOM.isCurrentFile(pCurrentFile) )
pCurrentFile = null;
var lCurrent = pCurrentFile || DOM.getCurrentFile(),

View file

@ -30,6 +30,7 @@ var CloudCommander, Util, DOM;
S : 83,
T : 84,
F1 : 112,
F2 : 113,
F3 : 114,
F4 : 115,
@ -118,6 +119,9 @@ var CloudCommander, Util, DOM;
else
DOM.promptDeleteCurrent(lCurrentFile);
}
else if(lKeyCode === KEY.F1){
DOM.preventDefault(pEvent);
}
else if(lKeyCode === KEY.F2)
DOM.renameCurrentFile(lCurrentFile);
/* if f3 or shift+f3 or alt+f3 pressed */

View file

@ -1,125 +1,156 @@
var CloudCommander, Util, DOM, $;
/* object contains viewer FancyBox
* https://github.com/fancyapps/fancyBox
*/
(function(CloudCmd, Util, DOM){
'use strict';
var KeyBinding = CloudCmd.KeyBinding,
FancyBox = {},
Config = {
beforeShow : function(){
DOM.Images.hideLoad();
KeyBinding.unSet();
},
afterShow : function(){
var lEditor = DOM.getById('CloudViewer');
if(lEditor)
lEditor.focus();
},
beforeClose : Util.retFunc( KeyBinding.set ),
openEffect : 'none',
closeEffect : 'none',
autoSize : false,
height : window.innerHeight,
helpers : {
overlay : {
css : {
'background' : 'rgba(255, 255, 255, 0.1)'
}
}
},
padding : 0
};
CloudCmd.Viewer = {
get: (function(){
return this.FancyBox;
})
};
/**
* function loads css and js of FancyBox
* @pParent - this
* @pCallBack - executes, when everything loaded
*/
FancyBox.load = function(pCallBack){
console.time('fancybox load');
var lDir = CloudCmd.LIBDIRCLIENT + 'viewer/fancyBox/source/',
lFiles = [ lDir + 'jquery.fancybox.css',
lDir + 'jquery.fancybox.js' ];
DOM.anyLoadOnLoad([lFiles], function(){
console.timeEnd('fancybox load');
Util.exec( pCallBack );
})
.cssSet({id:'viewer',
inner : '#CloudViewer{' +
'font-size: 16px;' +
'white-space :pre' +
'}' +
'#CloudViewer::selection{' +
/*
'background: #fe57a1;'
'color: #fff;'
*/
'background: #b3d4fc;' +
'text-shadow: none;' +
'}'
});
};
/**
* function shows FancyBox
*/
FancyBox.show = function(){
var lPath = DOM.getCurrentPath();
if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) )
$.fancybox.open({ href : lPath }, Config);
else
DOM.getCurrentData(function(pParams){
$.fancybox('<div id=CloudViewer tabindex=0>' +
pParams.data + '</div>', Config);
});
};
CloudCmd.Viewer.init = function(){
Util.loadOnLoad([
FancyBox.show,
FancyBox.load,
DOM.jqueryLoad
]);
var lView = function(){
DOM.Images.showLoad();
FancyBox.show( DOM.getCurrentFile() );
};
var lKeyListener = function(pEvent){
var lF3 = CloudCmd.KEY.F3,
lKeyBinded = KeyBinding.get(),
lKey = pEvent.keyCode,
lShift = pEvent.shiftKey;
/* если клавиши можно обрабатывать */
if( lKeyBinded && lKey === lF3 && lShift ){
lView();
pEvent.preventDefault();
}
};
/* добавляем обработчик клавишь */
DOM.addKeyListener(lKeyListener)
.setButtonKey('f3', lView);
};
CloudCmd.Viewer.FancyBox = FancyBox;
var CloudCommander, Util, DOM, $;
/* object contains viewer FancyBox
* https://github.com/fancyapps/fancyBox
*/
(function(CloudCmd, Util, DOM){
'use strict';
var KeyBinding = CloudCmd.KeyBinding,
FancyBox = {},
Config = {
beforeShow : function(){
DOM.Images.hideLoad();
KeyBinding.unSet();
},
afterShow : function(){
var lEditor = DOM.getById('CloudViewer');
if(lEditor)
lEditor.focus();
},
beforeClose : Util.retFunc( KeyBinding.set ),
openEffect : 'none',
closeEffect : 'none',
autoSize : false,
height : window.innerHeight,
helpers : {
overlay : {
css : {
'background' : 'rgba(255, 255, 255, 0.1)'
}
}
},
padding : 0
};
CloudCmd.Viewer = {
get: (function(){
return this.FancyBox;
})
};
/**
* function loads css and js of FancyBox
* @pParent - this
* @pCallBack - executes, when everything loaded
*/
FancyBox.load = function(pCallBack){
console.time('fancybox load');
var lDir = CloudCmd.LIBDIRCLIENT + 'viewer/fancyBox/source/',
lFiles = [ lDir + 'jquery.fancybox.css',
lDir + 'jquery.fancybox.js' ];
DOM.anyLoadOnLoad([lFiles], function(){
console.timeEnd('fancybox load');
Util.exec( pCallBack );
})
.cssSet({id:'viewer',
inner : '#CloudViewer{' +
'font-size: 16px;' +
'white-space :pre' +
'}' +
'#CloudViewer::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);
},
error: DOM.Images.showError
});
},
error:DOM.Images.showError
});
};
/**
* function shows FancyBox
*/
FancyBox.show = function(pCallBack){
var lPath = DOM.getCurrentPath();
if( Util.checkExtension(lPath, ['png','jpg', 'gif','ico']) )
$.fancybox.open({ href : lPath }, Config);
else
DOM.getCurrentData(function(pParams){
$.fancybox('<div id=CloudViewer tabindex=0>' +
pParams.data + '</div>', Config);
});
Util.exec(pCallBack);
};
CloudCmd.Viewer.init = function(pCallBack){
Util.loadOnLoad([
pCallBack,
FancyBox.show,
FancyBox.load,
DOM.jqueryLoad
]);
var lView = function(){
DOM.Images.showLoad();
FancyBox.show( DOM.getCurrentFile() );
};
var lKeyListener = function(pEvent){
var lKEY = CloudCmd.KEY,
lF3 = lKEY.F3,
lKeyBinded = KeyBinding.get(),
lKeyCode = pEvent.keyCode,
lShift = pEvent.shiftKey;
/* если клавиши можно обрабатывать */
if( lKeyBinded){
if(lKeyCode === lF3 && lShift){
lView();
pEvent.preventDefault();
}
else if(lKeyCode === lKEY.F1)
FancyBox.showHelp();
}
};
/* добавляем обработчик клавишь */
DOM.addKeyListener(lKeyListener)
.setButtonKey('f3', lView);
};
CloudCmd.Viewer.FancyBox = FancyBox;
})(CloudCommander, Util, DOM);

View file

@ -1,4 +1,4 @@
/* module make possible connectoin thrue socket.io on a server */
/* module make possible connectoin thru socket.io on a server */
(function(){
'use strict';