update components

This commit is contained in:
Luke Pulverenti 2016-03-23 22:44:27 -04:00
parent 0f44fb37b3
commit 3acf184be7
6 changed files with 29 additions and 17 deletions

View file

@ -82,8 +82,8 @@
if (dlg.getAttribute('modal')) {
dlg.showModal();
} else {
addBackdropOverlay(dlg);
dlg.show();
closeOnBackdropClick(dlg);
dlg.showModal();
}
// Undo the auto-focus applied by the native dialog element
safeBlur(document.activeElement);
@ -116,6 +116,18 @@
}
}
function closeOnBackdropClick(dlg) {
dlg.addEventListener('click', function (event) {
var rect = dlg.getBoundingClientRect();
var isInDialog = (rect.top <= event.clientY && event.clientY <= rect.top + rect.height
&& rect.left <= event.clientX && event.clientX <= rect.left + rect.width);
if (!isInDialog) {
close(dlg);
}
});
}
function autoFocus(dlg) {
// The dialog may have just been created and webComponents may not have completed initialiazation yet.