mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
Add checkbox
This commit is contained in:
parent
196ab6323b
commit
44c4e2ef26
2 changed files with 43 additions and 1 deletions
|
@ -76,6 +76,48 @@ function openInNewTab(el, removeAttribute = false){
|
||||||
prepareDjangoAdmin();
|
prepareDjangoAdmin();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
/** An IIFE for pages in DjangoAdmin that use a clipboard button
|
||||||
|
*/
|
||||||
|
(function (){
|
||||||
|
function copyToClipboardAndChangeIcon(button) {
|
||||||
|
// Assuming the input is the previous sibling of the button
|
||||||
|
let input = button.previousElementSibling;
|
||||||
|
|
||||||
|
// Copy input value to clipboard
|
||||||
|
if (input) {
|
||||||
|
navigator.clipboard.writeText(input.value).then(function() {
|
||||||
|
// Change the icon to a checkmark on successful copy
|
||||||
|
let buttonIcon = button .querySelector('.usa-button__clipboard use');
|
||||||
|
if (buttonIcon) {
|
||||||
|
let currentHref = buttonIcon.getAttribute('xlink:href');
|
||||||
|
let baseHref = currentHref.split('#')[0];
|
||||||
|
|
||||||
|
// Append the new icon reference
|
||||||
|
buttonIcon.setAttribute('xlink:href', baseHref + '#check');
|
||||||
|
setTimeout(function() {
|
||||||
|
// Change back to the copy icon
|
||||||
|
buttonIcon.setAttribute('xlink:href', currentHref);
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
}).catch(function(error) {
|
||||||
|
console.error('Clipboard copy failed', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClipboardButtons() {
|
||||||
|
clipboardButtons = document.querySelectorAll(".usa-button__clipboard")
|
||||||
|
clipboardButtons.forEach((button) => {
|
||||||
|
button.addEventListener("click", ()=>{copyToClipboardAndChangeIcon(button)});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClipboardButtons();
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An IIFE to listen to changes on filter_horizontal and enable or disable the change/delete/view buttons as applicable
|
* An IIFE to listen to changes on filter_horizontal and enable or disable the change/delete/view buttons as applicable
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,7 +21,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
{% elif field.field.name == "email" %}
|
{% elif field.field.name == "email" %}
|
||||||
<div class="admin-icon-group">
|
<div class="admin-icon-group">
|
||||||
{{ field.field }}
|
{{ field.field }}
|
||||||
<button class="usa-button usa-button__icon padding-05" type="button">
|
<button class="usa-button usa-button__icon usa-button__clipboard" type="button">
|
||||||
<svg
|
<svg
|
||||||
class="usa-icon"
|
class="usa-icon"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue