fix some stuff
parent
64ec1da64b
commit
58f5e4b1d9
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -317,7 +317,7 @@ fieldset input {
|
|||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
.editor.complete .block[data-content="title"] {
|
||||
.complete .block[data-content="title"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,23 @@
|
|||
$(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();
|
||||
var aceEditor = ace.edit('editor-source');
|
||||
aceEditor.getSession().setMode("ace/mode/" + mode);
|
||||
aceEditor.getSession().setValue(textarea.val());
|
||||
aceEditor.getSession().on('change', function(){
|
||||
aceEditor.getSession().on('change', function() {
|
||||
textarea.val(aceEditor.getSession().getValue());
|
||||
});
|
||||
aceEditor.setOptions({
|
||||
|
@ -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");
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue