mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-12 06:25:51 +03:00
f07940f0e7
no issue - find+replace to make service injection style consistent and take up much less space at the top of files that used multi-line syntax
35 lines
946 B
JavaScript
35 lines
946 B
JavaScript
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';
|
|
|
|
@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() {
|
|
super.click(...arguments);
|
|
|
|
this.dropdown.toggleDropdown(this.dropdownName, this);
|
|
|
|
if (this.tagName === 'a') {
|
|
return false;
|
|
}
|
|
}
|
|
}
|