forked from HoF-Halle-Wittenberg/amb-dido
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
84 lines (73 loc) · 2.81 KB
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
console.log("Hello World");
function toggleSVG(checkbox) {
var svgHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="presentation" class="components-checkbox-control__checked" aria-hidden="true" focusable="false"><path d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"></path></svg>';
var container = checkbox.parentNode;
if (checkbox.checked) {
if (!container.querySelector('svg')) {
container.insertAdjacentHTML('beforeend', svgHTML);
}
} else {
var svg = container.querySelector('svg');
if (svg) {
container.removeChild(svg);
}
}
}
function toggleNarrower(button) {
var container = button.nextElementSibling;
if (container.style.display === "none") {
container.style.display = "block";
button.classList.remove("collapsed");
button.setAttribute("aria-expanded", "true");
} else {
container.style.display = "none";
button.classList.add("collapsed");
button.setAttribute("aria-expanded", "false");
}
}
/*
document.addEventListener('DOMContentLoaded', function() {
const inputField = document.getElementById('components-form-token-input-amb');
inputField.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
e.preventDefault();
const keyword = inputField.value.trim();
inputField.value = '';
if (keyword) {
const formData = new FormData();
formData.append('action', 'add_amb_keyword');
formData.append('keyword', keyword);
formData.append('post_id', '<?php echo $post->ID; ?>');
formData.append('_wpnonce', '<?php echo wp_create_nonce(basename(__FILE__)); ?>');
fetch(ajaxurl, {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.success) {
console.log(data.message);
} else {
console.error('Fehler:', data);
}
})
.catch(error => console.error('Fehler:', error));
}
}
});
});
jQuery(document).ready(function($) {
// Rebind AJAX events or other interactions
$('#tagsdiv-ambkeywords .tagadd').unbind().click(function() {
// Custom AJAX handler if necessary
});
// Or reinitialize existing WordPress scripts
try {
if (typeof tagBox !== 'undefined') {
tagBox.init();
}
} catch (e) {
console.error('Error reinitializing tagBox:', e);
}
});
*/