|
4 | 4 | // @description FIRE adds a button to SmokeDetector reports that allows you to provide feedback & flag, all from chat. |
5 | 5 | // @author Cerbrus |
6 | 6 | // @attribution Michiel Dommerholt (https://github.com/Cerbrus) |
7 | | -// @version 1.0.30 |
| 7 | +// @version 1.0.31 |
8 | 8 | // @icon https://raw.githubusercontent.com/Ranks/emojione-assets/master/png/32/1f525.png |
9 | 9 | // @updateURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/fire/fire.meta.js |
10 | 10 | // @downloadURL https://raw.githubusercontent.com/Charcoal-SE/Userscripts/master/fire/fire.user.js |
|
904 | 904 | callback(); |
905 | 905 | } |
906 | 906 |
|
| 907 | + /** |
| 908 | + * stopPropagationIfTargetBody - If the target of the event is the body, then stop propagation. |
| 909 | + * |
| 910 | + * @private |
| 911 | + * @memberof module:fire |
| 912 | + * |
| 913 | + * @param {object} event An event |
| 914 | + */ |
| 915 | + function stopPropagationIfTargetBody(event) { |
| 916 | + if (event.target === document.body) |
| 917 | + event.stopPropagation(); |
| 918 | + } |
| 919 | + |
907 | 920 | /** |
908 | 921 | * keyboardShortcuts - Handle keypress events for the popup. |
909 | 922 | * |
|
1242 | 1255 | '.fire-popup-body pre', |
1243 | 1256 | ({currentTarget}) => $(currentTarget).toggleClass('fire-expanded') |
1244 | 1257 | ); |
| 1258 | + document.addEventListener('keypress', stopPropagationIfTargetBody, true); |
1245 | 1259 | } |
1246 | 1260 |
|
1247 | 1261 | /** |
|
1404 | 1418 | $(document) |
1405 | 1419 | .off('keydown', keyboardShortcuts) |
1406 | 1420 | .off('click', '.fire-popup-body pre'); |
| 1421 | + document.removeEventListener('keypress', stopPropagationIfTargetBody, true); |
1407 | 1422 |
|
1408 | 1423 | $('#container').removeClass('fire-blur'); |
1409 | 1424 |
|
|
1566 | 1581 | response = {message: jqXHR.responseText}; |
1567 | 1582 | } |
1568 | 1583 |
|
1569 | | - if (response.message === 'Spam flag option not present') { |
| 1584 | + if (response.message === 'Flag option not present') { |
1570 | 1585 | toastr.info('This post could not be flagged.<br />' + |
1571 | 1586 | 'It is probably deleted already.'); |
1572 | 1587 | closePopup(); |
|
0 commit comments