Skip to content

Commit

Permalink
https://github.com/NodeBB/NodeBB/issues/6865
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Oct 27, 2018
1 parent c29c9ca commit e6b5c26
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
22 changes: 12 additions & 10 deletions lib/quickreply.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

define('slick/quickreply', ['components'], function(components) {
var QuickReply = {};

QuickReply.init = function() {

var element = components.get('topic/quickreply/text');
var data = {
element: element,
Expand All @@ -20,28 +20,30 @@ define('slick/quickreply', ['components'], function(components) {
}
}
};

$(window).trigger('composer:autocomplete:init', data);
data.element.textcomplete(data.strategies, data.options);
$('.textcomplete-wrapper').css('height', '100%').find('textarea').css('height', '100%');

components.get('topic/quickreply/button').on('click', function(e) {
var replyMsg = components.get('topic/quickreply/text').val();
var replyData = {
tid: ajaxify.data.tid,
handle: undefined,
content: replyMsg
};

socket.emit('posts.reply', replyData, function(err, data) {
if (err) {
if (err) {
app.alertError(err.message);
}

components.get('topic/quickreply/text').val('');
}
if (data && data.queued) {
app.alertSuccess(data.message);
}
components.get('topic/quickreply/text').val('');
});
});
};

return QuickReply;
});
8 changes: 7 additions & 1 deletion lib/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ theme.getThemeConfig = function (config, callback) {
};

theme.addUserToTopic = function (data, callback) {

if (data.req.user) {
user.getUserData(data.req.user.uid, function (err, userdata) {
if (err) {
Expand All @@ -46,6 +45,13 @@ theme.addUserToTopic = function (data, callback) {
callback(null, data);
});
} else {
data.templateData.loggedInUser = {
uid: 0,
username: '[[global:guest]]',
picture: user.getDefaultAvatar(),
'icon:text': '?',
'icon:bgColor': '#aaa',
};
callback(null, data);
}
};
Expand Down
4 changes: 2 additions & 2 deletions templates/partials/topic/quickreply.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- IF loggedIn -->
<!-- IF privileges.topics:reply -->
<div class="row quick-reply">
<div class="col-sm-2 hidden-xs reply-user">
<a href="<!-- IF loggedInUser.userslug -->{config.relative_path}/user/{loggedInUser.userslug}<!-- ELSE -->#<!-- ENDIF loggedInUser.userslug -->">
Expand All @@ -19,4 +19,4 @@
</div>
<button component="topic/quickreply/button" class="btn btn-primary">Post quick reply</button>
</div>
<!-- ENDIF loggedIn -->
<!-- ENDIF privileges.topics:reply -->

0 comments on commit e6b5c26

Please sign in to comment.