MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/mpita.artinside.com.br/themes/web/assets/js/modules/topsearch.js
CNVS.TopSearch = function() {
	var __core = SEMICOLON.Core;

	return {
		init: function(selector) {
			selector = __core.getSelector( selector, false );
			if( selector.length < 1 ){
				return true;
			}

			var searchForm = document.querySelector('.top-search-form');

			if( !searchForm ) {
				return true;
			}

			searchForm.closest('.header-row').classList.add( 'top-search-parent' );

			var topSearchParent = document.querySelector('.top-search-parent'),
				timeout;

			selector[0].onclick = function(e) {
				e.stopPropagation();
				e.preventDefault();

				clearTimeout( timeout );

				__core.getVars.elBody.classList.toggle('top-search-open');
				document.getElementById('top-cart')?.classList.remove('top-cart-open');

				__core.getVars.recalls.menureset();

				if( __core.getVars.elBody.classList.contains('top-search-open') ) {
					topSearchParent.classList.add('position-relative');
				} else {
					timeout = setTimeout( function() {
						topSearchParent.classList.remove('position-relative');
					}, 500);
				}

				__core.getVars.elBody.classList.remove("primary-menu-open");
				__core.getVars.elPageMenu && __core.getVars.elPageMenu.classList.remove('page-menu-open');

				if (__core.getVars.elBody.classList.contains('top-search-open')){
					searchForm.querySelector('input').focus();
				}
			};

			document.addEventListener( 'click', function(e) {
				if (!e.target.closest('.top-search-form')) {
					__core.getVars.elBody.classList.remove('top-search-open');
					timeout = setTimeout( function() {
						topSearchParent.classList.remove('position-relative');
					}, 500);
				}
			}, false);
		}
	};
}();