contacts.js 9.27 KB
(()=>{"use strict";class t{constructor(t,e){this._selectors=t,this._classes=e}initTabs(){this._getElements(),this._setAttributes(),this._setListeners(),this._showByIndex(0)}_getElements(){this._section=document.querySelector(this._selectors.SECTION),this._tabRow=this._section.querySelector(this._selectors.TAB_ROW),this._headers=this._tabRow.querySelectorAll(this._selectors.TAB_BUTTON),this._contents=this._tabRow.querySelectorAll(this._selectors.TAB_CONTENT),this._activeTab=this._tabRow.querySelector(this._selectors.TAB_BTN_ACTIVE),this._activeTabContent=this._tabRow.querySelector(this._selectors.TAB_CONTENT_ACTIVE)}_setAttributes(){this._headers.forEach(((t,e)=>{t.dataset.index=e,t.setAttribute("role","tab"),this._contents[e].setAttribute("role","tab-content"),this._contents[e].dataset.index=e}))}_setListeners(){this._tabRow.addEventListener("click",(t=>{const e=t.target.closest(this._selectors.TAB_BUTTON);e&&(t.preventDefault(),this._setActiveTab(e))}))}_setActiveTab(t){t!==this._activeTab&&(this._toggleClass(!1),this._activeTab=t,this._activeTabContent=this._contents[t.dataset.index],this._toggleClass(!0))}setActiveTab(t){const e=this._headers[t];this._setActiveTab(e)}_toggleClass(t){this._activeTab&&this._activeTab.classList.toggle(this._classes.TAB_BTN_ACTIVE,t),this._activeTabContent&&this._activeTabContent.classList.toggle(this._classes.TAB_CONTENT_ACTIVE,t)}_showByIndex(t){this._setActiveTab(this._headers[t])}}const e={TAB_ROW:".maps-tabs",TAB_BUTTON:".maps-tabs__item",TAB_CONTENT:".maps-tabs__section",SECTION:".maps-contacts",TAB_BTN_ACTIVE:".maps-tabs__item_active",TAB_CONTENT_ACTIVE:".maps-tabs__section_active"},s={TAB_BTN_ACTIVE:"maps-tabs__item_active",TAB_CONTENT_ACTIVE:"maps-tabs__section_active"},o={scroll(){document.body.style.overflow=""},unscroll(){document.body.style.overflow="hidden"}};class i{constructor(t){this._popup=t,this.openPopup=this.openPopup.bind(this),this.closePopup=this.closePopup.bind(this),this._setEscHandler=this._setEscHandler.bind(this),this.setEventListeners=this.setEventListeners.bind(this)}openPopup(t){t&&(this._subject=t),this._popup.classList.add("popup-form_visible"),document.body.style.overflow="hidden",o.unscroll(),document.addEventListener("keydown",this._setEscHandler)}closePopup(){this._popup.classList.remove("popup-form_visible"),o.scroll(),document.removeEventListener("keydown",this._setEscHandler)}_setEscHandler(t){"Escape"===t.key&&this.closePopup()}setEventListeners(){this._popup.addEventListener("mousedown",(t=>{(t.target.classList.contains("popup-form_visible")||t.target.closest(".popup-form__close"))&&this.closePopup()}))}}class a extends i{constructor(t,e){super(t),this._form=t.querySelector(".form"),this._onSubmit=e,this._inputList=this._form.querySelectorAll(".form__item"),this._popupButton=this._form.querySelector(".form__btn"),this._inputValues={},this._hiddenInput=this._form.querySelector(".form__fields_input-hidden")}openPopup(t){super.openPopup(t),this._hiddenInput.value=this._subject,console.log(this._hiddenInput.value)}closePopup(){this._form.reset(),super.closePopup()}_getInputValues(){return this._inputList.forEach((t=>{this._inputValues[t.name]=t.value})),this._inputValues}setEventListeners(){super.setEventListeners(),this._form.addEventListener("submit",(t=>{t.preventDefault()}))}}const n={WRAPPER:document.querySelector(".wrapper"),CANVAS:document.querySelector(".canvas")},c=.003,l=20,r=0,h=0,d=l,u={MIN:-180,MAX:180},_={MIN:-90,MAX:90},p="#202020",m="#FBFBFB",b="#A42E2C",v="#670E0E",f="#511112",y="#340D0F",g={rotation:0,time:0,ctx:void 0,dots:[],background:m,KKK:0,WIDTH:0,HEIGHT:0,colorFill:b,colorStroke:v};try{S(),requestAnimationFrame(S),function(){for(let t=0;t<500;t++)g.dots.push(I())}(),function(){const t=n.CANVAS.getContext("2d");t.fillRect(0,0,n.CANVAS.width,n.CANVAS.height),g.ctx=t}(),C(),C()}catch(t){}function T(t){t?(g.background=m,g.colorFill=f,g.colorStroke=y):(g.background=p,g.colorFill=b,g.colorStroke=v)}function A(t){const e=l/t.z,s=g.WIDTH/2,o=g.HEIGHT/2,i=g.KKK*e*t.x+s,a=-g.KKK*e*t.y+o;t.xDisplay=i,t.yDisplay=a,g.ctx.beginPath(),g.ctx.ellipse(i,a,2,2,0,0,2*Math.PI),g.ctx.fill()}function E(t){t.links.forEach((e=>{g.ctx.beginPath(),g.ctx.moveTo(t.xDisplay,t.yDisplay),g.ctx.lineTo(e.xDisplay,e.yDisplay),g.ctx.stroke()}))}function C(){S(),g.time++,g.dots.forEach((t=>{t.a=t.a+t.da,t.b=t.b+t.db,function(t){t.x=r+1*Math.sin(-g.rotation-g.time/1e3+t.a)*Math.cos(t.b),t.y=h+1*Math.sin(t.b),t.z=d-1*Math.cos(t.b)*Math.cos(-g.rotation-g.time/1e3+t.a)}(t)})),g.dots.sort(((t,e)=>e.z-t.z)),g.dots.forEach((t=>{t.links=[],g.dots.forEach((e=>{var s,o;s=t,o=e,Math.sqrt(Math.pow(s.x-o.x,2)+Math.pow(s.y-o.y,2)+Math.pow(s.z-o.z,2))<.15&&t.links.push(e)}))})),g.ctx.fillStyle=g.background,g.ctx.fillRect(0,0,g.WIDTH,g.HEIGHT),g.ctx.fillStyle=g.colorFill,g.ctx.strokeStyle=g.colorStroke,g.dots.forEach(E),g.dots.forEach(A),requestAnimationFrame(C)}function I(...t){return t.length>0?{a:t[0],b:t[1],da:0,db:0,xDisplay:0,yDisplay:0,links:[]}:{a:(u.MAX-u.MIN)*Math.random()+u.MIN,b:(_.MAX-_.MIN)*Math.random()+_.MIN,da:c*Math.random()-.0015,db:c*Math.random()-.0015,links:[]}}function S(){const t=n.CANVAS.clientWidth,e=n.CANVAS.clientHeight,s=Math.min(t,e);g.KKK=s/3,g.WIDTH=t,g.HEIGHT=e,n.CANVAS.width=t,n.CANVAS.height=e}const k=document.querySelectorAll(".js_toggle_input");function L(){document.body.classList.add("light-mode"),T(!0),console.log("светлая тема")}function x(){document.body.classList.remove("light-mode"),T(!1),console.log("тёмная тема")}!function(){try{const o=new t(e,s);o.initTabs();"1"===new URL(window.location.href).searchParams.get("tab")&&o.setActiveTab(1)}catch(t){}"dark"===localStorage.getItem("theme")?(k.forEach((t=>{t.checked=!1})),x()):(k.forEach((t=>{t.checked=!0})),L()),k.forEach((t=>{t.addEventListener("change",(()=>{t.checked?(k.forEach((t=>{t.checked=!0})),localStorage.setItem("theme","light"),L()):(k.forEach((t=>{t.checked=!1})),localStorage.setItem("theme","dark"),x())}))})),function(){try{const t=document.querySelector(".js_header_btn"),e=document.querySelector(".js_menu"),s=document.querySelector(".js_menu_overlay"),i=document.querySelector(".js_menu_exit");e.style.display="",t.addEventListener("click",(()=>{s.classList.add("active"),e.classList.add("active-half"),i.classList.add("active"),o.unscroll()})),i.addEventListener("click",(()=>{a()})),s.addEventListener("click",(()=>{a()}));const a=()=>{s.classList.remove("active"),e.classList.remove("active-half","active-full"),i.classList.remove("active"),o.scroll()}}catch(t){}}(),function(){try{const t=document.querySelector("#popupform"),e=new a(t,(()=>{e.closePopup()}));e.setEventListeners(),document.querySelectorAll(".popup-form-open").forEach((t=>{t.addEventListener("click",(t=>{const s=t.target.dataset.subject;e.openPopup(s)}))}))}catch(t){console.log(t)}}(),ymaps.ready((function(){const t=new ymaps.Map("mapOffice",{center:[57.584237,34.558035],zoom:5,controls:[]},{}),e=new ymaps.Placemark([55.655867,37.555407],{balloonContentHeader:'<div class="balloon-content"><h3 class="h3 balloon-title">Москва</h3> <div class="text balloon-text"><p>117246, г. Москва, Научный проезд, 14А, стр. 1, БЦ SMART-PARK</p></div> </div>',balloonContentBody:"",balloonContentFooter:"",hintContent:"Москва"},{iconLayout:"default#image",iconImageHref:"/images/marker_office.svg",iconImageSize:[50,50],iconImageOffset:[-25,-25]}),s=new ymaps.Placemark([59.923419,30.362895],{balloonContentHeader:'<div class="balloon-content"><h3 class="h3 balloon-title">Санкт-Петербург</h3> <div class="text balloon-text"><p>191040, г. Санкт-Петербург, Лиговский проспект, 50 к. 12, офис 23</p></div> </div>',balloonContentBody:"",balloonContentFooter:"",hintContent:"Санкт-Петербург"},{iconLayout:"default#image",iconImageHref:"/images/marker_office.svg",iconImageSize:[52,74],iconImageOffset:[-26,-57]});/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&t.behaviors.disable("drag"),t.behaviors.disable("scrollZoom"),t.geoObjects.add(e).add(s)})),ymaps.ready((function(){const t=new ymaps.Map("mapWarehouses",{center:[55.570397,37.475477],zoom:9,controls:[]},{}),e=new ymaps.Placemark([55.446332,37.26027],{balloonContentHeader:'<div class="balloon-content"><h3 class="h3 balloon-title">Склад ООО «ИЛС»</h3> <div class="text balloon-text"><p>МО, Подольский район, Краснопахорское с/п, л-во Малинское, квартал 56</p></div> </div>',balloonContentBody:"",balloonContentFooter:"",hintContent:"Склад ООО «ИЛС»"},{iconLayout:"default#image",iconImageHref:"/images/marker_object.svg",iconImageSize:[50,50],iconImageOffset:[-25,-25]}),s=new ymaps.Placemark([55.666944,37.705104],{balloonContentHeader:'<div class="balloon-content"><h3 class="h3 balloon-title">Склад ООО «Деловая Лига»</h3> <div class="text balloon-text"><p>г. Москва, ул. Шоссейная 90с57</p></div> </div>',balloonContentBody:"",balloonContentFooter:"",hintContent:"Склад ООО «Деловая Лига»"},{iconLayout:"default#image",iconImageHref:"/images/marker_object.svg",iconImageSize:[52,74],iconImageOffset:[-26,-57]});t.behaviors.disable("scrollZoom"),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&t.behaviors.disable("drag"),t.geoObjects.add(e).add(s)}))}()})();