fix some stuff

pull/48/head
Henrique Dias 2016-02-07 09:55:16 +00:00
parent 64ec1da64b
commit 58f5e4b1d9
5 changed files with 75 additions and 69 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -317,7 +317,7 @@ fieldset input {
margin: 0.5em 0;
}
.editor.complete .block[data-content="title"] {
.complete .block[data-content="title"] {
display: none;
}

View File

@ -1,4 +1,16 @@
$(document).on('page:editor', function() {
var container = $('.editor');
var preview = $('#editor-preview');
var editor = $('#editor-source');
if (container.hasClass('complete')) {
// Change title field when editing the header
$('#site-title').keyup(function() {
$('.frontmatter #title').val($(this).val());
});
}
if (!container.hasClass('frontmatter-only')) {
// Setup ace editor
var mode = $("#editor-source").data('mode');
var textarea = $('textarea[name="content"]').hide();
@ -16,22 +28,6 @@ $(document).on('page:editor', function() {
fontSize: "1em"
});
$('body').off('keypress', 'input').on('keypress', 'input', function(event) {
if (event.keyCode == 13) {
event.preventDefault();
$('input[value="Save"]').focus().click();
return false;
}
});
// Change title field when editing the header
$('#site-title').keyup(function() {
$('.frontmatter #title').val($(this).val());
});
var preview = $('#editor-preview');
var editor = $('#editor-source');
$("#see-source").off('click').click(function(event) {
event.preventDefault();
preview.hide();
@ -64,17 +60,27 @@ $(document).on('page:editor', function() {
return false;
});
}
$('body').off('keypress', 'input').on('keypress', 'input', function(event) {
if (event.keyCode == 13) {
event.preventDefault();
$('input[value="Save"]').focus().click();
return false;
}
});
//TODO: reform this
// Submites any form in the page in JSON format
$('form').submit(function(event) {
event.preventDefault();
if (!container.hasClass('frontmatter-only')) {
// Reset preview area and button to make sure it will
// not serialize any form inside the preview
preview.html('').fadeOut();
$("#see-preview").data("previewing", "false");
editor.fadeIn();
}
var data = JSON.stringify($(this).serializeJSON()),
button = $(this).find("input[type=submit]:focus");

View File

@ -1,6 +1,5 @@
{{ define "content" }}
<div class="editor {{ .Class }} container">
<div class="editor container {{ .Class }}">
{{ if eq .Class "complete" }}
<h1><textarea id="site-title">{{ .Name }}</textarea></h1>
{{ end }}
@ -19,7 +18,8 @@
</div>
{{ else if eq .Class "content-only" }}
<div class="content">
<textarea id="editor-source" name="content" data-mode="{{ .Mode }}">{{ .Content }}</textarea>
<div id="editor-source" data-mode="{{ .Mode }}"></div>
<textarea name="content">{{ .Content }}</textarea>
</div>
{{ else }}
<div class="frontmatter">