Support for titles on d-editor buttons

This commit is contained in:
Robin Ward 2015-11-03 11:56:35 -05:00
parent 2e00e91cdc
commit 4aa601414d
3 changed files with 9 additions and 4 deletions

View File

@ -58,6 +58,7 @@ function Toolbar() {
id: 'bullet', id: 'bullet',
group: 'extras', group: 'extras',
icon: 'list-ul', icon: 'list-ul',
title: 'composer.ulist_title',
perform: e => e.applyList('* ', 'list_item') perform: e => e.applyList('* ', 'list_item')
}); });
@ -65,6 +66,7 @@ function Toolbar() {
id: 'list', id: 'list',
group: 'extras', group: 'extras',
icon: 'list-ol', icon: 'list-ol',
title: 'composer.olist_title',
perform: e => e.applyList(i => !i ? "1. " : `${parseInt(i) + 1}. `, 'list_item') perform: e => e.applyList(i => !i ? "1. " : `${parseInt(i) + 1}. `, 'list_item')
}); });
@ -79,6 +81,7 @@ function Toolbar() {
id: 'rule', id: 'rule',
group: 'extras', group: 'extras',
icon: 'minus', icon: 'minus',
title: 'composer.hr_title',
perform: e => e.addText("\n\n----------\n") perform: e => e.addText("\n\n----------\n")
}); });
}; };
@ -89,12 +92,14 @@ Toolbar.prototype.addButton = function(button) {
throw `Couldn't find toolbar group ${button.group}`; throw `Couldn't find toolbar group ${button.group}`;
} }
const title = button.title || `composer.${button.id}_title`;
g.buttons.push({ g.buttons.push({
id: button.id, id: button.id,
className: button.className || button.id, className: button.className || button.id,
icon: button.icon || button.id, icon: button.icon || button.id,
action: button.action || 'toolbarButton', 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: { actions: {
toolbarButton(button) { toolbarButton(button) {
const selected = this._getSelected(); const selected = this._getSelected();
button.perform({ button.perform({
selected, selected,

View File

@ -13,7 +13,8 @@ export default {
id: 'emoji', id: 'emoji',
group: 'extras', group: 'extras',
icon: 'smile-o', icon: 'smile-o',
action: 'emoji' action: 'emoji',
title: 'composer.emoji'
}); });
}); });

View File

@ -10,7 +10,7 @@
<div class='d-editor-button-bar'> <div class='d-editor-button-bar'>
{{#each toolbar.groups as |group|}} {{#each toolbar.groups as |group|}}
{{#each group.buttons as |b|}} {{#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}} {{/each}}
{{#unless group.lastGroup}} {{#unless group.lastGroup}}
<div class='d-editor-spacer'></div> <div class='d-editor-spacer'></div>