File manager - Edit - /var/www/html/portal/public/pmar/js/themes.js
Back
// JS específico do Gerenciador de Temas (Admin) // Sincroniza color picker com input de texto e preview de logo document.addEventListener('DOMContentLoaded', function () { // Preview da logo ao selecionar arquivo const logoInput = document.getElementById('logo'); const logoPreview = document.getElementById('logoPreview'); const removeLogoCheckbox = document.getElementById('remove_logo'); if (logoInput && logoPreview) { logoInput.addEventListener('change', function (e) { const file = e.target.files[0]; if (file) { const reader = new FileReader(); reader.onload = function (e) { logoPreview.src = e.target.result; }; reader.readAsDataURL(file); // Desmarca o checkbox de remover logo se existir if (removeLogoCheckbox) { removeLogoCheckbox.checked = false; } } }); } // Limpa o input de arquivo se o checkbox de remover logo for marcado if (removeLogoCheckbox && logoInput) { removeLogoCheckbox.addEventListener('change', function () { if (this.checked) { logoInput.value = ''; // Restaura a logo padrão no preview if (logoPreview) { logoPreview.src = logoPreview.getAttribute('data-default-logo') || '/pmar/assets/img/logo-pmar.png'; } } }); } // Sincroniza color picker com input de texto usando data attributes document.querySelectorAll('.theme-color-picker').forEach(function (colorPicker) { const textInputId = colorPicker.getAttribute('data-text-input'); const textInput = document.getElementById(textInputId); if (!textInput) return; // Atualiza o texto quando o color picker muda colorPicker.addEventListener('input', function () { textInput.value = colorPicker.value.toUpperCase(); }); }); // Sincroniza input de texto com color picker document.querySelectorAll('.theme-color-text').forEach(function (textInput) { const colorPickerId = textInput.getAttribute('data-color-picker'); const colorPicker = document.getElementById(colorPickerId); if (!colorPicker) return; // Atualiza o color picker quando o texto muda textInput.addEventListener('input', function () { const value = textInput.value.trim(); if (/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/i.test(value)) { // Converte #RGB para #RRGGBB se necessário let hex = value; if (value.length === 4) { hex = '#' + value[1] + value[1] + value[2] + value[2] + value[3] + value[3]; } colorPicker.value = hex.toUpperCase(); } }); // Validação ao perder o foco textInput.addEventListener('blur', function () { const value = textInput.value.trim(); if (value && !/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/i.test(value)) { textInput.value = colorPicker.value.toUpperCase(); } }); }); // Garante que todos os campos de cor sejam enviados no formulário const themeForm = document.getElementById('themeForm'); if (themeForm) { themeForm.addEventListener('submit', function (e) { // Sincroniza todos os color pickers com seus inputs de texto antes do submit document.querySelectorAll('.theme-color-picker').forEach(function (colorPicker) { const textInputId = colorPicker.getAttribute('data-text-input'); const textInput = document.getElementById(textInputId); if (textInput && colorPicker.value) { // Garante que o input de texto tenha o valor do color picker if (!textInput.value || textInput.value.trim() === '') { textInput.value = colorPicker.value.toUpperCase(); } } }); }); } });
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings