discourse/app/assets/javascripts/select-kit/components/toolbar-popup-menu-options.js.es6
Joffrey JAFFEUX d48542796e
FIX: select-kit refactoring
- improve mini-tag-chooser keyboard behavior
- all multil select now respond to select all and left/right arrows
- improve events handling
- many minor tweaks
2018-03-22 11:29:55 +01:00

48 lines
1.2 KiB
JavaScript

import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
import computed from "ember-addons/ember-computed-decorators";
export default DropdownSelectBoxComponent.extend({
pluginApiIdentifiers: ["toolbar-popup-menu-options"],
classNames: ["toolbar-popup-menu-options"],
isHidden: Ember.computed.empty("computedContent"),
showFullTitle: false,
@computed("title")
collectionHeader(title) {
return `<h3>${title}</h3>`;
},
mutateValue(value) {
this.sendAction("onPopupMenuAction", value);
this.setProperties({ value: null, highlighted: null });
},
computeContent(content) {
return content.map(contentItem => {
if (contentItem.condition) {
return {
icon: contentItem.icon,
name: I18n.t(contentItem.label),
id: contentItem.action
};
}
}).filter(contentItem => contentItem);
},
didInsertElement() {
this._super();
$("#reply-control").on("touchstart.toolbar-popup-menu-options", (event) => {
if (this.get("isExpanded") && !this.element.contains(event.target)) {
this.close(event);
}
});
},
willDestroyElement() {
this._super();
$("#reply-control").off("touchstart.toolbar-popup-menu-options");
}
});