// Helpers used by inline template scripts, so this is loaded in
(bundled with Bootstrap as jpop.js) // Run fn once the DOM is ready function ready(fn) { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', fn); } else { fn(); } } // Delegated event handler: on(document, 'click', '.selector', function (e) { this === matched element }) function on(root, type, selector, handler) { root.addEventListener(type, function (e) { var target = e.target instanceof Element ? e.target.closest(selector) : null; if (target && root.contains(target)) { handler.call(target, e); } }); } // fetch() for endpoints that return HTML fragments: the X-Requested-With header makes the server // render the ajax (modal) variant of a page, as jQuery's .load()/.post() used to function ajaxFetch(url, options) { options = Object.assign({credentials: 'same-origin'}, options); options.headers = Object.assign({'X-Requested-With': 'XMLHttpRequest'}, options.headers); return fetch(url, options); } // Replace the contents of an element with an HTML string, executing any