1const $ = jQuery 2let startSlider = false 3 4if (sessionStorage.getItem('banner')) { 5 $('body').addClass('remove-cover') 6 $('.navbar').removeClass('navbar-init') 7 8 if (!location.pathname || location.pathname === '/') { 9 startSlider = true 10 } 11} else { 12 if (!location.pathname || location.pathname === '/') { 13 sessionStorage.setItem('banner', true) 14 } 15} 16 17document.querySelector('html').classList.add('loaded') 18 19$(() => { 20 const imagesSlider = new Swiper('.hero-images-slider', { 21 loop: true, 22 slidesPerView: 1, 23 direction: 'vertical', 24 navigation: { 25 prevEl: '.slider-arrow.hero-prev', 26 nextEl: '.slider-arrow.hero-next', 27 }, 28 speed: 800, 29 allowTouchMove: false, 30 initialSlide: $('.hero-images-slider .swiper-slide').length - 1 31 }) 32 33 const heroSlider = new Swiper('.hero-text-slider', { 34 loop: true, 35 effect: 'fade', 36 slidesPerView: 1, 37 navigation: { 38 prevEl: '.slider-arrow.hero-prev', 39 nextEl: '.slider-arrow.hero-next', 40 }, 41 speed: 800, 42 pagination: { 43 el: '.hero-pagination', 44 clickable: true, 45 }, 46 on: { 47 activeIndexChange() { 48 imagesSlider.slideNext() 49 }, 50 }, 51 }) 52 53 if (startSlider) { 54 imagesSlider.slideNext() 55 56 heroSlider.params.autoplay = { 57 delay: 5000, 58 disableOnInteraction: false, 59 pauseOnMouseEnter: false, 60 enabled: true, 61 reverseDirection: false, 62 stopOnLastSlide: false, 63 waitForTransition: true, 64 } 65 66 heroSlider.autoplay.start() 67 } 68 69 $(window).scroll(() => { 70 if (window.scrollY > 0) { 71 $('.navbar').addClass('fixed') 72 } else { 73 $('.navbar').removeClass('fixed') 74 } 75 76 if (!$('body').hasClass('remove-cover') && $('.start-cover-section').length) { 77 const top = window.innerHeight 78 79 if (window.scrollY >= top - $('.navbar').outerHeight()) { 80 $('body').addClass('remove-cover') 81 $('.navbar').removeClass('navbar-init') 82 83 // window.scrollTo({ 84 // top: 0, 85 // behavior: 'instant', 86 // }) 87 88 // setTimeout(() => { 89 window.scrollTo({ 90 top: 0, 91 behavior: 'instant', 92 }) 93 94 $('body').addClass('overflow-hidden') 95 setTimeout(() => { 96 window.scroll(0, 0) 97 }, 200) 98 99 setTimeout(() => { 100 $('body').removeClass('overflow-hidden') 101 }, 1000) 102 // }, 100) 103 104 imagesSlider.slideNext() 105 106 heroSlider.params.autoplay = { 107 delay: 5000, 108 disableOnInteraction: false, 109 pauseOnMouseEnter: false, 110 enabled: true, 111 reverseDirection: false, 112 stopOnLastSlide: false, 113 waitForTransition: true, 114 } 115 116 heroSlider.autoplay.start() 117 } 118 } 119 }) 120 121 const setItemHeight = () => { 122 $('.gallery-slider img').height( 123 $('.gallery-slider img').width() * 1.4 124 ) 125 } 126 127 $('.gallery-slider').on('init', () => { 128 setItemHeight() 129 }) 130 131 $('.gallery-slider').slick({ 132 slidesToShow: 5, 133 centerMode: true, 134 pauseOnHover: true, 135 autoplay: true, 136 autoplaySpeed: 2000, 137 appendArrows: '.gallery-arrows', 138 responsive: [ 139 { 140 breakpoint: 1440, 141 settings: { 142 slidesToShow: 4, 143 } 144 }, 145 { 146 breakpoint: 992, 147 settings: { 148 slidesToShow: 2, 149 } 150 }, 151 { 152 breakpoint: 768, 153 settings: { 154 slidesToShow: 1, 155 } 156 }, 157 ], 158 }) 159 160 $(window).on('resize', setItemHeight) 161 162 new Swiper('.opinion-slider', { 163 loop: true, 164 navigation: { 165 prevEl: '.slider-arrow.opinion-prev', 166 nextEl: '.slider-arrow.opinion-next', 167 }, 168 autoplay: { 169 delay: 4000, 170 disableOnInteraction: false, 171 pauseOnMouseEnter: false, 172 }, 173 pagination: { 174 el: '.opinion-pagination', 175 clickable: true, 176 } 177 }) 178 179 $('.diet-dishes-slider').each(function (i) { 180 const dietSlider = new Swiper(this, { 181 slidesPerView: 1.5, 182 spaceBetween: 16, 183 loop: true, 184 speed: 1000, 185 pagination: {
186 el: $(this).find('.dishes-pagination').get(0), 187 clickable: true, 188 }, 189 navigation: { 190 prevEl: $(this).find('.diet-prev').get(0), 191 nextEl: $(this).find('.diet-next').get(0), 192 }, 193 breakpoints: { 194 768: { 195 slidesPerView: 2, 196 spaceBetween: 24, 197 navigation: { 198 nextEl: $('.dishes-arrow-next').get(i), 199 }, 200 }, 201 }, 202 }) 203 204 function hoverSlide() { 205 if ($(this).hasClass('swiper-slide-next')) { 206 dietSlider.slideNext() 207 } 208 } 209 210 $(this).find('.swiper-slide').on('mouseover', hoverSlide) 211 $(this).find('.swiper-slide').on('touchstart', hoverSlide) 212 }) 213 214 const resizeText = () => { 215 // if (window.innerWidth < 992) { 216 // $('.diet-dishes-slider .text-box p').css('width', $('.diet-dishes-slider').width() - 48 * 2) 217 218 // } else { 219 $('.diet-dishes-slider .text-box p').css('width', $('.diet-dishes-slider').width() - 48 * 2) 220 // } 221 222 } 223 224 resizeText() 225 $(window).on('resize', resizeText) 226 227 new Swiper('.diet-choose-slider', { 228 slidesPerView: 1, 229 spaceBetween: 24, 230 pagination: { 231 el: '.dishes-pagination', 232 clickable: true, 233 }, 234 navigation: { 235 prevEl: '.slider-arrow.diet-prev', 236 nextEl: '.slider-arrow.diet-next', 237 }, 238 breakpoints: { 239 768: { 240 slidesPerView: 2, 241 }, 242 992: { 243 slidesPerView: 4, 244 }, 245 1200: { 246 slidesPerView: 5, 247 }, 248 }, 249 }) 250 251 new Swiper('.diet-dishes-slider-single', { 252 slidesPerView: 1, 253 pagination: { 254 el: '.diet-dishes-slider-single .dishes-pagination', 255 clickable: true, 256 }, 257 navigation: { 258 prevEl: '.slider-arrow.diet-prev', 259 nextEl: '.slider-arrow.diet-next', 260 }, 261 }) 262 263 $('.header-height').css('height', $('.navbar').outerHeight()) 264 265 $('.faq-accordion').accordion({ 266 collapsible: true, 267 }) 268 269 const scrollDietsNav = (nav, direction) => { 270 if (nav.data('anim')) { 271 return 272 } 273 274 nav.data('anim', true) 275 276 const left = nav.get(0).scrollLeft + nav.width() * direction 277 278 nav.animate({ scrollLeft: left, }, 500, () => { 279 let lastItemCrop 280 281 nav.find('.diets-nav-link').each(function () { 282 if (this.getBoundingClientRect().left < 26) { 283 lastItemCrop = this.getBoundingClientRect().left - 12 284 } 285 }) 286 287 if (nav.get(0).scrollWidth !== Math.round(nav.get(0).scrollLeft + nav.width()) && lastItemCrop < 0) { 288 nav.animate({ scrollLeft: nav.get(0).scrollLeft - Math.abs(lastItemCrop), }, 300) 289 } 290 291 nav.data('anim', false) 292 }) 293 } 294 295 $('.diets-nav').each(function () { 296 const base = $(this) 297 const nav = base.find('.diets-links') 298 299 base.find('.diets-nav-link').click(function (e) { 300 if (nav.hasClass('as-tab')) { 301 e.preventDefault() 302 303 $('.menu-tab').addClass('d-none') 304 $('.menu-tab').eq($(this).index()).removeClass('d-none') 305 } 306 307 base.find('.diets-nav-link').removeClass('active') 308 $(this).addClass('active') 309 }) 310 311 base.find('.diets-arrow.prev').click(() => scrollDietsNav(nav, -1)) 312 base.find('.diets-arrow.next').click(() => scrollDietsNav(nav, 1)) 313 }) 314 315 const validateFields = form => { 316 let error 317 318 $(form).find('.street, .postal-code, .place').each(function () { 319 if (!$(this).val().trim()) { 320 error = true 321 $(this).addClass('error') 322 } 323 }) 324 325 if ($(form).find('.place').val().trim().length < 3) { 326 error = true 327 $(form).find('.place').addClass('error') 328 } 329 330 if (!/\d\d-\d\d\d/.test($(form).find('.postal-code').val().trim())) { 331 error = true 332 $(form).find('.postal-code').addClass('error') 333 } 334 335 if (error) { 336 return false 337 } else { 338 return { 339 street: $(form).find('.street').val().trim(), 340 postalCode: $(form).find('.postal-code').val().trim(), 341 place: $(form).find('.place').val().trim(), 342 } 343 } 344 } 345 346 $('.zones-form').on('submit', async function (e) { 347 e.preventDefault() 348 349 let data = validateFields(this) 350 351 if (!data) { 352 return 353 } 354 355 const response = await $.ajax({ 356 url: '/wp-json/api/v1/location', 357 type: 'GET', 358 data, 359 }) 360 361 console.log(response) 362 363 if (response.success) { 364 $('.zones-box').addClass('success') 365 } else { 366 $('.zones-box').addClass('fail') 367 } 368 }) 369 370 $('input').on('input', function () { 371 $(this).removeClass('error') 372 }) 373 374 $('.zones-box').find('.postal-code').on('input', function () { 375 const val = $(this).val().trim() 376 377 if (!/\d+$/.test(val)) { 378 if (val.length === 3 && val.slice(-1) === '-') { 379 return 380 } 381 382 $(this).val(val.slice(0, -1)) 383 } 384 385 if (val.length === 3 && val.slice(-1) !== '-' && /\d/.test(val.slice(-1))) { 386 $(this).val(`${val.slice(0, -1)}-${val.slice(-1)}`) 387 } 388 389 if (val.length > 6) { 390 $(this).val(val.slice(0, -1)) 391 } 392 }) 393 394 $('.zones-box').css('min-height', $('.zones-box').outerHeight()) 395 $('.zones-box .again').click(() => { 396 $('.zones-box').removeClass('fail') 397 $('.zones-box').removeClass('success') 398 $('.zones-box').removeClass('calorie') 399 }) 400 401 402 $('.custom-select').click(function () { 403 $(this).parent().find('.custom-select').removeClass('active') 404 $(this).addClass('active') 405 406 $(this).parent().find('.custom-select').attr('data-selected', 'false') 407 $(this).attr('data-selected', 'true') 408 }) 409 410 const validateCalc = form => { 411 let error = false 412 413 $(form).find('.height, .weight, .age').each(function () { 414 if (!$(this).val().trim()) { 415 error = true 416 $(this).addClass('error') 417 } 418 }) 419 420 return !error 421 } 422 423 $('.calculator-form').on('submit', function (e) { 424 e.preventDefault() 425 const form = $(this) 426 427 if (!validateCalc(form)) { 428 return 429 } 430 431 const tdeeCase = form.find('.tdee-case[data-selected=true]').data('case') 432 const height = +form.find('.height').val() 433 const weight = +form.find('.weight').val() 434 const age = +form.find('.age').val() 435 const activity = +form.find('.activity').val() 436 const gender = form.find('.gender[data-selected=true]').data('gender') 437 438 console.log(tdeeCase, height, weight, age, activity, gender) 439 440 let bmr 441 442 if (gender === 'male') { 443 bmr = 88.362 + (13.397 * weight) + (4.799 * height) - (5.677 * age) 444 } else { 445 bmr = 447.593 + (9.247 * weight) + (3.098 * height) - (4.330 * age) 446 } 447
448 let calorie 449 450 switch (tdeeCase) { 451 case 'tdee-low': 452 calorie = bmr * activity - 500 453 break; 454 case 'tdee': 455 calorie = bmr * activity 456 break; 457 case 'tdee-high': 458 calorie = bmr * activity + 500 459 break; 460 } 461 462 $('.calorie-container').addClass('calorie') 463 $('.calorie-text').text(calorie.toFixed(0)) 464 }) 465 466 if ($('.time-box').data('time')) { 467 const exp = moment($('.time-box').data('time')) 468 469 setInterval(function() { 470 let diffDuration = moment.duration(exp.diff()) 471 472 const days = diffDuration.days() 473 const hours = diffDuration.hours() 474 const minutes = diffDuration.minutes() 475 const seconds = diffDuration.seconds() 476 477 if (days > -1) { 478 $('.time-box .days').text(diffDuration.days()) 479 } 480 481 if (hours > -1) { 482 $('.time-box .hours').text(diffDuration.hours()) 483 } 484 485 if (minutes > -1) { 486 $('.time-box .minutes').text(diffDuration.minutes()) 487 } 488 489 if (seconds > -1) { 490 $('.time-box .seconds').text(diffDuration.seconds()) 491 } 492 }, 1000) 493 } 494 495 $('.scroll-to-start').click(function (e) { 496 e.preventDefault() 497 498 window.scrollTo(0, $('.start-cover-section').outerHeight()) 499 }) 500 501 $('.scroll-to-top').click(() => window.scroll(0, 0)) 502 503 $(window).on('scroll', () => { 504 if (window.scrollY > window.innerHeight) { 505 $('.scroll-to-top').addClass('show') 506 } else { 507 $('.scroll-to-top').removeClass('show') 508 } 509 }) 510 511 new Swiper('.rank-grid', { 512 slidesPerView: 1, 513 spaceBetween: 24, 514 loop: true, 515 navigation: { 516 prevEl: '.rank-arrow.slick-prev', 517 nextEl: '.rank-arrow.slick-next', 518 }, 519 breakpoints: { 520 768: { 521 slidesPerView: 2, 522 }, 523 992: { 524 slidesPerView: 4, 525 }, 526 1200: { 527 slidesPerView: 5, 528 }, 529 }, 530 }) 531})
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.