(dialog)
| 1140 | } |
| 1141 | |
| 1142 | function modalDialogCloseOnBackdropClick(dialog) { |
| 1143 | dialog.addEventListener('mousedown', function (event) { |
| 1144 | // Firefox creates an event with clientX|Y = 0|0 when choosing an <option>. |
| 1145 | // Test whether the element interacted with is a child of the dialog, but not the |
| 1146 | // dialog itself (the backdrop would be a part of the dialog) |
| 1147 | if (dialog.contains(event.target) && dialog != event.target) { |
| 1148 | return |
| 1149 | } |
| 1150 | var rect = dialog.getBoundingClientRect() |
| 1151 | var isInDialog = (rect.top <= event.clientY && event.clientY <= rect.top + rect.height |
| 1152 | && rect.left <= event.clientX && event.clientX <= rect.left + rect.width) |
| 1153 | if (!isInDialog) { |
| 1154 | dialog.close() |
| 1155 | } |
| 1156 | }) |
| 1157 | } |
| 1158 | |
| 1159 | function makeDialogDraggable(element) { |
| 1160 | element.querySelector(".dialog-header").addEventListener('mousedown', (function () { |
no test coverage detected