Skip to content

Commit ae5075c

Browse files
authored
Merge pull request #494 from topcoder-platform/issues-480
Issues-490: moved comment options to comment block
2 parents e6e7c5e + 671427e commit ae5075c

File tree

6 files changed

+691
-2
lines changed

6 files changed

+691
-2
lines changed

config/vanilla/bootstrap.before.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,4 +804,79 @@ function myDraftsMenuItem($CountDrafts) {
804804
$cssClass .= $CountDrafts == 0 ? ' hidden': '';
805805
return sprintf('<li id="MyDrafts" class="%s">%s</li>', $cssClass, anchor(sprite('SpMyDrafts').$Drafts, '/drafts'));
806806
}
807+
}
808+
809+
if(!function_exists('writeInlineDiscussionOptions')) {
810+
function writeInlineDiscussionOptions($discussionRow) {
811+
$discussionID = val('DiscussionID', $discussionRow);
812+
Gdn::controller()->EventArguments['RecordID'] = $discussionID;
813+
//Gdn_Theme::bulletRow();
814+
echo '<div class="Controls flex">';
815+
echo '<div class="left">';
816+
Gdn::controller()->EventArguments['RecordID'] = $discussionID;
817+
Gdn::controller()->fireEvent('InlineDiscussionOptionsLeft');
818+
echo '</div>';
819+
echo '<div class="center"></div>';
820+
echo '<div class="right">';
821+
822+
// Write the items.
823+
static $items = [];
824+
825+
// $canEdit = DiscussionModel::canEdit($discussionRow, $timeLeft);
826+
// if($canEdit) {
827+
// array_push($items, anchor(t('Edit'), '/post/editdiscussion/'.$discussionID));
828+
// }
829+
830+
Gdn::controller()->EventArguments['Items'] = &$items;
831+
// Allow addons to work with items
832+
Gdn::controller()->fireEvent('InlineDiscussionOptionsRight');
833+
if (!empty($items) && is_array($items)) {
834+
array_walk($items, function(&$value, $key) {
835+
$value = '<span class="" style="">'.$value.'</span>';
836+
});
837+
838+
echo implode('<span class="MiddleDot">·</span>', $items);
839+
}
840+
echo '</div>';
841+
echo '</div>';
842+
843+
}
844+
}
845+
846+
if(!function_exists('writeInlineCommentOptions')) {
847+
function writeInlineCommentOptions($comment) {
848+
$iD = val('CommentID', $comment);
849+
Gdn::controller()->EventArguments['RecordID'] = $iD;
850+
//Gdn_Theme::bulletRow();
851+
echo '<div class="Controls flex">';
852+
echo '<div class="left">';
853+
854+
$commentOptions = getCommentOptions($comment);
855+
if (!empty($commentOptions) && is_array($commentOptions)) {
856+
857+
array_walk($commentOptions, function(&$value, $key) {
858+
$anchor = anchor($value['Label'], $value['Url'], val('Class', $value, $key));
859+
$value = '<span class="" style="">'.$anchor.'</span>';
860+
});
861+
862+
echo implode('<span class="MiddleDot">·</span>', $commentOptions);
863+
}
864+
echo '</div>';
865+
echo '<div class="center"></div>';
866+
echo '<div class="right">';
867+
868+
// Write the items.
869+
$items = null;
870+
Gdn::controller()->EventArguments['Comment'] = $comment;
871+
Gdn::controller()->EventArguments['Items'] = &$items;
872+
// Allow addons to work with items
873+
Gdn::controller()->fireEvent('InlineCommentOptionsRight');
874+
if (!empty($items) && is_array($items)) {
875+
array_walk($items, function(&$x) {$x = '<span class="" style="">'.$x.'</span>';});
876+
echo implode('<span class="MiddleDot">·</span>', $items);
877+
}
878+
echo '</div>';
879+
echo '</div>';
880+
881+
}
807882
}

vanilla/applications/vanilla/js/discussion.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ jQuery(document).ready(function($) {
310310
$(container).addClass('Editing');
311311
var parent = $(container).find('div.Comment');
312312
var msg = $(parent).find('div.Message').first();
313+
var commentControls = $(container).find('.Controls');
313314
$(parent).find('div.Meta span:last').after('<span class="TinyProgress">&#160;</span>');
314315
if (!parent.find('.EditCommentForm').length) {
315316
$.ajax({
@@ -323,6 +324,7 @@ jQuery(document).ready(function($) {
323324
success: function(json) {
324325
$(msg).afterTrigger(json.Data);
325326
$(msg).hide();
327+
$(commentControls).hide();
326328
$(document).trigger('EditCommentFormLoaded', [container]);
327329

328330
// Dispatch a native event for things that don't use jquery
@@ -341,6 +343,7 @@ jQuery(document).ready(function($) {
341343
$(parent).find('div.EditCommentForm').remove();
342344
$(parent).find('span.TinyProgress').remove();
343345
$(msg).show();
346+
$(commentControls).show();
344347
}
345348

346349
$(document).trigger('CommentEditingComplete', [msg]);
@@ -352,6 +355,7 @@ jQuery(document).ready(function($) {
352355
var $container = $(btn).closest('.ItemComment');
353356
$(btn).closest('.Comment').find('.MenuItems').attr('style', '');
354357
$(btn).closest('.Comment').find('div.Message').show();
358+
$(btn).closest('.Comment').find('.Controls').show();
355359
$(btn).closest('.CommentForm, .EditCommentForm').remove();
356360
$container.removeClass('Editing');
357361
return false;

vanilla/applications/vanilla/views/discussion/discussion.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
if (val('Attachments', $Discussion)) {
8989
writeAttachments($Discussion->Attachments);
9090
}
91+
writeInlineDiscussionOptions($Discussion);
9192
?>
9293
</div>
9394
</div>

vanilla/applications/vanilla/views/discussion/helper_functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function writeComment($comment, $sender, $session, $currentOffset) {
117117
}
118118
?>
119119
<div class="Options">
120-
<?php writeCommentOptions($comment); ?>
120+
<?php // writeCommentOptions($comment); ?>
121121
</div>
122122
<?php $sender->fireEvent('BeforeCommentMeta'); ?>
123123
<div class="Item-Header CommentHeader">
@@ -180,6 +180,7 @@ function writeComment($comment, $sender, $session, $currentOffset) {
180180
writeAttachments($comment->Attachments);
181181
}
182182
}
183+
writeInlineCommentOptions($comment);
183184
?>
184185
</div>
185186
</div>

vanilla/applications/vanilla/views/discussion/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
<div class="Item-BodyWrap">
3939
<div class="Item-Body">
4040
<?php
41-
Gdn::controller()->fireEvent('Replies');
41+
writeInlineDiscussionOptions($this->data('Discussion'));
42+
// Gdn::controller()->fireEvent('Replies');
4243
?>
4344
</div>
4445
</div>

0 commit comments

Comments
 (0)