diff options
author | friendica <info@friendica.com> | 2012-01-05 16:38:24 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-01-05 16:38:24 -0800 |
commit | b99cb511ca665bad0022de2ca43b5de78b3ffdbf (patch) | |
tree | 792ef6a835be450e65b2849b18ebf54e7ee6c2d8 | |
parent | 53878625f6ecc014283cefbd84f92b6f1294b8a3 (diff) | |
download | volse-hubzilla-b99cb511ca665bad0022de2ca43b5de78b3ffdbf.tar.gz volse-hubzilla-b99cb511ca665bad0022de2ca43b5de78b3ffdbf.tar.bz2 volse-hubzilla-b99cb511ca665bad0022de2ca43b5de78b3ffdbf.zip |
comment preview
-rw-r--r-- | include/conversation.php | 5 | ||||
-rw-r--r-- | js/main.js | 23 | ||||
-rw-r--r-- | mod/item.php | 2 | ||||
-rw-r--r-- | mod/photos.php | 1 | ||||
-rw-r--r-- | view/comment_item.tpl | 3 |
5 files changed, 31 insertions, 3 deletions
diff --git a/include/conversation.php b/include/conversation.php index ec1fd4152..d4d6a5569 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 96c7fa642..009fb55bb 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 d4d337584..069f1393c 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 bf3299de0..d2f45652f 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 0216e31d3..49751c42b 100644 --- a/view/comment_item.tpl +++ b/view/comment_item.tpl @@ -5,6 +5,7 @@ <input type="hidden" name="parent" value="$parent" /> <input type="hidden" name="return" value="$return_path" /> <input type="hidden" name="jsreload" value="$jsreload" /> + <input type="hidden" name="preview" id="comment-preview-inp-$id" value="0" /> <div class="comment-edit-photo" id="comment-edit-photo-$id" > <a class="comment-edit-photo-link" href="$mylink" title="$mytitle"><img class="my-comment-photo" src="$myphoto" alt="$mytitle" title="$mytitle" /></a> @@ -15,6 +16,8 @@ <div class="comment-edit-text-end"></div> <div class="comment-edit-submit-wrapper" id="comment-edit-submit-wrapper-$id" style="display: none;" > <input type="submit" onclick="post_comment($id); return false;" id="comment-edit-submit-$id" class="comment-edit-submit" name="submit" value="$submit" /> + <span onclick="preview_comment($id);" id="comment-edit-preview-link-$id" class="fakelink">$preview</span> + <div id="comment-edit-preview-$id" style="display:none;"></div> </div> <div class="comment-edit-end"></div> |