fix: rebuild mockup with Windows-safe filenames and correct CSS paths

This commit is contained in:
2026-04-09 14:13:25 +05:00
parent 2e9e7ace4b
commit 21c0520b0e
44 changed files with 638 additions and 6376 deletions
+123
View File
@@ -0,0 +1,123 @@
/**
* БИТ.WMS Child Theme — js/ajax-filter.js
*
* Handles filter button clicks and "Load more" for the content feed section.
* Communicates with the WordPress AJAX handler (bitwms_ajax_filter_handler).
*
* Global: bitwmsAjax { url: string, nonce: string }
*/
( function () {
'use strict';
document.addEventListener( 'DOMContentLoaded', function () {
var filterBar = document.querySelector( '.filter-bar' );
var contentGrid = document.getElementById( 'content-grid' );
var loadMoreBtn = document.getElementById( 'load-more-btn' );
if ( ! filterBar || ! contentGrid ) {
return;
}
var currentFilter = 'all';
var currentPage = 1;
var isLoading = false;
// ---------------------------------------------------------------
// Filter button click
// ---------------------------------------------------------------
filterBar.addEventListener( 'click', function ( e ) {
var btn = e.target.closest( '.filter-bar__btn' );
if ( ! btn ) return;
var filter = btn.getAttribute( 'data-filter' );
if ( filter === currentFilter ) return;
// Update active state.
filterBar.querySelectorAll( '.filter-bar__btn' ).forEach( function ( b ) {
b.classList.remove( 'filter-bar__btn--active' );
b.setAttribute( 'aria-selected', 'false' );
} );
btn.classList.add( 'filter-bar__btn--active' );
btn.setAttribute( 'aria-selected', 'true' );
currentFilter = filter;
currentPage = 1;
loadContent( false );
} );
// ---------------------------------------------------------------
// Load more button click
// ---------------------------------------------------------------
if ( loadMoreBtn ) {
loadMoreBtn.addEventListener( 'click', function () {
if ( isLoading ) return;
currentPage += 1;
loadContent( true );
} );
}
// ---------------------------------------------------------------
// loadContent( append )
// append === false: replace grid content
// append === true: append to existing grid content
// ---------------------------------------------------------------
function loadContent( append ) {
if ( isLoading ) return;
isLoading = true;
if ( loadMoreBtn ) {
loadMoreBtn.disabled = true;
loadMoreBtn.textContent = loadMoreBtn.getAttribute( 'data-loading' ) || 'Загрузка…';
}
var formData = new FormData();
formData.append( 'action', 'bitwms_filter' );
formData.append( 'nonce', bitwmsAjax.nonce );
formData.append( 'post_type', currentFilter );
formData.append( 'page', currentPage );
fetch( bitwmsAjax.url, {
method: 'POST',
body: formData,
} )
.then( function ( response ) {
return response.json();
} )
.then( function ( data ) {
if ( ! data.success ) return;
var html = data.data.html;
var hasMore = data.data.has_more;
if ( append ) {
contentGrid.insertAdjacentHTML( 'beforeend', html );
} else {
contentGrid.innerHTML = html || '<p>Материалы не найдены.</p>';
}
// Show/hide load-more button.
if ( loadMoreBtn ) {
if ( hasMore ) {
loadMoreBtn.style.display = '';
loadMoreBtn.disabled = false;
loadMoreBtn.textContent = 'Загрузить ещё';
} else {
loadMoreBtn.style.display = 'none';
}
}
} )
.catch( function ( err ) {
console.error( 'bitwms filter error:', err );
if ( loadMoreBtn ) {
loadMoreBtn.disabled = false;
loadMoreBtn.textContent = 'Загрузить ещё';
}
} )
.finally( function () {
isLoading = false;
} );
}
} );
} )();
+38
View File
@@ -0,0 +1,38 @@
document.addEventListener('DOMContentLoaded', function () {
var modal = document.getElementById('gated-modal');
if (!modal) return;
var overlay = modal.querySelector('.gated-modal__overlay');
var closeBtn = modal.querySelector('.gated-modal__close');
// Open modal on [data-gated] click
document.addEventListener('click', function (e) {
var trigger = e.target.closest('[data-gated]');
if (!trigger) return;
e.preventDefault();
var materialId = trigger.dataset.gated;
var downloadUrl = trigger.dataset.downloadUrl;
// Set hidden field + store download URL
var hiddenField = modal.querySelector('input[name="material-id"]');
if (hiddenField) hiddenField.value = materialId;
modal.dataset.downloadUrl = downloadUrl || '';
modal.classList.add('gated-modal--open');
document.body.style.overflow = 'hidden';
});
function closeModal() {
modal.classList.remove('gated-modal--open');
document.body.style.overflow = '';
}
if (closeBtn) closeBtn.addEventListener('click', closeModal);
if (overlay) overlay.addEventListener('click', closeModal);
// After CF7 successful submit — trigger download
document.addEventListener('wpcf7mailsent', function () {
if (modal.classList.contains('gated-modal--open') && modal.dataset.downloadUrl) {
window.open(modal.dataset.downloadUrl, '_blank');
closeModal();
}
});
});
+1
View File
File diff suppressed because one or more lines are too long
+71
View File
@@ -0,0 +1,71 @@
/**
* БИТ.WMS Child Theme — js/sidebar-nav.js
*
* Sidebar navigation toggle behaviour.
* Placeholder for Task 3 — full sidebar implementation will extend this file.
*
* Behaviour:
* - Clicking the hamburger button toggles `.sidebar-nav--open` on the sidebar.
* - Simultaneously toggles `.sidebar-overlay` on <body> to show the dim overlay.
* - Clicking the overlay closes the sidebar.
*/
document.addEventListener( 'DOMContentLoaded', function () {
'use strict';
// Guard: abort if there is no sidebar on this page.
var sidebar = document.querySelector( '.sidebar-nav' );
if ( ! sidebar ) {
return;
}
var hamburger = document.querySelector( '.sidebar-nav__toggle' );
var body = document.body;
/**
* Open the sidebar and show the overlay.
*/
function openSidebar() {
sidebar.classList.add( 'sidebar-nav--open' );
body.classList.add( 'sidebar-overlay' );
}
/**
* Close the sidebar and hide the overlay.
*/
function closeSidebar() {
sidebar.classList.remove( 'sidebar-nav--open' );
body.classList.remove( 'sidebar-overlay' );
}
/**
* Toggle sidebar state.
*/
function toggleSidebar() {
if ( sidebar.classList.contains( 'sidebar-nav--open' ) ) {
closeSidebar();
} else {
openSidebar();
}
}
// Attach toggle to hamburger button (if present).
if ( hamburger ) {
hamburger.addEventListener( 'click', function ( e ) {
e.preventDefault();
toggleSidebar();
} );
}
// Close sidebar when the overlay (body::after pseudo-element area) is clicked.
// We detect clicks on <body> that land outside the sidebar itself.
body.addEventListener( 'click', function ( e ) {
if (
body.classList.contains( 'sidebar-overlay' ) &&
! sidebar.contains( e.target ) &&
( ! hamburger || ! hamburger.contains( e.target ) )
) {
closeSidebar();
}
} );
} );