Changes to directory structure

This commit is contained in:
Jeremy Rangel
2024-12-18 02:27:09 -08:00
parent d5a5f4e87b
commit 94d2c7c8a2
135 changed files with 335 additions and 5435 deletions

View File

@ -0,0 +1,58 @@
// JavaScript code (lcp-svg-repeater.js) to handle adding/removing rows dynamically
document.addEventListener('DOMContentLoaded', function () {
// Add row
document.getElementById('add-svg-row').addEventListener('click', function () {
const container = document.getElementById('svg-repeater-container');
const newRow = document.createElement('div');
newRow.classList.add('repeater-row');
newRow.innerHTML = `
<input type="text" name="lcp_custom_svgs[][name]" placeholder="SVG Name" />
<textarea name="lcp_custom_svgs[][path]" placeholder="SVG Path"></textarea>
<button type="button" class="remove-row">Remove</button>
`;
container.appendChild(newRow);
});
// Remove row
document.getElementById('svg-repeater-container').addEventListener('click', function (event) {
if (event.target.classList.contains('remove-row')) {
event.target.closest('.repeater-row').remove();
}
});
});
// REPEATERS
document.addEventListener('DOMContentLoaded', function() {
// Function to add a new row to the repeater
function addRepeaterRow(repeaterElement) {
const newRow = repeaterElement.querySelector('.lcp-repeater-row').cloneNode(true); // Clone the first row
repeaterElement.appendChild(newRow);
// Add remove functionality to the new row's remove button
const removeButton = newRow.querySelector('.remove-row');
removeButton.addEventListener('click', function() {
newRow.remove(); // Remove the row when the button is clicked
});
}
// Find all .lcp-repeater elements in the DOM
const repeaters = document.querySelectorAll('.lcp-repeater');
repeaters.forEach(function(repeaterElement) {
// Add event listener for the "Add Row" button
const addButton = repeaterElement.querySelector('.add-row');
addButton.addEventListener('click', function() {
addRepeaterRow(repeaterElement); // Add a new row when clicked
});
// Initially, make sure each row has a remove button functionality
const rows = repeaterElement.querySelectorAll('.lcp-repeater-row');
rows.forEach(function(row) {
const removeButton = row.querySelector('.remove-row');
removeButton.addEventListener('click', function() {
row.remove(); // Remove the row when the remove button is clicked
});
});
});
});