FEATURE: Add options to inject class / page into emoji toolbar (#4312)

* Add options to inject class / page into emoji toolbar

* Fix options page setter
This commit is contained in:
James Kiesel 2016-07-06 11:42:24 -04:00 committed by Robin Ward
parent 3b119dac6d
commit 3035d144c0
2 changed files with 6 additions and 4 deletions

View File

@ -132,7 +132,7 @@ function render(page, offset, options) {
for(let i=offset; i<max; i++){
if(!icons[i]){ break; }
if(row.length === PER_ROW){
if(row.length === (options.perRow || PER_ROW)){
rows.push(row);
row = [];
}
@ -144,7 +144,8 @@ function render(page, offset, options) {
toolbarItems: toolbarItems,
rows: rows,
prevDisabled: offset === 0,
nextDisabled: (max + 1) > icons.length
nextDisabled: (max + 1) > icons.length,
modalClass: options.modalClass
};
$('.emoji-modal', options.appendTo).remove();
@ -162,7 +163,8 @@ function showSelector(options) {
$('.emoji-modal-wrapper').click(() => closeSelector());
if (Discourse.Site.currentProp('mobileView')) { PER_ROW = 9; }
const page = keyValueStore.getInt("emojiPage", 0);
const page = options.page ? _.findIndex(groups, (g) => { return g.name === options.page; })
: keyValueStore.getInt("emojiPage", 0);
const offset = keyValueStore.getInt("emojiOffset", 0);
render(page, offset, options);

View File

@ -1,4 +1,4 @@
<div class='emoji-modal'>
<div class='emoji-modal {{modalClass}}'>
<ul class='toolbar'>
{{#each toolbarItems as |item|}}<li><a title='{{item.title}}' {{#if item.selected}}class='selected'{{/if}} data-group-id='{{item.groupId}}'><img src='{{item.src}}' class='emoji'></a></li>{{/each}}
</ul>