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

30 lines
800 B
JavaScript
Raw Normal View History

import Component from '@ember/component';
import DropdownMixin from 'ghost-admin/mixins/dropdown-mixin';
import {computed} from '@ember/object';
import {inject as service} from '@ember/service';
2014-09-28 19:39:25 +04:00
export default Component.extend(DropdownMixin, {
dropdown: service(),
2014-09-28 19:39:25 +04:00
tagName: 'button',
attributeBindings: ['href', 'role', 'type'],
2015-03-07 23:35:45 +03:00
role: 'button',
// matches with the dropdown this button toggles
2014-09-28 19:39:25 +04:00
dropdownName: null,
type: computed(function () {
return this.tagName === 'button' ? 'button' : null;
}),
// Notify dropdown service this dropdown should be toggled
click(event) {
2014-09-28 19:39:25 +04:00
this._super(event);
this.dropdown.toggleDropdown(this.dropdownName, this);
if (this.tagName === 'a') {
return false;
}
2014-09-28 19:39:25 +04:00
}
});