mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 12:53:13 +03:00
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
|
import BodyEventListener from 'ghost/mixins/body-event-listener';
|
||
|
|
||
|
var DropdownService = Ember.Object.extend(Ember.Evented, BodyEventListener, {
|
||
|
bodyClick: function (event) {
|
||
|
/*jshint unused:false */
|
||
|
this.closeDropdowns();
|
||
|
},
|
||
|
closeDropdowns: function () {
|
||
|
this.trigger('close');
|
||
|
},
|
||
|
toggleDropdown: function (dropdownName, dropdownButton) {
|
||
|
this.trigger('toggle', {target: dropdownName, button: dropdownButton});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var dropdownInitializer = {
|
||
|
name: 'dropdown',
|
||
|
|
||
|
initialize: function (container, application) {
|
||
|
application.register('dropdown:service', DropdownService);
|
||
|
|
||
|
application.inject('component:gh-dropdown', 'dropdown', 'dropdown:service');
|
||
|
application.inject('component:gh-dropdown-button', 'dropdown', 'dropdown:service');
|
||
|
application.inject('controller:modals.delete-post', 'dropdown', 'dropdown:service');
|
||
|
application.inject('controller:modals.transfer-owner', 'dropdown', 'dropdown:service');
|
||
|
application.inject('route:application', 'dropdown', 'dropdown:service');
|
||
|
}
|
||
|
};
|
||
|
|
||
|
export default dropdownInitializer;
|