Refactor custom API.
This commit is contained in:
parent
808b1bf657
commit
11c3750690
2 changed files with 15 additions and 18 deletions
|
@ -12,26 +12,27 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server',
|
||||||
|
|
||||||
server.request({action: 'get', custom: item.absHref}, function (response) {
|
server.request({action: 'get', custom: item.absHref}, function (response) {
|
||||||
|
|
||||||
|
var custom = response && response.custom;
|
||||||
var hasHeader;
|
var hasHeader;
|
||||||
var hasFooter;
|
var hasFooter;
|
||||||
var data;
|
|
||||||
|
if (custom) {
|
||||||
|
var header = custom.header;
|
||||||
|
var footer = custom.footer;
|
||||||
var content;
|
var content;
|
||||||
|
|
||||||
if (response) {
|
if (header.content) {
|
||||||
data = response.custom;
|
content = header.content;
|
||||||
|
if (header.type === 'md') {
|
||||||
if (data.header) {
|
|
||||||
content = data.header;
|
|
||||||
if (data.headerType === 'md') {
|
|
||||||
content = marked(content);
|
content = marked(content);
|
||||||
}
|
}
|
||||||
$header.html(content).stop().slideDown(duration);
|
$header.html(content).stop().slideDown(duration);
|
||||||
hasHeader = true;
|
hasHeader = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.footer) {
|
if (footer.content) {
|
||||||
content = data.footer;
|
content = footer.content;
|
||||||
if (data.footerType === 'md') {
|
if (footer.type === 'md') {
|
||||||
content = marked(content);
|
content = marked(content);
|
||||||
}
|
}
|
||||||
$footer.html(content).stop().slideDown(duration);
|
$footer.html(content).stop().slideDown(duration);
|
||||||
|
|
|
@ -340,10 +340,8 @@ class App {
|
||||||
|
|
||||||
if (!$this->get_option("custom.enabled", false)) {
|
if (!$this->get_option("custom.enabled", false)) {
|
||||||
return array(
|
return array(
|
||||||
"header" => null,
|
"header" => array("content" => null, "type" => null),
|
||||||
"headerType" => null,
|
"footer" => array("content" => null, "type" => null)
|
||||||
"footer" => null,
|
|
||||||
"footerType" => null
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,10 +375,8 @@ class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
"header" => $header,
|
"header" => array("content" => $header, "type" => $header_type),
|
||||||
"headerType" => $header_type,
|
"footer" => array("content" => $footer, "type" => $footer_type)
|
||||||
"footer" => $footer,
|
|
||||||
"footerType" => $footer_type
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue