Skip to content
Snippets Groups Projects
Commit 0d433ac5 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Use events instead of the more rudimentary implementation

parent 6e0d4e8f
No related branches found
No related tags found
No related merge requests found
ready(function () {
document.addEventListener("DOMContentLoaded", function(event) {
var button = document.getElementById("submit_button");
button.onclick = function () {
this.innerHTML = button.getAttribute("data-processing");
......@@ -8,5 +8,10 @@ ready(function () {
form.submit();
return true;
};
button.focus();
var username = document.getElementById("username");
username.focus();
});
......@@ -1387,11 +1387,6 @@
}
}
},
"jquery": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz",
"integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw=="
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
......
import ClipboardJS from "clipboard/dist/clipboard";
ready(function () {
// Clipboard
document.addEventListener("DOMContentLoaded", function(event) {
var clipboard = new ClipboardJS('.copy');
clipboard.on('success', function (e) {
setTimeout(function () {
......
ready(function () {
// Expander boxes
document.addEventListener("DOMContentLoaded", function(event) {
var expandable = document.querySelectorAll('.expandable > .expander');
for (var i = 0; i < expandable.length; i++) {
expandable[i].currentValue.onclick = function (e) {
var parent = e.currentTarget.parentNode;
if (parent.className.match(/(?:^|\s)expanded(?!\S)/)) {
parent.className = parent.className.replace(/(?:^|\s)expanded(?!\S)/g , '');
} else {
parent.className += " expanded";
}
parent.classList.toggle('expanded');
e.currentTarget.blur();
};
}
......
......@@ -3,8 +3,7 @@ import xml from "highlight.js/lib/languages/xml";
import php from "highlight.js/lib/languages/php";
import json from "highlight.js/lib/languages/json";
ready(function () {
// Syntax highlight
document.addEventListener("DOMContentLoaded", function(event) {
hljs.registerLanguage('xml', xml);
hljs.registerLanguage('php', php);
hljs.registerLanguage('json', json);
......
ready(function () {
document.addEventListener("DOMContentLoaded", function(event) {
// Language selector
var languageSelector = document.getElementById("language-selector");
languageSelector.onchange = function() {
......@@ -14,23 +14,11 @@ ready(function () {
e.preventDefault();
var layout = document.getElementById("layout");
if (layout.className.match(/(?:^|\s)active(?!\S)/)) {
layout.className = layout.className.replace(/(?:^|\s)active(?!\S)/g , '');
} else {
layout.className += " active";
}
layout.classList.toggle('active');
var foot = document.getElementById("foot");
if (foot.className.match(/(?:^|\s)active(?!\S)/)) {
foot.className = foot.className.replace(/(?:^|\s)active(?!\S)/g , '');
} else {
foot.className += " active";
}
foot.classList.toggle('active');
if (menuLink.className.match(/(?:^|\s)active(?!\S)/)) {
menuLink.className = menuLink.className.replace(/(?:^|\s)active(?!\S)/g , '');
} else {
menuLink.className += " active";
}
menuLink.classList.toggle('active');
};
});
......@@ -2,7 +2,6 @@
import "es5-shim";
import "es6-shim";
import * as ready from './ready';
import * as language from './language';
import * as expander from './expander';
import * as clipboard from './clipboard';
......
window.readyHandlers = [];
window.ready = function ready(handler) {
window.readyHandlers.push(handler);
handleState();
};
window.handleState = function handleState () {
if (document.readyState === 'interactive' || document.readyState === "complete") {
while(window.readyHandlers.length > 0) {
(window.readyHandlers.shift())();
}
}
};
document.onreadystatechange = window.handleState;
......@@ -2,6 +2,6 @@
import SimpleSAMLLogout from './logout.js';
ready(function () {
document.addEventListener("DOMContentLoaded", function(event) {
new SimpleSAMLLogout(document.body.id);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment