From 7011f71e8f3e6de89dae2d46d4dece0d02a78351 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Jan 2012 20:03:00 -0800 Subject: [PATCH] post preview --- include/conversation.php | 7 ++++++- js/main.js | 6 +++--- mod/item.php | 3 +++ view/theme/duepuntozero/jot.tpl | 4 ++-- view/theme/duepuntozero/search_item.tpl | 2 +- view/theme/duepuntozero/style.css | 4 ++++ view/theme/duepuntozero/wall_item.tpl | 2 +- view/theme/duepuntozero/wallwall_item.tpl | 2 +- 8 files changed, 21 insertions(+), 9 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 4a53060e3b..293c5a84a3 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -136,6 +136,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $profile_owner = 0; $page_writeable = false; + $previewing = (($preview) ? ' preview ' : ''); + if($mode === 'network') { $profile_owner = local_user(); $page_writeable = true; @@ -261,7 +263,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $body = prepare_body($item,true); $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'])), '$profile_url' => $profile_link, '$item_photo_menu' => item_photo_menu($item), @@ -288,6 +290,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { '$dislike' => '', '$comment' => '', '$conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), + '$previewing' => $previewing, '$wait' => t('Please wait'), )); @@ -624,6 +627,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { '$like' => $like, '$dislike' => $dislike, '$comment' => $comment, + '$previewing' => $previewing, '$wait' => t('Please wait'), )); @@ -890,6 +894,7 @@ function status_editor($a,$x, $notes_cid = 0) { '$acl' => $x['acl'], '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], + '$preview' => t('Preview'), )); return $o; diff --git a/js/main.js b/js/main.js index be6b5dbae9..a156dbadd1 100644 --- a/js/main.js +++ b/js/main.js @@ -423,7 +423,7 @@ if(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" @@ -443,12 +443,12 @@ function(data) { if(data.preview) { $("#jot-preview-content").html(data.preview); - $("#jot-preview-content" + " a").removeAttr('href'); + $("#jot-preview-content" + " a").click(function() { return false; }); } }, "json" ); - $("#jot-preview").val("1"); + $("#jot-preview").val("0"); return true; } diff --git a/mod/item.php b/mod/item.php index a5fb81263f..93becdee4c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -201,6 +201,8 @@ function item_post(&$a) { if(! strlen($body)) { + if($preview) + killme(); info( t('Empty post discarded.') . EOL ); if(x($_POST,'return')) goaway($a->get_baseurl() . "/" . $return_path ); @@ -590,6 +592,7 @@ function item_post(&$a) { if($preview) { require_once('include/conversation.php'); $o = conversation(&$a,array(array_merge($contact_record,$datarray)),'search',false,true); + logger('preview: ' . $o); echo json_encode(array('preview' => $o)); killme(); } diff --git a/view/theme/duepuntozero/jot.tpl b/view/theme/duepuntozero/jot.tpl index 3ef902c63f..1a3cc92e7e 100644 --- a/view/theme/duepuntozero/jot.tpl +++ b/view/theme/duepuntozero/jot.tpl @@ -68,8 +68,8 @@ - + $preview + diff --git a/view/theme/duepuntozero/search_item.tpl b/view/theme/duepuntozero/search_item.tpl index b4a1c82cbf..f046e41ecf 100644 --- a/view/theme/duepuntozero/search_item.tpl +++ b/view/theme/duepuntozero/search_item.tpl @@ -1,4 +1,4 @@ -
+
+
+