Sha256: 365c875ead8bcf67084c7d20c2f1c6ae1906f38b408b907c2ee0dc496ad08775
Contents?: true
Size: 1.24 KB
Versions: 14
Compression:
Stored size: 1.24 KB
Contents
// This is used to get a proper binding of the actionData // https://stackoverflow.com/questions/750486/javascript-closure-inside-loops-simple-practical-example function createDialogHandler(dialog) { return function () { dialog.close(); }; } export function initDialogs() { console.log('\tDialogs'); var dialogs = document.querySelectorAll('.v-js-dialog'); if (dialogs) { for (var i = 0; i < dialogs.length; i++) { var dialog = dialogs[i]; var dialogButtons = dialog.querySelectorAll('button:not([disabled])'); for (var j = 0; j != dialogButtons.length; j++) { var dialogButton = dialogButtons[j]; if (!dialogButton.dialog) { dialogButton.dialog = dialog; var buttonEvents = dialogButton.dataset.events; // If the dialog button does not have any events tied to it, // then close the dialog on click, otherwise let the events handlers // take care of the close. if (!buttonEvents) { dialogButton.addEventListener('click', createDialogHandler(dialog)); } } } } } }
Version data entries
14 entries across 14 versions & 1 rubygems