|
227 | 227 | '<div ', |
228 | 228 | 'class="', |
229 | 229 | 'emoji emoji-', emoji.emoji.icon, |
| 230 | + ' ', (!_user || !_user.id ? 'is-unknown' : ''), |
230 | 231 | ' ', (emoji.contributing ? 'contributing' : ''), |
231 | 232 | ' ', (after && i === 0 ? 'after-first' : ''), |
232 | 233 | ' ', specialCls, |
|
242 | 243 | ].join(''); |
243 | 244 | }).join('')); |
244 | 245 |
|
245 | | - var lastEmojiButton = _$el.content.find('.newEmoji:last')[0]; |
| 246 | + var lastEmojiButton = _$el.content.find('.newEmoji:last')[0], |
| 247 | + $newEmoji = _$el.content.find('.newEmoji'); |
246 | 248 |
|
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) { |
250 | 253 | _toggleEmoji(this, event, $this[0]); |
251 | 254 | }); |
| 255 | + } |
252 | 256 |
|
253 | 257 | return lastEmojiButton; |
254 | 258 | } |
255 | 259 |
|
256 | 260 | function _applyReactions() { |
257 | | - if (!_user || !_user.id) { |
258 | | - return; |
259 | | - } |
260 | | - |
261 | 261 | _$el.content.find('.add-reaction').remove(); |
262 | 262 |
|
263 | 263 | var emojis = WikiPost.get('post.emojis'); |
|
275 | 275 | imgInTable = false, |
276 | 276 | after = tagName == 'PRE' || tagName == 'IMG' || $this.hasClass('mceCover'), |
277 | 277 | specialCls = [], |
278 | | - $addReactionButton = $('<div class="add-reaction"></div>'), |
279 | 278 | nodeId = $this.attr('data-emoji'), |
280 | 279 | lastEmojiButton = null; |
281 | 280 |
|
|
320 | 319 | specialCls.push('after-first'); |
321 | 320 | } |
322 | 321 |
|
323 | | - if (specialCls.length) { |
324 | | - $addReactionButton.addClass(specialCls.join(' ')); |
325 | | - } |
| 322 | + if (_user && _user.id) { |
| 323 | + var $addReactionButton = $('<div class="add-reaction"></div>'); |
326 | 324 |
|
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 | + } |
336 | 328 |
|
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 | + } |
340 | 338 |
|
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]); |
349 | 341 | }); |
| 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 | + } |
350 | 353 | }); |
351 | 354 | } |
352 | 355 |
|
|
0 commit comments