comment preview

This commit is contained in:
friendica 2012-01-05 16:38:24 -08:00
parent 53878625f6
commit b99cb511ca
5 changed files with 31 additions and 3 deletions

View File

@ -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 : '')
));
}

View File

@ -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;

View File

@ -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();

View File

@ -1203,6 +1203,7 @@ function photos_content(&$a) {
'$myphoto' => $contact['thumb'],
'$comment' => t('Comment'),
'$submit' => t('Submit'),
'$preview' => t('Preview'),
'$ww' => ''
));
}

View File

@ -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>