Add markdown support for custom headers and footers.

This commit is contained in:
Lars Jung 2014-06-08 15:13:36 +02:00
parent f0721afb88
commit b6cf568e31
7 changed files with 132 additions and 36 deletions

View file

@ -1,5 +1,5 @@
modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/event'], function (_, $, allsettings, server, event) {
modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/event', 'core/resource'], function (_, $, allsettings, server, event, resource) {
var settings = _.extend({
enabled: false
@ -10,16 +10,38 @@ modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/e
server.request({action: 'get', custom: true, customHref: item.absHref}, function (response) {
var h, f;
if (response) {
if (response.custom.header) {
$('#content-header').html(response.custom.header).stop().slideDown(200);
if (response.custom.header_type === 'md') {
resource.loadMarkdown(function (md) {
if (md) {
$('#content-header').html(md.toHTML(response.custom.header)).stop().slideDown(200);
}
});
} else {
$('#content-header').html(response.custom.header).stop().slideDown(200);
}
h = true;
}
if (response.custom.footer) {
$('#content-footer').html(response.custom.footer).stop().slideDown(200);
if (response.custom.footer_type === 'md') {
resource.loadMarkdown(function (md) {
if (md) {
$('#content-footer').html(md.toHTML(response.custom.footer)).stop().slideDown(200);
}
});
} else {
$('#content-footer').html(response.custom.footer).stop().slideDown(200);
}
f = true;
}
}
if (!h) {
$('#content-header').stop().slideUp(200);
}