backup: estado antes de limpieza de defaults
This commit is contained in:
511
admin/assets/css/admin-panel.css
Normal file
511
admin/assets/css/admin-panel.css
Normal file
@@ -0,0 +1,511 @@
|
||||
/**
|
||||
* Admin Panel Styles
|
||||
*
|
||||
* Estilos base para el panel de administración
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
/* ========================================
|
||||
Container
|
||||
======================================== */
|
||||
|
||||
.apus-admin-panel {
|
||||
max-width: 1400px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
Header
|
||||
======================================== */
|
||||
|
||||
.apus-admin-panel h1 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.apus-admin-panel .description {
|
||||
color: #666;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
Tabs
|
||||
======================================== */
|
||||
|
||||
.nav-tabs {
|
||||
border-bottom: 2px solid #dee2e6;
|
||||
}
|
||||
|
||||
.nav-tabs .nav-link {
|
||||
color: #666;
|
||||
border: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
margin-bottom: -2px;
|
||||
}
|
||||
|
||||
.nav-tabs .nav-link:hover {
|
||||
color: #0073aa;
|
||||
border-bottom-color: #0073aa;
|
||||
}
|
||||
|
||||
.nav-tabs .nav-link.active {
|
||||
color: #0073aa;
|
||||
font-weight: 600;
|
||||
border-bottom-color: #0073aa;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
Tab Content
|
||||
======================================== */
|
||||
|
||||
.tab-content {
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.tab-pane h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 15px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.tab-pane h4 {
|
||||
margin-top: 25px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 16px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
Form Sections
|
||||
======================================== */
|
||||
|
||||
.form-section {
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.form-section:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.form-group input[type="text"],
|
||||
.form-group input[type="url"],
|
||||
.form-group input[type="email"],
|
||||
.form-group input[type="number"],
|
||||
.form-group select,
|
||||
.form-group textarea {
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
.form-group .form-text {
|
||||
margin-top: 5px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.form-group .form-text code {
|
||||
background: #f5f5f5;
|
||||
padding: 2px 5px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
Action Buttons
|
||||
======================================== */
|
||||
|
||||
.admin-actions {
|
||||
padding: 20px;
|
||||
background: #f9f9f9;
|
||||
border-top: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.admin-actions .button-primary {
|
||||
font-size: 14px;
|
||||
padding: 8px 20px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.admin-actions .button-primary i {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* ========================================
|
||||
Responsive
|
||||
======================================== */
|
||||
|
||||
@media (max-width: 782px) {
|
||||
.apus-admin-panel {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.form-group input[type="text"],
|
||||
.form-group input[type="url"],
|
||||
.form-group input[type="email"],
|
||||
.form-group select,
|
||||
.form-group textarea {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
MEJORAS ESPECÍFICAS PARA ADMIN PANEL
|
||||
============================================ */
|
||||
|
||||
/* Variables CSS */
|
||||
:root {
|
||||
--color-navy-primary: #1E3A5F;
|
||||
--color-navy-light: #2C5282;
|
||||
--color-navy-dark: #0E2337;
|
||||
--color-orange-primary: #FF8600;
|
||||
--color-orange-hover: #FF6B35;
|
||||
--color-neutral-50: #F9FAFB;
|
||||
--color-neutral-100: #F3F4F6;
|
||||
--color-neutral-600: #6B7280;
|
||||
--color-neutral-700: #4B5563;
|
||||
}
|
||||
|
||||
/* Colores de marca como clases de utilidad */
|
||||
.text-navy-primary { color: var(--color-navy-primary) !important; }
|
||||
.text-navy-dark { color: var(--color-navy-dark) !important; }
|
||||
.text-orange-primary { color: var(--color-orange-primary) !important; }
|
||||
.text-neutral-600 { color: var(--color-neutral-600) !important; }
|
||||
.text-neutral-700 { color: var(--color-neutral-700) !important; }
|
||||
|
||||
.bg-neutral-50 { background-color: var(--color-neutral-50) !important; }
|
||||
.bg-neutral-100 { background-color: var(--color-neutral-100) !important; }
|
||||
|
||||
/* Tab Header mejorado */
|
||||
.tab-header {
|
||||
padding: 1.5rem;
|
||||
background: linear-gradient(135deg, rgba(30, 58, 95, 0.03) 0%, rgba(255, 134, 0, 0.02) 100%);
|
||||
border-radius: 8px;
|
||||
margin-bottom: 2rem;
|
||||
border-left: 4px solid var(--color-orange-primary);
|
||||
}
|
||||
|
||||
/* Section Title con icono */
|
||||
.section-title {
|
||||
color: var(--color-navy-primary);
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 1.5rem;
|
||||
padding-bottom: 0.75rem;
|
||||
border-bottom: 2px solid var(--color-neutral-100);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.section-title .title-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background: linear-gradient(135deg, var(--color-orange-primary), var(--color-orange-hover));
|
||||
border-radius: 8px;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
/* Form Section Cards mejorados */
|
||||
.form-section.card {
|
||||
border: 1px solid var(--color-neutral-100);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.form-section.card:hover {
|
||||
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
|
||||
border-color: var(--color-neutral-100);
|
||||
}
|
||||
|
||||
/* Toggle Container mejorado */
|
||||
.toggle-container {
|
||||
background: var(--color-neutral-50);
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--color-neutral-100);
|
||||
}
|
||||
|
||||
/* Switch más grande */
|
||||
.form-switch-lg .form-check-input {
|
||||
width: 3rem;
|
||||
height: 1.5rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.form-switch-lg .form-check-input:checked {
|
||||
background-color: var(--color-orange-primary);
|
||||
border-color: var(--color-orange-primary);
|
||||
}
|
||||
|
||||
.form-switch-lg .form-check-input:focus {
|
||||
box-shadow: 0 0 0 0.25rem rgba(255, 134, 0, 0.25);
|
||||
border-color: var(--color-orange-primary);
|
||||
}
|
||||
|
||||
.form-switch-lg .form-check-label {
|
||||
margin-left: 0.5rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Input Group merge (sin borde en el medio) */
|
||||
.input-group-merge .input-group-text {
|
||||
border-right: 0;
|
||||
background-color: var(--color-neutral-50);
|
||||
}
|
||||
|
||||
.input-group-merge .form-control {
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.input-group-merge .form-control:focus {
|
||||
border-color: var(--color-orange-primary);
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
/* Color Picker mejorado */
|
||||
.color-picker-wrapper .form-control-color {
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
border-radius: 8px;
|
||||
border: 2px solid var(--color-neutral-100);
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.color-picker-wrapper .form-control-color:hover {
|
||||
border-color: var(--color-orange-primary);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(255, 134, 0, 0.15);
|
||||
}
|
||||
|
||||
.color-picker-wrapper .form-control-color::-webkit-color-swatch {
|
||||
border-radius: 4px;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.color-picker-wrapper .color-preview-text {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.color-picker-wrapper .color-preview-text code {
|
||||
display: block;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
/* Alert personalizado */
|
||||
.alert-info-custom {
|
||||
background: linear-gradient(135deg, rgba(255, 134, 0, 0.08), rgba(255, 134, 0, 0.03));
|
||||
border: 1px solid rgba(255, 134, 0, 0.2);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.alert-info-custom .alert-heading {
|
||||
color: var(--color-navy-primary);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.alert-info-custom p {
|
||||
color: var(--color-neutral-600);
|
||||
}
|
||||
|
||||
/* Preview Container */
|
||||
.preview-container {
|
||||
position: relative;
|
||||
min-height: 150px;
|
||||
}
|
||||
|
||||
.top-bar-preview {
|
||||
animation: fadeInUp 0.5s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Botones de marca */
|
||||
.btn-navy-primary {
|
||||
background-color: var(--color-navy-primary);
|
||||
border-color: var(--color-navy-primary);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-navy-primary:hover {
|
||||
background-color: var(--color-navy-light);
|
||||
border-color: var(--color-navy-light);
|
||||
color: white;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 12px rgba(30, 58, 95, 0.2);
|
||||
}
|
||||
|
||||
.btn-orange-primary {
|
||||
background-color: var(--color-orange-primary);
|
||||
border-color: var(--color-orange-primary);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-orange-primary:hover {
|
||||
background-color: var(--color-orange-hover);
|
||||
border-color: var(--color-orange-hover);
|
||||
color: white;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 12px rgba(255, 134, 0, 0.3);
|
||||
}
|
||||
|
||||
/* Sticky Footer Actions */
|
||||
.sticky-bottom {
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
z-index: 10;
|
||||
box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
/* Progress bar para textarea */
|
||||
.progress {
|
||||
background-color: var(--color-neutral-100);
|
||||
height: 4px;
|
||||
border-radius: 2px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress .progress-bar {
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.progress .progress-bar.bg-orange-primary {
|
||||
background-color: var(--color-orange-primary);
|
||||
}
|
||||
|
||||
/* Badges personalizados */
|
||||
.badge.bg-neutral-100 {
|
||||
background-color: var(--color-neutral-100) !important;
|
||||
}
|
||||
|
||||
.badge.text-neutral-600 {
|
||||
color: var(--color-neutral-600) !important;
|
||||
}
|
||||
|
||||
/* Form control improvements */
|
||||
.form-control-lg {
|
||||
font-size: 1rem;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.form-select-lg {
|
||||
font-size: 1rem;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
/* Gap utilities */
|
||||
.g-4 {
|
||||
gap: 1.5rem;
|
||||
}
|
||||
|
||||
/* Border utilities */
|
||||
.border-0 {
|
||||
border: 0 !important;
|
||||
}
|
||||
|
||||
.border-neutral-100 {
|
||||
border-color: var(--color-neutral-100) !important;
|
||||
}
|
||||
|
||||
/* Shadow utilities */
|
||||
.shadow-sm {
|
||||
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06) !important;
|
||||
}
|
||||
|
||||
/* Rounded utilities */
|
||||
.rounded-3 {
|
||||
border-radius: 0.5rem !important;
|
||||
}
|
||||
|
||||
.rounded-bottom {
|
||||
border-bottom-left-radius: 0.5rem !important;
|
||||
border-bottom-right-radius: 0.5rem !important;
|
||||
}
|
||||
|
||||
/* Card utilities */
|
||||
.card {
|
||||
background-color: #fff;
|
||||
border: 1px solid rgba(0, 0, 0, 0.125);
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
/* Typography utilities */
|
||||
.fw-bold {
|
||||
font-weight: 700 !important;
|
||||
}
|
||||
|
||||
.fw-medium {
|
||||
font-weight: 500 !important;
|
||||
}
|
||||
|
||||
.small {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* Responsive mejoras */
|
||||
@media (max-width: 768px) {
|
||||
.tab-header {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.tab-header .d-flex {
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.color-picker-wrapper .form-control-color {
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.form-switch-lg .form-check-input {
|
||||
width: 2.5rem;
|
||||
height: 1.25rem;
|
||||
}
|
||||
}
|
||||
292
admin/assets/css/component-navbar.css
Normal file
292
admin/assets/css/component-navbar.css
Normal file
@@ -0,0 +1,292 @@
|
||||
/* ========================================
|
||||
ADMIN PANEL - NAVBAR COMPONENT STYLES
|
||||
Estilos compactos para el panel de administración
|
||||
======================================== */
|
||||
|
||||
/* Sobrescribir estilos del contenedor tab-content */
|
||||
.tab-content {
|
||||
padding: 24px 12px !important;
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
/* Títulos de sección compactos */
|
||||
.section-title-compact {
|
||||
font-size: 1rem;
|
||||
font-weight: 700;
|
||||
color: var(--color-navy-primary);
|
||||
margin-bottom: 0.75rem;
|
||||
padding-bottom: 0.5rem;
|
||||
border-bottom: 2px solid var(--color-neutral-100);
|
||||
}
|
||||
|
||||
.section-title-compact i {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
/* Fix conflicto con WordPress: Sobreescribir max-width de .card */
|
||||
body .card,
|
||||
.apus-admin .card {
|
||||
max-width: none !important;
|
||||
}
|
||||
|
||||
/* Fix conflicto con WordPress: Sobreescribir estilos de checkbox para que funcionen los switches de Bootstrap */
|
||||
.form-switch .form-check-input[type="checkbox"] {
|
||||
width: 2em !important;
|
||||
height: 1em !important;
|
||||
border-radius: 2em !important;
|
||||
background-color: var(--bs-form-check-bg) !important;
|
||||
background-image: var(--bs-form-switch-bg) !important;
|
||||
background-position: left center !important;
|
||||
background-size: contain !important;
|
||||
background-repeat: no-repeat !important;
|
||||
margin-left: -2.5em !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
.form-switch .form-check-input[type="checkbox"]:checked {
|
||||
background-color: #0d6efd !important;
|
||||
border-color: #0d6efd !important;
|
||||
background-position: right center !important;
|
||||
background-size: contain !important;
|
||||
background-repeat: no-repeat !important;
|
||||
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e") !important;
|
||||
}
|
||||
|
||||
body .form-switch .form-check-input[type="checkbox"]::before,
|
||||
.apus-admin .form-switch .form-check-input[type="checkbox"]::before {
|
||||
content: none !important;
|
||||
display: none !important;
|
||||
background-image: none !important;
|
||||
width: 0 !important;
|
||||
height: 0 !important;
|
||||
}
|
||||
|
||||
body .form-switch .form-check-input[type="checkbox"]::after,
|
||||
.apus-admin .form-switch .form-check-input[type="checkbox"]::after {
|
||||
content: none !important;
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Cards compactos */
|
||||
#navbarTab .card {
|
||||
border: 1px solid #dee2e6 !important;
|
||||
border-left: 4px solid #1e3a5f !important;
|
||||
border-radius: 6px !important;
|
||||
box-shadow: rgba(0, 0, 0, 0.075) 0px 2px 4px 0px !important;
|
||||
transition: all 0.3s ease !important;
|
||||
background-color: #ffffff !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 0 16px !important;
|
||||
}
|
||||
|
||||
.form-section.card {
|
||||
border: 2px solid #d1d5db !important;
|
||||
border-radius: 12px !important;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.form-section.card:hover {
|
||||
border-color: #FF8600 !important;
|
||||
box-shadow: 0 4px 16px rgba(255, 134, 0, 0.15) !important;
|
||||
}
|
||||
|
||||
.form-section.card .card-body.p-3 {
|
||||
padding: 1.25rem !important;
|
||||
}
|
||||
|
||||
/* Color pickers compactos */
|
||||
.form-control-color-compact {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
border-radius: 0.375rem;
|
||||
border: 1px solid var(--color-neutral-100);
|
||||
cursor: pointer;
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
.form-control-color-compact:hover {
|
||||
border-color: var(--color-orange-primary);
|
||||
}
|
||||
|
||||
/* Form controls pequeños con mejor UX */
|
||||
#navbarTab .form-control-sm,
|
||||
#navbarTab .form-select-sm {
|
||||
font-size: 14px !important;
|
||||
padding: 6px 12px !important;
|
||||
border: 1px solid rgb(222, 226, 230) !important;
|
||||
border-radius: 4px !important;
|
||||
color: rgb(33, 37, 41) !important;
|
||||
}
|
||||
|
||||
.form-control-sm,
|
||||
.form-select-sm {
|
||||
font-size: 0.875rem;
|
||||
padding: 0.375rem 0.75rem;
|
||||
}
|
||||
|
||||
/* Labels compactos */
|
||||
.form-label.small {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-neutral-700);
|
||||
margin-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
/* Fix alineación vertical de labels en switches */
|
||||
#navbarTab .form-check.form-switch {
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
}
|
||||
|
||||
#navbarTab .form-switch .form-check-input {
|
||||
margin-top: 0 !important;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
#navbarTab .form-switch .form-check-label,
|
||||
.form-switch .form-check-label.small {
|
||||
line-height: 16px !important;
|
||||
padding-top: 0 !important;
|
||||
margin-top: 0 !important;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
/* Switches más compactos */
|
||||
.form-check-switch .form-check-input {
|
||||
width: 2.5rem;
|
||||
height: 1.25rem;
|
||||
}
|
||||
|
||||
/* Reducir gaps globales */
|
||||
.row.g-3 {
|
||||
--bs-gutter-x: 1rem;
|
||||
--bs-gutter-y: 1rem;
|
||||
}
|
||||
|
||||
.row.g-2 {
|
||||
--bs-gutter-x: 0.5rem;
|
||||
--bs-gutter-y: 0.5rem;
|
||||
}
|
||||
|
||||
/* Badges pequeños */
|
||||
.badge {
|
||||
font-size: 0.7rem;
|
||||
padding: 0.2em 0.5em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* Tab header compacto */
|
||||
.tab-header {
|
||||
background: linear-gradient(135deg, #0E2337 0%, #1a3a5c 100%);
|
||||
border-radius: 12px;
|
||||
padding: 1.5rem;
|
||||
border: 2px solid #FF8600;
|
||||
box-shadow: 0 4px 12px rgba(14, 35, 55, 0.15);
|
||||
}
|
||||
|
||||
.tab-header h3 {
|
||||
font-size: 1.4rem;
|
||||
margin-bottom: 0.25rem;
|
||||
color: #ffffff;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.tab-header p {
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
}
|
||||
|
||||
/* Header específico del Navbar Tab */
|
||||
#navbarTab > .rounded {
|
||||
background: linear-gradient(135deg, #0E2337 0%, #1e3a5f 100%) !important;
|
||||
border-left: 4px solid #FF8600 !important;
|
||||
border-radius: 6px !important;
|
||||
padding: 24px !important;
|
||||
margin-bottom: 24px !important;
|
||||
box-shadow: rgba(0, 0, 0, 0.15) 0px 8px 16px 0px !important;
|
||||
}
|
||||
|
||||
#navbarTab > .rounded h3 {
|
||||
font-size: 1.5rem !important;
|
||||
margin-bottom: 0.25rem !important;
|
||||
color: #ffffff !important;
|
||||
font-weight: 700 !important;
|
||||
}
|
||||
|
||||
#navbarTab > .rounded p {
|
||||
color: rgba(255, 255, 255, 0.85) !important;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
/* Card body padding */
|
||||
#navbarTab .card-body {
|
||||
padding: 1rem !important;
|
||||
}
|
||||
|
||||
/* Progress bar pequeña */
|
||||
.progress[style*="height: 3px"] {
|
||||
border-radius: 2px;
|
||||
background-color: var(--color-neutral-100);
|
||||
}
|
||||
|
||||
/* Botones pequeños */
|
||||
.btn-sm {
|
||||
font-size: 0.875rem;
|
||||
padding: 0.375rem 0.75rem;
|
||||
}
|
||||
|
||||
/* Botón primario con estilo de marca */
|
||||
.btn-primary {
|
||||
background-color: var(--color-orange-primary);
|
||||
border-color: var(--color-orange-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: var(--color-orange-hover);
|
||||
border-color: var(--color-orange-hover);
|
||||
}
|
||||
|
||||
/* Clases de utilidad de colores */
|
||||
.text-navy-primary {
|
||||
color: var(--color-navy-primary);
|
||||
}
|
||||
|
||||
.text-orange-primary {
|
||||
color: var(--color-orange-primary);
|
||||
}
|
||||
|
||||
.text-neutral-600 {
|
||||
color: var(--color-neutral-600);
|
||||
}
|
||||
|
||||
.border-neutral-200 {
|
||||
border-color: #dee2e6 !important;
|
||||
}
|
||||
|
||||
/* Responsive: Mobile First */
|
||||
@media (max-width: 991px) {
|
||||
.tab-header {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.tab-header h3 {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.form-section.card .card-body.p-3 {
|
||||
padding: 0.75rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
.tab-header .d-flex {
|
||||
flex-direction: column;
|
||||
align-items: flex-start !important;
|
||||
}
|
||||
|
||||
.tab-header button {
|
||||
width: 100%;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
}
|
||||
471
admin/assets/css/theme-options.css
Normal file
471
admin/assets/css/theme-options.css
Normal file
@@ -0,0 +1,471 @@
|
||||
/**
|
||||
* Theme Options Admin Styles
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
/* Main Container */
|
||||
.apus-theme-options {
|
||||
margin: 20px 20px 0 0;
|
||||
}
|
||||
|
||||
/* Header */
|
||||
.apus-options-header {
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
}
|
||||
|
||||
.apus-options-logo h2 {
|
||||
margin: 0;
|
||||
font-size: 24px;
|
||||
color: #1d2327;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.apus-options-logo .version {
|
||||
background: #2271b1;
|
||||
color: #fff;
|
||||
padding: 3px 8px;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.apus-options-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.apus-options-actions .button .dashicons {
|
||||
margin-top: 3px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
/* Form */
|
||||
.apus-options-form {
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
}
|
||||
|
||||
/* Tabs Container */
|
||||
.apus-options-container {
|
||||
display: flex;
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
/* Tabs Navigation */
|
||||
.apus-tabs-nav {
|
||||
width: 200px;
|
||||
background: #f6f7f7;
|
||||
border-right: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.apus-tabs-nav ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-bottom: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li:first-child {
|
||||
border-top: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a {
|
||||
display: block;
|
||||
padding: 15px 20px;
|
||||
color: #50575e;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a .dashicons {
|
||||
margin-right: 8px;
|
||||
color: #787c82;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a:hover {
|
||||
background: #fff;
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a:hover .dashicons {
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li.active a {
|
||||
background: #fff;
|
||||
color: #2271b1;
|
||||
font-weight: 600;
|
||||
border-left: 3px solid #2271b1;
|
||||
padding-left: 17px;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li.active a .dashicons {
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
/* Tabs Content */
|
||||
.apus-tabs-content {
|
||||
flex: 1;
|
||||
padding: 30px;
|
||||
}
|
||||
|
||||
.apus-tab-pane {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.apus-tab-pane.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.apus-tab-pane h2 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 23px;
|
||||
font-weight: 400;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.apus-tab-pane > p.description {
|
||||
margin: 0 0 20px 0;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
.apus-tab-pane h3 {
|
||||
margin: 30px 0 0 0;
|
||||
padding: 15px 0 10px 0;
|
||||
border-top: 1px solid #dcdcde;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
/* Form Table */
|
||||
.apus-tab-pane .form-table {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.apus-tab-pane .form-table th {
|
||||
padding: 20px 10px 20px 0;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.apus-tab-pane .form-table td {
|
||||
padding: 15px 10px;
|
||||
}
|
||||
|
||||
/* Toggle Switch */
|
||||
.apus-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 50px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.apus-switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.apus-slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
transition: .4s;
|
||||
border-radius: 24px;
|
||||
}
|
||||
|
||||
.apus-slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
left: 3px;
|
||||
bottom: 3px;
|
||||
background-color: white;
|
||||
transition: .4s;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
input:checked + .apus-slider {
|
||||
background-color: #2271b1;
|
||||
}
|
||||
|
||||
input:focus + .apus-slider {
|
||||
box-shadow: 0 0 1px #2271b1;
|
||||
}
|
||||
|
||||
input:checked + .apus-slider:before {
|
||||
transform: translateX(26px);
|
||||
}
|
||||
|
||||
/* Image Upload */
|
||||
.apus-image-upload {
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
.apus-image-preview {
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid #c3c4c7;
|
||||
background: #f6f7f7;
|
||||
padding: 10px;
|
||||
min-height: 100px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.apus-image-preview:empty {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.apus-preview-image {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.apus-upload-image,
|
||||
.apus-remove-image {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/* Submit Button */
|
||||
.apus-options-form .submit {
|
||||
margin: 0;
|
||||
padding: 20px 30px;
|
||||
border-top: 1px solid #c3c4c7;
|
||||
background: #f6f7f7;
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.apus-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 100000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.apus-modal-content {
|
||||
background-color: #fff;
|
||||
margin: 10% auto;
|
||||
padding: 30px;
|
||||
border: 1px solid #c3c4c7;
|
||||
width: 80%;
|
||||
max-width: 600px;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.apus-modal-close {
|
||||
color: #646970;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
line-height: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.apus-modal-close:hover,
|
||||
.apus-modal-close:focus {
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.apus-modal-content h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.apus-modal-content textarea {
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Notices */
|
||||
.apus-notice {
|
||||
padding: 12px;
|
||||
margin: 20px 0;
|
||||
border-left: 4px solid;
|
||||
background: #fff;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.04);
|
||||
}
|
||||
|
||||
.apus-notice.success {
|
||||
border-left-color: #00a32a;
|
||||
}
|
||||
|
||||
.apus-notice.error {
|
||||
border-left-color: #d63638;
|
||||
}
|
||||
|
||||
.apus-notice.warning {
|
||||
border-left-color: #dba617;
|
||||
}
|
||||
|
||||
.apus-notice.info {
|
||||
border-left-color: #2271b1;
|
||||
}
|
||||
|
||||
/* Code Editor */
|
||||
textarea.code {
|
||||
font-family: 'Courier New', Courier, monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media screen and (max-width: 782px) {
|
||||
.apus-options-container {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.apus-tabs-nav {
|
||||
width: 100%;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.apus-tabs-nav ul {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li {
|
||||
flex: 1;
|
||||
min-width: 50%;
|
||||
border-right: 1px solid #c3c4c7;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a {
|
||||
text-align: center;
|
||||
padding: 12px 10px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.apus-tabs-nav a .dashicons {
|
||||
display: block;
|
||||
margin: 0 auto 5px;
|
||||
}
|
||||
|
||||
.apus-tabs-nav li.active a {
|
||||
border-left: none;
|
||||
border-bottom: 3px solid #2271b1;
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
.apus-tabs-content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.apus-options-header {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.apus-options-actions {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.apus-options-actions .button {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.apus-tab-pane .form-table th {
|
||||
width: auto;
|
||||
padding: 15px 10px 5px 0;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.apus-tab-pane .form-table td {
|
||||
display: block;
|
||||
padding: 5px 10px 15px 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loading Spinner */
|
||||
.apus-spinner {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(0,0,0,.1);
|
||||
border-radius: 50%;
|
||||
border-top-color: #2271b1;
|
||||
animation: apus-spin 1s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes apus-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* Helper Classes */
|
||||
.apus-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.apus-text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.apus-mt-20 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.apus-mb-20 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Color Picker */
|
||||
.wp-picker-container {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Field Dependencies */
|
||||
.apus-field-dependency {
|
||||
opacity: 0.5;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Success Animation */
|
||||
@keyframes apus-saved {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
.apus-saved {
|
||||
animation: apus-saved 0.3s ease-in-out;
|
||||
}
|
||||
430
admin/assets/js/admin-app.js
Normal file
430
admin/assets/js/admin-app.js
Normal file
@@ -0,0 +1,430 @@
|
||||
/**
|
||||
* Admin Panel Application
|
||||
*
|
||||
* Gestión de configuraciones de componentes del tema
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
const AdminPanel = {
|
||||
/**
|
||||
* Estado de la aplicación
|
||||
*/
|
||||
STATE: {
|
||||
settings: {},
|
||||
hasChanges: false,
|
||||
isLoading: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Inicializar aplicación
|
||||
*/
|
||||
init() {
|
||||
this.bindEvents();
|
||||
this.loadSettings();
|
||||
},
|
||||
|
||||
/**
|
||||
* Vincular eventos
|
||||
*/
|
||||
bindEvents() {
|
||||
// Botón guardar
|
||||
document.getElementById('saveSettings').addEventListener('click', () => {
|
||||
this.saveSettings();
|
||||
});
|
||||
|
||||
// Detectar cambios en formularios
|
||||
const enableSaveButton = () => {
|
||||
this.STATE.hasChanges = true;
|
||||
document.getElementById('saveSettings').disabled = false;
|
||||
};
|
||||
|
||||
document.querySelectorAll('input, select, textarea').forEach(input => {
|
||||
// Evento 'input' se dispara mientras se escribe (tiempo real)
|
||||
input.addEventListener('input', enableSaveButton);
|
||||
// Evento 'change' se dispara cuando pierde foco (para select y checkboxes)
|
||||
input.addEventListener('change', enableSaveButton);
|
||||
});
|
||||
|
||||
// Tabs
|
||||
const tabs = document.querySelectorAll('.nav-tabs .nav-link');
|
||||
tabs.forEach(tab => {
|
||||
tab.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
this.switchTab(tab);
|
||||
});
|
||||
});
|
||||
|
||||
// Contador de caracteres
|
||||
this.setupCharacterCounter();
|
||||
|
||||
// Vista previa en tiempo real
|
||||
this.setupLivePreview();
|
||||
},
|
||||
|
||||
/**
|
||||
* Configurar contador de caracteres para textarea
|
||||
*/
|
||||
setupCharacterCounter() {
|
||||
const messageTextarea = document.getElementById('topBarMessageText');
|
||||
if (!messageTextarea) return;
|
||||
|
||||
messageTextarea.addEventListener('input', () => {
|
||||
const count = messageTextarea.value.length;
|
||||
const maxLength = 250;
|
||||
const percentage = (count / maxLength) * 100;
|
||||
|
||||
const counter = document.getElementById('topBarMessageTextCount');
|
||||
const progress = document.getElementById('topBarMessageTextProgress');
|
||||
|
||||
if (counter) {
|
||||
counter.textContent = count;
|
||||
|
||||
// Cambiar color según proximidad al límite
|
||||
counter.classList.remove('text-danger', 'text-warning', 'text-muted');
|
||||
|
||||
if (count > 230) {
|
||||
counter.classList.add('text-danger');
|
||||
} else if (count > 200) {
|
||||
counter.classList.add('text-warning');
|
||||
} else {
|
||||
counter.classList.add('text-muted');
|
||||
}
|
||||
}
|
||||
|
||||
// Actualizar progress bar
|
||||
if (progress) {
|
||||
progress.style.width = percentage + '%';
|
||||
progress.setAttribute('aria-valuenow', count);
|
||||
|
||||
// Cambiar color del progress bar
|
||||
progress.classList.remove('bg-orange-primary', 'bg-warning', 'bg-danger');
|
||||
if (count > 230) {
|
||||
progress.classList.add('bg-danger');
|
||||
} else if (count > 200) {
|
||||
progress.classList.add('bg-warning');
|
||||
} else {
|
||||
progress.classList.add('bg-orange-primary');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Trigger inicial para mostrar count actual
|
||||
messageTextarea.dispatchEvent(new Event('input'));
|
||||
},
|
||||
|
||||
/**
|
||||
* Configurar vista previa en tiempo real
|
||||
*/
|
||||
setupLivePreview() {
|
||||
const preview = document.getElementById('topBarPreview');
|
||||
if (!preview) return;
|
||||
|
||||
// Campos que afectan la vista previa
|
||||
const fields = {
|
||||
iconClass: document.getElementById('topBarIconClass'),
|
||||
showIcon: document.getElementById('topBarShowIcon'),
|
||||
highlightText: document.getElementById('topBarHighlightText'),
|
||||
messageText: document.getElementById('topBarMessageText'),
|
||||
linkText: document.getElementById('topBarLinkText'),
|
||||
showLink: document.getElementById('topBarShowLink'),
|
||||
bgColor: document.getElementById('topBarBgColor'),
|
||||
textColor: document.getElementById('topBarTextColor'),
|
||||
highlightColor: document.getElementById('topBarHighlightColor'),
|
||||
fontSize: document.getElementById('topBarFontSize')
|
||||
};
|
||||
|
||||
// Función para actualizar la vista previa
|
||||
const updatePreview = () => {
|
||||
// Obtener valores
|
||||
const iconClass = fields.iconClass.value || 'bi bi-megaphone-fill';
|
||||
const showIcon = fields.showIcon.checked;
|
||||
const highlightText = fields.highlightText.value;
|
||||
const messageText = fields.messageText.value || 'Tu mensaje aquí...';
|
||||
const linkText = fields.linkText.value || 'Ver más';
|
||||
const showLink = fields.showLink.checked;
|
||||
const bgColor = fields.bgColor.value || '#0E2337';
|
||||
const textColor = fields.textColor.value || '#ffffff';
|
||||
const highlightColor = fields.highlightColor.value || '#FF8600';
|
||||
|
||||
// Mapeo de tamaños de fuente
|
||||
const fontSizeMap = {
|
||||
'small': '0.8rem',
|
||||
'normal': '0.9rem',
|
||||
'large': '1rem'
|
||||
};
|
||||
const fontSize = fontSizeMap[fields.fontSize.value] || '0.9rem';
|
||||
|
||||
// Construir HTML de la vista previa
|
||||
let html = '';
|
||||
|
||||
// Icono
|
||||
if (showIcon && iconClass) {
|
||||
html += `<i class="${iconClass}" style="font-size: 1.2rem; color: ${highlightColor};"></i>`;
|
||||
}
|
||||
|
||||
// Texto destacado
|
||||
if (highlightText) {
|
||||
html += `<span style="font-weight: 700; color: ${highlightColor};">${highlightText}</span>`;
|
||||
}
|
||||
|
||||
// Mensaje principal
|
||||
html += `<span style="flex: 1; min-width: 300px; text-align: center;">${messageText}</span>`;
|
||||
|
||||
// Enlace
|
||||
if (showLink && linkText) {
|
||||
html += `<a href="#" style="color: ${textColor}; text-decoration: underline; white-space: nowrap; transition: color 0.3s;">${linkText}</a>`;
|
||||
}
|
||||
|
||||
// Actualizar la vista previa
|
||||
preview.innerHTML = html;
|
||||
preview.style.backgroundColor = bgColor;
|
||||
preview.style.color = textColor;
|
||||
preview.style.fontSize = fontSize;
|
||||
};
|
||||
|
||||
// Agregar listeners a todos los campos
|
||||
Object.values(fields).forEach(field => {
|
||||
if (field) {
|
||||
field.addEventListener('input', updatePreview);
|
||||
field.addEventListener('change', updatePreview);
|
||||
}
|
||||
});
|
||||
|
||||
// Actualización inicial
|
||||
updatePreview();
|
||||
},
|
||||
|
||||
/**
|
||||
* Cambiar tab
|
||||
*/
|
||||
switchTab(tab) {
|
||||
// Remover active de todos
|
||||
document.querySelectorAll('.nav-tabs .nav-link').forEach(t => {
|
||||
t.classList.remove('active');
|
||||
});
|
||||
document.querySelectorAll('.tab-pane').forEach(pane => {
|
||||
pane.classList.remove('show', 'active');
|
||||
});
|
||||
|
||||
// Activar seleccionado
|
||||
tab.classList.add('active');
|
||||
const targetId = tab.getAttribute('data-bs-target').substring(1);
|
||||
const targetPane = document.getElementById(targetId);
|
||||
if (targetPane) {
|
||||
targetPane.classList.add('show', 'active');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Cargar configuraciones desde servidor
|
||||
*/
|
||||
async loadSettings() {
|
||||
this.STATE.isLoading = true;
|
||||
this.showSpinner(true);
|
||||
|
||||
try {
|
||||
const response = await axios({
|
||||
method: 'POST',
|
||||
url: apusAdminData.ajaxUrl,
|
||||
data: new URLSearchParams({
|
||||
action: 'apus_get_settings',
|
||||
nonce: apusAdminData.nonce
|
||||
})
|
||||
});
|
||||
|
||||
if (response.data.success) {
|
||||
this.STATE.settings = response.data.data;
|
||||
this.renderAllComponents();
|
||||
} else {
|
||||
this.showNotice('Error al cargar configuraciones', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading settings:', error);
|
||||
this.showNotice('Error de conexión', 'error');
|
||||
} finally {
|
||||
this.STATE.isLoading = false;
|
||||
this.showSpinner(false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Guardar configuraciones al servidor
|
||||
*/
|
||||
async saveSettings() {
|
||||
if (!this.STATE.hasChanges) {
|
||||
this.showNotice('No hay cambios para guardar', 'info');
|
||||
return;
|
||||
}
|
||||
|
||||
this.showSpinner(true);
|
||||
|
||||
try {
|
||||
const formData = this.collectFormData();
|
||||
|
||||
// Crear FormData para WordPress AJAX
|
||||
const postData = new URLSearchParams();
|
||||
postData.append('action', 'apus_save_settings');
|
||||
postData.append('nonce', apusAdminData.nonce);
|
||||
|
||||
// Agregar components como JSON string
|
||||
postData.append('components', JSON.stringify(formData.components));
|
||||
|
||||
const response = await axios({
|
||||
method: 'POST',
|
||||
url: apusAdminData.ajaxUrl,
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
data: postData
|
||||
});
|
||||
|
||||
if (response.data.success) {
|
||||
this.STATE.hasChanges = false;
|
||||
document.getElementById('saveSettings').disabled = true;
|
||||
this.showNotice('Configuración guardada correctamente', 'success');
|
||||
} else {
|
||||
this.showNotice(response.data.data.message || 'Error al guardar', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving settings:', error);
|
||||
this.showNotice('Error de conexión', 'error');
|
||||
} finally {
|
||||
this.showSpinner(false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Recolectar datos del formulario
|
||||
* Cada componente agregará su sección aquí
|
||||
*/
|
||||
collectFormData() {
|
||||
return {
|
||||
components: {
|
||||
top_bar: {
|
||||
enabled: document.getElementById('topBarEnabled').checked,
|
||||
show_on_mobile: document.getElementById('topBarShowOnMobile').checked,
|
||||
show_on_desktop: document.getElementById('topBarShowOnDesktop').checked,
|
||||
icon_class: document.getElementById('topBarIconClass').value.trim(),
|
||||
show_icon: document.getElementById('topBarShowIcon').checked,
|
||||
highlight_text: document.getElementById('topBarHighlightText').value.trim(),
|
||||
message_text: document.getElementById('topBarMessageText').value.trim(),
|
||||
link_text: document.getElementById('topBarLinkText').value.trim(),
|
||||
link_url: document.getElementById('topBarLinkUrl').value.trim(),
|
||||
link_target: document.getElementById('topBarLinkTarget').value,
|
||||
show_link: document.getElementById('topBarShowLink').checked,
|
||||
custom_styles: {
|
||||
background_color: this.getColorValue('topBarBgColor', ''),
|
||||
text_color: this.getColorValue('topBarTextColor', ''),
|
||||
highlight_color: this.getColorValue('topBarHighlightColor', ''),
|
||||
link_hover_color: this.getColorValue('topBarLinkHoverColor', ''),
|
||||
font_size: document.getElementById('topBarFontSize').value
|
||||
}
|
||||
}
|
||||
// Navbar - Pendiente
|
||||
// Hero - Pendiente
|
||||
// Footer - Pendiente
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Renderizar todos los componentes
|
||||
*/
|
||||
renderAllComponents() {
|
||||
const components = this.STATE.settings.components || {};
|
||||
|
||||
// Top Bar
|
||||
if (components.top_bar) {
|
||||
this.renderTopBar(components.top_bar);
|
||||
}
|
||||
// Navbar - Pendiente
|
||||
// Hero - Pendiente
|
||||
// Footer - Pendiente
|
||||
},
|
||||
|
||||
/**
|
||||
* Renderizar Top Bar
|
||||
*/
|
||||
renderTopBar(topBar) {
|
||||
document.getElementById('topBarEnabled').checked = topBar.enabled !== undefined ? topBar.enabled : true;
|
||||
document.getElementById('topBarShowOnMobile').checked = topBar.show_on_mobile !== undefined ? topBar.show_on_mobile : true;
|
||||
document.getElementById('topBarShowOnDesktop').checked = topBar.show_on_desktop !== undefined ? topBar.show_on_desktop : true;
|
||||
document.getElementById('topBarIconClass').value = topBar.icon_class || 'bi bi-megaphone-fill';
|
||||
document.getElementById('topBarShowIcon').checked = topBar.show_icon !== undefined ? topBar.show_icon : true;
|
||||
document.getElementById('topBarHighlightText').value = topBar.highlight_text || 'Nuevo:';
|
||||
document.getElementById('topBarMessageText').value = topBar.message_text || 'Accede a más de 200,000 Análisis de Precios Unitarios actualizados para 2025.';
|
||||
document.getElementById('topBarLinkText').value = topBar.link_text || 'Ver Catálogo';
|
||||
document.getElementById('topBarLinkUrl').value = topBar.link_url || '/catalogo';
|
||||
document.getElementById('topBarLinkTarget').value = topBar.link_target || '_self';
|
||||
document.getElementById('topBarShowLink').checked = topBar.show_link !== undefined ? topBar.show_link : true;
|
||||
|
||||
// Estilos personalizados
|
||||
if (topBar.custom_styles) {
|
||||
if (topBar.custom_styles.background_color) {
|
||||
document.getElementById('topBarBgColor').value = topBar.custom_styles.background_color;
|
||||
}
|
||||
if (topBar.custom_styles.text_color) {
|
||||
document.getElementById('topBarTextColor').value = topBar.custom_styles.text_color;
|
||||
}
|
||||
if (topBar.custom_styles.highlight_color) {
|
||||
document.getElementById('topBarHighlightColor').value = topBar.custom_styles.highlight_color;
|
||||
}
|
||||
if (topBar.custom_styles.link_hover_color) {
|
||||
document.getElementById('topBarLinkHoverColor').value = topBar.custom_styles.link_hover_color;
|
||||
}
|
||||
document.getElementById('topBarFontSize').value = topBar.custom_styles.font_size || 'normal';
|
||||
}
|
||||
|
||||
// Trigger contador de caracteres
|
||||
const messageTextarea = document.getElementById('topBarMessageText');
|
||||
if (messageTextarea) {
|
||||
messageTextarea.dispatchEvent(new Event('input'));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Utilidad: Obtener valor de color con fallback
|
||||
*/
|
||||
getColorValue(inputId, defaultValue) {
|
||||
const input = document.getElementById(inputId);
|
||||
const value = input ? input.value.trim() : '';
|
||||
return value || defaultValue;
|
||||
},
|
||||
|
||||
/**
|
||||
* Utilidad: Mostrar spinner
|
||||
*/
|
||||
showSpinner(show) {
|
||||
const spinner = document.querySelector('.spinner');
|
||||
if (spinner) {
|
||||
spinner.style.display = show ? 'inline-block' : 'none';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Utilidad: Mostrar notificación
|
||||
*/
|
||||
showNotice(message, type = 'info') {
|
||||
// WordPress admin notices
|
||||
const noticeDiv = document.createElement('div');
|
||||
noticeDiv.className = `notice notice-${type} is-dismissible`;
|
||||
noticeDiv.innerHTML = `<p>${message}</p>`;
|
||||
|
||||
const container = document.querySelector('.apus-admin-panel');
|
||||
if (container) {
|
||||
container.insertBefore(noticeDiv, container.firstChild);
|
||||
|
||||
// Auto-dismiss después de 5 segundos
|
||||
setTimeout(() => {
|
||||
noticeDiv.remove();
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Inicializar cuando el DOM esté listo
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
AdminPanel.init();
|
||||
});
|
||||
191
admin/assets/js/component-navbar.js
Normal file
191
admin/assets/js/component-navbar.js
Normal file
@@ -0,0 +1,191 @@
|
||||
/**
|
||||
* Navbar Component - JavaScript Controller
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @since 2.0.0
|
||||
*/
|
||||
|
||||
window.NavbarComponent = {
|
||||
/**
|
||||
* Inicialización del componente
|
||||
*/
|
||||
init: function() {
|
||||
console.log('Navbar component initialized');
|
||||
|
||||
// Actualizar valores hexadecimales de color pickers en tiempo real
|
||||
this.initColorPickers();
|
||||
},
|
||||
|
||||
/**
|
||||
* Inicializar event listeners para color pickers
|
||||
*/
|
||||
initColorPickers: function() {
|
||||
const colorPickers = [
|
||||
{ input: 'navbarBgColor', display: 'navbarBgColorValue' },
|
||||
{ input: 'navbarTextColor', display: 'navbarTextColorValue' },
|
||||
{ input: 'navbarLinkHoverColor', display: 'navbarLinkHoverColorValue' },
|
||||
{ input: 'navbarLinkHoverBgColor', display: 'navbarLinkHoverBgColorValue' },
|
||||
{ input: 'navbarDropdownBgColor', display: 'navbarDropdownBgColorValue' },
|
||||
{ input: 'navbarDropdownItemColor', display: 'navbarDropdownItemColorValue' },
|
||||
{ input: 'navbarDropdownItemHoverColor', display: 'navbarDropdownItemHoverColorValue' }
|
||||
];
|
||||
|
||||
colorPickers.forEach(function(picker) {
|
||||
const inputEl = document.getElementById(picker.input);
|
||||
const displayEl = document.getElementById(picker.display);
|
||||
|
||||
if (inputEl && displayEl) {
|
||||
// Actualizar cuando cambia el color
|
||||
inputEl.addEventListener('input', function() {
|
||||
displayEl.textContent = inputEl.value.toUpperCase();
|
||||
});
|
||||
|
||||
// Inicializar valor al cargar
|
||||
displayEl.textContent = inputEl.value.toUpperCase();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Recolectar datos del formulario
|
||||
* @returns {Object} Configuración del navbar
|
||||
*/
|
||||
collect: function() {
|
||||
return {
|
||||
// Grupo 1: Activación y Visibilidad
|
||||
enabled: document.getElementById('navbarEnabled').checked,
|
||||
show_on_mobile: document.getElementById('navbarShowOnMobile').checked,
|
||||
show_on_desktop: document.getElementById('navbarShowOnDesktop').checked,
|
||||
position: document.getElementById('navbarPosition').value,
|
||||
responsive_breakpoint: document.getElementById('navbarBreakpoint').value,
|
||||
|
||||
// Grupo 4: Efectos (booleans)
|
||||
enable_box_shadow: document.getElementById('navbarEnableBoxShadow').checked,
|
||||
enable_underline_effect: document.getElementById('navbarEnableUnderlineEffect').checked,
|
||||
enable_hover_background: document.getElementById('navbarEnableHoverBackground').checked,
|
||||
|
||||
// Grupo 6: Let's Talk Button
|
||||
lets_talk_button: {
|
||||
enabled: document.getElementById('navbarLetsTalkEnabled').checked,
|
||||
text: document.getElementById('navbarLetsTalkText').value.trim(),
|
||||
icon_class: document.getElementById('navbarLetsTalkIconClass').value.trim(),
|
||||
show_icon: document.getElementById('navbarLetsTalkShowIcon').checked,
|
||||
position: document.getElementById('navbarLetsTalkPosition').value
|
||||
},
|
||||
|
||||
// Grupo 7: Dropdown
|
||||
dropdown: {
|
||||
enable_hover_desktop: document.getElementById('navbarDropdownEnableHoverDesktop').checked,
|
||||
max_height: parseInt(document.getElementById('navbarDropdownMaxHeight').value) || 70,
|
||||
border_radius: parseInt(document.getElementById('navbarDropdownBorderRadius').value) || 8,
|
||||
item_padding_vertical: parseFloat(document.getElementById('navbarDropdownItemPaddingVertical').value) || 0.5,
|
||||
item_padding_horizontal: parseFloat(document.getElementById('navbarDropdownItemPaddingHorizontal').value) || 1.25
|
||||
},
|
||||
|
||||
// Grupos 2, 3, 5: Custom Styles
|
||||
custom_styles: {
|
||||
// Grupo 2: Colores
|
||||
background_color: document.getElementById('navbarBgColor').value || '#1e3a5f',
|
||||
text_color: document.getElementById('navbarTextColor').value || '#ffffff',
|
||||
link_hover_color: document.getElementById('navbarLinkHoverColor').value || '#FF8600',
|
||||
link_hover_bg_color: document.getElementById('navbarLinkHoverBgColor').value || '#FF8600',
|
||||
dropdown_bg_color: document.getElementById('navbarDropdownBgColor').value || '#ffffff',
|
||||
dropdown_item_color: document.getElementById('navbarDropdownItemColor').value || '#4A5568',
|
||||
dropdown_item_hover_color: document.getElementById('navbarDropdownItemHoverColor').value || '#FF8600',
|
||||
|
||||
// Grupo 3: Tipografía
|
||||
font_size: document.getElementById('navbarFontSize').value,
|
||||
font_weight: document.getElementById('navbarFontWeight').value,
|
||||
|
||||
// Grupo 4: Efectos
|
||||
box_shadow_intensity: document.getElementById('navbarBoxShadowIntensity').value,
|
||||
border_radius: parseInt(document.getElementById('navbarBorderRadius').value) || 4,
|
||||
|
||||
// Grupo 5: Spacing
|
||||
padding_vertical: parseFloat(document.getElementById('navbarPaddingVertical').value) || 0.75,
|
||||
link_padding_vertical: parseFloat(document.getElementById('navbarLinkPaddingVertical').value) || 0.5,
|
||||
link_padding_horizontal: parseFloat(document.getElementById('navbarLinkPaddingHorizontal').value) || 0.65,
|
||||
|
||||
// Grupo 8: Avanzado
|
||||
z_index: parseInt(document.getElementById('navbarZIndex').value) || 1030,
|
||||
transition_speed: document.getElementById('navbarTransitionSpeed').value || 'normal'
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Renderizar configuración en el formulario
|
||||
* @param {Object} config - Configuración del navbar
|
||||
*/
|
||||
render: function(config) {
|
||||
if (!config) {
|
||||
console.warn('No navbar config provided');
|
||||
return;
|
||||
}
|
||||
|
||||
// Grupo 1: Activación y Visibilidad
|
||||
document.getElementById('navbarEnabled').checked = config.enabled !== undefined ? config.enabled : true;
|
||||
document.getElementById('navbarShowOnMobile').checked = config.show_on_mobile !== undefined ? config.show_on_mobile : true;
|
||||
document.getElementById('navbarShowOnDesktop').checked = config.show_on_desktop !== undefined ? config.show_on_desktop : true;
|
||||
document.getElementById('navbarPosition').value = config.position || 'sticky';
|
||||
document.getElementById('navbarBreakpoint').value = config.responsive_breakpoint || 'lg';
|
||||
|
||||
// Grupo 2: Colores Personalizados
|
||||
if (config.custom_styles) {
|
||||
document.getElementById('navbarBgColor').value = config.custom_styles.background_color || '#1e3a5f';
|
||||
document.getElementById('navbarTextColor').value = config.custom_styles.text_color || '#ffffff';
|
||||
document.getElementById('navbarLinkHoverColor').value = config.custom_styles.link_hover_color || '#FF8600';
|
||||
document.getElementById('navbarLinkHoverBgColor').value = config.custom_styles.link_hover_bg_color || '#FF8600';
|
||||
document.getElementById('navbarDropdownBgColor').value = config.custom_styles.dropdown_bg_color || '#ffffff';
|
||||
document.getElementById('navbarDropdownItemColor').value = config.custom_styles.dropdown_item_color || '#4A5568';
|
||||
document.getElementById('navbarDropdownItemHoverColor').value = config.custom_styles.dropdown_item_hover_color || '#FF8600';
|
||||
}
|
||||
|
||||
// Grupo 3: Tipografía
|
||||
if (config.custom_styles) {
|
||||
document.getElementById('navbarFontSize').value = config.custom_styles.font_size || 'normal';
|
||||
document.getElementById('navbarFontWeight').value = config.custom_styles.font_weight || '500';
|
||||
}
|
||||
|
||||
// Grupo 4: Efectos Visuales
|
||||
document.getElementById('navbarEnableBoxShadow').checked = config.enable_box_shadow !== undefined ? config.enable_box_shadow : true;
|
||||
document.getElementById('navbarEnableUnderlineEffect').checked = config.enable_underline_effect !== undefined ? config.enable_underline_effect : true;
|
||||
document.getElementById('navbarEnableHoverBackground').checked = config.enable_hover_background !== undefined ? config.enable_hover_background : true;
|
||||
|
||||
if (config.custom_styles) {
|
||||
document.getElementById('navbarBoxShadowIntensity').value = config.custom_styles.box_shadow_intensity || 'normal';
|
||||
document.getElementById('navbarBorderRadius').value = config.custom_styles.border_radius !== undefined ? config.custom_styles.border_radius : 4;
|
||||
}
|
||||
|
||||
// Grupo 5: Spacing
|
||||
if (config.custom_styles) {
|
||||
document.getElementById('navbarPaddingVertical').value = config.custom_styles.padding_vertical !== undefined ? config.custom_styles.padding_vertical : 0.75;
|
||||
document.getElementById('navbarLinkPaddingVertical').value = config.custom_styles.link_padding_vertical !== undefined ? config.custom_styles.link_padding_vertical : 0.5;
|
||||
document.getElementById('navbarLinkPaddingHorizontal').value = config.custom_styles.link_padding_horizontal !== undefined ? config.custom_styles.link_padding_horizontal : 0.65;
|
||||
}
|
||||
|
||||
// Grupo 8: Avanzado
|
||||
if (config.custom_styles) {
|
||||
document.getElementById('navbarZIndex').value = config.custom_styles.z_index !== undefined ? config.custom_styles.z_index : 1030;
|
||||
document.getElementById('navbarTransitionSpeed').value = config.custom_styles.transition_speed || 'normal';
|
||||
}
|
||||
|
||||
// Grupo 6: Let's Talk Button
|
||||
if (config.lets_talk_button) {
|
||||
document.getElementById('navbarLetsTalkEnabled').checked = config.lets_talk_button.enabled !== undefined ? config.lets_talk_button.enabled : true;
|
||||
document.getElementById('navbarLetsTalkText').value = config.lets_talk_button.text || "Let's Talk";
|
||||
document.getElementById('navbarLetsTalkIconClass').value = config.lets_talk_button.icon_class || 'bi bi-lightning-charge-fill';
|
||||
document.getElementById('navbarLetsTalkShowIcon').checked = config.lets_talk_button.show_icon !== undefined ? config.lets_talk_button.show_icon : true;
|
||||
document.getElementById('navbarLetsTalkPosition').value = config.lets_talk_button.position || 'right';
|
||||
}
|
||||
|
||||
// Grupo 7: Dropdown
|
||||
if (config.dropdown) {
|
||||
document.getElementById('navbarDropdownEnableHoverDesktop').checked = config.dropdown.enable_hover_desktop !== undefined ? config.dropdown.enable_hover_desktop : true;
|
||||
document.getElementById('navbarDropdownMaxHeight').value = config.dropdown.max_height !== undefined ? config.dropdown.max_height : 70;
|
||||
document.getElementById('navbarDropdownBorderRadius').value = config.dropdown.border_radius !== undefined ? config.dropdown.border_radius : 8;
|
||||
document.getElementById('navbarDropdownItemPaddingVertical').value = config.dropdown.item_padding_vertical !== undefined ? config.dropdown.item_padding_vertical : 0.5;
|
||||
document.getElementById('navbarDropdownItemPaddingHorizontal').value = config.dropdown.item_padding_horizontal !== undefined ? config.dropdown.item_padding_horizontal : 1.25;
|
||||
}
|
||||
}
|
||||
};
|
||||
440
admin/assets/js/theme-options.js
Normal file
440
admin/assets/js/theme-options.js
Normal file
@@ -0,0 +1,440 @@
|
||||
/**
|
||||
* Theme Options Admin JavaScript
|
||||
*
|
||||
* @package Apus_Theme
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
var ApusThemeOptions = {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
init: function() {
|
||||
this.tabs();
|
||||
this.imageUpload();
|
||||
this.resetOptions();
|
||||
this.exportOptions();
|
||||
this.importOptions();
|
||||
this.formValidation();
|
||||
this.conditionalFields();
|
||||
},
|
||||
|
||||
/**
|
||||
* Tab Navigation
|
||||
*/
|
||||
tabs: function() {
|
||||
// Tab click handler
|
||||
$('.apus-tabs-nav a').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var tabId = $(this).attr('href');
|
||||
|
||||
// Update active states
|
||||
$('.apus-tabs-nav li').removeClass('active');
|
||||
$(this).parent().addClass('active');
|
||||
|
||||
// Show/hide tab content
|
||||
$('.apus-tab-pane').removeClass('active');
|
||||
$(tabId).addClass('active');
|
||||
|
||||
// Update URL hash without scrolling
|
||||
if (history.pushState) {
|
||||
history.pushState(null, null, tabId);
|
||||
} else {
|
||||
window.location.hash = tabId;
|
||||
}
|
||||
});
|
||||
|
||||
// Load tab from URL hash on page load
|
||||
if (window.location.hash) {
|
||||
var hash = window.location.hash;
|
||||
if ($(hash).length) {
|
||||
$('.apus-tabs-nav a[href="' + hash + '"]').trigger('click');
|
||||
}
|
||||
}
|
||||
|
||||
// Handle browser back/forward buttons
|
||||
$(window).on('hashchange', function() {
|
||||
if (window.location.hash) {
|
||||
$('.apus-tabs-nav a[href="' + window.location.hash + '"]').trigger('click');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Image Upload
|
||||
*/
|
||||
imageUpload: function() {
|
||||
var self = this;
|
||||
var mediaUploader;
|
||||
|
||||
// Upload button click
|
||||
$(document).on('click', '.apus-upload-image', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var container = button.closest('.apus-image-upload');
|
||||
var preview = container.find('.apus-image-preview');
|
||||
var input = container.find('.apus-image-id');
|
||||
var removeBtn = container.find('.apus-remove-image');
|
||||
|
||||
// If the media uploader already exists, reopen it
|
||||
if (mediaUploader) {
|
||||
mediaUploader.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new media uploader
|
||||
mediaUploader = wp.media({
|
||||
title: apusAdminOptions.strings.selectImage,
|
||||
button: {
|
||||
text: apusAdminOptions.strings.useImage
|
||||
},
|
||||
multiple: false
|
||||
});
|
||||
|
||||
// When an image is selected
|
||||
mediaUploader.on('select', function() {
|
||||
var attachment = mediaUploader.state().get('selection').first().toJSON();
|
||||
|
||||
// Set image ID
|
||||
input.val(attachment.id);
|
||||
|
||||
// Show preview
|
||||
var imgUrl = attachment.sizes && attachment.sizes.medium ?
|
||||
attachment.sizes.medium.url : attachment.url;
|
||||
preview.html('<img src="' + imgUrl + '" class="apus-preview-image" />');
|
||||
|
||||
// Show remove button
|
||||
removeBtn.show();
|
||||
});
|
||||
|
||||
// Open the uploader
|
||||
mediaUploader.open();
|
||||
});
|
||||
|
||||
// Remove button click
|
||||
$(document).on('click', '.apus-remove-image', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
var container = button.closest('.apus-image-upload');
|
||||
var preview = container.find('.apus-image-preview');
|
||||
var input = container.find('.apus-image-id');
|
||||
|
||||
// Clear values
|
||||
input.val('');
|
||||
preview.empty();
|
||||
button.hide();
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset Options
|
||||
*/
|
||||
resetOptions: function() {
|
||||
$('#apus-reset-options').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (!confirm(apusAdminOptions.strings.confirmReset)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var button = $(this);
|
||||
button.prop('disabled', true).addClass('updating-message');
|
||||
|
||||
$.ajax({
|
||||
url: apusAdminOptions.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'apus_reset_options',
|
||||
nonce: apusAdminOptions.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// Show success message
|
||||
ApusThemeOptions.showNotice('success', response.data.message);
|
||||
|
||||
// Reload page after 1 second
|
||||
setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
} else {
|
||||
ApusThemeOptions.showNotice('error', response.data.message);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
ApusThemeOptions.showNotice('error', apusAdminOptions.strings.error);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Export Options
|
||||
*/
|
||||
exportOptions: function() {
|
||||
$('#apus-export-options').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var button = $(this);
|
||||
button.prop('disabled', true).addClass('updating-message');
|
||||
|
||||
$.ajax({
|
||||
url: apusAdminOptions.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'apus_export_options',
|
||||
nonce: apusAdminOptions.nonce
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// Create download link
|
||||
var blob = new Blob([response.data.data], { type: 'application/json' });
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
var a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = response.data.filename;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
|
||||
ApusThemeOptions.showNotice('success', 'Options exported successfully!');
|
||||
} else {
|
||||
ApusThemeOptions.showNotice('error', response.data.message);
|
||||
}
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
},
|
||||
error: function() {
|
||||
ApusThemeOptions.showNotice('error', apusAdminOptions.strings.error);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Import Options
|
||||
*/
|
||||
importOptions: function() {
|
||||
var modal = $('#apus-import-modal');
|
||||
var importData = $('#apus-import-data');
|
||||
|
||||
// Show modal
|
||||
$('#apus-import-options').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
modal.show();
|
||||
});
|
||||
|
||||
// Close modal
|
||||
$('.apus-modal-close, #apus-import-cancel').on('click', function() {
|
||||
modal.hide();
|
||||
importData.val('');
|
||||
});
|
||||
|
||||
// Close modal on outside click
|
||||
$(window).on('click', function(e) {
|
||||
if ($(e.target).is(modal)) {
|
||||
modal.hide();
|
||||
importData.val('');
|
||||
}
|
||||
});
|
||||
|
||||
// Submit import
|
||||
$('#apus-import-submit').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var data = importData.val().trim();
|
||||
|
||||
if (!data) {
|
||||
alert('Please paste your import data.');
|
||||
return;
|
||||
}
|
||||
|
||||
var button = $(this);
|
||||
button.prop('disabled', true).addClass('updating-message');
|
||||
|
||||
$.ajax({
|
||||
url: apusAdminOptions.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'apus_import_options',
|
||||
nonce: apusAdminOptions.nonce,
|
||||
import_data: data
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
ApusThemeOptions.showNotice('success', response.data.message);
|
||||
modal.hide();
|
||||
importData.val('');
|
||||
|
||||
// Reload page after 1 second
|
||||
setTimeout(function() {
|
||||
window.location.reload();
|
||||
}, 1000);
|
||||
} else {
|
||||
ApusThemeOptions.showNotice('error', response.data.message);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
ApusThemeOptions.showNotice('error', apusAdminOptions.strings.error);
|
||||
button.prop('disabled', false).removeClass('updating-message');
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Form Validation
|
||||
*/
|
||||
formValidation: function() {
|
||||
$('.apus-options-form').on('submit', function(e) {
|
||||
var valid = true;
|
||||
var firstError = null;
|
||||
|
||||
// Validate required fields
|
||||
$(this).find('[required]').each(function() {
|
||||
if (!$(this).val()) {
|
||||
valid = false;
|
||||
$(this).addClass('error');
|
||||
|
||||
if (!firstError) {
|
||||
firstError = $(this);
|
||||
}
|
||||
} else {
|
||||
$(this).removeClass('error');
|
||||
}
|
||||
});
|
||||
|
||||
// Validate number fields
|
||||
$(this).find('input[type="number"]').each(function() {
|
||||
var val = $(this).val();
|
||||
var min = $(this).attr('min');
|
||||
var max = $(this).attr('max');
|
||||
|
||||
if (val && min && parseInt(val) < parseInt(min)) {
|
||||
valid = false;
|
||||
$(this).addClass('error');
|
||||
if (!firstError) {
|
||||
firstError = $(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (val && max && parseInt(val) > parseInt(max)) {
|
||||
valid = false;
|
||||
$(this).addClass('error');
|
||||
if (!firstError) {
|
||||
firstError = $(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Validate URL fields
|
||||
$(this).find('input[type="url"]').each(function() {
|
||||
var val = $(this).val();
|
||||
if (val && !ApusThemeOptions.isValidUrl(val)) {
|
||||
valid = false;
|
||||
$(this).addClass('error');
|
||||
if (!firstError) {
|
||||
firstError = $(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!valid) {
|
||||
e.preventDefault();
|
||||
|
||||
if (firstError) {
|
||||
// Scroll to first error
|
||||
$('html, body').animate({
|
||||
scrollTop: firstError.offset().top - 100
|
||||
}, 500);
|
||||
firstError.focus();
|
||||
}
|
||||
|
||||
ApusThemeOptions.showNotice('error', 'Please fix the errors in the form.');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add saving animation
|
||||
$(this).find('.submit .button-primary').addClass('updating-message');
|
||||
});
|
||||
|
||||
// Remove error class on input
|
||||
$('.apus-options-form input, .apus-options-form select, .apus-options-form textarea').on('change input', function() {
|
||||
$(this).removeClass('error');
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Conditional Fields
|
||||
*/
|
||||
conditionalFields: function() {
|
||||
// Enable/disable related posts options based on checkbox
|
||||
$('#enable_related_posts').on('change', function() {
|
||||
var checked = $(this).is(':checked');
|
||||
var fields = $('#related_posts_count, #related_posts_taxonomy, #related_posts_title, #related_posts_columns');
|
||||
|
||||
fields.closest('tr').toggleClass('apus-field-dependency', !checked);
|
||||
fields.prop('disabled', !checked);
|
||||
}).trigger('change');
|
||||
|
||||
// Enable/disable breadcrumb separator based on breadcrumbs checkbox
|
||||
$('#enable_breadcrumbs').on('change', function() {
|
||||
var checked = $(this).is(':checked');
|
||||
var field = $('#breadcrumb_separator');
|
||||
|
||||
field.closest('tr').toggleClass('apus-field-dependency', !checked);
|
||||
field.prop('disabled', !checked);
|
||||
}).trigger('change');
|
||||
},
|
||||
|
||||
/**
|
||||
* Show Notice
|
||||
*/
|
||||
showNotice: function(type, message) {
|
||||
var notice = $('<div class="notice notice-' + type + ' is-dismissible"><p>' + message + '</p></div>');
|
||||
|
||||
$('.apus-theme-options h1').after(notice);
|
||||
|
||||
// Auto-dismiss after 5 seconds
|
||||
setTimeout(function() {
|
||||
notice.fadeOut(function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}, 5000);
|
||||
|
||||
// Scroll to top
|
||||
$('html, body').animate({ scrollTop: 0 }, 300);
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate URL
|
||||
*/
|
||||
isValidUrl: function(url) {
|
||||
try {
|
||||
new URL(url);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Initialize on document ready
|
||||
$(document).ready(function() {
|
||||
ApusThemeOptions.init();
|
||||
});
|
||||
|
||||
// Make it globally accessible
|
||||
window.ApusThemeOptions = ApusThemeOptions;
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user