mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(key) f3: add parse markdown on shift
This commit is contained in:
parent
c953150deb
commit
01a25dab39
6 changed files with 99 additions and 29 deletions
|
|
@ -3,6 +3,7 @@
|
|||
"menu",
|
||||
"view",
|
||||
"help",
|
||||
"markdown",
|
||||
"config",
|
||||
"contact",
|
||||
"socket",
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
67
lib/client/markdown.js
Normal 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);
|
||||
15
lib/util.js
15
lib/util.js
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue