mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-14 18:52:05 +03:00
37fd17c084
Closes #2418, #2714 Ref #2446, #2565 - Added and injected `popover` service to globally control popovers - Added `gh-popover-button` component - Added `popover-mixin` for popover and popover-buttons to mixin - Added body-event-listener mixin for popover service to watch for body clicks with - Post settings and post save button both now use `gh-popover` - Added hacks to `ember-hacks.css` to make popovers work until ghost-ui consolidates functionality
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import PopoverMixin from 'ghost/mixins/popover-mixin';
|
|
|
|
var GhostPopover = Ember.Component.extend(PopoverMixin, {
|
|
classNames: 'ghost-popover fade-in',
|
|
classNameBindings: ['open'],
|
|
name: null,
|
|
closeOnClick: false,
|
|
didInsertElement: function () {
|
|
this._super();
|
|
|
|
var popoverService = this.get('popover');
|
|
|
|
popoverService.on('close', this, this.close);
|
|
popoverService.on('toggle', this, this.toggle);
|
|
},
|
|
willDestroyElement: function () {
|
|
this._super();
|
|
var popoverService = this.get('popover');
|
|
|
|
popoverService.off('close', this, this.close);
|
|
popoverService.off('toggle', this, this.toggle);
|
|
},
|
|
click: function (event) {
|
|
this._super(event);
|
|
if (this.get('closeOnClick')) {
|
|
return this.close();
|
|
}
|
|
},
|
|
close: function () {
|
|
return this.set('open', false);
|
|
},
|
|
toggle: function (options) {
|
|
/*
|
|
Close all popovers whose button was not clicked,
|
|
and toggle the actual target.
|
|
*/
|
|
var targetPopoverName = options.target;
|
|
if (this.get('name') === targetPopoverName) {
|
|
this.toggleProperty('open');
|
|
} else {
|
|
this.close();
|
|
}
|
|
}
|
|
});
|
|
|
|
export default GhostPopover; |