Skip to content

Commit 960cd88

Browse files
committed
fix(wiki post): display emojis to unknown users
fixes #8
1 parent a1430dd commit 960cd88

2 files changed

Lines changed: 39 additions & 32 deletions

File tree

features/wiki/views/css/wiki-post.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,10 @@
640640
color: #4fb0fc;
641641
}
642642

643+
&.is-unknown {
644+
cursor: default;
645+
}
646+
643647
&.after-first {
644648
margin-left: 0;
645649
}

features/wiki/views/wiki-post.js

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@
227227
'<div ',
228228
'class="',
229229
'emoji emoji-', emoji.emoji.icon,
230+
' ', (!_user || !_user.id ? 'is-unknown' : ''),
230231
' ', (emoji.contributing ? 'contributing' : ''),
231232
' ', (after && i === 0 ? 'after-first' : ''),
232233
' ', specialCls,
@@ -242,22 +243,21 @@
242243
].join('');
243244
}).join(''));
244245

245-
var lastEmojiButton = _$el.content.find('.newEmoji:last')[0];
246+
var lastEmojiButton = _$el.content.find('.newEmoji:last')[0],
247+
$newEmoji = _$el.content.find('.newEmoji');
246248

247-
_$el.content.find('.newEmoji')
248-
.removeClass('newEmoji')
249-
.click(function(event) {
249+
$newEmoji.removeClass('newEmoji');
250+
251+
if (_user && _user.id) {
252+
$newEmoji.click(function(event) {
250253
_toggleEmoji(this, event, $this[0]);
251254
});
255+
}
252256

253257
return lastEmojiButton;
254258
}
255259

256260
function _applyReactions() {
257-
if (!_user || !_user.id) {
258-
return;
259-
}
260-
261261
_$el.content.find('.add-reaction').remove();
262262

263263
var emojis = WikiPost.get('post.emojis');
@@ -275,7 +275,6 @@
275275
imgInTable = false,
276276
after = tagName == 'PRE' || tagName == 'IMG' || $this.hasClass('mceCover'),
277277
specialCls = [],
278-
$addReactionButton = $('<div class="add-reaction"></div>'),
279278
nodeId = $this.attr('data-emoji'),
280279
lastEmojiButton = null;
281280

@@ -320,33 +319,37 @@
320319
specialCls.push('after-first');
321320
}
322321

323-
if (specialCls.length) {
324-
$addReactionButton.addClass(specialCls.join(' '));
325-
}
322+
if (_user && _user.id) {
323+
var $addReactionButton = $('<div class="add-reaction"></div>');
326324

327-
if (after && lastEmojiButton) {
328-
$(lastEmojiButton).after($addReactionButton);
329-
}
330-
else if (after) {
331-
$this.after($addReactionButton);
332-
}
333-
else {
334-
$this.append($addReactionButton);
335-
}
325+
if (specialCls.length) {
326+
$addReactionButton.addClass(specialCls.join(' '));
327+
}
336328

337-
$addReactionButton.click(function(event) {
338-
_addReactionMenu(this, event, $this[0]);
339-
});
329+
if (after && lastEmojiButton) {
330+
$(lastEmojiButton).after($addReactionButton);
331+
}
332+
else if (after) {
333+
$this.after($addReactionButton);
334+
}
335+
else {
336+
$this.append($addReactionButton);
337+
}
340338

341-
$this
342-
.off('mouseenter')
343-
.on('mouseenter', function() {
344-
$addReactionButton.addClass('hover');
345-
})
346-
.off('mouseleave')
347-
.on('mouseleave', function() {
348-
$addReactionButton.removeClass('hover');
339+
$addReactionButton.click(function(event) {
340+
_addReactionMenu(this, event, $this[0]);
349341
});
342+
343+
$this
344+
.off('mouseenter')
345+
.on('mouseenter', function() {
346+
$addReactionButton.addClass('hover');
347+
})
348+
.off('mouseleave')
349+
.on('mouseleave', function() {
350+
$addReactionButton.removeClass('hover');
351+
});
352+
}
350353
});
351354
}
352355

0 commit comments

Comments
 (0)