Refactor custom API.

This commit is contained in:
Lars Jung 2015-05-05 21:53:23 +02:00
parent 808b1bf657
commit 11c3750690
2 changed files with 15 additions and 18 deletions

View file

@ -12,26 +12,27 @@ modulejs.define('ext/custom', ['_', '$', 'marked', 'core/event', 'core/server',
server.request({action: 'get', custom: item.absHref}, function (response) {
var custom = response && response.custom;
var hasHeader;
var hasFooter;
var data;
var content;
if (response) {
data = response.custom;
if (custom) {
var header = custom.header;
var footer = custom.footer;
var content;
if (data.header) {
content = data.header;
if (data.headerType === 'md') {
if (header.content) {
content = header.content;
if (header.type === 'md') {
content = marked(content);
}
$header.html(content).stop().slideDown(duration);
hasHeader = true;
}
if (data.footer) {
content = data.footer;
if (data.footerType === 'md') {
if (footer.content) {
content = footer.content;
if (footer.type === 'md') {
content = marked(content);
}
$footer.html(content).stop().slideDown(duration);

View file

@ -340,10 +340,8 @@ class App {
if (!$this->get_option("custom.enabled", false)) {
return array(
"header" => null,
"headerType" => null,
"footer" => null,
"footerType" => null
"header" => array("content" => null, "type" => null),
"footer" => array("content" => null, "type" => null)
);
}
@ -377,10 +375,8 @@ class App {
}
return array(
"header" => $header,
"headerType" => $header_type,
"footer" => $footer,
"footerType" => $footer_type
"header" => array("content" => $header, "type" => $header_type),
"footer" => array("content" => $footer, "type" => $footer_type)
);
}