| Server IP : 38.190.208.107 / Your IP : 216.73.217.13 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/themes/woodmart/js/scripts/global/ |
Upload File : |
woodmartThemeModule.beforeSearchcontent = function() {
var init = function() {
var forms = document.querySelectorAll('form.searchform');
var isUsingKeyboard = false;
document.addEventListener('keydown', function(e) {
if ('Tab' === e.key || (e.shiftKey && 'Tab' === e.key)) {
isUsingKeyboard = true;
}
});
document.addEventListener('mousedown', function() {
isUsingKeyboard = false;
});
forms.forEach(function(form) {
var resultsNode = form.parentNode.querySelector('.wd-dropdown-results');
if (!resultsNode) {
return;
}
var input = form.querySelector('[type="text"]');
var searchCatBtn = form.querySelector('.wd-search-cat-btn');
input.addEventListener('focus', openContent);
input.addEventListener('keydown', openContent);
if (searchCatBtn) {
searchCatBtn.addEventListener('click', closeContent);
}
[form, resultsNode].forEach(function(el) {
el.addEventListener('focusout', function() {
setTimeout(function() {
if (isUsingKeyboard && !form.contains(document.activeElement) && !resultsNode.contains(document.activeElement)) {
closeResults(form, resultsNode);
}
}, 10);
});
});
});
// Add event listener to close content when clicking outside.
document.addEventListener('click', handleOutsideClick, { passive: true });
}
var handleOutsideClick = function (e) {
var clickedForm = e.target.closest('form.searchform');
document.querySelectorAll('.wd-dropdown-results.wd-opened').forEach(function(openedResults) {
var formWrapper = openedResults.closest('.wd-search-form, .wd-search-dropdown');
if (!formWrapper) {
return;
}
var parentForm = formWrapper.querySelector('form.searchform');
if (!clickedForm || parentForm !== clickedForm) {
closeResults(parentForm, openedResults);
}
});
}
var closeResults = function (form, resultsNode) {
resultsNode.classList.remove('wd-opened');
backgroundOverlay(form, 'close');
setTimeout(function() {
form.parentNode.classList.remove('wd-searched');
}, 400);
}
var closeContent = function (e) {
var form = this.closest('form');
var resultsNode = form.parentNode.querySelector('.wd-dropdown-results');
closeResults(form, resultsNode);
}
var openContent = function (e) {
var input = this;
var form = input.closest('form');
var resultsNode = form.parentNode.querySelector('.wd-dropdown-results');
var key = e.keyCode || e.charCode;
if ('Tab' === e.key || (e.shiftKey && 'Tab' === e.key)) {
return;
}
if (0 === input.value.length && (8 === key || 46 === key)) {
closeResults(form, resultsNode);
return;
}
input.dispatchEvent(new Event('wdOpenBeforeSearchContent'));
setTimeout(function() {
var showContent = true;
var searchHistory = resultsNode.querySelector('.wd-search-history');
var popularRequests = resultsNode.querySelector('.wd-search-requests');
var searchContent = resultsNode.querySelector('.wd-search-area');
if (
(!searchHistory || 0 === searchHistory.childElementCount) &&
(!popularRequests || 0 === popularRequests.childElementCount) &&
(!searchContent || (0 === searchContent.childElementCount && 0 === searchContent.textContent.length))
) {
showContent = false;
}
if (showContent) {
resultsNode.classList.add('wd-opened');
backgroundOverlay(form, 'open');
}
}, 100);
}
var backgroundOverlay = function(form, action) {
if (! form.closest('.wd-search-form.wd-display-form.wd-with-overlay')) {
return;
}
jQuery('.wd-close-side').trigger('wdCloseSideAction', [action === 'open' ? 'show' : 'hide', 'click']);
}
init();
}
window.addEventListener('load',function() {
woodmartThemeModule.beforeSearchcontent();
});