1 2; /* Start:"a:4:{s:4:"full";s:83:"/local/templates/wedev/components/bitrix/menu/main_catalog/script.js?17841765475816";s:6:"source";s:68:"/local/templates/wedev/components/bitrix/menu/main_catalog/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 3var grid = { 4 "158": "grid-cols-6", 5 "300": "grid-cols-2", 6 "252": "grid-cols-6", 7 "99": "grid-cols-6", 8 "99916": "grid-cols-4", 9 "175": "grid-cols-4", 10 11 "2338": "grid-cols-3", 12 13 "358": "grid-cols-6" 14}; 15var mobileGrid = { 16 "158": "grid-cols-2", 17 "300": "grid-cols-1", 18 "252": "grid-cols-2", 19 "99": "grid-cols-2", 20 "99916": "grid-cols-2", 21 "175": "grid-cols-2", 22 23 "2338": "grid-cols-2", 24 "358": "grid-cols-2" 25}; 26 27function toggleSubMenu(event, anchor) { 28 event.preventDefault(); 29 30 const parentName = anchor.getAttribute('data-name'); 31 const parentTotal = anchor.getAttribute('parent-total'); 32 const allSubmenus = document.querySelectorAll('.submenu'); 33 const targetSubmenus = document.querySelectorAll(`[data-section="${parentTotal}"] .submenu[data-parent="${parentName}"]`); 34 // debugger; 35 // const targetSubmenus = document.querySelectorAll(`.submenu[data-parent="${parentName}"]`); 36 const isHidden = [...targetSubmenus].every(el => 37 el.classList.contains('hidden') || el.style.display === 'none' 38 ); 39 anchor.style.display = "none"; 40 41 allSubmenus.forEach(sm => { 42 sm.classList.add('hidden'); 43 sm.style.display = 'none'; 44 }); 45 46 document.querySelectorAll(`[parent-total="${parentTotal}"]`).forEach(p => { 47 p.classList.add('hidden'); 48 p.style.display = 'none'; 49 }); 50 51 if (isHidden) { 52 targetSubmenus.forEach(sm => { 53 sm.classList.remove('hidden'); 54 sm.style.display = ''; 55 }); 56 57 58 } 59 60 const sectionDiv = anchor.closest('div[data-section]'); 61 if (sectionDiv) { 62 debugger; 63 sectionDiv.classList.forEach(cls => { 64 if (cls.startsWith('grid-cols-')) sectionDiv.classList.remove(cls); 65 }); 66 67 if (targetSubmenus.length < 3) { 68 if (window.IsMobile720()) { 69 sectionDiv.classList.add('grid-cols-1'); 70 } 71 else { 72 sectionDiv.classList.add('grid-cols-2'); 73 } 74 } 75 else if (parentName == "319" && parentTotal == "99") { 76 sectionDiv.classList.add( 77 'max-[720px]:grid-cols-2', 78 'max-[1280px]:grid-cols-3', 79 'grid-cols-3' 80 ); 81 } 82 else { 83 sectionDiv.classList.add( 84 'max-[720px]:grid-cols-2', 85 'max-[1280px]:grid-cols-4', 86 'grid-cols-4' 87 ); 88 } 89 90 sectionDiv.classList.add('subchid-grid'); 91 } 92 93 if (!window.IsMobile()) 94 $("#mobileCardHeader").removeClass("hidden-important"); 95} 96 97 98 99function setupGrids() { 100 const sections = document.querySelectorAll('[data-section]'); 101 102 sections.forEach(section => { 103 const sectionName = section.getAttribute("data-section"); 104 105 const sourceGrid = window.IsMobile720() ? mobileGrid : grid; 106 const defaultGrid = window.IsMobile720() ? "grid-cols-2" : "grid-cols-6"; 107 currentGrid = sourceGrid.hasOwnProperty(sectionName) ? sourceGrid[sectionName] : defaultGrid; 108 109 const cards = section.querySelectorAll('.group'); 110 section.classList.remove('grid-cols-2', 'grid-cols-4', 'grid-cols-6', 'grid-cols-3'); 111 section.style.gridTemplateColumns = ''; 112 113 section.style.display = ''; 114 section.classList.add(currentGrid); 115 116 cards.forEach(card => { 117 const wrapper = card.querySelector('.image-wrapper'); 118 const img = card.querySelector('img'); 119 120 if (wrapper && img) { 121 setAspectRatio(wrapper, img); 122 if (!img.complete) { 123 } 124 else{ 125 img.addEventListener('load', () => setAspectRatio(wrapper, img)); 126 } 127 } 128 }); 129 130 function setAspectRatio(wrapper, img) {
131 const naturalWidth = img.naturalWidth; 132 const naturalHeight = img.naturalHeight; 133 if (naturalWidth && naturalHeight || true) { 134 const sectionParent = img.closest('[data-section]'); 135 var link = img.closest('a'); 136 if (!link) { 137 138 link = img.closest('button'); 139 } 140 141 if ($(link).attr("parent-total") == "2338" || $(link).attr("parent-total") == "99916" || $(link).attr("parent-total") == "300" || $(link).attr("parent-total") == "175") { 142 wrapper.style.width = '100%'; 143 wrapper.style.aspectRatio = `253 / 176`; 144 return; 145 } 146 147 if (sectionParent && !sectionParent.classList.contains('grid-cols-2') && link && !link.classList.contains("submenu")) { 148 img.style.aspectRatio = `1 / 1`; 149 } 150 151 } 152 } 153 }); 154} 155 156document.addEventListener('DOMContentLoaded', () => { 157 $('#mobileCardBackBtn').on('click', function () { 158 159 $('.subchid-grid').each(function () { 160 const sectionName = $(this).attr('data-section'); 161 162 const sourceGrid = window.IsMobile720() ? mobileGrid : grid; 163 const defaultGrid = window.IsMobile720() ? "grid-cols-2" : "grid-cols-6"; 164 var currentGrid = sourceGrid.hasOwnProperty(sectionName) ? sourceGrid[sectionName] : defaultGrid; 165 166 $(this).removeClass( 167 'max-[720px]:grid-cols-2 max-[1280px]:grid-cols-4 grid-cols-1 grid-cols-6' 168 ); 169 170 171 $(this).removeClass("grid-cols-1"); 172 $(this).removeClass("grid-cols-2"); 173 $(this).removeClass("grid-cols-3"); 174 $(this).addClass(currentGrid); 175 $(this).removeClass('subchid-grid'); 176 }); 177 178 }); 179 180 setupGrids(); 181 window.addEventListener("resize", setupGrids); 182}); 183 184 185/* End */ 186;; /* /local/templates/wedev/components/bitrix/menu/main_catalog/script.js?17841765475816*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.