Add option to collapse buttons in post menu

This commit is contained in:
Robin Ward 2017-08-25 13:11:37 -04:00
parent 324b02a830
commit 4e9c4f0768
1 changed files with 9 additions and 0 deletions

View File

@ -219,6 +219,10 @@ function replaceButton(buttons, find, replace) {
export default createWidget('post-menu', {
tagName: 'section.post-menu-area.clearfix',
settings: {
collapseButtons: true
},
defaultState() {
return { collapsed: true, likedUsers: [], adminVisible: false };
},
@ -258,12 +262,17 @@ export default createWidget('post-menu', {
const button = this.attachButton(i, attrs);
if (button) {
allButtons.push(button);
if ((attrs.yours && button.attrs.alwaysShowYours) || (hiddenButtons.indexOf(i) === -1)) {
visibleButtons.push(button);
}
}
});
if (!this.settings.collapseButtons) {
visibleButtons = allButtons;
}
// Only show ellipsis if there is more than one button hidden
// if there are no more buttons, we are not collapsed
if (!state.collapsed || (allButtons.length <= visibleButtons.length + 1)) {