File manager - Edit - /var/www/html/portal/public/pmar/js/functionsArteSacra.js
Back
// ============================================= // FUNÇÕES GLOBAIS (disponíveis em todas as páginas) // ============================================= // Função para alternar texto (ver mais/ver menos) function toggleText(link) { const td = link.parentElement; const shortText = td.querySelector('.short-text'); const fullText = td.querySelector('.full-text'); if (shortText.style.display === 'none') { shortText.style.display = ''; fullText.style.display = 'none'; link.textContent = 'ver mais'; } else { shortText.style.display = 'none'; fullText.style.display = ''; link.textContent = 'ver menos'; } } // Funções para edição de campos function enableEdit(id) { document.querySelectorAll('[id^="input-"]').forEach(input => input.disabled = true); document.querySelectorAll('[id^="btn-update-"]').forEach(btn => btn.style.display = 'none'); document.querySelectorAll('[id^="btn-cancel-"]').forEach(btn => btn.style.display = 'none'); const input = document.getElementById(`input-${id}`); const btnUpdate = document.getElementById(`btn-update-${id}`); const btnCancel = document.getElementById(`btn-cancel-${id}`); if (input && btnUpdate && btnCancel) { input.disabled = false; btnUpdate.style.display = 'inline-block'; btnCancel.style.display = 'inline-block'; } } function cancelEdit(id) { const input = document.getElementById(`input-${id}`); const btnUpdate = document.getElementById(`btn-update-${id}`); const btnCancel = document.getElementById(`btn-cancel-${id}`); if (input && btnUpdate && btnCancel) { input.disabled = true; btnUpdate.style.display = 'none'; btnCancel.style.display = 'none'; } } // ============================================= // MÁSCARAS DE INPUT (executadas automaticamente) // ============================================= function aplicarMascaraCodigoAcervo() { const input = document.getElementById("codigo_acervo"); if (!input) return; input.addEventListener("input", function (e) { let value = e.target.value.replace(/\D/g, ""); if (value.length > 8) value = value.slice(0, 8); let formatted = ''; if (value.length > 0) formatted = value.slice(0, 2); if (value.length > 2) formatted += '.' + value.slice(2, 4); if (value.length > 4) formatted += '.' + value.slice(4, 8); e.target.value = formatted; }); input.addEventListener("paste", function (e) { e.preventDefault(); const pasteData = e.clipboardData.getData("text").replace(/\D/g, "").slice(0, 8); let formatted = ''; if (pasteData.length > 0) formatted = pasteData.slice(0, 2); if (pasteData.length > 2) formatted += '.' + pasteData.slice(2, 4); if (pasteData.length > 4) formatted += '.' + pasteData.slice(4, 8); input.value = formatted; }); } function aplicarMascaraFloatInputs() { document.querySelectorAll(".float-input").forEach(input => { input.addEventListener("input", function (e) { let value = e.target.value; value = value.replace(/[^\d,.]/g, ""); value = value.replace(",", "."); const parts = value.split("."); if (parts.length > 2) { value = parts[0] + "." + parts.slice(1).join(""); } e.target.value = value; }); }); } // ============================================= // CONFIGURAÇÕES ESPECÍFICAS DE PÁGINAS // ============================================= function configurarAvaliacaoTecnica() { const btnIncluir = document.getElementById('btn-incluir'); const btnCancelar = document.getElementById('btn-cancelar'); if (btnIncluir) { btnIncluir.addEventListener('click', function () { const formAdd = document.getElementById('form-add'); const containerBotao = document.getElementById('container-botao-incluir'); if (formAdd && containerBotao) { formAdd.classList.remove('d-none'); containerBotao.classList.add('d-none'); window.scrollTo({ top: formAdd.offsetTop - 50, behavior: 'smooth' }); } }); } if (btnCancelar) { btnCancelar.addEventListener('click', function () { const formAdd = document.getElementById('form-add'); const containerBotao = document.getElementById('container-botao-incluir'); if (formAdd && containerBotao) { formAdd.classList.add('d-none'); containerBotao.classList.remove('d-none'); } }); } } function configurarHistorico() { const btnIncluir = document.getElementById('btn-incluir'); const btnCancelar = document.getElementById('btn-cancelar'); if (btnIncluir) { btnIncluir.addEventListener('click', function () { const form = document.getElementById('form-avaliacao'); if (form) form.style.display = 'block'; btnIncluir.classList.add('d-none'); }); } if (btnCancelar) { btnCancelar.addEventListener('click', function () { const form = document.getElementById('form-avaliacao'); if (form) form.style.display = 'none'; btnIncluir.classList.remove('d-none'); }); } document.querySelectorAll('.btn-editar').forEach(btn => { btn.addEventListener('click', function () { const form = document.getElementById('formEditar'); if (!form) return; form.action = btn.dataset.url || ''; const campos = [ 'novo_acervo', 'restauracoes', 'dados', 'referencias', 'observacoes', 'data_realizacao', 'responsavel', 'data_revisao', 'revisor' ]; campos.forEach(campo => { const element = document.getElementById(`editar_${campo}`); if (element) { element.value = btn.dataset[campo] || ''; } }); const modalElement = document.getElementById('modalEditar'); if (modalElement) { const modalInstance = new bootstrap.Modal(modalElement); modalInstance.show(); } }); }); } function configurarRelatorio() { const btnSelecionarTodos = document.getElementById('selecionarTodosBtn'); const btnDeselecionarTodos = document.getElementById('deselecionarTodosBtn'); if (btnSelecionarTodos) { btnSelecionarTodos.addEventListener('click', function () { document.querySelectorAll('.campo-exportar').forEach(checkbox => { checkbox.checked = true; }); }); } if (btnDeselecionarTodos) { btnDeselecionarTodos.addEventListener('click', function () { document.querySelectorAll('.campo-exportar').forEach(checkbox => { checkbox.checked = false; }); }); } } function toggleNovoAcervo() { const wrapper = document.getElementById('novoAcervoWrapper'); wrapper.style.display = wrapper.style.display === 'none' ? 'block' : 'none'; } // ============================================= // INICIALIZAÇÃO GERAL // ============================================= document.addEventListener('DOMContentLoaded', function () { aplicarMascaraCodigoAcervo(); aplicarMascaraFloatInputs(); if (document.getElementById('descricaoArte')) { tinymce.init({ selector: '#descricaoArte', height: 150, menubar: false, resize: false, plugins: 'link lists autolink', toolbar: 'undo redo | bold italic underline | link', language: 'pt_BR', content_style: ` body { max-height: 150px; overflow-y: auto; overflow-x: hidden; word-wrap: break-word; padding-right: 10px; } `, setup: function (editor) { const maxChars = 600; const counterEl = document.getElementById('charCount'); function updateCharCount() { const text = editor.getContent({ format: 'text' }); const len = text.length; if (counterEl) counterEl.textContent = len + ' / ' + maxChars; if (len >= maxChars) { editor.notificationManager.open({ text: "Você atingiu o limite máximo de 600 caracteres.", type: 'warning', timeout: 3000 }); } } editor.on('keydown', function (e) { const text = editor.getContent({ format: 'text' }); if (text.length >= maxChars && ![8, 46, 37, 39].includes(e.keyCode)) { e.preventDefault(); } }); editor.on('init change input keyup', updateCharCount); } }); } configurarAvaliacaoTecnica(); configurarHistorico(); configurarRelatorio(); const inputImagem = document.getElementById('imagem'); if (inputImagem) { inputImagem.addEventListener('change', function () { const file = this.files[0]; const maxSize = 5 * 1024 * 1024; // 5MB const errorMessage = document.getElementById('imagem-error'); if (file && file.size > maxSize) { if (errorMessage) errorMessage.style.display = 'block'; this.value = ''; } else if (errorMessage) { errorMessage.style.display = 'none'; } }); } }); // ============================================= // FUNÇÕES GLOBAIS PARA MODAIS // ============================================= // Fechar modal genérico window.fecharModal = function (modalId) { const modal = document.getElementById(modalId); if (modal) modal.style.display = 'none'; }; // Fechar modal de edição (específico) window.fecharModalEditar = function () { fecharModal('modalEditar'); }; // Abrir modal de exportação (para relatório) function abrirModalExportacao() { const modal = new bootstrap.Modal(document.getElementById('modalExportacao')); modal.show(); }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.01 |
proxy
|
phpinfo
|
Settings