From 4aa601414d666a5fd04a1fbe10b09c922f70345e Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 3 Nov 2015 11:56:35 -0500 Subject: [PATCH] Support for titles on d-editor buttons --- .../javascripts/discourse/components/d-editor.js.es6 | 8 ++++++-- .../discourse/initializers/enable-emoji.js.es6 | 3 ++- .../discourse/templates/components/d-editor.hbs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index 43b07533a..54f07dcd9 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -58,6 +58,7 @@ function Toolbar() { id: 'bullet', group: 'extras', icon: 'list-ul', + title: 'composer.ulist_title', perform: e => e.applyList('* ', 'list_item') }); @@ -65,6 +66,7 @@ function Toolbar() { id: 'list', group: 'extras', icon: 'list-ol', + title: 'composer.olist_title', perform: e => e.applyList(i => !i ? "1. " : `${parseInt(i) + 1}. `, 'list_item') }); @@ -79,6 +81,7 @@ function Toolbar() { id: 'rule', group: 'extras', icon: 'minus', + title: 'composer.hr_title', perform: e => e.addText("\n\n----------\n") }); }; @@ -89,12 +92,14 @@ Toolbar.prototype.addButton = function(button) { throw `Couldn't find toolbar group ${button.group}`; } + const title = button.title || `composer.${button.id}_title`; g.buttons.push({ id: button.id, className: button.className || button.id, icon: button.icon || button.id, action: button.action || 'toolbarButton', - perform: button.perform || Ember.k + perform: button.perform || Ember.k, + title }); }; @@ -288,7 +293,6 @@ export default Ember.Component.extend({ actions: { toolbarButton(button) { - const selected = this._getSelected(); button.perform({ selected, diff --git a/app/assets/javascripts/discourse/initializers/enable-emoji.js.es6 b/app/assets/javascripts/discourse/initializers/enable-emoji.js.es6 index be1b47b12..d5204d172 100644 --- a/app/assets/javascripts/discourse/initializers/enable-emoji.js.es6 +++ b/app/assets/javascripts/discourse/initializers/enable-emoji.js.es6 @@ -13,7 +13,8 @@ export default { id: 'emoji', group: 'extras', icon: 'smile-o', - action: 'emoji' + action: 'emoji', + title: 'composer.emoji' }); }); diff --git a/app/assets/javascripts/discourse/templates/components/d-editor.hbs b/app/assets/javascripts/discourse/templates/components/d-editor.hbs index 61e68ae45..ca7146068 100644 --- a/app/assets/javascripts/discourse/templates/components/d-editor.hbs +++ b/app/assets/javascripts/discourse/templates/components/d-editor.hbs @@ -10,7 +10,7 @@
{{#each toolbar.groups as |group|}} {{#each group.buttons as |b|}} - {{d-button action=b.action actionParam=b icon=b.icon class=b.className title=t.title}} + {{d-button action=b.action actionParam=b title=b.title icon=b.icon class=b.className}} {{/each}} {{#unless group.lastGroup}}