1
0

Fixes highlighting of comments selected for multidelete.

NOTE: Also figured out the mystery about the duplicate function
      invertSelection, but will take care of that in a seperate
      commit. Documented it in a comment, though.
This commit is contained in:
Matthias Mees
2013-06-01 15:37:21 +02:00
parent 2e886e9405
commit f79a258c80
3 changed files with 51 additions and 38 deletions

View File

@ -112,56 +112,54 @@
{if is_array($comments)}
<ul id="serendipity_comments_list" class="clearfix plainList zebra_list">
{foreach $comments AS $comment}
<li class="clearfix {cycle values="odd,even"}"><div class="form_check">
<input id="serendipity_multidelete_comment_{$comment.id}" type="checkbox" name="serendipity[delete][{$comment.id}]" value="{$comment.entry_id}" onclick="highlightComment('comment_{$comment.id}', this.checked)" tabindex="{$i}">
<li id="comment_{$comment.id}" class="clearfix {cycle values="odd,even"}"><div class="form_check">
<input id="serendipity_multidelete_comment_{$comment.id}" class="serendipity_multidelete_comment" type="checkbox" name="serendipity[delete][{$comment.id}]" value="{$comment.entry_id}" data-commentid="comment_{$comment.id}">
<label for="serendipity_multidelete_comment_{$comment.id}" class="visuallyhidden">Multiselect this comment</label> {* i18n *}
</div>
<h4 id="c{$comment.id}">{($comment.type == 'NORMAL') ? $CONST.COMMENT : (($comment.type == 'TRACKBACK') ? $CONST.TRACKBACK : $CONST.PINGBACK )} #{$comment.id}, {$CONST.IN_REPLY_TO} <a href="{$comment.entry_url}">{$comment.title|escape}</a> {$CONST.ON} {$comment.timestamp|@formatTime:'%b %e %Y, %H:%M'}</h4>
<div id="comment_{$comment.id}">
<dl class="comment_data clearfix">
{* TODO: This should not emit any images *}
<dt>{$CONST.AUTHOR}:</dt>
<dd>{$comment.author|escape|truncate:30:"&hellip;"} {$comment.action_author}</dd>
<dt>{$CONST.EMAIL}:</dt>
<dd>{if empty($comment.email)}N/A{else}<a href="mailto:{$comment.email|escape}" title="{$comment.email|escape}">{$comment.email|escape|truncate:30:"&hellip;"}</a>{if $comment.subscribed == 'true'} <span class="serendipity_subscription_on">({$CONST.ACTIVE_COMMENT_SUBSCRIPTION})</span>{/if}{/if} {$comment.action_email}</dd>
<dt>IP:</dt>
<dd>{if empty($comment.ip)}N/A{else}{$comment.ip|escape}{/if} {$comment.action_ip}</dd>
<dt>URL:</dt>
<dd>{if empty($comment.url)}N/A{else}<a class="icon_link" href="{$comment.url|escape}" title="{$comment.url|escape}"><span class="icon-link"></span> {$comment.url|escape|truncate:30:"&hellip;"}</a> {/if} {$comment.action_url}</dd>
<dt>{$CONST.REFERER}:</dt>
<dd>{if empty($comment.referer)}N/A{else}<a href="{$comment.referer|escape}" title="{$comment.referer|escape}">{$comment.referer|escape|truncate:30:"&hellip;"}</a>{/if} {$comment.action_referer}</dd>
</dl>
<div id="{$comment.id}_summary" class="comment_summary">{$comment.fullBody|truncate:120:"&hellip;"}</div>
<dl class="comment_data clearfix">
{* TODO: This should not emit any images *}
<dt>{$CONST.AUTHOR}:</dt>
<dd>{$comment.author|escape|truncate:30:"&hellip;"} {$comment.action_author}</dd>
<dt>{$CONST.EMAIL}:</dt>
<dd>{if empty($comment.email)}N/A{else}<a href="mailto:{$comment.email|escape}" title="{$comment.email|escape}">{$comment.email|escape|truncate:30:"&hellip;"}</a>{if $comment.subscribed == 'true'} <span class="serendipity_subscription_on">({$CONST.ACTIVE_COMMENT_SUBSCRIPTION})</span>{/if}{/if} {$comment.action_email}</dd>
<dt>IP:</dt>
<dd>{if empty($comment.ip)}N/A{else}{$comment.ip|escape}{/if} {$comment.action_ip}</dd>
<dt>URL:</dt>
<dd>{if empty($comment.url)}N/A{else}<a class="icon_link" href="{$comment.url|escape}" title="{$comment.url|escape}"><span class="icon-link"></span> {$comment.url|escape|truncate:30:"&hellip;"}</a> {/if} {$comment.action_url}</dd>
<dt>{$CONST.REFERER}:</dt>
<dd>{if empty($comment.referer)}N/A{else}<a href="{$comment.referer|escape}" title="{$comment.referer|escape}">{$comment.referer|escape|truncate:30:"&hellip;"}</a>{/if} {$comment.action_referer}</dd>
</dl>
<div id="{$comment.id}_full" class="comment_full hidden">{$comment.fullBody}</div>
<div id="{$comment.id}_summary" class="comment_summary">{$comment.fullBody|truncate:120:"&hellip;"}</div>
<ul class="plainList clearfix actions">
{if ($comment.status == 'pending') || ($comment.status == 'confirm')}
<li><a class="button_link" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=approve&amp;serendipity[id]={$comment.id}&amp;{$urltoken}" title="{$CONST.APPROVE}"><span class="icon-lock-open"></span><span class="visuallyhidden">{$CONST.APPROVE}</span></a></li>
{/if}
{if ($comment.status == 'approved')}
<li><a class="button_link" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=pending&amp;serendipity[id]={$comment.id}&amp;{$urltoken}" title="{$CONST.SET_TO_MODERATED}"><span class="icon-lock"></span><span class="visuallyhidden"> {$CONST.SET_TO_MODERATED}</span></a></li>
{/if}
{if $comment.excerpt}
<li><a class="button_link" href="#c{$comment.id}" onclick="FT_toggle({$comment.id}); return false;" title="{$CONST.TOGGLE_ALL}"><span id="{$comment.id}_text">{$CONST.TOGGLE_ALL}</span></a></li>
{/if}
<li><a class="button_link" href="{$comment.entrylink}" title="{$CONST.VIEW}"><span class="icon-eye"></span><span class="visuallyhidden"> {$CONST.VIEW}</span></a></li>
<li><a class="button_link" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=edit&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;{$urltoken}" title="{$CONST.EDIT}"><span class="icon-edit"></span><span class="visuallyhidden"> {$CONST.EDIT}</span></a></li>
<li><a class="button_link" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=delete&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;{$urltoken}" onclick='return confirm("{($CONST.COMMENT_DELETE_CONFIRM|sprintf:$comment.id:$comment.author)|escape}")' title="{$CONST.DELETE}"><span class="icon-trash"></span><span class="visuallyhidden"> {$CONST.DELETE}</span></a></li>
<li><a class="button_link" onclick="cf = window.open(this.href, 'CommentForm', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); cf.focus(); return false;" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=reply&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;{$urltoken}" title="{$CONST.REPLY}"><span class="icon-chat"></span><span class="visuallyhidden"> {$CONST.REPLY}</span></a></li>
</ul>
{$comment.action_more}
</div>
<div id="{$comment.id}_full" class="comment_full hidden">{$comment.fullBody}</div>
<ul class="plainList clearfix actions">
{if ($comment.status == 'pending') || ($comment.status == 'confirm')}
<li><a class="button_link" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=approve&amp;serendipity[id]={$comment.id}&amp;{$urltoken}" title="{$CONST.APPROVE}"><span class="icon-lock-open"></span><span class="visuallyhidden">{$CONST.APPROVE}</span></a></li>
{/if}
{if ($comment.status == 'approved')}
<li><a class="button_link" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=pending&amp;serendipity[id]={$comment.id}&amp;{$urltoken}" title="{$CONST.SET_TO_MODERATED}"><span class="icon-lock"></span><span class="visuallyhidden"> {$CONST.SET_TO_MODERATED}</span></a></li>
{/if}
{if $comment.excerpt}
<li><a class="button_link" href="#c{$comment.id}" onclick="FT_toggle({$comment.id}); return false;" title="{$CONST.TOGGLE_ALL}"><span id="{$comment.id}_text">{$CONST.TOGGLE_ALL}</span></a></li>
{/if}
<li><a class="button_link" href="{$comment.entrylink}" title="{$CONST.VIEW}"><span class="icon-eye"></span><span class="visuallyhidden"> {$CONST.VIEW}</span></a></li>
<li><a class="button_link" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=edit&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;{$urltoken}" title="{$CONST.EDIT}"><span class="icon-edit"></span><span class="visuallyhidden"> {$CONST.EDIT}</span></a></li>
<li><a class="button_link" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=delete&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;{$urltoken}" onclick='return confirm("{($CONST.COMMENT_DELETE_CONFIRM|sprintf:$comment.id:$comment.author)|escape}")' title="{$CONST.DELETE}"><span class="icon-trash"></span><span class="visuallyhidden"> {$CONST.DELETE}</span></a></li>
<li><a class="button_link" onclick="cf = window.open(this.href, 'CommentForm', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1'); cf.focus(); return false;" href="?serendipity[action]=admin&amp;serendipity[adminModule]=comments&amp;serendipity[adminAction]=reply&amp;serendipity[id]={$comment.id}&amp;serendipity[entry_id]={$comment.entry_id}&amp;serendipity[noBanner]=true&amp;serendipity[noSidebar]=true&amp;{$urltoken}" title="{$CONST.REPLY}"><span class="icon-chat"></span><span class="visuallyhidden"> {$CONST.REPLY}</span></a></li>
</ul>
{$comment.action_more}
</li>
{/foreach}
</ul>
{/if}
<div class="multidelete_actions form_buttons">
<input name="toggle" type="button" value="{$CONST.INVERT_SELECTIONS}" onclick="invertSelection()">
<input class="state_cancel" name="toggle" type="submit" value="{$CONST.DELETE_SELECTED_COMMENTS}" onclick="return confirm('{$CONST.COMMENTS_DELETE_CONFIRM}')" tabindex="{($i+1)}">
<input class="state_cancel" name="toggle" type="submit" value="{$CONST.DELETE_SELECTED_COMMENTS}" onclick="return confirm('{$CONST.COMMENTS_DELETE_CONFIRM}')">
<input name="serendipity[togglemoderate]" type="submit" value="{$CONST.MODERATE_SELECTED_COMMENTS}">
</div>
{* TODO: Clone pagination using JS *}

View File

@ -546,6 +546,10 @@ function invertSelection() {
// Somebody needs to figure out why there were two functions of the same name
// and which one is supposed to be used or if both should be used in different
// contexts. Commented out since I assume that the first one is the proper one …
//
// … aaaand I was completely wrong. The second one (commented out) works, but it
// only inverts the checkboxes. It does not highlight comments. This needs a
// rewrite in jQuery anyway.
// ------------------------------------------------------------------------------
// Inverts a selection of checkboxes
// NOTE: also used in serendipity_event_karma
@ -562,7 +566,7 @@ function invertSelection() {
// Purely cosmetic function to highlight/dehighlight a comment by toggling the class comment_selected
function highlightComment(id, checkvalue) {
$('#'+id).toggleClass('comment_selected');
$('#' + id).toggleClass('comment_selected');
}
(function($) {
@ -696,6 +700,13 @@ function highlightComment(id, checkvalue) {
$('#imagepreview').attr('src', $('#category_icon').val());
});
// Comment selection for multidelete
// onclick="highlightComment('comment_{$comment.id}', this.checked)"
$('.serendipity_multidelete_comment').click(function(e) {
var $el = $(this);
highlightComment($el.attr('data-commentid'), $el.attr('checked'));
});
// Add media db upload field
var $uploadForm = $('body').has('#uploadform');

View File

@ -1261,6 +1261,10 @@ form > .button_link:first-of-type { margin-top: 0; }
#categories .odd,
#serendipity_image_folders .odd { background: #eee; }
.zebra_list .comment_selected {
border: 1px solid #b94a48;
}
#entries_list h3,
#serendipity_comments_list h4 {
font-size: 1em;