diff --git a/include/conversation.php b/include/conversation.php index ec1fd4152c..d4d6a55694 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -129,7 +129,7 @@ function localize_item(&$item){ * that are based on unique features of the calling module. * */ -function conversation(&$a, $items, $mode, $update) { +function conversation(&$a, $items, $mode, $update, $preview = false) { require_once('bbcode.php'); @@ -287,7 +287,7 @@ function conversation(&$a, $items, $mode, $update) { '$like' => '', '$dislike' => '', '$comment' => '', - '$conv' => array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context')), + '$conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), '$wait' => t('Please wait'), )); @@ -483,6 +483,7 @@ function conversation(&$a, $items, $mode, $update) { '$myphoto' => $a->contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), + '$preview' => t('Preview'), '$ww' => (($mode === 'network') ? $commentww : '') )); } diff --git a/js/main.js b/js/main.js index 96c7fa642b..009fb55bbb 100644 --- a/js/main.js +++ b/js/main.js @@ -389,6 +389,7 @@ unpause(); commentBusy = true; $('body').css('cursor', 'wait'); + $("#comment-preview-inp-" + id).val("0"); $.post( "item", $("#comment-edit-form-" + id).serialize(), @@ -411,6 +412,28 @@ return false; } + + function preview_comment(id) { + $("#comment-preview-inp-" + id).val("1"); + $("#comment-edit-preview-" + id).show(); + $.post( + "item", + $("#comment-edit-form-" + id).serialize(), + function(data) { + if(data.preview) { + + $("#comment-edit-preview-" + id).html(data.preview); + $("#comment-edit-preview-" + id + " a").removeAttr('href'); + } + }, + "json" + ); + return true; + } + + + + function unpause() { // unpause auto reloads if they are currently stopped totStopped = false; diff --git a/mod/item.php b/mod/item.php index d4d337584c..069f1393cf 100644 --- a/mod/item.php +++ b/mod/item.php @@ -588,7 +588,7 @@ function item_post(&$a) { if($preview) { $b = prepare_body($datarray,true); require_once('include/conversation.php'); - $o = conversation(&$a,array(array_merge($datarray,$contact_record)),'search',false); + $o = conversation(&$a,array(array_merge($contact_record,$datarray)),'search',false,true); $json = array('preview' => $o); echo json_encode($json); killme(); diff --git a/mod/photos.php b/mod/photos.php index bf3299de07..d2f45652ff 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -1203,6 +1203,7 @@ function photos_content(&$a) { '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), + '$preview' => t('Preview'), '$ww' => '' )); } diff --git a/view/comment_item.tpl b/view/comment_item.tpl index 0216e31d3d..49751c42b3 100644 --- a/view/comment_item.tpl +++ b/view/comment_item.tpl @@ -5,6 +5,7 @@ +