eb12c84e9a
Canonical names to forced to lowercase Made user model compatible to other DBs CSS adjustments Basic Firepad support (no presence info) Cleaned up JS a bit Added ability to remove draft from localstorage Added support for drafts on multiple pages Alert user if page changes, issue #1
77 lines
1.9 KiB
JavaScript
77 lines
1.9 KiB
JavaScript
var $entry_markdown_header = $("#entry-markdown-header");
|
|
var $entry_preview_header = $("#entry-preview-header");
|
|
var $entry_markdown = $(".entry-markdown");
|
|
var $entry_preview = $(".entry-preview");
|
|
|
|
// Tabs
|
|
$entry_markdown_header.click(function(){
|
|
$entry_markdown.addClass('active');
|
|
$entry_preview.removeClass('active');
|
|
});
|
|
|
|
$entry_preview_header.click(function(){
|
|
$entry_preview.addClass('active');
|
|
$entry_markdown.removeClass('active');
|
|
});
|
|
|
|
$(document).on('shaMismatch', function() {
|
|
bootbox.dialog({
|
|
title: "Page has changed",
|
|
message: "This page has changed and differs from your draft. What do you want to do?",
|
|
buttons: {
|
|
ignore: {
|
|
label: "Ignore",
|
|
className: "btn-default",
|
|
callback: function() {
|
|
var info = aced.info();
|
|
info['ignore'] = true;
|
|
aced.info(info);
|
|
}
|
|
},
|
|
discard: {
|
|
label: "Discard Draft",
|
|
className: "btn-danger",
|
|
callback: function() {
|
|
aced.discard();
|
|
}
|
|
},
|
|
changes: {
|
|
label: "Show Diff",
|
|
className: "btn-primary",
|
|
callback: function() {
|
|
bootbox.alert("Draft diff not done! Sorry");
|
|
}
|
|
}
|
|
}
|
|
})
|
|
});
|
|
|
|
$(function(){
|
|
$("#discard-draft-btn").click(function() {
|
|
aced.discard();
|
|
});
|
|
|
|
$(".entry-markdown .floatingheader").click(function(){
|
|
aced.editor.focus();
|
|
});
|
|
|
|
$("#delete-draft-btn").click(function() {
|
|
bootbox.alert("Not Done Yet! Sorry");
|
|
});
|
|
});
|
|
|
|
var aced = new Aced({
|
|
editor: $('#entry-markdown-content').find('.editor').attr('id'),
|
|
renderer: function(md) { return MDR.convert(md) },
|
|
info: Commit.info,
|
|
submit: function(content) {
|
|
var data = {
|
|
name: $("#page-name").val(),
|
|
message: $("#page-message").val(),
|
|
content: content
|
|
};
|
|
$.post(window.location, data, function() {
|
|
location.href = Config['RELATIVE_PATH'] + '/' + data['name'];
|
|
});
|
|
}
|
|
}); |