From 3f54730c2d826fce650b581c6645a96f987046e4 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 18 Nov 2016 12:35:23 +0800 Subject: [PATCH] Make title attribute on emoji widget optional. --- app/assets/javascripts/discourse/lib/plugin-api.js.es6 | 6 +++++- app/assets/javascripts/discourse/widgets/emoji.js.es6 | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 b/app/assets/javascripts/discourse/lib/plugin-api.js.es6 index 33d985440cb..86ffc6c57b1 100644 --- a/app/assets/javascripts/discourse/lib/plugin-api.js.es6 +++ b/app/assets/javascripts/discourse/lib/plugin-api.js.es6 @@ -92,7 +92,11 @@ class PluginApi { if (result.icon) { iconBody = iconNode(result.icon); } else if (result.emoji) { - iconBody = result.emoji.split('|').map(name => dec.attach('emoji', { name })); + iconBody = result.emoji.split('|').map(name => { + let widgetAttrs = { name }; + if (result.title) widgetAttrs.title = true; + dec.attach('emoji', widgetAttrs); + }); } if (result.text) { diff --git a/app/assets/javascripts/discourse/widgets/emoji.js.es6 b/app/assets/javascripts/discourse/widgets/emoji.js.es6 index 8060db39358..566f6f09b76 100644 --- a/app/assets/javascripts/discourse/widgets/emoji.js.es6 +++ b/app/assets/javascripts/discourse/widgets/emoji.js.es6 @@ -11,6 +11,8 @@ export default createWidget('emoji', { tagName: 'img.emoji', buildAttributes(attrs) { - return { src: emojiUrlFor(attrs.name), title: attrs.name, alt: `:${attrs.name}:` }; + let result = { src: emojiUrlFor(attrs.name), alt: `:${attrs.name}:` }; + if (attrs.title) result.title = attrs.name; + return result; }, });