2017-08-22 10:53:26 +03:00
|
|
|
import Component from '@ember/component';
|
2016-05-24 15:06:59 +03:00
|
|
|
import DropdownMixin from 'ghost-admin/mixins/dropdown-mixin';
|
2022-02-01 12:34:03 +03:00
|
|
|
import classic from 'ember-classic-decorator';
|
|
|
|
import {attributeBindings, tagName} from '@ember-decorators/component';
|
2021-05-04 19:22:14 +03:00
|
|
|
import {computed} from '@ember/object';
|
2017-10-30 12:38:01 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2014-09-28 19:39:25 +04:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@classic
|
|
|
|
@tagName('button')
|
|
|
|
@attributeBindings('href', 'role', 'type')
|
|
|
|
export default class GhDropdownButton extends Component.extend(DropdownMixin) {
|
2022-02-01 20:03:45 +03:00
|
|
|
@service dropdown;
|
2018-01-11 20:43:23 +03:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
role = 'button';
|
2014-10-25 01:09:50 +04:00
|
|
|
|
|
|
|
// matches with the dropdown this button toggles
|
2022-02-01 12:34:03 +03:00
|
|
|
dropdownName = null;
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2022-02-01 12:34:03 +03:00
|
|
|
@computed
|
|
|
|
get type() {
|
2021-05-04 19:22:14 +03:00
|
|
|
return this.tagName === 'button' ? 'button' : null;
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|
2021-05-04 19:22:14 +03:00
|
|
|
|
2014-10-25 01:09:50 +04:00
|
|
|
// Notify dropdown service this dropdown should be toggled
|
2022-02-01 12:34:03 +03:00
|
|
|
click() {
|
2022-02-01 14:42:42 +03:00
|
|
|
super.click(...arguments);
|
|
|
|
|
2019-03-06 16:53:54 +03:00
|
|
|
this.dropdown.toggleDropdown(this.dropdownName, this);
|
2017-04-11 16:39:45 +03:00
|
|
|
|
2019-03-06 16:53:54 +03:00
|
|
|
if (this.tagName === 'a') {
|
2017-04-11 16:39:45 +03:00
|
|
|
return false;
|
|
|
|
}
|
2014-09-28 19:39:25 +04:00
|
|
|
}
|
2022-02-01 12:34:03 +03:00
|
|
|
}
|