Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions config/vanilla/bootstrap.before.php
Original file line number Diff line number Diff line change
Expand Up @@ -804,4 +804,79 @@ function myDraftsMenuItem($CountDrafts) {
$cssClass .= $CountDrafts == 0 ? ' hidden': '';
return sprintf('<li id="MyDrafts" class="%s">%s</li>', $cssClass, anchor(sprite('SpMyDrafts').$Drafts, '/drafts'));
}
}

if(!function_exists('writeInlineDiscussionOptions')) {
function writeInlineDiscussionOptions($discussionRow) {
$discussionID = val('DiscussionID', $discussionRow);
Gdn::controller()->EventArguments['RecordID'] = $discussionID;
//Gdn_Theme::bulletRow();
echo '<div class="Controls flex">';
echo '<div class="left">';
Gdn::controller()->EventArguments['RecordID'] = $discussionID;
Gdn::controller()->fireEvent('InlineDiscussionOptionsLeft');
echo '</div>';
echo '<div class="center"></div>';
echo '<div class="right">';

// Write the items.
static $items = [];

// $canEdit = DiscussionModel::canEdit($discussionRow, $timeLeft);
// if($canEdit) {
// array_push($items, anchor(t('Edit'), '/post/editdiscussion/'.$discussionID));
// }

Gdn::controller()->EventArguments['Items'] = &$items;
// Allow addons to work with items
Gdn::controller()->fireEvent('InlineDiscussionOptionsRight');
if (!empty($items) && is_array($items)) {
array_walk($items, function(&$value, $key) {
$value = '<span class="" style="">'.$value.'</span>';
});

echo implode('<span class="MiddleDot">·</span>', $items);
}
echo '</div>';
echo '</div>';

}
}

if(!function_exists('writeInlineCommentOptions')) {
function writeInlineCommentOptions($comment) {
$iD = val('CommentID', $comment);
Gdn::controller()->EventArguments['RecordID'] = $iD;
//Gdn_Theme::bulletRow();
echo '<div class="Controls flex">';
echo '<div class="left">';

$commentOptions = getCommentOptions($comment);
if (!empty($commentOptions) && is_array($commentOptions)) {

array_walk($commentOptions, function(&$value, $key) {
$anchor = anchor($value['Label'], $value['Url'], val('Class', $value, $key));
$value = '<span class="" style="">'.$anchor.'</span>';
});

echo implode('<span class="MiddleDot">·</span>', $commentOptions);
}
echo '</div>';
echo '<div class="center"></div>';
echo '<div class="right">';

// Write the items.
$items = null;
Gdn::controller()->EventArguments['Comment'] = $comment;
Gdn::controller()->EventArguments['Items'] = &$items;
// Allow addons to work with items
Gdn::controller()->fireEvent('InlineCommentOptionsRight');
if (!empty($items) && is_array($items)) {
array_walk($items, function(&$x) {$x = '<span class="" style="">'.$x.'</span>';});
echo implode('<span class="MiddleDot">·</span>', $items);
}
echo '</div>';
echo '</div>';

}
}
4 changes: 4 additions & 0 deletions vanilla/applications/vanilla/js/discussion.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ jQuery(document).ready(function($) {
$(container).addClass('Editing');
var parent = $(container).find('div.Comment');
var msg = $(parent).find('div.Message').first();
var commentControls = $(container).find('.Controls');
$(parent).find('div.Meta span:last').after('<span class="TinyProgress">&#160;</span>');
if (!parent.find('.EditCommentForm').length) {
$.ajax({
Expand All @@ -323,6 +324,7 @@ jQuery(document).ready(function($) {
success: function(json) {
$(msg).afterTrigger(json.Data);
$(msg).hide();
$(commentControls).hide();
$(document).trigger('EditCommentFormLoaded', [container]);

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

$(document).trigger('CommentEditingComplete', [msg]);
Expand All @@ -352,6 +355,7 @@ jQuery(document).ready(function($) {
var $container = $(btn).closest('.ItemComment');
$(btn).closest('.Comment').find('.MenuItems').attr('style', '');
$(btn).closest('.Comment').find('div.Message').show();
$(btn).closest('.Comment').find('.Controls').show();
$(btn).closest('.CommentForm, .EditCommentForm').remove();
$container.removeClass('Editing');
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
if (val('Attachments', $Discussion)) {
writeAttachments($Discussion->Attachments);
}
writeInlineDiscussionOptions($Discussion);
?>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function writeComment($comment, $sender, $session, $currentOffset) {
}
?>
<div class="Options">
<?php writeCommentOptions($comment); ?>
<?php // writeCommentOptions($comment); ?>
</div>
<?php $sender->fireEvent('BeforeCommentMeta'); ?>
<div class="Item-Header CommentHeader">
Expand Down Expand Up @@ -180,6 +180,7 @@ function writeComment($comment, $sender, $session, $currentOffset) {
writeAttachments($comment->Attachments);
}
}
writeInlineCommentOptions($comment);
?>
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion vanilla/applications/vanilla/views/discussion/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<div class="Item-BodyWrap">
<div class="Item-Body">
<?php
Gdn::controller()->fireEvent('Replies');
writeInlineDiscussionOptions($this->data('Discussion'));
// Gdn::controller()->fireEvent('Replies');
?>
</div>
</div>
Expand Down
Loading