post preview

This commit is contained in:
friendica 2012-01-09 20:03:00 -08:00
parent 805eb35a1a
commit 7011f71e8f
8 changed files with 21 additions and 9 deletions

View File

@ -136,6 +136,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$profile_owner = 0; $profile_owner = 0;
$page_writeable = false; $page_writeable = false;
$previewing = (($preview) ? ' preview ' : '');
if($mode === 'network') { if($mode === 'network') {
$profile_owner = local_user(); $profile_owner = local_user();
$page_writeable = true; $page_writeable = true;
@ -261,7 +263,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$body = prepare_body($item,true); $body = prepare_body($item,true);
$tmp_item = replace_macros($tpl,array( $tmp_item = replace_macros($tpl,array(
'$id' => $item['item_id'], '$id' => (($preview) ? 'P0' : $item['item_id']),
'$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
'$profile_url' => $profile_link, '$profile_url' => $profile_link,
'$item_photo_menu' => item_photo_menu($item), '$item_photo_menu' => item_photo_menu($item),
@ -288,6 +290,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'$dislike' => '', '$dislike' => '',
'$comment' => '', '$comment' => '',
'$conv' => (($preview) ? '' : 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'))),
'$previewing' => $previewing,
'$wait' => t('Please wait'), '$wait' => t('Please wait'),
)); ));
@ -624,6 +627,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
'$like' => $like, '$like' => $like,
'$dislike' => $dislike, '$dislike' => $dislike,
'$comment' => $comment, '$comment' => $comment,
'$previewing' => $previewing,
'$wait' => t('Please wait'), '$wait' => t('Please wait'),
)); ));
@ -890,6 +894,7 @@ function status_editor($a,$x, $notes_cid = 0) {
'$acl' => $x['acl'], '$acl' => $x['acl'],
'$bang' => $x['bang'], '$bang' => $x['bang'],
'$profile_uid' => $x['profile_uid'], '$profile_uid' => $x['profile_uid'],
'$preview' => t('Preview'),
)); ));
return $o; return $o;

View File

@ -423,7 +423,7 @@
if(data.preview) { if(data.preview) {
$("#comment-edit-preview-" + id).html(data.preview); $("#comment-edit-preview-" + id).html(data.preview);
$("#comment-edit-preview-" + id + " a").removeAttr('href'); $("#comment-edit-preview-" + id + " a").click(function() { return false; });
} }
}, },
"json" "json"
@ -443,12 +443,12 @@
function(data) { function(data) {
if(data.preview) { if(data.preview) {
$("#jot-preview-content").html(data.preview); $("#jot-preview-content").html(data.preview);
$("#jot-preview-content" + " a").removeAttr('href'); $("#jot-preview-content" + " a").click(function() { return false; });
} }
}, },
"json" "json"
); );
$("#jot-preview").val("1"); $("#jot-preview").val("0");
return true; return true;
} }

View File

@ -201,6 +201,8 @@ function item_post(&$a) {
if(! strlen($body)) { if(! strlen($body)) {
if($preview)
killme();
info( t('Empty post discarded.') . EOL ); info( t('Empty post discarded.') . EOL );
if(x($_POST,'return')) if(x($_POST,'return'))
goaway($a->get_baseurl() . "/" . $return_path ); goaway($a->get_baseurl() . "/" . $return_path );
@ -590,6 +592,7 @@ function item_post(&$a) {
if($preview) { if($preview) {
require_once('include/conversation.php'); require_once('include/conversation.php');
$o = conversation(&$a,array(array_merge($contact_record,$datarray)),'search',false,true); $o = conversation(&$a,array(array_merge($contact_record,$datarray)),'search',false,true);
logger('preview: ' . $o);
echo json_encode(array('preview' => $o)); echo json_encode(array('preview' => $o));
killme(); killme();
} }

View File

@ -68,8 +68,8 @@
</div> </div>
</div> </div>
<!--span onclick="preview_post();" id="jot-preview-link" class="fakelink">$preview</span> <span onclick="preview_post();" id="jot-preview-link" class="fakelink">$preview</span>
<div id="jot-preview-content" style="display:none;"></div--> <div id="jot-preview-content" style="display:none;"></div>
</div> </div>

View File

@ -1,4 +1,4 @@
<div class="wall-item-outside-wrapper$indent" id="wall-item-outside-wrapper-$id" > <div class="wall-item-outside-wrapper$indent$previewing" id="wall-item-outside-wrapper-$id" >
<div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" > <div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" >
<div class="wall-item-info" id="wall-item-info-$id"> <div class="wall-item-info" id="wall-item-info-$id">
<div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id" <div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id"

View File

@ -247,6 +247,10 @@ div.wall-item-content-wrapper.shiny {
background-repeat:no-repeat; background-repeat:no-repeat;
} }
.preview {
background: #FFFFC8;
}
/* from default */ /* from default */
#jot-perms-icon, #jot-perms-icon,
#profile-location, #profile-location,

View File

@ -1,4 +1,4 @@
<div class="wall-item-outside-wrapper$indent" id="wall-item-outside-wrapper-$id" > <div class="wall-item-outside-wrapper$indent$previewing" id="wall-item-outside-wrapper-$id" >
<div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" > <div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" >
<div class="wall-item-info" id="wall-item-info-$id"> <div class="wall-item-info" id="wall-item-info-$id">
<div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id" <div class="wall-item-photo-wrapper" id="wall-item-photo-wrapper-$id"

View File

@ -1,4 +1,4 @@
<div class="wall-item-outside-wrapper$indent wallwall" id="wall-item-outside-wrapper-$id" > <div class="wall-item-outside-wrapper$indent$previewing wallwall" id="wall-item-outside-wrapper-$id" >
<div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" > <div class="wall-item-content-wrapper$indent" id="wall-item-content-wrapper-$id" >
<div class="wall-item-info wallwall" id="wall-item-info-$id"> <div class="wall-item-info wallwall" id="wall-item-info-$id">
<div class="wall-item-photo-wrapper wwto" id="wall-item-ownerphoto-wrapper-$id" > <div class="wall-item-photo-wrapper wwto" id="wall-item-ownerphoto-wrapper-$id" >