изменил дизайн выпадающих списков
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
}
|
||||
|
||||
.form-group input,
|
||||
.form-group select {
|
||||
.filter-row input {
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
background: var(--bg-input);
|
||||
@@ -85,20 +85,22 @@
|
||||
transition: all var(--transition);
|
||||
}
|
||||
|
||||
.form-group input::placeholder {
|
||||
.form-group input::placeholder,
|
||||
.filter-row input::placeholder {
|
||||
color: var(--text-placeholder);
|
||||
transition: opacity var(--transition);
|
||||
}
|
||||
|
||||
.form-group input:focus,
|
||||
.form-group select:focus {
|
||||
.filter-row input:focus {
|
||||
background: var(--bg-input-focus);
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 4px var(--accent-glow);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.form-group input:focus::placeholder {
|
||||
.form-group input:focus::placeholder,
|
||||
.filter-row input:focus::placeholder {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@@ -114,34 +116,187 @@ input[type="number"] {
|
||||
appearance: textfield;
|
||||
}
|
||||
|
||||
/* Select Base Style */
|
||||
.form-group select,
|
||||
.filter-row select {
|
||||
cursor: pointer;
|
||||
appearance: none;
|
||||
background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 0.75rem center;
|
||||
padding-right: 2.25rem;
|
||||
/* ===== Premium Custom Dropdown Styles ===== */
|
||||
.custom-select-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
user-select: none;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.form-group select option,
|
||||
.filter-row select option {
|
||||
background: #1a1a2e;
|
||||
.custom-select-trigger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
padding: 0.75rem 1rem;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid var(--bg-card-border);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-primary);
|
||||
font-size: 0.95rem;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
transition: all var(--transition);
|
||||
}
|
||||
|
||||
.filter-row .custom-select-trigger {
|
||||
padding: 0.45rem 1rem;
|
||||
font-size: 0.85rem;
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.custom-select-trigger:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
.custom-select-trigger:focus,
|
||||
.custom-select-wrapper.open .custom-select-trigger {
|
||||
background: var(--bg-input-focus);
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 4px var(--accent-glow);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.filter-row .custom-select-wrapper.open .custom-select-trigger,
|
||||
.filter-row .custom-select-trigger:focus {
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 3px var(--accent-glow);
|
||||
}
|
||||
|
||||
.custom-select-trigger.placeholder-active .custom-select-text {
|
||||
color: var(--text-placeholder);
|
||||
}
|
||||
|
||||
.custom-select-text {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.custom-select-icon {
|
||||
margin-left: 0.75rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--text-secondary);
|
||||
transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
|
||||
}
|
||||
|
||||
.custom-select-wrapper.open .custom-select-icon {
|
||||
transform: rotate(180deg);
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.custom-select-menu {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.5rem);
|
||||
left: 0;
|
||||
width: 100%;
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
background: rgba(10, 10, 15, 0.95);
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
border: 1px solid var(--bg-card-border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
|
||||
padding: 0.5rem;
|
||||
z-index: 9999;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(-8px) scale(0.98);
|
||||
transform-origin: top center;
|
||||
transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.custom-select-wrapper.open .custom-select-menu {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
|
||||
/* Custom Scrollbar for Dropdown */
|
||||
.custom-select-menu::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
.custom-select-menu::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.custom-select-menu::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.custom-select-menu::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
.custom-select-item {
|
||||
padding: 0.6rem 0.8rem;
|
||||
margin-bottom: 0.15rem;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--text-primary);
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
|
||||
}
|
||||
|
||||
.custom-select-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.custom-select-item:hover:not(.disabled) {
|
||||
background: var(--bg-hover);
|
||||
padding-left: 1.1rem;
|
||||
}
|
||||
|
||||
.custom-select-item.selected {
|
||||
background: var(--accent-glow);
|
||||
color: #fff;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.custom-select-item.selected:hover {
|
||||
background: var(--accent-glow);
|
||||
padding-left: 0.8rem;
|
||||
}
|
||||
|
||||
.custom-select-item.disabled {
|
||||
color: var(--text-secondary);
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.custom-select-item.placeholder-item {
|
||||
display: none; /* Hide placeholder options in the actual dropdown list naturally */
|
||||
}
|
||||
|
||||
/* Light theme selects */
|
||||
[data-theme="light"] .form-group input,
|
||||
[data-theme="light"] .form-group select,
|
||||
[data-theme="light"] .filter-row select {
|
||||
[data-theme="light"] .filter-row input,
|
||||
[data-theme="light"] .custom-select-trigger {
|
||||
border-color: rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
[data-theme="light"] .form-group select option,
|
||||
[data-theme="light"] .filter-row select option {
|
||||
background: #fff;
|
||||
color: #1a1a2e;
|
||||
[data-theme="light"] .custom-select-menu {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
|
||||
}
|
||||
|
||||
[data-theme="light"] .custom-select-menu::-webkit-scrollbar-thumb {
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
[data-theme="light"] .custom-select-menu::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
[data-theme="light"] .custom-select-item.selected {
|
||||
background: rgba(99, 102, 241, 0.15);
|
||||
color: var(--accent-hover);
|
||||
}
|
||||
|
||||
/* Filter Row */
|
||||
@@ -172,7 +327,7 @@ input[type="number"] {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.filter-row select {
|
||||
.filter-row input {
|
||||
padding: 0.45rem 2rem 0.45rem 0.7rem;
|
||||
background: var(--bg-input);
|
||||
border: 1px solid transparent;
|
||||
@@ -182,7 +337,7 @@ input[type="number"] {
|
||||
transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
|
||||
}
|
||||
|
||||
.filter-row select:focus {
|
||||
.filter-row input:focus {
|
||||
background-color: var(--bg-input-focus);
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 3px var(--accent-glow);
|
||||
@@ -230,26 +385,33 @@ input[type="number"] {
|
||||
|
||||
.dropdown-menu {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
top: calc(100% + 0.5rem);
|
||||
left: 0;
|
||||
width: 100%;
|
||||
margin-top: 0.5rem;
|
||||
background: rgba(15, 23, 42, 0.95);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
background: rgba(10, 10, 15, 0.95);
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
border: 1px solid var(--bg-card-border);
|
||||
border-radius: var(--radius-sm);
|
||||
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
|
||||
padding: 1rem;
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
|
||||
padding: 0.5rem;
|
||||
z-index: 100;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(-10px);
|
||||
transition: all var(--transition);
|
||||
transform: translateY(-8px) scale(0.98);
|
||||
transform-origin: top center;
|
||||
transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
|
||||
}
|
||||
|
||||
[data-theme="light"] .custom-multi-select .dropdown-menu {
|
||||
background: rgba(255, 255, 255, 0.98);
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
|
||||
}
|
||||
|
||||
.dropdown-menu.open {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
|
||||
.dropdown-menu.open {
|
||||
@@ -261,26 +423,102 @@ input[type="number"] {
|
||||
.checkbox-group-vertical {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
max-height: 200px;
|
||||
gap: 0.25rem;
|
||||
max-height: 250px;
|
||||
overflow-y: auto;
|
||||
padding-right: 0.25rem;
|
||||
}
|
||||
|
||||
.checkbox-group-vertical::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
.checkbox-group-vertical::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.checkbox-group-vertical::-webkit-scrollbar-thumb {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.checkbox-group-vertical::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(255, 255, 255, 0.25);
|
||||
}
|
||||
|
||||
[data-theme="light"] .checkbox-group-vertical::-webkit-scrollbar-thumb {
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
[data-theme="light"] .checkbox-group-vertical::-webkit-scrollbar-thumb:hover {
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.checkbox-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
position: relative;
|
||||
padding: 0.5rem 0.5rem 0.5rem 2.25rem;
|
||||
cursor: pointer;
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-primary);
|
||||
padding: 0.25rem 0;
|
||||
border-radius: var(--radius-sm);
|
||||
user-select: none;
|
||||
transition: background 0.2s ease;
|
||||
}
|
||||
|
||||
.checkbox-item:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
.checkbox-item input[type="checkbox"] {
|
||||
position: absolute;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
width: 1.1rem;
|
||||
height: 1.1rem;
|
||||
accent-color: var(--accent);
|
||||
height: 0;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.checkbox-item .checkmark {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0.6rem;
|
||||
transform: translateY(-50%);
|
||||
height: 1.15rem;
|
||||
width: 1.15rem;
|
||||
background-color: var(--bg-input);
|
||||
border: 1px solid var(--bg-card-border);
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.checkbox-item:hover input ~ .checkmark {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.checkbox-item input:focus ~ .checkmark {
|
||||
box-shadow: 0 0 0 3px var(--accent-glow);
|
||||
}
|
||||
|
||||
.checkbox-item input:checked ~ .checkmark {
|
||||
background-color: var(--accent);
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
|
||||
}
|
||||
|
||||
.checkmark::after {
|
||||
content: "";
|
||||
display: none;
|
||||
width: 4px;
|
||||
height: 8px;
|
||||
border: solid white;
|
||||
border-width: 0 2px 2px 0;
|
||||
transform: rotate(45deg);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.checkbox-item input:checked ~ .checkmark::after {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ===== Buttons ===== */
|
||||
|
||||
@@ -162,50 +162,57 @@
|
||||
bottom: calc(100% + 0.5rem);
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: rgba(15, 23, 42, 0.97);
|
||||
background: rgba(10, 10, 15, 0.95);
|
||||
backdrop-filter: blur(16px);
|
||||
-webkit-backdrop-filter: blur(16px);
|
||||
border: 1px solid var(--bg-card-border);
|
||||
border-radius: var(--radius-sm);
|
||||
box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
|
||||
padding: 0.4rem;
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
|
||||
padding: 0.5rem;
|
||||
z-index: 200;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(8px);
|
||||
transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
|
||||
transform: translateY(8px) scale(0.98);
|
||||
transform-origin: bottom center;
|
||||
transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
|
||||
}
|
||||
|
||||
[data-theme="light"] .settings-menu {
|
||||
background: rgba(255, 255, 255, 0.98);
|
||||
box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.1);
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
|
||||
}
|
||||
|
||||
.settings-dropdown.open .settings-menu {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0);
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
|
||||
.settings-menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
padding: 0.6rem 0.75rem;
|
||||
padding: 0.6rem 0.8rem;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: none;
|
||||
color: var(--text-primary);
|
||||
font-family: inherit;
|
||||
font-size: 0.88rem;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
transition: background 0.2s ease;
|
||||
transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
|
||||
width: 100%;
|
||||
margin-bottom: 0.15rem;
|
||||
}
|
||||
|
||||
.settings-menu-item:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.settings-menu-item:hover {
|
||||
background: var(--bg-hover);
|
||||
padding-left: 1.1rem;
|
||||
}
|
||||
|
||||
.settings-menu-item--danger {
|
||||
@@ -214,6 +221,7 @@
|
||||
|
||||
.settings-menu-item--danger:hover {
|
||||
background: rgba(248, 113, 113, 0.1);
|
||||
padding-left: 1.1rem;
|
||||
}
|
||||
|
||||
.settings-menu-divider {
|
||||
|
||||
222
frontend/admin/js/dropdown.js
Normal file
222
frontend/admin/js/dropdown.js
Normal file
@@ -0,0 +1,222 @@
|
||||
// dropdown.js - Premium Custom Dropdowns
|
||||
|
||||
export class CustomSelect {
|
||||
constructor(originalSelect) {
|
||||
if (originalSelect.classList.contains('custom-select-initialized')) return;
|
||||
|
||||
this.originalSelect = originalSelect;
|
||||
this.originalSelect.classList.add('custom-select-initialized');
|
||||
|
||||
// Hide original but keep it accessible for form submissions and JS
|
||||
this.originalSelect.style.display = 'none';
|
||||
|
||||
// Bind methods
|
||||
this.handleTriggerClick = this.handleTriggerClick.bind(this);
|
||||
this.closeAll = this.closeAll.bind(this);
|
||||
this.handleItemClick = this.handleItemClick.bind(this);
|
||||
this.rebuildMenu = this.rebuildMenu.bind(this);
|
||||
|
||||
this.init();
|
||||
|
||||
// Watch for dynamic changes (like when api fetching populates <option> tags)
|
||||
this.observer = new MutationObserver((mutations) => {
|
||||
let shouldRebuild = false;
|
||||
mutations.forEach(mut => {
|
||||
if (mut.type === 'childList') shouldRebuild = true;
|
||||
});
|
||||
if (shouldRebuild) {
|
||||
this.rebuildMenu();
|
||||
}
|
||||
});
|
||||
|
||||
this.observer.observe(this.originalSelect, { childList: true });
|
||||
|
||||
// Listen for external value changes (e.g. form.reset())
|
||||
this.originalSelect.addEventListener('change', () => {
|
||||
this.syncTriggerText();
|
||||
});
|
||||
}
|
||||
|
||||
init() {
|
||||
// Create wrapper
|
||||
this.wrapper = document.createElement('div');
|
||||
this.wrapper.className = 'custom-select-wrapper';
|
||||
|
||||
// Insert wrapper right after the original select
|
||||
this.originalSelect.parentNode.insertBefore(this.wrapper, this.originalSelect.nextSibling);
|
||||
|
||||
// Create trigger button
|
||||
this.trigger = document.createElement('div');
|
||||
this.trigger.className = 'custom-select-trigger';
|
||||
this.trigger.tabIndex = 0; // Make focusable
|
||||
|
||||
this.triggerText = document.createElement('span');
|
||||
this.triggerText.className = 'custom-select-text';
|
||||
|
||||
this.triggerIcon = document.createElement('div');
|
||||
this.triggerIcon.className = 'custom-select-icon';
|
||||
this.triggerIcon.innerHTML = `<svg width="12" height="8" viewBox="0 0 12 8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1.5L6 6.5L11 1.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
||||
|
||||
this.trigger.appendChild(this.triggerText);
|
||||
this.trigger.appendChild(this.triggerIcon);
|
||||
|
||||
// Create menu
|
||||
this.menu = document.createElement('ul');
|
||||
this.menu.className = 'custom-select-menu';
|
||||
|
||||
this.wrapper.appendChild(this.trigger);
|
||||
this.wrapper.appendChild(this.menu);
|
||||
|
||||
this.rebuildMenu();
|
||||
|
||||
// Events
|
||||
this.trigger.addEventListener('click', this.handleTriggerClick);
|
||||
this.trigger.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
this.handleTriggerClick(e);
|
||||
} else if (e.key === 'Escape') {
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Close when clicking outside
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!this.wrapper.contains(e.target)) {
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
rebuildMenu() {
|
||||
this.menu.innerHTML = '';
|
||||
const options = Array.from(this.originalSelect.options);
|
||||
|
||||
if (options.length === 0) {
|
||||
const li = document.createElement('li');
|
||||
li.className = 'custom-select-item disabled';
|
||||
li.textContent = 'Нет опций';
|
||||
this.menu.appendChild(li);
|
||||
} else {
|
||||
options.forEach((option, index) => {
|
||||
const li = document.createElement('li');
|
||||
li.className = 'custom-select-item';
|
||||
li.textContent = option.text;
|
||||
li.dataset.value = option.value;
|
||||
li.dataset.index = index;
|
||||
|
||||
if (option.disabled || option.value === '') {
|
||||
li.classList.add('disabled');
|
||||
if (option.value === '') li.classList.add('placeholder-item');
|
||||
} else {
|
||||
li.addEventListener('click', (e) => this.handleItemClick(e, index));
|
||||
}
|
||||
|
||||
if (option.selected) {
|
||||
li.classList.add('selected');
|
||||
}
|
||||
|
||||
this.menu.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
this.syncTriggerText();
|
||||
}
|
||||
|
||||
syncTriggerText() {
|
||||
const selectedOption = this.originalSelect.options[this.originalSelect.selectedIndex];
|
||||
|
||||
if (selectedOption) {
|
||||
this.triggerText.textContent = selectedOption.text;
|
||||
if (selectedOption.value === '') {
|
||||
this.trigger.classList.add('placeholder-active');
|
||||
} else {
|
||||
this.trigger.classList.remove('placeholder-active');
|
||||
}
|
||||
} else {
|
||||
this.triggerText.textContent = '—';
|
||||
this.trigger.classList.add('placeholder-active');
|
||||
}
|
||||
|
||||
// Disable state sync
|
||||
if (this.originalSelect.disabled) {
|
||||
this.wrapper.classList.add('disabled');
|
||||
this.trigger.tabIndex = -1;
|
||||
} else {
|
||||
this.wrapper.classList.remove('disabled');
|
||||
this.trigger.tabIndex = 0;
|
||||
}
|
||||
|
||||
// Highlight selected in menu
|
||||
const items = this.menu.querySelectorAll('.custom-select-item');
|
||||
items.forEach(item => item.classList.remove('selected'));
|
||||
if (selectedOption && this.originalSelect.selectedIndex >= 0) {
|
||||
const activeItem = this.menu.querySelector(`[data-index="${this.originalSelect.selectedIndex}"]`);
|
||||
if(activeItem) activeItem.classList.add('selected');
|
||||
}
|
||||
}
|
||||
|
||||
handleTriggerClick(e) {
|
||||
if (this.originalSelect.disabled) return;
|
||||
|
||||
const isOpen = this.wrapper.classList.contains('open');
|
||||
this.closeAll(); // Close other open dropdowns
|
||||
|
||||
if (!isOpen) {
|
||||
this.wrapper.classList.add('open');
|
||||
// Scroll selected item into view
|
||||
const selectedItem = this.menu.querySelector('.selected');
|
||||
if (selectedItem) {
|
||||
setTimeout(() => {
|
||||
selectedItem.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeAll() {
|
||||
document.querySelectorAll('.custom-select-wrapper.open').forEach(wrapper => {
|
||||
wrapper.classList.remove('open');
|
||||
});
|
||||
}
|
||||
|
||||
close() {
|
||||
this.wrapper.classList.remove('open');
|
||||
}
|
||||
|
||||
handleItemClick(e, index) {
|
||||
e.stopPropagation();
|
||||
this.originalSelect.selectedIndex = index;
|
||||
|
||||
// Trigger native change event so other scripts (users.js) pick it up
|
||||
this.originalSelect.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
|
||||
this.syncTriggerText();
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Global initializer
|
||||
export function initAllCustomDropdowns(root = document) {
|
||||
const selects = root.querySelectorAll('select:not(.custom-select-initialized)');
|
||||
selects.forEach(select => {
|
||||
new CustomSelect(select);
|
||||
});
|
||||
}
|
||||
|
||||
// Observe DOM for automatically picking up new select elements
|
||||
export function startDropdownAutoObserver() {
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
let shouldInit = false;
|
||||
mutations.forEach(mut => {
|
||||
if (mut.addedNodes.length > 0) {
|
||||
shouldInit = true;
|
||||
}
|
||||
});
|
||||
if (shouldInit) {
|
||||
initAllCustomDropdowns(document.body);
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
}
|
||||
@@ -5,6 +5,18 @@ if (!['localhost', '127.0.0.1'].includes(window.location.hostname)) {
|
||||
|
||||
import { isAuthenticatedAsAdmin } from './api.js';
|
||||
import { applyRippleEffect, closeAllDropdownsOnOutsideClick } from './utils.js';
|
||||
import { startDropdownAutoObserver, initAllCustomDropdowns } from './dropdown.js';
|
||||
|
||||
// Auth check
|
||||
if (!isAuthenticatedAsAdmin()) {
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
// Global initialization for Custom Selects
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initAllCustomDropdowns(document.body);
|
||||
startDropdownAutoObserver();
|
||||
});
|
||||
|
||||
import { initUsers } from './views/users.js';
|
||||
import { initGroups } from './views/groups.js';
|
||||
|
||||
@@ -24,7 +24,9 @@ export function renderEquipmentCheckboxes(equipments, containerId, textId, check
|
||||
const isChecked = checkedIds.includes(eq.id) ? 'checked' : '';
|
||||
return `
|
||||
<label class="checkbox-item">
|
||||
<input type="checkbox" value="${eq.id}" ${isChecked}> ${escapeHtml(eq.name)}
|
||||
<input type="checkbox" value="${eq.id}" ${isChecked}>
|
||||
<span class="checkmark"></span>
|
||||
<span class="checkbox-label">${escapeHtml(eq.name)}</span>
|
||||
</label>
|
||||
`}).join('');
|
||||
updateSelectText(containerId, textId);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Settings page main.js
|
||||
import { startDropdownAutoObserver, initAllCustomDropdowns } from '../../js/dropdown.js';
|
||||
|
||||
// Auth check
|
||||
const token = localStorage.getItem('token');
|
||||
@@ -7,6 +8,12 @@ if (!token || role !== 'ADMIN') {
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
// Global initialization for Custom Selects
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initAllCustomDropdowns(document.body);
|
||||
startDropdownAutoObserver();
|
||||
});
|
||||
|
||||
// Configuration
|
||||
const ROUTES = {
|
||||
general: { title: 'Общие настройки', file: 'views/general.html' },
|
||||
|
||||
@@ -2,29 +2,31 @@
|
||||
'use strict';
|
||||
|
||||
// --- OpenTelemetry Frontend Instrumentation ---
|
||||
// Загружаем OTel Web SDK динамически через esm.sh, чтобы не ломать старый Vanilla JS (без type="module")
|
||||
import('https://esm.sh/@opentelemetry/sdk-trace-web').then(async ({ WebTracerProvider, BatchSpanProcessor }) => {
|
||||
const { OTLPTraceExporter } = await import('https://esm.sh/@opentelemetry/exporter-trace-otlp-http');
|
||||
const { getWebAutoInstrumentations } = await import('https://esm.sh/@opentelemetry/auto-instrumentations-web');
|
||||
const { registerInstrumentations } = await import('https://esm.sh/@opentelemetry/instrumentation');
|
||||
const { Resource } = await import('https://esm.sh/@opentelemetry/resources');
|
||||
// Загружаем OTel только на продакшене (не на localhost)
|
||||
if (!['localhost', '127.0.0.1'].includes(window.location.hostname)) {
|
||||
import('https://esm.sh/@opentelemetry/sdk-trace-web').then(async ({ WebTracerProvider, BatchSpanProcessor }) => {
|
||||
const { OTLPTraceExporter } = await import('https://esm.sh/@opentelemetry/exporter-trace-otlp-http');
|
||||
const { getWebAutoInstrumentations } = await import('https://esm.sh/@opentelemetry/auto-instrumentations-web');
|
||||
const { registerInstrumentations } = await import('https://esm.sh/@opentelemetry/instrumentation');
|
||||
const { Resource } = await import('https://esm.sh/@opentelemetry/resources');
|
||||
|
||||
const exporter = new OTLPTraceExporter({
|
||||
url: window.location.origin + '/otel/v1/traces' // Трафик пойдет через ваш Caddy Proxy
|
||||
});
|
||||
|
||||
const provider = new WebTracerProvider({
|
||||
resource: new Resource({ 'service.name': 'magistr-frontend' }),
|
||||
});
|
||||
|
||||
provider.addSpanProcessor(new BatchSpanProcessor(exporter));
|
||||
provider.register();
|
||||
const exporter = new OTLPTraceExporter({
|
||||
url: window.location.origin + '/otel/v1/traces'
|
||||
});
|
||||
|
||||
const provider = new WebTracerProvider({
|
||||
resource: new Resource({ 'service.name': 'magistr-frontend' }),
|
||||
});
|
||||
|
||||
provider.addSpanProcessor(new BatchSpanProcessor(exporter));
|
||||
provider.register();
|
||||
|
||||
registerInstrumentations({
|
||||
instrumentations: [getWebAutoInstrumentations()]
|
||||
});
|
||||
console.log("SigNoz (OpenTelemetry) инициализирован во фронтенде.");
|
||||
}).catch(e => console.error("Ошибка загрузки OTel:", e));
|
||||
registerInstrumentations({
|
||||
instrumentations: [getWebAutoInstrumentations()]
|
||||
});
|
||||
console.log("SigNoz (OpenTelemetry) инициализирован во фронтенде.");
|
||||
}).catch(e => console.error("Ошибка загрузки OTel:", e));
|
||||
}
|
||||
// ----------------------------------------------
|
||||
|
||||
const form = document.getElementById('login-form');
|
||||
|
||||
Reference in New Issue
Block a user