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 class="ancestor module post">
</li> </li>
<div id="post-preview-template">
<div id="post-preview">
</div>
</div>
<li id="post-template" class="module post" data-time=""> <li id="post-template" class="module post" data-time="">
<div class="post-data" data-userpost="" data-content_to_rt="" data-content_to_sigrt="" <div class="post-data" data-userpost="" data-content_to_rt="" data-content_to_sigrt=""
data-screen-name="" data-id="" data-text="" data-text-mentions=""> data-screen-name="" data-id="" data-text="" data-text-mentions="">

View File

@ -298,6 +298,11 @@
<li class="ancestor module post"> <li class="ancestor module post">
</li> </li>
<div id="post-preview-template">
<div id="post-preview">
</div>
</div>
<li id="post-template" class="module post" data-time=""> <li id="post-template" class="module post" data-time="">
<div class="post-data" data-userpost="" data-content_to_rt="" data-content_to_sigrt="" <div class="post-data" data-userpost="" data-content_to_rt="" data-content_to_sigrt=""
data-screen-name="" data-id="" data-text="" data-text-mentions=""> 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(); 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 // Reduz Área do Novo post
function unfocusThis() { function unfocusThis() {
$(this).removeClass('open'); $(this).removeClass('open');
@ -680,6 +689,8 @@ function replyTextInput(event) {
textArea.caret(caretPos); textArea.caret(caretPos);
} }
} }
textAreaForm.find('#post-preview').html(htmlFormatMsg(textArea[0].value, []));
} }
function getPostSplitingPML() { function getPostSplitingPML() {
@ -1372,6 +1383,7 @@ function initInterfaceCommon() {
.clickoutside(unfocusThis) .clickoutside(unfocusThis)
.children('textarea') .children('textarea')
.on({ .on({
'focus': posPostPreview,
'input': replyTextInput, // input event fires in modern browsers (IE9+) on any changes in textarea (and copypasting with mouse too) 'input': replyTextInput, // input event fires in modern browsers (IE9+) on any changes in textarea (and copypasting with mouse too)
'input focus': replyTextUpdateRemaining, 'input focus': replyTextUpdateRemaining,
'keyup': replyTextKeySend 'keyup': replyTextKeySend

View File

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

View File

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