Commit 537672e2 authored by sampaioprimo's avatar sampaioprimo

[ENH] comments preview uses the same code as final view

[ENH] when previewing a comment set the proper page anchor to directly view the comment
parent 3812ebc5
......@@ -1533,6 +1533,7 @@ lib/ckeditor_tiki/plugins/autosave/plugin.js -text
lib/ckeditor_tiki/plugins/tikiwiki/plugin.js -text
lib/commcenter/commlib.php -text
lib/commcenter/index.php -text
lib/comments/commentslib.js -text
lib/commentslib.php -text
lib/contribution/contributionlib.php -text
lib/contribution/index.php -text
......
......@@ -375,18 +375,24 @@ if ($_REQUEST["comments_threadId"] > 0) {
$smarty->assign('comment_preview', 'n');
if (isset($_REQUEST["comments_previewComment"]) || !empty($errors)) {
$smarty->assign('comments_preview_title', $_REQUEST["comments_title"]);
$comments_show = 'y';
$smarty->assign('comments_preview_data', $commentslib->parse_comment_data(strip_tags($_REQUEST["comments_data"])));
$smarty->assign('comment_title', $_REQUEST["comments_title"]);
$smarty->assign('comment_rating', $_REQUEST["comment_rating"]);
$smarty->assign('comment_data', $_REQUEST["comments_data"]);
$smarty->assign('comment_preview_date', $tikilib->now);
$comment_preview = array();
$comment_preview['title'] = $_REQUEST["comments_title"];
$comment_preview['parsed'] = $commentslib->parse_comment_data(strip_tags($_REQUEST["comments_data"]));
$comment_preview['rating'] = $_REQUEST["comment_rating"];
$comment_preview['commentDate'] = $tikilib->now;
if (isset($_REQUEST["anonymous_name"])) {
$smarty->assign('comments_preview_anonymous_name', $_REQUEST["anonymous_name"]);
$comment_preview['userName'] = $_REQUEST["anonymous_name"];
}
if (isset($_REQUEST["comments_previewComment"]))
$smarty->assign('comment_preview_data', $comment_preview);
if (isset($_REQUEST["comments_previewComment"])) {
$smarty->assign('comment_preview', 'y');
}
$smarty->assign('comment_data', $_REQUEST["comments_data"]);
$comments_show = 'y';
}
// Always show comments when a display setting has been explicitely specified
......@@ -541,6 +547,6 @@ if ($section == 'wiki page') {
}
}
$headerlib->add_jsfile('lib/comments/commentslib.js');
$smarty->assign('comments_objectId', $comments_objectId);
$smarty->assign('comments_show', $comments_show);
//$Id$
$(document).ready(function() {
// when previewing a comment set the page anchor to the comment preview
$('#comments_previewComment').click(function() {
action = $('#editpostform').attr('action');
$('#editpostform').attr('action', action.replace('#comments', '#form'));
});
});
......@@ -315,27 +315,7 @@ smarty.session.tiki_cookie_jar.{$cookie_key}: {$smarty.session.tiki_cookie_jar.$
</div>
{if $comment_preview eq 'y'}
<div class="clearfix post_preview" id="preview_comment">
{jq}
$(window).attr('location','#preview_comment');
{/jq}
{if $forum_mode neq 'y'}<b>{tr}Preview{/tr}</b>{/if}
<div class="post"><div class="inner"><span class="corners-top"><span></span></span><div class="postbody">
<div class="postbody-title"><div class="title">{$comments_preview_title|escape}</div></div>
<div class="content">
<div class="clearfix author">
<span class="author_post_info">
{tr}Published by{/tr} <span class="author_post_info_by">{if $user}{$user|userlink}{else}{$comments_preview_anonymous_name}{/if}</span>
{if $comment_preview_date > 0}
{tr}on{/tr} <span class="author_post_info_on">{$comment_preview_date|tiki_short_datetime}</span>
{/if}
</span>
</div>
{$comments_preview_data}
</div>
</div><span class="corners-bottom"><span></span></span></div></div>
</div>
{* <br class="clear" />*}
{include file='comment.tpl' comment=$comment_preview_data}
{/if}
<form enctype="multipart/form-data" method="post" action="{$comments_father}#comments" id='editpostform'>
......@@ -358,7 +338,7 @@ smarty.session.tiki_cookie_jar.{$cookie_key}: {$smarty.session.tiki_cookie_jar.$
{if !$user}
<tr>
<td class="formcolor"><label for="anonymous_name">{tr}Name{/tr}</span></label></td>
<td class="formcolor"><input type="text" maxlength="50" id="anonymous_name" name="anonymous_name" /></td>
<td class="formcolor"><input type="text" maxlength="50" size="30" id="anonymous_name" name="anonymous_name" value="{$comment_preview_data.name|escape}"/></td>
</tr>
{if $forum_mode eq 'y'}
<tr>
......@@ -387,7 +367,7 @@ smarty.session.tiki_cookie_jar.{$cookie_key}: {$smarty.session.tiki_cookie_jar.$
But I don't know how else to deal with this issue.
*}
<input type="text" name="comments_title" id="comments-title" value="{$comment_title|escape}" />
<input type="text" name="comments_title" id="comments-title" value="{$comment_preview_data.title|escape}" />
</td>
</tr>
......@@ -515,7 +495,7 @@ smarty.session.tiki_cookie_jar.{$cookie_key}: {$smarty.session.tiki_cookie_jar.$
{if !empty($user) && $prefs.feature_comments_post_as_anonymous eq 'y'}
<input type="submit" name="comments_postComment_anonymous" value="{tr}Post as Anonymous{/tr}" />
{/if}
<input type="submit" name="comments_previewComment" value="{tr}Preview{/tr}"
<input type="submit" name="comments_previewComment" id="comments_previewComment" value="{tr}Preview{/tr}"
{if ( isset($can_attach_file) && $can_attach_file eq 'y' ) or empty($user)}{strip}
{assign var='file_preview_warning' value="{tr}Please note that the preview does not keep the attached file which you will have to choose before posting.{/tr}"}
onclick="
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment