Ghost/ghost/admin/app/components/gh-dropdown-button.js

34 lines
914 B
JavaScript
Raw Normal View History

import Component from '@ember/component';
import DropdownMixin from 'ghost-admin/mixins/dropdown-mixin';
import classic from 'ember-classic-decorator';
import {attributeBindings, tagName} from '@ember-decorators/component';
import {computed} from '@ember/object';
import {inject as service} from '@ember/service';
2014-09-28 19:39:25 +04:00
@classic
@tagName('button')
@attributeBindings('href', 'role', 'type')
export default class GhDropdownButton extends Component.extend(DropdownMixin) {
@service
dropdown;
role = 'button';
// matches with the dropdown this button toggles
dropdownName = null;
@computed
get type() {
return this.tagName === 'button' ? 'button' : null;
}
// Notify dropdown service this dropdown should be toggled
click() {
this.dropdown.toggleDropdown(this.dropdownName, this);
if (this.tagName === 'a') {
return false;
}
2014-09-28 19:39:25 +04:00
}
}