FossilRepo

fossilrepo / assets / admin / js / cancel.js
Source Blame History 29 lines
afe42d0… ragelink 1 'use strict';
afe42d0… ragelink 2 {
afe42d0… ragelink 3 // Call function fn when the DOM is loaded and ready. If it is already
afe42d0… ragelink 4 // loaded, call the function now.
afe42d0… ragelink 5 // http://youmightnotneedjquery.com/#ready
afe42d0… ragelink 6 function ready(fn) {
afe42d0… ragelink 7 if (document.readyState !== 'loading') {
afe42d0… ragelink 8 fn();
afe42d0… ragelink 9 } else {
afe42d0… ragelink 10 document.addEventListener('DOMContentLoaded', fn);
afe42d0… ragelink 11 }
afe42d0… ragelink 12 }
afe42d0… ragelink 13
afe42d0… ragelink 14 ready(function() {
afe42d0… ragelink 15 function handleClick(event) {
afe42d0… ragelink 16 event.preventDefault();
afe42d0… ragelink 17 const params = new URLSearchParams(window.location.search);
afe42d0… ragelink 18 if (params.has('_popup')) {
afe42d0… ragelink 19 window.close(); // Close the popup.
afe42d0… ragelink 20 } else {
afe42d0… ragelink 21 window.history.back(); // Otherwise, go back.
afe42d0… ragelink 22 }
afe42d0… ragelink 23 }
afe42d0… ragelink 24
afe42d0… ragelink 25 document.querySelectorAll('.cancel-link').forEach(function(el) {
afe42d0… ragelink 26 el.addEventListener('click', handleClick);
afe42d0… ragelink 27 });
afe42d0… ragelink 28 });
afe42d0… ragelink 29 }

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button