main
riley 10 months ago
parent 75d2fe5442
commit 3235e5d087

@ -31,49 +31,5 @@
},
false
);
})();
document.addEventListener("DOMContentLoaded", function() {
// Move all your code here
var mutationObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
var checkboxes = document.querySelectorAll('.cbi-checkbox input[type="checkbox"]');
checkboxes.forEach(function(checkbox) {
// Check if toggle switch is already created
if (!checkbox.nextSibling || checkbox.nextSibling.className !== 'switch') {
var switchElement = document.createElement('label');
switchElement.className = 'switch';
var input = document.createElement('input');
input.type = 'checkbox';
input.checked = checkbox.checked;
switchElement.appendChild(input);
var slider = document.createElement('span');
slider.className = 'slider';
switchElement.appendChild(slider);
// Add the switch to the div wrapping the checkbox
checkbox.parentNode.insertBefore(switchElement, checkbox);
// Hide the original checkbox
checkbox.style.display = 'none';
input.addEventListener('change', function() {
checkbox.checked = this.checked;
});
var observer = new MutationObserver(function() {
input.checked = checkbox.checked;
});
observer.observe(checkbox, { attributes: true });
}
});
});
});
mutationObserver.observe(document.documentElement, { childList: true, subtree: true });
});
})(); // Make sure to include this closing partz

@ -3028,52 +3028,51 @@ strong {
}
}
/* The switch - the box around the slider */
.cbi-checkbox .switch {
.cbi-checkbox {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
width: 40px; /* Decreased from 75px */
height: 20px; /* Decreased from 25px */
border-radius: 20px; /* Optional: added for rounded corners */
}
/* Hide default HTML checkbox */
.cbi-checkbox .switch input {
opacity: 0;
width: 0;
height: 0;
.cbi-checkbox input[type="checkbox"] {
position: absolute;
width: 100%;
height: 100%;
z-index: 2;
opacity: 0; /* Make it invisible but still clickable */
cursor: pointer;
}
/* The slider */
.cbi-checkbox .switch .slider {
.cbi-checkbox label {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
background-color: #bbb;
transition: background-color .4s;
border-radius: 20px; /* Make the background rounded */
}
.cbi-checkbox .switch .slider:before {
position: absolute;
.cbi-checkbox label::after {
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
transition: .4s;
}
.cbi-checkbox .switch input:checked + .slider {
background-color: #2196F3;
position: absolute;
top: 1px; /* Adjusted to match the new height */
left: 1px; /* Adjusted to match the new width */
width: 18px; /* Decreased to fit the new dimensions */
height: 18px; /* Decreased to fit the new dimensions */
background-color: #fff;
transition: left .4s;
border-radius: 50%; /* Ensures the slider stays circular */
}
.cbi-checkbox .switch input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
.cbi-checkbox input[type="checkbox"]:checked + label {
background-color: #77C2BB;
}
.cbi-checkbox .switch input:checked + .slider:before {
transform: translateX(26px);
.cbi-checkbox input[type="checkbox"]:checked + label::after {
left: 20px; /* Adjusted to new width */
background-color: #009688;
}
Loading…
Cancel
Save