open-consul/ui-v2/app/components/modal-layer.js
John Cowen d2b1698c0d ui: Improvements to modal-dialog (#5585)
1. If the modal gets bigger than 80% of the viewport height a scrollbar
will be shown. Currently there isn't anywhere it can get this big, but
future work involves possible larger modals
2. Usually its difficult to figure out which was the 'unchecked' radio
button using an onchange event. Luckily ember/handlebars changes its
properties after the onchange event, so knowing that and using an extra
data-checked attribute set via ember, we can figure out which radio
button has been 'unchecked'. This means the logic for opening an
closing modals becomes slightly easier
2019-05-01 18:22:30 +00:00

21 lines
620 B
JavaScript

import DomBufferFlushComponent from 'consul-ui/components/dom-buffer-flush';
import { inject as service } from '@ember/service';
import { get } from '@ember/object';
export default DomBufferFlushComponent.extend({
dom: service('dom'),
actions: {
change: function(e) {
[...get(this, 'dom').elements('[name="modal"]')]
.filter(function(item) {
return item.getAttribute('id') !== 'modal_close';
})
.forEach(function(item, i) {
if (item.getAttribute('data-checked') === 'true') {
item.onchange({ target: item });
}
});
},
},
});