audiovanish-plugin-markdown
Version:
A Markdown parser for Audiovanish
59 lines (54 loc) • 1.66 kB
JavaScript
define('admin/plugins/markdown', ['settings'], function(Settings) {
var Markdown = {};
Markdown.init = function() {
Settings.load('markdown', $('.markdown-settings'), function(err, settings) {
var defaults = {
'html': false,
'xhtmlOut': true,
'breaks': true,
'langPrefix': 'language-',
'linkify': true,
'externalBlank': false,
'nofollow': true,
'typographer': false,
'highlight': true,
'highlightTheme': 'railscasts.css'
};
// Set defaults
for(var setting in defaults) {
if (!settings.hasOwnProperty(setting)) {
if (typeof defaults[setting] === 'boolean') {
$('#' + setting).prop('checked', defaults[setting]);
} else {
$('#' + setting).val(defaults[setting]);
}
}
}
});
$('#save').on('click', function() {
Settings.save('markdown', $('.markdown-settings'), function() {
app.alert({
type: 'success',
alert_id: 'markdown-saved',
title: 'Reload Required',
message: 'Please reload your Audiovanish to have your changes take effect',
clickfn: function() {
socket.emit('admin.reload');
}
})
});
});
// Warning for "html" option
$('#html').on('change', function() {
var inputEl = $(this);
if (inputEl.prop('checked')) {
bootbox.confirm('Are you sure you wish to disable sanitisation of HTML? <strong>Doing so compromises your system's client-side security, and allows malicious users to execute arbitrary javascript on other users' browsers.</strong>', function(result) {
if (!result) {
inputEl.prop('checked', false);
}
});
}
});
};
return Markdown;
});