open-consul/ui/packages/consul-ui/app/components/modal-dialog/index.js

29 lines
697 B
JavaScript
Raw Normal View History

import Component from '@ember/component';
import Slotted from 'block-slots';
2021-03-09 09:30:01 +00:00
import A11yDialog from 'a11y-dialog';
export default Component.extend(Slotted, {
tagName: '',
onclose: function() {},
onopen: function() {},
actions: {
2021-03-09 09:30:01 +00:00
connect: function($el) {
this.dialog = new A11yDialog($el);
this.dialog.on('hide', () => this.onclose({ target: $el }));
this.dialog.on('show', () => this.onopen({ target: $el }));
if (this.open) {
this.dialog.show();
}
},
2021-03-09 09:30:01 +00:00
disconnect: function($el) {
this.dialog.destroy();
},
open: function() {
this.dialog.show();
},
close: function() {
2021-03-09 09:30:01 +00:00
this.dialog.hide();
},
},
});