initial very basic post preview

This commit is contained in:
Simon Grim 2015-07-24 00:51:24 +05:00
parent a245bc449f
commit 3b696e336a
5 changed files with 87 additions and 58 deletions

View File

@ -206,6 +206,12 @@
<li class="ancestor module post">
</li>
<div id="post-preview-template">
<div id="post-preview">
</div>
</div>
<li id="post-template" class="module post" data-time="">
<div class="post-data" data-userpost="" data-content_to_rt="" data-content_to_sigrt=""
data-screen-name="" data-id="" data-text="" data-text-mentions="">

View File

@ -298,6 +298,11 @@
<li class="ancestor module post">
</li>
<div id="post-preview-template">
<div id="post-preview">
</div>
</div>
<li id="post-template" class="module post" data-time="">
<div class="post-data" data-userpost="" data-content_to_rt="" data-content_to_sigrt=""
data-screen-name="" data-id="" data-text="" data-text-mentions="">

View File

@ -578,6 +578,15 @@ function composeNewPost(e, postAreaNew) {
postAreaNew.find('textarea:last').focus();
}
function posPostPreview(event) {
var textArea = $(event.target);
var postPreview = textArea.siblings('#post-preview');
if (!postPreview.length)
postPreview = $('#post-preview-template').children().clone();
postPreview.html(htmlFormatMsg(textArea[0].value, []))
textArea.before(postPreview);
}
// Reduz Área do Novo post
function unfocusThis() {
$(this).removeClass('open');
@ -680,6 +689,8 @@ function replyTextInput(event) {
textArea.caret(caretPos);
}
}
textAreaForm.find('#post-preview').html(htmlFormatMsg(textArea[0].value, []));
}
function getPostSplitingPML() {
@ -1372,6 +1383,7 @@ function initInterfaceCommon() {
.clickoutside(unfocusThis)
.children('textarea')
.on({
'focus': posPostPreview,
'input': replyTextInput, // input event fires in modern browsers (IE9+) on any changes in textarea (and copypasting with mouse too)
'input focus': replyTextUpdateRemaining,
'keyup': replyTextKeySend

View File

@ -26,6 +26,7 @@ function initializeTwister( redirectNetwork, redirectLogin, cbFunc, cbArg ) {
// reply text counter both newmsg and dmchat
$('.post-area-new textarea')
.off('input keyup')
.on('focus', posPostPreview)
.on('keyup', replyTextInput)
.on('keyup', function() { replyTextUpdateRemaining(this); })
;

View File

@ -718,6 +718,11 @@
</div>
</li> <!-- post-template -->
<div id="post-preview-template">
<div id="post-preview">
</div>
</div>
<li id="post-template-post" class="module post" data-time="">
<img class="avatar" src="img/grayed_avatar_placeholder_24.png" alt="user-photo"/>
<div class="post-data" data-userpost="" data-content_to_rt="" data-content_to_sigrt=""