feature(key) f3: add parse markdown on shift

This commit is contained in:
coderaiser 2014-04-15 09:32:11 -04:00
parent c953150deb
commit 01a25dab39
6 changed files with 99 additions and 29 deletions

View file

@ -3,6 +3,7 @@
"menu",
"view",
"help",
"markdown",
"config",
"contact",
"socket",

View file

@ -113,8 +113,9 @@ var Util, DOM, CloudFunc;
path += '.js';
if (!CloudCmd[name]) {
CloudCmd[name] = function(arg) {
var pathFull = CloudCmd.LIBDIRCLIENT + path;
CloudCmd[name] = function() {
var pathFull = CloudCmd.LIBDIRCLIENT + path,
args = arguments;
Util.exec(doBefore);
@ -123,7 +124,7 @@ var Util, DOM, CloudFunc;
var Proto = CloudCmd[name];
if (Util.isFunction(Proto))
CloudCmd[name] = new Proto(arg);
CloudCmd[name] = Util.applyConstructor(Proto, args);
});
};

View file

@ -6,39 +6,22 @@ var CloudCmd, Util, DOM;
function HelpProto() {
var Images = DOM.Images,
RESTful = DOM.RESTful,
Markdown = RESTful.Markdown,
Help = this;
function init() {
Images.showLoad({
top:true
top: true
});
Util.loadOnLoad([
CloudCmd.View,
Help.show,
]);
Help.show();
}
this.show = function() {
var name = '/HELP.md?relative';
Images.showLoad({
top:true
});
Markdown.read(name, function(result) {
var div = DOM.anyload({
name : 'div',
className : 'help',
inner : result
});
Images.hideLoad();
CloudCmd.View.show(div);
});
CloudCmd
.Markdown
.show('/HELP.md', {
topLoad : true,
relative: true
});
};
this.hide = function() {

View file

@ -234,7 +234,10 @@ var CloudCmd, Util, DOM;
break;
case Key.F3:
Util.exec(CloudCmd.View.show);
if (shift)
Util.exec(CloudCmd.Markdown.show, path);
else
Util.exec(CloudCmd.View.show);
DOM.preventDefault(event);
break;

67
lib/client/markdown.js Normal file
View file

@ -0,0 +1,67 @@
var CloudCmd, Util, DOM;
(function(CloudCmd, Util, DOM){
'use strict';
CloudCmd.Markdown = MarkdownProto;
function MarkdownProto(nameParam, optionsParam) {
var Images = DOM.Images,
RESTful = DOM.RESTful,
Markdown = RESTful.Markdown,
MD = this;
function init() {
Images.showLoad({
top:true
});
Util.loadOnLoad([
CloudCmd.View,
Util.bind(MD.show, null, null),
]);
}
this.show = function(name, options) {
var o = options,
relativeQuery = '?relative';
if (!name)
name = nameParam;
if (!options)
o =
options = optionsParam;
if (options) {
Images.showLoad({
top: o.topLoad
});
if (o.relative)
name += relativeQuery;
}
Markdown.read(name, function(result) {
var div = DOM.anyload({
name : 'div',
className : 'help',
inner : result
});
Images.hideLoad();
CloudCmd.View.show(div);
nameParam =
optionsParam = null;
});
};
this.hide = function() {
CloudCmd.View.hide();
};
init();
}
})(CloudCmd, Util, DOM);

View file

@ -67,6 +67,21 @@
return result;
};
/*
* apply arguemnts to constructor
*
* @param constructo
* @param args
*/
this.applyConstructor = function(constructor, args) {
var F = function () {
return constructor.apply(this, args);
};
F.prototype = constructor.prototype;
return new F();
};
/**
* Функция ищет в имени файла расширение
* и если находит возвращает true