123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- window.addEventListener("load", function(event) {
- // Main SLider
-
- // Set height price block
-
- let priceBlockWrapper = document.querySelector('.price-block__slider');
-
- if(document.querySelector('.price-block__list--slider')) {
- let priceListHeight = document.querySelector('.price-block__list--slider').offsetHeight;
- priceBlockWrapper.style.height = priceListHeight + "px";
- }
-
- // Set height price block
-
- let allButtonsWrapper = document.querySelectorAll('.js-arrow');
-
- allButtonsWrapper.forEach(itemWrapper => {
- let wrapper = itemWrapper.closest('.slider');
- let allButtons = wrapper.querySelectorAll('.js-button-slider');
- let allItems = wrapper.querySelectorAll('.js-item-slider');
- let arrowNext = wrapper.querySelector('.js-arrow-slider-next');
- let arrowPrev = wrapper.querySelector('.js-arrow-slider-prev');
-
- if(arrowNext) {
- arrowNext.addEventListener('click', function(){
- let arctiveButton = wrapper.querySelector('.js-button-slider.active');
- if(arctiveButton.nextElementSibling.classList.contains('js-button-slider')) {
- arctiveButton.nextElementSibling.click();
- }else {
- wrapper.querySelector(".js-button-slider[data-index='1']").click();
- }
- });
-
- arrowPrev.addEventListener('click', function(){
- let arctiveButton = wrapper.querySelector('.js-button-slider.active');
- if(arctiveButton.previousElementSibling != null) {
- arctiveButton.previousElementSibling.click();
- }else {
- wrapper.querySelector(`.js-button-slider[data-index='${allButtons.length}']`).click();
- }
- });
- }
-
- allButtons.forEach(itemButton => {
- itemButton.addEventListener('click', function(){
- let dataIndex = itemButton.dataset.index;
-
- allButtons.forEach(item => {
- item.classList.remove('active');
- });
-
- allItems.forEach(item => {
- item.classList.remove('show');
- });
-
- this.classList.add('active');
-
- let activeElem = wrapper.querySelector(`.js-item-slider[data-index="${dataIndex}"]`);
-
- if(activeElem.classList.contains("price-block__list--slider")) {
- let heightBlock = activeElem.offsetHeight;
- priceBlockWrapper.style.height = heightBlock + "px";
- }
-
- activeElem.classList.add('show');
- });
- });
-
- });
-
- // /Main SLider
-
- // Popup
-
- let mainButton = document.querySelectorAll('.js-button');
- let overlay = document.querySelector('.overlay');
- let htmlOverflow = document.querySelector('html');
-
- for(var i = 0; mainButton.length > i; i++) {
- if(mainButton[i] !== null) {
-
- mainButton[i].addEventListener('click', function(){
- let getData = this.getAttribute('data-target');
- let popup = document.querySelector('.js-popup[data-target = ' + getData + ']');
- popup.classList.add('active');
- overlay.classList.add('active');
- htmlOverflow.classList.add('overflow');
- });
- }
- }
-
- document.addEventListener('click', function(e){
- let elem = e.target;
-
- if(elem.closest('.js-close')){
- let popupActive = document.querySelector('.js-popup.active');
-
- if(popupActive) {
- popupActive.classList.remove('active');
- overlay.classList.remove('active');
- htmlOverflow.classList.remove('overflow');
- }
- }
- });
- overlay.addEventListener('click', function(){
- let popupActive = document.querySelector('.js-popup.active');
-
- popupActive.classList.remove('active');
- overlay.classList.remove('active');
- htmlOverflow.classList.remove('overflow');
- });
-
- // //Popup
-
- // Check call back form
-
- let callBackButton = document.querySelector('.js-button-call-back');
-
-
- callBackButton.addEventListener('click', function() {
- let thanksPopup = document.querySelector('.js-call-back-popup');
- let callBackform = this.closest('.js-call-back-form');
- let callbackEmail = callBackform.querySelector('.js-call-back-email');
- let callbackEmailValue = callbackEmail.value;
- let chekEmail = callbackEmailValue.match(/@/);
-
- if(chekEmail && callbackEmailValue != "") {
- callbackEmail.classList.remove('error');
-
- thanksPopup.classList.add('active');
- overlay.classList.add('active');
- htmlOverflow.classList.add('overflow');
-
- }else {
- callbackEmail.classList.add('error');
- }
- });
-
- // //Check call back form
-
- // Staff block
-
- let staffWrapper = document.querySelector('.js-staff');
- let staffButton = document.querySelector('.js-button-staff');
- let allSraffItemsLength = document.querySelectorAll('.our-staff__item').length;
-
- if(staffWrapper) {
- if(allSraffItemsLength > 9 ) {
- staffButton.classList.add('show');
- }
-
- staffButton.addEventListener('click', function(){
- staffWrapper.classList.toggle('active');
- });
- }
-
- // Staff block
-
- });
|