Added post note previews

This commit is contained in:
Marcin Kurczewski 2014-11-16 10:41:12 +01:00
parent 4e28ccb4dc
commit 8e06881a3e
3 changed files with 23 additions and 1 deletions

View file

@ -204,7 +204,7 @@
top: 20%;
}
.post-note-edit textarea {
width: 20em;
width: 25em;
height: 5em;
display: block;
}

View file

@ -86,6 +86,8 @@ App.Presenters.PostNotesPresenter = function(
removePostNote(postNote);
} else if (sender === 'save') {
savePostNote(postNote);
} else if (sender === 'preview') {
previewPostNote(postNote);
}
}
@ -132,6 +134,20 @@ App.Presenters.PostNotesPresenter = function(
}
}
function previewPostNote(postNote) {
var previewText = $form.find('textarea').val();
postNote.$element.find('.text').html(util.formatMarkdown(previewText));
showPostNoteText(postNote);
}
function showPostNoteText(postNote) {
postNote.$element.find('.text-wrapper').show();
}
function hidePostNoteText(postNote) {
postNote.$element.find('.text-wrapper').css('display', '');
}
function postNoteClicked(e) {
e.preventDefault();
var $postNote = jQuery(e.currentTarget).parents('.post-note');
@ -142,6 +158,7 @@ App.Presenters.PostNotesPresenter = function(
}
function showFormForPostNote($postNote) {
hideForm();
var postNote = $postNote.data('postNote');
$form.data('postNote', postNote);
$form.find('textarea').val(postNote.text);
@ -150,6 +167,10 @@ App.Presenters.PostNotesPresenter = function(
}
function hideForm() {
var previousPostNote = $form.data('post-note');
if (previousPostNote) {
hidePostNoteText(previousPostNote);
}
$form.hide();
}

View file

@ -21,6 +21,7 @@
<div class="actions"><!--
--><% if (privileges.canEditPostNotes) { %><!--
--><button type="submit" name="sender" value="save">Save</button><!--
--><button type="submit" name="sender" value="preview">Preview</button><!--
--><% } %><!--
--><button type="submit" name="sender" value="cancel">Cancel</button><!--
--><% if (privileges.canDeletePostNotes) { %><!--