1(function ($, root, undefined) { 2 "use strict"; 3 4 $.migrateMute = true; 5 $.migrateTrace = false; 6 7 root.templines_videos = []; 8 root.templines_players = []; 9 root.templines_env_init = false; 10 root.templines_slick_paused = false; 11 root.templines_is_mobile = false; 12 13 root.old_windows_width = 0; 14 15 var $window = $(window); 16 var templines_date_format = templines_wp_vars.dateFormat; 17 var templines_scroll_busy = true; 18 var templines_resize_busy = true; 19 20 var $templines_masonry_grid = $('.js-masonry'); 21 var templines_masonry_grid_on = !!$templines_masonry_grid.length; 22 var templines_is_masonry_init = false; 23 var $templines_mobile_menu = $('.js-mobile-menu'); 24 var $templines_mobile_menu_open = $('#templines-mobile-menu-button'); 25 var $templines_mobile_menu_close = $('#templines-menu-close'); 26 var $templines_mobile_menu_back = $('#templines-menu-back'); 27 var $templines_mobile_menu_wrap = $('.c-header__menu-wrap'); 28 var $templines_mobile_menu_content = $('.c-header__menu-content'); 29 var $templines_mobile_submenu = []; 30 var templines_mobile_menu_initialized = false; 31 var templines_mobile_menu_active = false; 32 var templines_shop_sidebar_active = false; 33 var $templines_shop_sidebar = $('.js-popup-sidebar'); 34 var $templines_shop_sidebar_open = $('#templines-shop-sidebar-button'); 35 var $templines_shop_sidebar_close = $('#templines-shop-sidebar-close'); 36 var $templines_shop_sidebar_wrap = $('.c-catalog-sidebar__wrap'); 37 var $templines_shop_sidebar_content = $('.c-catalog-sidebar__content--mobile'); 38 var templines_shop_sidebar_initialized = false; 39 var $templines_search = $('#templines-ajax-search'); 40 var $templines_search_input = $('#templines-ajax-search-input'); 41 var $templines_search_result = $('#templines-ajax-search-result'); 42 var $templines_search_loader = $('<i class="h-loading c-header-search__loading"></i>'); 43 var templines_search_popup_active = false; 44 var templines_search_input_filled = false; 45 var templines_on_transition_end = 'transitionend webkitTransitionEnd oTransitionEnd'; 46 var $templines_callback_popup = $('.js-callback-popup'); 47 var templines_is_mobile_layout = window.innerWidth < 1170; 48 var templines_layout_4 = window.innerWidth < 600; 49 50 var $templines_desktop_sticky_row = $('#js-sticky-desktop'); 51 var $templines_mobile_sticky_row = $('#js-sticky-mobile'); 52 var $templines_top_row = $('#js-header-top-row'); 53 var $templines_header_outer_desktop = $('#js-sticky-outer-desktop'); 54 var $templines_header_outer_mobile = $('#js-header-outer-mobile'); 55 var templines_before_header_height = 0; 56 var templines_header_height = 0; 57 var templines_sticky_desktop_active = false; 58 var templines_sticky_animation = false; 59 var templines_sticky_desktop_init = false; 60 var templines_sticky_mobile_active = false; 61 var templines_sticky_mobile_init = false; 62 63 var $templines_admin_bar; 64 var templines_adminbar_height = 0; 65 var templines_adminbar_visible_height = 0; 66 var templines_adminbar_position = 0; 67 var $templines_to_top_button = $('.js-to-top-button'); 68 var $templines_sticky_sidebar = $('.js-sticky-sidebar'); 69 var $templines_sticky_sidebar_nearby = $('.js-sticky-sidebar-nearby'); 70 var templines_sticky_sidebar_old_style = null; 71 var templines_sticky_sidebar_position = 'relative'; 72 var $templines_counters = $('.js-counter-number'); 73 74 var $slick_product_single = $('.slick-product-single'); 75 var $slick_product_single_slides = $('.slide', $slick_product_single); 76 var $slick_product_thumbnails = $('.slick-product'); 77 78 var templines_vehicle_types_short_block = false; 79 var $templines_vehicle_types_short_last = null; 80 var templines_date_class_lock = false; 81 82 var templines_default_start; 83 var templines_default_end; 84 var templines_maximum_days; 85 86 var templines_is_night = templines_wp_vars.bookingType == 'night'; 87 var templines_is_day = templines_wp_vars.bookingType == 'day'; 88 var templines_minimal_days_error = ''; 89 90 $(function () { 91 $templines_to_top_button.click(function () { 92 $('html, body').animate({scrollTop: 0}, 800); 93 }); 94 95 $templines_counters = $('.js-counter-number'); 96 97 $(window).bind("pageshow", function (e) { 98 if (e.originalEvent.persisted) { 99 $('.js-filter-form').trigger('reset'); 100 $('.js-book-form').trigger('reset'); 101 var $input_start = $('.js-book-date-start'); 102 var $input_end = $('.js-book-date-end'); 103 var $input_range = $('.js-book-date-range'); 104 if ($input_start.length && $input_end.length) { 105 moment.locale(templines_wp_vars.locale); 106 var dateFormat = templines_date_format; 107 var startDateText = moment($input_start.data('value'), dateFormat).format(dateFormat); 108 var endDateText = moment($input_end.data('value'), dateFormat).format(dateFormat); 109 $input_start.val(startDateText); 110 $input_end.val(endDateText); 111 $input_range.val(startDateText + ' â ' + endDateText); 112 } 113 } 114 }); 115 116 $('.woocommerce-product-gallery__wrapper').addClass('js-single-product-carou
116sel h-carousel h-carousel--compact h-carousel--hover'); 117 118 $('#tab-reviews').removeClass('entry-content'); 119 120 $('.js-filter-reset').click(function () { 121 var $form = $('.js-filter-form'); 122 if ($form.length) { 123 $('.js-type-all').first().trigger('click'); 124 if ($form.hasClass('js-filter-form--active')) { 125 $form.submit(); 126 } else { 127 document.location.href = $form.attr('action'); 128 } 129 } else { 130 document.location.href = $('.js-catalog-url').val(); 131 } 132 }); 133 134 $('.js-filter-type').change(function () { 135 var $this = $(this); 136 var $form = $('.js-filter-form'); 137 var $hidden_permalink = $('.js-filter-permalink'); 138 if ($hidden_permalink.length) { 139 $hidden_permalink.remove(); 140 var params = $.parseParams($this.val().replace(/(^.*\?)/, '')); 141 if (params) { 142 for (var prop in params) { 143 var $new_param = $('<input class="js-filter-permalink" type="hidden">').attr('name', prop).attr('value', params[prop]); 144 $form.prepend($new_param); 145 } 146 } 147 } 148 $form.attr('action', $this.val()); 149 }); 150 151 $('.js-filter-capacity-seating,.js-filter-capacity-berth').change(function () { 152 $(document).trigger('templines.filter.update'); 153 }); 154 155 $('.js-filter-feature').click(function () { 156 $(document).trigger('templines.filter.update'); 157 }); 158 159 $('.js-filter-type-widget').click(function () { 160 $(document).trigger('templines.filter.update'); 161 var $this = $(this); 162 var $form = $('.js-filter-form'); 163 var $widget = $this.closest('.c-filter-types__wrap'); 164 $widget.find('.js-filter-type-widget').not(this).prop('checked', false); 165 var $hidden_permalink = $('.js-filter-permalink'); 166 if ($hidden_permalink.length) { 167 var params = $.parseParams($this.val().replace(/(^.*\?)/, '')); 168 if (params) { 169 for (var prop in params) { 170 $hidden_permalink.attr('name', prop); 171 $hidden_permalink.attr('value', params[prop]); 172 } 173 } 174 } 175 if ($form.length) { 176 $form.attr('action', $this.val()); 177 } 178 }); 179 180 if ($('.js-filter-type-widget:checked').hasClass('js-type')) { 181 $('.c-filter-reset.h-hidden').removeClass('h-hidden'); 182 } 183 184 $('.js-sidebar-filter-btn').click(function () { 185 var exclude = ''; 186 var url = ''; 187 var $min_price = $('.js-filter-price-min_price'); 188 var $max_price = $('.js-filter-price-max_price'); 189 if ($min_price.length && $min_price.val() == $min_price.data('min')) { 190 exclude += ':not(.js-filter-price-min_price)'; 191 } 192 if ($max_price.length && $max_price.val() == $max_price.data('max')) { 193 exclude += ':not(.js-filter-price-max_price)'; 194 } 195 var $form = $('.js-filter-form'); 196 var $type_filter = $('.js-filter-type-widget:checked'); 197 if ($form.length) { 198 url = $form.attr('action'); 199 } else if ($type_filter.length) { 200 url = $type_filter.val(); 201 } else { 202 url = $('.js-catalog-url').val(); 203 } 204 var params = $('.js-filter-field' + exclude).serialize(); 205 document.location.href = url + (params ? (url.indexOf('?') === -1 ? '?' : '&') + params : ''); 206 }); 207 208 $('.js-ordering-map').click(function () { 209 var $this = $(this); 210 if ($this.hasClass('active')) { 211 templines_cookies.remove('map-mode_' + templines_wp_vars.cookieHash); 212 $this.removeClass('active'); 213 } else { 214 templines_cookies.set('map-mode_' + templines_wp_vars.cookieHash, 'on', 31536000); 215 $this.addClass('active'); 216 } 217 }); 218 219 $('.js-ordering-grid,.js-ordering-list').click(function () { 220 var $this = $(this); 221 var is_grid = $this.hasClass('js-ordering-grid'); 222 var $catalog = $('.c-catalog__list'); 223 if (!$this.hasClass('active')) { 224 $('.js-ordering-grid,.js-ordering-list').removeClass('active'); 225 templines_cookies.set('view-mode_' + templines_wp_vars.cookieHash, is_grid ? 'grid' : 'list', 31536000); 226 $this.addClass('active'); 227 if (is_grid) { 228 $catalog.removeClass('c-catalog__list--list-mode'); 229 $catalog.addClass('c-catalog__list--grid-mode'); 230 } else { 231 $catalog.removeClass('c-catalog__list--grid-mode'); 232 $catalog.addClass('c-catalog__list--list-mode'); 233 } 234 } 235 }); 236 237 var templines_vehicle_types_tab_timeout = null; 238 $('.js-vehicle-types-tab').on('mouseover click', function () { 239 240 if (templines_vehicle_types_tab_timeout !== null) { 241 clearTimeout(templines_vehicle_types_tab_timeout); 242 templines_vehicle_types_tab_timeout = null; 243 } 244 245 var $this = $(this); 246 if ($this.hasClass('active')) { 247 return; 248 } 249 $('.c-vehicle-types__item--layout-2.active').removeClass('active'); 250 $('.c-vehicle-types__tab.active').removeClass('active visible'); 251 $this.addClass('active'); 252 253 var $tab_content = $('.c-vehicle-types__tab[data-id="' + $this.data('id') + '"]'); 254 255 $tab_content.addClass('visible'); 256 257 templines_vehicle_types_tab_timeout = setTimeout(function () { 258 $tab_content.addClass('active'); 259 $('.c-vehicle-types__tab.visible:not(.active)').removeClass('visible'); 260 templines_vehicle_types_tab_timeout = null; 261 }, 100); 262 }); 263 264 $('.c-vehicle-types__item').each(function () { 265 var $this = $(this); 266 $this.css({'min-height': $this.outerHeight() + 'px'}); 267 }); 268 269 $('.js-extra-minus').click(function () { 270 var $this = $(this); 271 var $li = $this.closest('.c-vehicle-book__extra-item'); 272 var $qty = $li.find('.js-extra-qty'); 273 var qty = parseInt($qty.val()); 274 if (qty > 0) { 275 qty--; 276 $qty.val(qty); 277 } 278 279 templines_get_total(); 280 }); 281 282 $('.js-extra-plus').click(function () { 283 var $this = $(this); 284 var $li = $this.closest('.c-vehicle-book__extra-item'); 285 var $qty = $li.find('.js-extra-qty'); 286 var qty = parseInt($qty.val()); 287 var max = parseInt($li.data('max')); 288 if (qty < max) { 289 qty++; 290 $qty.val(qty); 291 } 292 293 templines_get_total(); 294 }); 295 296 $('.js-extra-chk').change(function () { 297 var $extra_qty_field = $(this).parent().find(".js-extra-qty"); 298 $extra_qty_field.val($(this).prop('checked') ? 1 : 0).trigger('change'); 299 }); 300 301 $('.js-extra-qty,.js-book-drop-off,.js-book-pick-up').change(function () { 302 templines_get_total(); 303 }); 304 305 $('.js-book').click(function () { 306 var $button = $(this); 307 if ($('.js-book-total').text() == '') { 308 return; 309 } 310 $button.templines_button('loading', 22); 311 $('.js-book-action').val('templines_book'); 312 $.ajax({ 313 url : templines_wp_vars.ajaxUrl, 314 type : 'POST', 315 data : $('.js-book-form').serialize(), 316 dataType: 'json', 317 success : function (results) { 318 if (results.redirect) { 319 document.location.href = results.redirect; 320 } else if (results.error) { 321 $button.templines_button('reset'); 322 templines_show_notice_error(results.error); 323 } else if (results.message) { 324 $button.templines_button('reset'); 325 templines_show_notice_success(results.message); 326 } else { 327 $button.templines_button('reset'); 328 } 329 } 330 }); 331 }); 332 333 $('.js-vehicle-types-short').on('mouseover', function () { 334 var $this = $(this); 335 $templines_vehicle_types_short_last = $this; 336 if (templines_vehicle_types_short_block) { 337 return; 338 } 339 var $block = $this.closest('.c-vehicle-types'); 340 var $bottom = $('.c-vehicle-types__bottom', $this); 341 if ($this.hasClass('active')) { 342 return; 343 } 344 345 $('.c-vehicle-types__short.active').removeClass('active'); 346 var $tab_content = $('.c-vehicle-types__short[data-id="' + $this.data('id') + '"]'); 347 var left = $this.offset().left - $block.offset().left; 348 var top = $bottom.offset().top - $block.offset().top; 349 350 $tab_content.css({left: left + 'px', top: top + 'px'}).addClass('active'); 351 352 }).on('mouseout', function () { 353 $templines_vehicle_types_short_last = null; 354 $('.c-vehicle-types__short.active').removeClass('active'); 355 }); 356 357 if ($templines_callback_popup.length) { 358 359 $templines_callback_popup.each(function () { 360 var $popup = $(this); 361 var $button = $($popup.data('button')); 362 $popup.removeClass('c-header__callback-popup--disabled'); 363 364 $button.click(function () { 365 templines_mobile_menu_popup(false); 366 $popup.addClass('c-header__callback-popup--active'); 367 bodyScrollLock.disableBodyScroll($('.c-header__callback-content', $popup)[0]); 368 }); 369 370 $('.js-callback-close', $popup).click(function () { 371 $popup.removeClass('c-header__callback-popup--disabled'); 372 $popup.toggleClass('c-header__callback-popup--active'); 373 bodyScrollLock.clearAllBodyScrollLocks(); 374 }); 375 376 $(document).on('templines.wpadminbar.scroll', function (event, wpadminbar_height) { 377 $popup.css({ 378 transform : 'translateY(' + wpadminbar_height + 'px)', 379 'max-height': 'calc(100% - ' + wpadminbar_height + 'px)' 380 }); 381 }); 382 }); 383 384 if (templines_wp_vars.priceRequestField || templines_wp_vars.requestField) { 385 $('.js-request-price').click(function () { 386 var info = ''; 387 var $field = $('.js-callback-popup[data-button=".js-request-price"] [name="' + (templines_wp_vars.priceRequestField ? templines_wp_vars.priceRequestField.trim() : templines_wp_vars.requestField.trim()) + '"]'); 388 if (!$field.length && templines_wp_vars.requestField) { 389 $field = $('.js-callback-popup[data-button=".js-request-price"] [name="' + templines_wp_vars.requestField.trim() + '"]'); 390 } 391 var names = templines_wp_vars.priceRequestNames; 392 var disable_booking = templines_wp_vars.disableBooking; 393 if ($field.length) { 394 395 if (disable_booking) { 396 info = names.name + ': ' + $('.c-vehicle-details__title').text() + "\n"; 397 } else { 398 var dateFormat = templines_date_format; 399 var startDate = moment($('.js-book-date-start').val(), dateFormat); 400 var endDate = moment($('.js-book-date-end').val(), dateFormat); 401 var days = endDate.diff(startDate, 'days') + (templines_is_day ? 1 : 0); 402 403 var new_start_time = '', new_end_time = ''; 404 if (templines_wp_vars.pickup_dropoff_time) { 405 new_start_time = $('.js-book-date-start-time').val(); 406 if (new_start_time !== '') { 407 new_start_time = ' â ' + new_start_time; 408 } 409 new_end_time = $('.js-book-date-end-time').val(); 410 if (new_end_time !== '') { 411 new_end_time = ' â ' + new_end_time; 412 } 413 } 414 415 416 info = names.name + ': ' + $('.c-vehicle-details__title').text() + "\n"; 417 info += names.start + ': ' + $('.js-book-date-start').val() + new_start_time + "\n"; 418 info += names.end + ': ' + $('.js-book-date-end').val() + new_end_time + "\n"; 419 info += names.days + ': ' + days + "\n"; 420 421 var puck_up_text = $('.js-book-pick-up-text').text().trim(); 422 var drop_off_text = $('.js-book-drop-off-text').text().trim(); 423 if (!drop_off_text) { 424 drop_off_text = $('.js-book-drop-off.styled option:selected').text().trim(); 425 } 426 427 if (puck_up_text) { 428 if (!drop_off_text) { 429 info += names.where + ': ' + puck_up_text + "\n"; 430 } else { 431 info += names.pickup + ': ' + puck_up_text + "\n"; 432 } 433 } 434 435 if (drop_off_text) { 436 info += names.dropoff + ': ' + drop_off_text + "\n"; 437 } 438 439 var $extra = $('.js-extra-item'); 440 if ($extra.length) { 441 info += names.extra + ': ' + "\n"; 442 $extra.each(function () { 443 var $item = $(this); 444 info += ' - ' + $('.c-vehicle-book__extra-title-text', $item).text().trim() + ' x ' + $('.js-extra-qty', $item).val() + "\n"; 445 }); 446 } 447 } 448 $field.val(info); 449 } 450 }); 451 } 452 } 453 454 $('.js-tab-header').click(function (e) { 455 var $this = $(this); 456 e.preventDefault(); 457 if ($this.hasClass('c-login__tab-register')) { 458 $this.addClass('c-login__tab-register--active').removeClass('c-login__tab-register--not-active'); 459 $('.c-login__tab-login--active').removeClass('c-login__tab-login--active').addClass('c-login__tab-login--not-active'); 460 } else { 461 $this.addClass('c-login__tab-login--active').removeClass('c-login__tab-login--not-active'); 462 $('.c-login__tab-register--active').removeClass('c-login__tab-register--active').addClass('c-login__tab-register--not-active'); 463 } 464 $('.c-login__form--active').removeClass('c-login__form--active'); 465 $('.' + $this.data('tab-class')).addClass('c-login__form--active'); 466 }); 467 468 $(document) 469 .on('templines.filter.update', function (e, $thisbutton) { 470 $('.c-catalog-sidebar__sticky').addClass('c-catalog-sidebar__sticky--visible'); 471 472 }) 473 .on('adding_to_cart', function (e, $thisbutton) { 474 $thisbutton.templines_button('loading', 16); 475 }) 476 .on('added_to_cart', function (e, fragments, cart_hash, $thisbutton) { 477 $thisbutton.templines_button('reset'); 478 if (typeof fragments.templines_notice !== 'undefined') { 479 templines_show_notice(fragments.templines_notice); 480 } 481 }) 482 .on('click', ".js-product-zoom", function (e) { 483 e.preventDefault(); 484 var $button = $(this); 485 var $button_loading = $button.find('.js-loading-wrap'); 486 if ($button.hasClass('js-product-zoom-video')) { 487 $button_loading = $button.find('.c-product__video-wrap'); 488 } 489 if ($button.hasClass('js-loading')) { 490 return; 491 } 492 var index = 0; 493 if (templines_isset($button.data('index'))) { 494 $button_loading.templines_button('loading', 25); 495 index = $button.data('index'); 496 } else { 497 $button_loading.templines_button('loading'); 498 } 499 var $product = $button.closest('.product'); 500 var variation_id = $product.find('.variation_id').val(); 501 502 503 templines_require([
504 templines_wp_vars.themeUri + '/assets/js/photoswipe/photoswipe.min.js?v=' + templines_wp_vars.stylesHash, 505 templines_wp_vars.themeUri + '/assets/js/photoswipe/photoswipe-ui-default.min.js?v=' + templines_wp_vars.stylesHash, 506 templines_wp_vars.ajaxUrl + '?action=templines_product_images&product_id=' + $('.js-product-id').val() + (!templines_empty(variation_id) ? '&variation_id=' + variation_id : ''), 507 templines_wp_vars.themeUri + '/assets/css/photoswipe/photoswipe.css', 508 templines_wp_vars.themeUri + '/assets/css/photoswipe/default-skin/default-skin.css' 509 ], function (values) { 510 var images = values[2]; 511 $button_loading.templines_button('reset'); 512 if (images.images.length) { 513 var options = { 514 index : index ? index : 0, 515 showHideOpacity : true, 516 bgOpacity : 1, 517 loop : false, 518 closeOnVerticalDrag: false, 519 mainClass : '', 520 barsSize : {top: 0, bottom: 0}, 521 captionEl : false, 522 fullscreenEl : false, 523 zoomEl : true, 524 shareEl : false, 525 counterEl : false, 526 tapToClose : true, 527 tapToToggleControls: false, 528 history : false 529 }; 530 531 var pswpElement = $('.pswp')[0]; 532 533 templines_wpadminbar_resize(); 534 535 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, images.images, options); 536 gallery.init(); 537 538 gallery.listen('afterChange', function () { 539 if (!templines_empty(gallery.currItem.html)) { 540 $('.pswp__video-wrap').fitVids(); 541 } 542 }); 543 544 gallery.listen('close', function () { 545 $('.pswp__video-wrap').html(''); 546 }); 547 548 $('.pswp__video-wrap').fitVids(); 549 } 550 }); 551 }) 552 .on('click', ".js-vehicle-zoom", function (e) { 553 e.preventDefault(); 554 var $button = $(this); 555 var $button_loading = $button; 556 if ($button.hasClass('js-loading')) { 557 return; 558 } 559 var index = 0; 560 if (templines_isset($button.data('index'))) { 561 $button_loading.templines_button('loading', 25); 562 index = $button.data('index'); 563 } else { 564 $button_loading.templines_button('loading'); 565 } 566 567 templines_require([ 568 templines_wp_vars.themeUri + '/assets/js/photoswipe/photoswipe.min.js?v=' + templines_wp_vars.stylesHash, 569 templines_wp_vars.themeUri + '/assets/js/photoswipe/photoswipe-ui-default.min.js?v=' + templines_wp_vars.stylesHash, 570 templines_wp_vars.ajaxUrl + '?action=templines_vehicle_images&product_id=' + $button.data('product-id'), 571 templines_wp_vars.themeUri + '/assets/css/photoswipe/photoswipe.css', 572 templines_wp_vars.themeUri + '/assets/css/photoswipe/default-skin/default-skin.css' 573 ], function (values) { 574 var images = values[2]; 575 $button_loading.templines_button('reset'); 576 if (images.images.length) { 577 var options = { 578 index : index ? index : 0, 579 showHideOpacity : true, 580 bgOpacity : 1, 581 loop : false, 582 closeOnVerticalDrag: false, 583 mainClass : '', 584 barsSize : {top: 0, bottom: 0}, 585 captionEl : false, 586 fullscreenEl : false, 587 zoomEl : true, 588 shareEl : false, 589 counterEl : false, 590 tapToClose : true, 591 tapToToggleControls: false, 592 history : false 593 }; 594 595 var pswpElement = $('.pswp')[0]; 596 597 templines_wpadminbar_resize(); 598 599 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, images.images, options); 600 gallery.init(); 601 602 gallery.listen('afterChange', function () { 603 if (!templines_empty(gallery.currItem.html)) { 604 $('.pswp__video-wrap').fitVids(); 605 } 606 }); 607 608 gallery.listen('close', function () { 609 $('.pswp__video-wrap').html(''); 610 }); 611 612 $('.pswp__video-wrap').fitVids(); 613 } 614 }); 615 }) 616 .on('click', ".js-ajax-search-all", function (e) { 617 $('.js-search-form').submit(); 618 }) 619 .on('click', '.js-notice-close', function (e) { 620 e.preventDefault(); 621 var $notice = $(this).closest('.woocommerce-notice'); 622 $notice.animate({ 623 opacity: 0, 624 }, 500, function () { 625 $notice.remove(); 626 }); 627 }) 628 .on('click', '.js-cart-coupon', function (e) { 629 e.preventDefault(); 630 var $coupon = $(".c-cart__coupon-from-wrap"); 631 $coupon.toggleClass('c-cart__coupon-from-wrap--opened'); 632 $('.c-cart__select-svg').toggleClass('c-cart__select-svg--opened'); 633 if ($coupon.hasClass('c-cart__coupon-from-wrap--opened')) { 634 setTimeout(function () { 635 $coupon.find('input[type=text]').first().focus(); 636 }, 500); 637 } 638 return false;
639 }) 640 .on('checkout_error updated_checkout applied_coupon removed_coupon', function () { 641 var $notices = $('div.woocommerce-notice:not(.shown), div.woocommerce-error:not(.shown), div.woocommerce-message:not(.shown)'); 642 if ($notices.length) { 643 $notices.detach(); 644 templines_show_notice($notices); 645 } 646 }) 647 .on('change', '#ship-to-different-address input', function () { 648 if (templines_wp_vars.stickySidebar && $templines_sticky_sidebar_nearby.length && $templines_sticky_sidebar_nearby.length) { 649 setTimeout(function () { 650 delete root.templines_scroll_offset_last; 651 if (templines_sticky_sidebar_old_style !== null) { 652 $templines_sticky_sidebar.attr('style', templines_sticky_sidebar_old_style); 653 templines_sticky_sidebar_old_style = null; 654 } 655 templines_sticky_sidebar(); 656 }, 1000); 657 } 658 }) 659 .on('click', ".js-apply-coupon", function () { 660 661 var params = null; 662 var is_cart = false; 663 664 if (typeof wc_checkout_params != 'undefined') { 665 params = wc_checkout_params; 666 is_cart = false; 667 } 668 669 if (typeof wc_cart_params != 'undefined') { 670 params = wc_cart_params; 671 is_cart = true; 672 } 673 674 if (!params) { 675 return false; 676 } 677 678 var $collaterals = $(this).closest('.c-cart__collaterals'); 679 680 if ($collaterals.is('.processing')) { 681 return false; 682 } 683 684 $collaterals.addClass('processing').block({ 685 message : null, 686 overlayCSS: { 687 background: '#fff', 688 opacity : 0.6 689 } 690 }); 691 692 var data = { 693 security : params.apply_coupon_nonce, 694 coupon_code: $collaterals.find('input[name="coupon_code"]').val() 695 }; 696 697 $.ajax({ 698 type : 'POST', 699 url : params.wc_ajax_url.toString().replace('%%endpoint%%', 'apply_coupon'), 700 data : data, 701 success : function (code) { 702 if (code) { 703 templines_show_notice(code); 704 if (is_cart) { 705 $.ajax({ 706 url : params.wc_ajax_url.toString().replace('%%endpoint%%', 'get_cart_totals'), 707 dataType: 'html', 708 success : function (response) { 709 $collaterals.html(response); 710 }, 711 complete: function () { 712 $collaterals.removeClass('processing').unblock(); 713 } 714 }); 715 $('.c-cart__shop-update-button').prop('disabled', false).trigger('click'); 716 } else { 717 $collaterals.removeClass('processing').unblock(); 718 $(document.body).trigger('update_checkout', {update_shipping_method: false}); 719 } 720 } 721 }, 722 dataType: 'html' 723 }); 724 725 return false; 726 }); 727 728 templines_wpadminbar_resize(); 729 templines_init_custom_select(); 730 templines_init_notice(); 731 templines_search_init(); 732 templines_header_sticky_init(); 733 templines_header_sticky(); 734 templines_top_menu_init(); 735 templines_mobile_menu_init(); 736 templines_shop_sidebar_init(); 737 templines_init_product_carousel(); 738 templines_init_masonry(); 739 templines_init_vehicle_types_carousel(); 740 templines_init_product_widget_carousel(); 741 templines_init_activities_widget_carousel(); 742 templines_init_news_widget_carousel(); 743 templines_init_reviews_widget_carousel(); 744 templines_init_woocommerce_widget_carousel(); 745 templines_init_date_range_picker(); 746 templines_init_date_range_picker_filter(); 747 templines_init_price_filter(); 748 templines_init_image_list_2(); 749 templines_start_counters(); 750 templines_init_anchor_smooth_scrolling(); 751 752 $('.daterangepicker:not(.type-day):not(.type-night)').addClass('type-' + templines_wp_vars.bookingType); 753 754 $(document) 755 .on('templines.wpadminbar.scroll templines.sticky templines.sticky.late', templines_set_notice_offset) 756 .trigger('templines.wpadminbar.scroll', templines_adminbar_visible_height); 757 758 $('.entry-content').fitVids(); 759 760 templines_scroll_busy = false; 761 templines_resize_busy = false; 762 }); 763 764 $(document).on('click', '.wc-tabs li a', function (e) { 765 e.preventDefault(); 766 var $tab = $(this); 767 var $tabs_wrapper = $tab.closest('.wc-tabs-wrapper, .woocommerce-tabs'); 768 $tabs_wrapper.find('.wc-tab.visible').removeClass('visible'); 769 $tabs_wrapper.find('.wc-tab.current').removeClass('current'); 770 $tabs_wrapper.find($tab.attr('href')).addClass('current'); 771 772 setTimeout(function () { 773 $tabs_wrapper.find($tab.attr('href')).addClass('visible'); 774 }, 100); 775 776 }); 777 778 root.templines_scroll_actions = function () { 779 templines_wpadminbar_scroll(); 780 templines_to_top_button(); 781 templines_header_sticky(); 782 templines_sticky_sidebar(); 783 templines_init_masonry(); 784 templines_start_counters(); 785 templines_filter_sticky(); 786 787 templines_scroll_busy = false;
788 }; 789 790 root.templines_resize_actions = function () { 791 792 var templines_is_mobile_layout_new = (window.innerWidth < 1170); 793 var is_layout_changed = (templines_is_mobile_layout !== templines_is_mobile_layout_new); 794 templines_is_mobile_layout = templines_is_mobile_layout_new; 795 796 var templines_layout_4_new = (window.innerWidth < 600); 797 var is_layout_changed_4 = (templines_layout_4 !== templines_layout_4_new); 798 templines_layout_4 = templines_layout_4_new; 799 800 801 templines_wpadminbar_resize(); 802 templines_set_notice_offset(); 803 804 if (is_layout_changed) { // switch between mobile and desktop layouts 805 $(document).addClass('block-transition'); 806 setTimeout(function () { 807 $(document).removeClass('block-transition'); 808 }, 500); 809 810 templines_header_sticky_init(); 811 templines_header_sticky(); 812 templines_search_popup(false); 813 templines_mobile_menu_popup(false); 814 templines_sidebar_popup(false); 815 templines_mobile_menu_init(); 816 templines_shop_sidebar_init(); 817 templines_set_notice_offset(); 818 templines_sticky_sidebar(); 819 templines_init_vehicle_height(); 820 templines_filter_sticky(); 821 822 setTimeout(function () { 823 templines_wpadminbar_resize(); 824 $(document).trigger('templines.wpadminbar.scroll', templines_adminbar_visible_height); 825 }, 100); 826 } 827 828 if (is_layout_changed_4) { 829 templines_init_masonry(); 830 } 831 832 $('.hasCustomSelect').trigger('render'); 833 834 templines_resize_busy = false; 835 }; 836
837 838 $(window).on('scroll', 839 function () { 840 if (window.requestAnimationFrame) { 841 if (!templines_scroll_busy) { 842 templines_scroll_busy = true; 843 window.requestAnimationFrame(templines_scroll_actions); 844 } 845 } else { 846 templines_scroll_actions(); 847 } 848 } 849 ); 850 851 $(window).on('resize', 852 function () { 853 if (window.requestAnimationFrame) { 854 if (!templines_resize_busy) { 855 templines_resize_busy = true; 856 window.requestAnimationFrame(templines_resize_actions); 857 } 858 } else { 859 templines_resize_actions(); 860 } 861 } 862 ); 863 864 root.templines_init_vehicle_height = function (is_first) { 865 $('.js-vehicle-types-carousel').each(function () { 866 var $list = $(this); 867 var $vehicles = $('.c-vehicle', $list); 868 if (is_first) { 869 if (!$list.hasClass('owl-carousel')) { 870 $vehicles.each(function () { 871 var $this = $(this); 872 $this.css({'min-height': $this.outerHeight() + 'px'}); 873 }); 874 } 875 } else { 876 $vehicles.each(function () { 877 var $this = $(this); 878 $this.css({'min-height': ''}); 879 }); 880 setTimeout(function () { 881 var max_height = 0; 882 $vehicles.each(function () { 883 var $this = $(this); 884 max_height = Math.max($this.outerHeight(), max_height); 885 }); 886 $vehicles.each(function () { 887 var $this = $(this); 888 $this.css({'min-height': max_height + 'px'}); 889 }); 890 }, 100); 891 } 892 }); 893 $('.js-vehicle-types-tabs').each(function () { 894 var $list = $(this); 895 var $tabs = $('.c-vehicle-types__tab', $list); 896 if (is_first) { 897 if (!$list.hasClass('loaded')) { 898 var max_height = 0; 899 $tabs.each(function () { 900 var $this = $(this); 901 max_height = Math.max($this.outerHeight(), max_height); 902 }); 903 $list.css({'height': max_height + 'px'}); 904 $list.addClass('loaded'); 905 } 906 } else { 907 $tabs.each(function () { 908 var $this = $(this); 909 $this.css({'min-height': ''}); 910 }); 911 setTimeout(function () { 912 var max_height = 0; 913 $tabs.each(function () { 914 var $this = $(this); 915 max_height = Math.max($this.outerHeight(), max_height); 916 }); 917 $list.css({'height': max_height + 'px'}); 918 }, 100); 919 } 920 }); 921 }; 922 923 root.templines_start_counters = function (force) { 924 925 if (force) { 926 $templines_counters = $('.js-counter-number'); 927 } 928 929 $templines_counters.each(function () { 930 931 var $number = $(this), 932 data = $number.data(); 933 934 if ($number.data('started')) { 935 return; 936 } 937 938 if ($(window).scrollTop() > $number.offset().top - window.innerHeight) { 939 940 var decimalDigits = data.toValue.toString().match(/\.(.*)/); 941 942 if (decimalDigits) { 943 data.rounding = decimalDigits[1].length; 944 } 945 946 $number.numerator(data).data('started', true); 947 } 948 }); 949 }; 950 951 root.templines_search_popup = function (show) { 952 if (show && !templines_search_popup_active) { 953 templines_mobile_menu_popup(false); 954 templines_search_popup_active = true; 955 $templines_search.addClass('c-header-search--active'); 956 $templines_search.find('.c-header-search__wrap').addClass('c-header-search__wrap--active'); 957 bodyScrollLock.disableBodyScroll(templines_is_mobile_layout ? $templines_search_result[0] : $templines_search[0]); 958 } else if (templines_search_popup_active) { 959 templines_search_popup_active = false; 960 $templines_search.removeClass('c-header-search--active'); 961 $templines_search.find('.c-header-search__wrap').removeClass('c-header-search__wrap--active'); 962 bodyScrollLock.clearAllBodyScrollLocks(); 963 } 964 }; 965 966 root.templines_search_clear = function () { 967 $templines_search_input.val('').trigger('input').focus(); 968 $templines_search.off(templines_on_transition_end, templines_search_clear); 969 }; 970 971 root.templines_wpadminbar_resize = function () { 972 $templines_admin_bar = $('#wpadminbar'); 973 if ($templines_admin_bar.length) { 974 var window_width = $window.width(); 975 if (window_width > 782 && $templines_admin_bar.hasClass('mobile')) { 976 $templines_admin_bar.removeClass('mobile'); 977 } else if (window_width <= 782 && !$templines_admin_bar.hasClass('mobile')) { 978 $templines_admin_bar.addClass('mobile'); 979 } 980 templines_adminbar_height = $templines_admin_bar.outerHeight(); 981 templines_adminbar_position = $templines_admin_bar.css('position'); 982 983 if (templines_adminbar_position === 'fixed' || templines_adminbar_position === 'absolute') { 984 $(".js-fixed").css({ 985 top : templines_adminbar_visible_height, 986 'max-height': 'calc(100% - ' + templines_adminbar_visible_height + 'px)' 987 }); 988 } else { 989 $(".js-fixed").css({ 990 top : 0, 991 'max-height': '100%' 992 }); 993 } 994 995 templines_wpadminbar_scroll(); 996 } 997 }; 998 999 root.templines_wpadminbar_scroll = function () { 1000 if ($templines_admin_bar === null) { 1001 $templines_admin_bar = $('#wpadminbar'); 1002 } 1003 if ($templines_admin_bar.length) { 1004 var scroll_top_mobile = window.scrollY; 1005 var top_new = 0; 1006 1007 if (templines_adminbar_position === 'fixed') { 1008 top_new = templines_adminbar_height; 1009 } else { 1010 top_new = templines_adminbar_height - scroll_top_mobile; 1011 if (top_new < 0) { 1012 top_new = 0; 1013 } 1014 } 1015 1016 if (templines_adminbar_visible_height != top_new) { 1017 templines_adminbar_visible_height = top_new; 1018 $(document).trigger('templines.wpadminbar.scroll', templines_adminbar_visible_height); 1019 } 1020 } 1021 }; 1022 1023 root.templines_open_photo_swipe = function (imageWrap, index) { 1024 var $this, $a, $img, items = [], size, item; 1025 $slick_product_single_slides.each(function () { 1026 $this = $(this); 1027 $a = $this.children('a'); 1028 $img = $a.children('img'); 1029 size = $a.data('size').split('x'); 1030 1031 item = { 1032 src : $a.attr('href'), 1033 w : parseInt(size[0], 10), 1034 h : parseInt(size[1], 10), 1035 msrc: $img.attr('src'), 1036 el : $a[0] 1037 }; 1038 1039 items.push(item); 1040 }); 1041 1042 var options = { 1043 index : index, 1044 showHideOpacity : true, 1045 bgOpacity : 1, 1046 loop : false, 1047 closeOnVerticalDrag: false, 1048 mainClass : ($slick_product_single_slides.length >
1048 1) ? 'pswp--minimal--dark' : 'pswp--minimal--dark pswp--single--image', 1049 barsSize : {top: 0, bottom: 0}, 1050 captionEl : false, 1051 fullscreenEl : false, 1052 zoomEl : false, 1053 shareEl : false, 1054 counterEl : false, 1055 tapToClose : true, 1056 tapToToggleControls: false, 1057 history : false 1058 }; 1059 1060 var pswpElement = $('.pswp')[0]; 1061 1062 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 1063 gallery.init(); 1064 1065 gallery.listen('initialZoomIn', function () { 1066 $(this).product_thumbnails_speed = $slick_product_thumbnails.slick('slickGetOption', 'speed'); 1067 $slick_product_thumbnails.slick('slickSetOption', 'speed', 0); 1068 }); 1069 1070 var slide = index; 1071 gallery.listen('beforeChange', function (dirVal) { 1072 slide = slide + dirVal; 1073 $slick_product_single.slick('slickGoTo', slide, true); 1074 }); 1075 gallery.listen('close', function () { 1076 $slick_product_thumbnails.slick('slickSetOption', 'speed', $(this).product_thumbnails_speed); 1077 }); 1078 }; 1079 1080 root.ajaxSearchFunction = templines_debounce(function () { 1081 var search = $templines_search_input.val().trim(); 1082 var $search_form = $templines_search_input.closest('form'); 1083 if (templines_empty(search)) { 1084 $templines_search_result.html(''); 1085 } else { 1086 $templines_search_loader.insertBefore($templines_search_input); 1087 $.ajax({ 1088 url : templines_wp_vars.ajaxUrl, 1089 type : 'POST', 1090 data : { 1091 action: 'templines_ajax_search', 1092 s : search, 1093 lang : $('input[name="lang"]', $search_form).val() 1094 }, 1095 success: function (results) { 1096 $templines_search_loader.remove(); 1097 $templines_search_result.html((templines_empty($templines_search_input.val().trim())) ? '' : results); 1098 } 1099 }); 1100 } 1101 }, 500); 1102 1103 root.templines_top_menu_init = function () { 1104 var $templines_top_menu = $('.js-top-menu'); 1105 1106 if ($templines_top_menu.length) { 1107 $templines_top_menu.find('.c-top-menu__subitem--has-children').each(function () { 1108 var $li = $(this); 1109 if ($li.find('ul').length) { 1110 $li.append('<i class="ip-z-angle-right-solid c-top-menu__more-svg"></i>'); 1111 } else { 1112 $li.removeClass('c-top-menu__subitem--has-children'); 1113 } 1114 }); 1115 } 1116 }; 1117 1118 root.templines_search_init = function () { 1119 $templines_search.removeClass('c-header-search--disabled'); 1120 1121 $('.js-search-button').click(function () { 1122 templines_search_popup(true); 1123 setTimeout(function () { 1124 $templines_search_input.focus(); 1125 }, 500); 1126 }); 1127 1128 $('#templines-ajax-search-close').click(function () { 1129 $templines_search.on(templines_on_transition_end, templines_search_clear); 1130 templines_search_popup(false); 1131 }); 1132 1133 $templines_search_input.on('keydown', function (e) { 1134 var $this = $(this); 1135 var is_not_empty = !templines_empty($this.val().trim()); 1136 1137 if (e.keyCode == 13) { 1138 e.preventDefault(); 1139 if ($this.hasClass('c-header-search__input--no-ajax') && is_not_empty) { 1140 $this.closest('form').submit(); 1141 } 1142 } else if (e.keyCode == 27) { 1143 templines_search_popup(false); 1144 } 1145 }).on('input', function () { 1146 var $this = $(this); 1147 var is_not_empty = !templines_empty($this.val().trim()); 1148 1149 if (is_not_empty && !templines_search_input_filled) { 1150 templines_search_input_filled = true; 1151 $('#templines-ajax-search-clear').addClass('c-header-search__clear--active'); 1152 1153 } else if (!is_not_empty && templines_search_input_filled) { 1154 templines_search_input_filled = false; 1155 $('#templines-ajax-search-clear').removeClass('c-header-search__clear--active'); 1156 } 1157 ajaxSearchFunction(); 1158 }); 1159 1160 $('#templines-ajax-search-clear').click(function () { 1161 templines_search_clear(); 1162 }); 1163 1164 $(document).on('templines.wpadminbar.scroll', function (event, wpadminbar_height) { 1165 $templines_search.css({ 1166 transform : 'translateY(' + wpadminbar_height + 'px)', 1167 'max-height': 'calc(100% - ' + wpadminbar_height + 'px)' 1168 }); 1169 }); 1170 }; 1171 1172 root.templines_sidebar_popup = function (show) { 1173 if (templines_shop_sidebar_initialized) { 1174 if (show && !templines_shop_sidebar_active) { 1175 templines_shop_sidebar_active = true; 1176 $templines_shop_sidebar.addClass('c-catalog-sidebar--active'); 1177 $templines_shop_sidebar_wrap.addClass('c-catalog-sidebar__wrap--active'); 1178 bodyScrollLock.disableBodyScroll($templines_shop_sidebar_content[0]); 1179 } else if (templines_shop_sidebar_active) { 1180 templines_shop_sidebar_active = false;
1181 $templines_shop_sidebar.removeClass('c-catalog-sidebar--active'); 1182 $templines_shop_sidebar_wrap.removeClass('c-catalog-sidebar__wrap--active'); 1183 bodyScrollLock.clearAllBodyScrollLocks(); 1184 } 1185 } 1186 }; 1187 1188 root.templines_shop_sidebar_init = function () { 1189 if (templines_is_mobile_layout && !templines_shop_sidebar_initialized && $templines_shop_sidebar.length) { 1190 $(document).on('templines.wpadminbar.scroll', function (event, wpadminbar_height) { 1191 if (templines_is_mobile_layout) { 1192 $templines_shop_sidebar.css({ 1193 transform : 'translateY(' + wpadminbar_height + 'px)', 1194 'max-height': 'calc(100% - ' + wpadminbar_height + 'px)' 1195 }); 1196 } else { 1197 $templines_shop_sidebar.css({ 1198 transform : '', 1199 'max-height': '' 1200 }); 1201 } 1202 }); 1203 $templines_shop_sidebar_open.click(function () { 1204 templines_sidebar_popup(true); 1205 }); 1206 1207 $templines_shop_sidebar_close.click(function () { 1208 templines_sidebar_popup(false); 1209 }); 1210 templines_shop_sidebar_initialized = true; 1211 } 1212 }; 1213 1214 root.templines_mobile_menu_popup = function (show) { 1215 if (templines_mobile_menu_initialized) { 1216 if (show && !templines_mobile_menu_active) { 1217 templines_mobile_menu_active = true; 1218 $templines_mobile_menu.addClass('c-header__menu--active'); 1219 $templines_mobile_menu_wrap.addClass('c-header__menu-wrap--active'); 1220 bodyScrollLock.disableBodyScroll($templines_mobile_menu_content[0]); 1221 } else if (templines_mobile_menu_active) { 1222 templines_mobile_menu_active = false; 1223 $templines_mobile_menu.removeClass('c-header__menu--active'); 1224 $templines_mobile_menu_wrap.removeClass('c-header__menu-wrap--active'); 1225 bodyScrollLock.clearAllBodyScrollLocks(); 1226 } 1227 } 1228 }; 1229 1230 root.templines_mobile_menu_init = function () { 1231 if (templines_is_mobile_layout && !templines_mobile_menu_initialized && $templines_mobile_menu.length) { 1232 $(document).on('templines.wpadminbar.scroll', function (event, wpadminbar_height) { 1233 $templines_mobile_menu.css({ 1234 transform : 'translateY(' + wpadminbar_height + 'px)', 1235 'max-height': 'calc(100% - ' + wpadminbar_height + 'px)' 1236 }); 1237 }); 1238 1239 $templines_mobile_menu.find('.c-mega-menu__item--has-children, .c-mega-menu__subitem--has-children').each(function () { 1240 var $li = $(this); 1241 if ($li.find('ul').length) { 1242 var $button = $('<button type="button" class="h-cb c-mega-menu__more js-menu-more"><i class="ip-z-angle-right-solid c-mega-menu__more-svg"></i></button>'); 1243 $li.append($button); 1244 $li.children('a').each(function () { 1245 if (templines_empty($(this).attr('href'))) { 1246 $(this).click(function () { 1247 $button.trigger('click'); 1248 }); 1249 } 1250 }); 1251 } 1252 }); 1253 1254 $('.js-menu-more').click(function () { 1255 var $submenu = $(this).closest('li').children('ul'); 1256 var $current_submenu = $(this).closest('.c-mega-menu__submenu'); 1257 $templines_mobile_submenu.push($submenu); 1258 var top = $('.c-header__menu-buttons').outerHeight(); 1259 var bottom = $('.c-header__menu-bottom').outerHeight(); 1260 if ($templines_mobile_submenu.length == 1) { 1261 $submenu.css({ 1262 top : top + 'px', 1263 bottom : bottom + 'px', 1264 'max-height': 'calc(100% - ' + (top + bottom) + 'px)' 1265 }); 1266 } 1267 if ($current_submenu.length) { 1268 $current_submenu.scrollTop(0); 1269 $current_submenu.addClass('c-mega-menu__submenu--parent'); 1270 } 1271 $submenu.addClass('c-mega-menu__submenu--active'); 1272 $templines_mobile_menu_back.addClass('c-header__menu-back--active'); 1273 bodyScrollLock.clearAllBodyScrollLocks(); 1274 bodyScrollLock.disableBodyScroll($submenu[0]); 1275 }); 1276 1277 $templines_mobile_menu_back.click(function () { 1278 if ($templines_mobile_submenu.length) { 1279 var $submenu = $templines_mobile_submenu.pop(); 1280 $submenu.removeClass('c-mega-menu__submenu--active'); 1281 bodyScrollLock.clearAllBodyScrollLocks(); 1282 } 1283 if (!$templines_mobile_submenu.length) { 1284 bodyScrollLock.disableBodyScroll($templines_mobile_menu_content[0]); 1285 $templines_mobile_menu_back.removeClass('c-header__menu-back--active'); 1286 } else { 1287 var $prev = $templines_mobile_submenu[$templines_mobile_submenu.length - 1]; 1288 $prev.removeClass('c-mega-menu__submenu--parent'); 1289 bodyScrollLock.disableBodyScroll($prev[0]); 1290 } 1291 }); 1292 1293 $templines_mobile_menu_open.click(function () { 1294 templines_mobile_menu_popup(true); 1295 }); 1296 1297 $templines_mobile_menu_close.click(function () { 1298 templines_mobile_menu_popup(false); 1299 }); 1300 1301 templines_mobile_menu_initialized = true; 1302 } 1303 }; 1304 1305 root.templines_init_vehicle_types_carousel = function () { 1306 templines_init_vehicle_height(true); 1307 $('.js-vehicle-types-carousel:not(.owl-carousel)') 1308 .addClass('owl-carousel') 1309 .on('drag.owl.carousel ', function (event) { 1310 templines_vehicle_types_short_block = true; 1311 $('.c-vehicle-types__short.active').removeClass('active'); 1312 }) 1313 .on('translated.owl.carousel', function (event) { 1314 templines_vehicle_types_short_block = false;
1315 if ($templines_vehicle_types_short_last !== null) { 1316 $templines_vehicle_types_short_last.trigger('mouseover'); 1317 } 1318 }) 1319 .on('resized.owl.carousel', templines_owl_hide_arrows) 1320 .owlCarousel({ 1321 center : false, 1322 autoWidth : true, 1323 loop : false, 1324 margin : 0, 1325 nav : true, 1326 dots : false, 1327 navText : [ 1328 '<i class="ip-arrow-left h-carousel__prev"></i>', 1329 '<i class="ip-arrow-right h-carousel__next"></i>' 1330 ], 1331 onInitialized: templines_owl_hide_arrows 1332 }); 1333 }; 1334 1335 root.templines_init_woocommerce_widget_carousel = function () { 1336 $('.js-woocommerce-carousel:not(.owl-carousel)').each(function () { 1337 var $this = $(this); 1338 $this 1339 .addClass('owl-carousel') 1340 .on('resized.owl.carousel', templines_owl_hide_arrows) 1341 .owlCarousel({ 1342 center : false, 1343 autoWidth : true, 1344 loop : false, 1345 margin : 0, 1346 nav : true, 1347 dots : true, 1348 onInitialized: templines_owl_hide_arrows, 1349 navText : [ 1350 '<i class="ip-arrow-left h-carousel__prev"></i>', 1351 '<i class="ip-arrow-right h-carousel__next"></i>' 1352 ] 1353 }) 1354 .on('changed.owl.carousel', function () { 1355 templines_owl_hide_arrows($this); 1356 }); 1357 }); 1358 }; 1359 1360 root.templines_init_product_widget_carousel = function () { 1361 $('.js-product-carousel:not(.owl-carousel)').each(function () { 1362 var $this = $(this); 1363 $this 1364 .addClass('owl-carousel') 1365 .on('resized.owl.carousel', templines_owl_hide_arrows) 1366 .owlCarousel({ 1367 center : false, 1368 autoWidth : true, 1369 loop : false, 1370 margin : 0, 1371 nav : true, 1372 dots : true, 1373 onInitialized: templines_owl_hide_arrows, 1374 navText : [ 1375 '<i class="ip-arrow-left h-carousel__prev"></i>', 1376 '<i class="ip-arrow-right h-carousel__next"></i>' 1377 ] 1378 }) 1379 .on('changed.owl.carousel', function () { 1380 templines_owl_hide_arrows($this); 1381 }); 1382 }); 1383 }; 1384 1385 root.templines_init_activities_widget_carousel = function () { 1386 $('.js-activities-carousel:not(.owl-carousel)').each(function () { 1387 var $this = $(this); 1388 $this 1389 .addClass('owl-carousel') 1390 .on('resized.owl.carousel', templines_owl_hide_arrows) 1391 .owlCarousel({ 1392 center : false, 1393 autoWidth : true, 1394 loop : false, 1395 margin : 0, 1396 nav : true, 1397 dots : true, 1398 onInitialized: templines_owl_hide_arrows, 1399 navText : [ 1400 '<i class="ip-arrow-left h-carousel__prev"></i>', 1401 '<i class="ip-arrow-right h-carousel__next"></i>' 1402 ] 1403 }) 1404 .on('changed.owl.carousel', function () { 1405 templines_owl_hide_arrows($this); 1406 }); 1407 }); 1408 }; 1409 1410 root.templines_init_news_widget_carousel = function () { 1411 $('.js-news-carousel:not(.owl-carousel)').each(function () { 1412 var $this = $(this); 1413 $this 1414 .addClass('owl-carousel') 1415 .on('resized.owl.carousel', templines_owl_hide_arrows) 1416 .owlCarousel({ 1417 center : false, 1418 autoWidth : true, 1419 loop : false, 1420 margin : 0, 1421 nav : true, 1422 dots : true, 1423 onInitialized: templines_owl_hide_arrows, 1424 navText : [ 1425 '<i class="ip-arrow-left h-carousel__prev"></i>', 1426 '<i class="ip-arrow-right h-carousel__next"></i>' 1427 ] 1428 }) 1429 .on('changed.owl.carousel', function () { 1430 templines_owl_hide_arrows($this); 1431 }); 1432 }); 1433 }; 1434 1435 root.templines_init_reviews_widget_carousel = function () { 1436 $('.js-reviews-carousel:not(.owl-carousel)').each(function () { 1437 var $this = $(this); 1438 $this 1439 .addClass('owl-carousel') 1440 .on('resized.owl.carousel', templines_owl_hide_arrows) 1441 .owlCarousel({ 1442 center : false, 1443 autoWidth : true, 1444 loop : false, 1445 margin : 0, 1446 nav : !$this.hasClass('h-carousel--hide'), 1447 dots : !$this.hasClass('h-carousel--dots-hide'), 1448 onInitialized: templines_owl_hide_arrows, 1449 navText : [ 1450 '<i class="ip-arrow-left h-carousel__prev"></i>', 1451 '<i class="ip-arrow-right h-carousel__next"></i>' 1452 ], 1453 responsive : { 1454 0 : { 1455 nav: 1 1456 }, 1457 1170: { 1458 nav: !$this.hasClass('h-carousel--hide'), 1459 } 1460 } 1461 }) 1462 .on('changed.owl.carousel', function () { 1463 templines_owl_hide_arrows($this); 1464 }); 1465 }); 1466 1467 }; 1468
1469 root.templines_init_product_carousel = function () { 1470 1471 var $carousel = $('.js-single-product-carousel:not(.owl-carousel)'); 1472 if ($carousel.hasClass('woocommerce-product-gallery__wrapper')) { 1473 var index = 0; 1474 $carousel.find('a').each(function () { 1475 var $this = $(this); 1476 $this.addClass('js-product-zoom').data('index', index).attr('data-elementor-open-lightbox', 'no'); 1477 index++; 1478 $this.append('<span class="c-product__loading js-loading-wrap"></span>'); 1479 }); 1480 } 1481 1482 if ($carousel.children().length > 1) { 1483 $carousel.addClass('owl-carousel').owlCarousel({ 1484 center : false, 1485 items : 1, 1486 loop : false, 1487 margin : 0, 1488 nav : true, 1489 dots : false, 1490 autoHeight: true, 1491 navText : [ 1492 '<i class="ip-arrow-left h-carousel__prev"></i>', 1493 '<i class="ip-arrow-right h-carousel__next"></i>' 1494 ] 1495 }) 1496 .on('changed.owl.carousel', function (event) { 1497 var currentItem = event.item.index; 1498 $('.c-vehicle-details__thumbs-item.active').removeClass('active'); 1499 $('.c-vehicle-details__thumbs-item').eq(currentItem).addClass('active'); 1500 $('.js-product-thumbs-carousel').trigger('to.owl.carousel', [currentItem, 300]); 1501 }); 1502 templines_init_product_thumbs_carousel(); 1503 } 1504 }; 1505 1506 root.templines_init_product_thumbs_carousel = function () { 1507 $('.js-product-thumbs-carousel:not(.owl-carousel)').addClass('owl-carousel').owlCarousel({ 1508 center : false, 1509 loop : false, 1510 margin : 20, 1511 nav : true, 1512 dots : false, 1513 autoWidth: true, 1514 navText : [ 1515 '<i class="ip-arrow-left h-carousel__prev"></i>', 1516 '<i class="ip-arrow-right h-carousel__next"></i>' 1517 ] 1518 }); 1519 $('.js-single-product-thumb:not(.init)').addClass('init').click(function () { 1520 var index = $(this).data('index'); 1521 var $item = $(this).closest('.c-vehicle-details__thumbs-item'); 1522 $('.c-vehicle-details__thumbs-item.active').removeClass('active'); 1523 $item.addClass('active'); 1524 $('.js-single-product-carousel').trigger("to.owl.carousel", [index, 300]); 1525 }); 1526 }; 1527 1528 root.templines_init_masonry = function (force) { 1529 if (templines_masonry_grid_on && !templines_is_masonry_init && !templines_layout_4 && ($window.scrollTop() > 0 || force)) { 1530 templines_is_masonry_init = true; 1531 $templines_masonry_grid.find('img[loading]').removeAttr('loading'); 1532 1533 templines_require([ 1534 templines_wp_vars.masonryUrl, 1535 templines_wp_vars.imagesloadedUrl 1536 ], function () { 1537 var msnry = new Masonry($templines_masonry_grid[0], { 1538 itemSelector : '.js-post-item',
1539 columnWidth : '.js-post-sizer', 1540 percentPosition: true 1541 }); 1542 1543 $templines_masonry_grid.imagesLoaded().progress(function () { 1544 msnry.layout(); 1545 }); 1546 1547 $templines_masonry_grid.imagesLoaded(function () { 1548 msnry.layout(); 1549 }); 1550 }); 1551 } 1552 }; 1553 1554 root.templines_init_custom_select = function () { 1555 $('select.styled:not(.hasCustomSelect), select.orderby:not(.hasCustomSelect), .c-ordering__select select:not(.hasCustomSelect), .variations select:not(.hasCustomSelect), .widget select:not(.hasCustomSelect):not(.woocommerce-widget-layered-nav-dropdown):not(.dropdown_product_cat)').each(function () { 1556 $(this).customSelect({ 1557 customClass: "c-custom-select", 1558 mapClass : false, 1559 }).parent().find('.c-custom-select').append('<i class="ip-select c-custom-select__angle"><!-- --></i>'); 1560 }); 1561 }; 1562 1563 root.templines_to_top_button = function () { 1564 if ($templines_to_top_button.length) { 1565 if ($window.scrollTop() > 500) { 1566 if (!$templines_to_top_button.hasClass('c-to-top-button--active')) { 1567 $templines_to_top_button.addClass('c-to-top-button--active'); 1568 } 1569 } else { 1570 if ($templines_to_top_button.hasClass('c-to-top-button--active')) { 1571 $templines_to_top_button.removeClass('c-to-top-button--active'); 1572 } 1573 } 1574 } 1575 }; 1576 1577 root.templines_daterangepicker_position = function (position) { 1578 var $input = $('.js-book-date-range'); 1579 var $daterangepicker = $('.daterangepicker:not(.inner-calendar)'); 1580 if (!position || position === 'relative') { 1581 $daterangepicker.css({position: 'absolute'}); 1582 $(window).trigger('resize.daterangepicker'); 1583 } else { 1584 if ($input.length && $input.hasClass('opened')) { 1585 if (position === 'fixed') { 1586 var $sidebar = $('.js-sticky-sidebar'); 1587 var _top = $input.offset().top - $sidebar.offset().top + $input.outerHeight() + $sidebar.position().top; 1588 $daterangepicker.css({ 1589 top : _top + 'px', 1590 position: 'fixed' 1591 }); 1592 } else if ((position === 'absolute')) { 1593 $daterangepicker.css({position: 'absolute'}); 1594 $(window).trigger('resize.daterangepicker'); 1595 } 1596 } 1597 } 1598 }; 1599 1600 root.templines_sticky_sidebar = function () { 1601 1602 if (templines_wp_vars.stickySidebar && $templines_sticky_sidebar.length && $templines_sticky_sidebar_nearby.length) { 1603 1604 var sb = $templines_sticky_sidebar; 1605 var content = $templines_sticky_sidebar_nearby; 1606 1607 if (templines_is_mobile_layout) { 1608 1609 if (templines_sticky_sidebar_old_style !== null) { 1610 sb.attr('style', templines_sticky_sidebar_old_style); 1611 templines_sticky_sidebar_old_style = null; 1612 } 1613 1614 } else { 1615 1616 var sb_height = sb.outerHeight(true); 1617 var content_height = content.outerHeight(true); 1618 var content_top = content.offset().top; 1619 var scroll_offset = $window.scrollTop(); 1620 var window_width = $window.width(); 1621 1622 var top_panel_fixed_height = templines_sticky_desktop_active ? $templines_desktop_sticky_row.outerHeight() + templines_adminbar_visible_height + 25 : templines_adminbar_visible_height; 1623 1624 if (sb_height < content_height && scroll_offset + top_panel_fixed_height > content_top) { 1625 1626 var sb_init = { 1627 'position': 'undefined', 1628 'float' : 'none', 1629 'top' : 'auto', 1630 'bottom' : 'auto' 1631 }; 1632 1633 if (typeof templines_scroll_offset_last == 'undefined') { 1634 root.templines_sb_top_last = content_top; 1635 root.templines_scroll_offset_last = scroll_offset; 1636 root.templines_scroll_dir_last = 1; 1637 root.templines_window_width_last = window_width; 1638 } 1639 1640 var scroll_dir = scroll_offset - templines_scroll_offset_last; 1641 if (scroll_dir === 0) { 1642 scroll_dir = templines_scroll_dir_last; 1643 } else { 1644 scroll_dir = scroll_dir > 0 ? 1 : -1; 1645 } 1646 1647 var sb_big = sb_height + 30 >= $window.height() - top_panel_fixed_height, 1648 sb_top = sb.offset().top; 1649 1650 if (sb_top < 0) { 1651 sb_top = templines_sb_top_last; 1652 } 1653 1654 if (sb_big) { 1655 1656 if (scroll_dir != templines_scroll_dir_last && sb.css('position') == 'fixed') {
1657 sb_init.top = sb_top - content_top; 1658 sb_init.position = 'absolute'; 1659 1660 } else if (scroll_dir > 0) { 1661 if (scroll_offset + $window.height() >= content_top + content_height + 30) { 1662 sb_init.bottom = 0; 1663 sb_init.position = 'absolute'; 1664 } else if (scroll_offset + $window.height() >= (sb.css('position') == 'absolute' ? sb_top : content_top) + sb_height + 30) { 1665 1666 sb_init.bottom = 30; 1667 sb_init.position = 'fixed'; 1668 } 1669 1670 } else { 1671 1672 if (scroll_offset + top_panel_fixed_height <= sb_top) { 1673 sb_init.top = top_panel_fixed_height; 1674 sb_init.position = 'fixed'; 1675 } 1676 } 1677 1678 } else { 1679 if (scroll_offset + top_panel_fixed_height >= content_top + content_height - sb_height) { 1680 sb_init.bottom = 0; 1681 sb_init.position = 'absolute'; 1682 } else { 1683 sb_init.top = top_panel_fixed_height; 1684 sb_init.position = 'fixed'; 1685 } 1686 } 1687 1688 if (sb_init.position != 'undefined') { 1689 1690 if (sb.css('position') != sb_init.position || templines_scroll_dir_last != scroll_dir || templines_window_width_last != window_width) { 1691 1692 root.templines_window_width_last = window_width; 1693 sb_init.width = sb.parent().width(); 1694 1695 if (templines_sticky_sidebar_old_style === null) { 1696 var style = sb.attr('style'); 1697 if (!style) { 1698 style = ''; 1699 } 1700 templines_sticky_sidebar_old_style = style; 1701 } 1702 sb.css(sb_init); 1703 1704 templines_sticky_sidebar_position = sb_init.position; 1705 templines_daterangepicker_position(sb_init.position); 1706 } 1707 } 1708 1709 root.templines_sb_top_last = sb_top; 1710 root.templines_scroll_offset_last = scroll_offset; 1711 root.templines_scroll_dir_last = scroll_dir; 1712 1713 } else { 1714 if (templines_sticky_sidebar_old_style !== null) { 1715 sb.attr('style', templines_sticky_sidebar_old_style); 1716 templines_sticky_sidebar_old_style = null; 1717 1718 templines_sticky_sidebar_position = 'relative'; 1719 templines_daterangepicker_position(); 1720 } 1721 1722 } 1723 } 1724 1725 } 1726 }; 1727 1728 root.templines_hash_menu_animate = function (e, $a) { 1729 if (typeof templines_hash_menu_animate.cnt === 'undefined') { 1730 templines_hash_menu_animate.cnt = 0; 1731 } else { 1732 templines_hash_menu_animate.cnt++; 1733 } 1734 var $this = $(this), $el; 1735 if (typeof $a !== 'undefined') { 1736 $this = $a; 1737 } 1738 if (templines_isset(e)) { 1739 e.preventDefault(); 1740 } 1741 var element_selector = $this.attr('href'); 1742 if (typeof element_selector !== 'undefined' && element_selector.length > 1 && element_selector.indexOf("#tab-") !== 0 && ($el = $(element_selector)) && $el.length) { 1743 if ($el.offset().top == 0 && templines_hash_menu_animate.cnt < 5) { 1744 setTimeout(function () { 1745 templines_hash_menu_animate(e, $this); 1746 }, 100); 1747 return; 1748 } 1749 var offset = $el.offset().top - 25 - (templines_adminbar_position === 'fixed' ? templines_adminbar_height : 0); 1750 if (templines_is_mobile_layout) { 1751 templines_mobile_menu_popup(false); 1752 if ($templines_mobile_sticky_row.length) { 1753 offset -= $templines_mobile_sticky_row.outerHeight(); 1754 } 1755 } 1756 $('html, body').animate({scrollTop: offset}, 800); 1757 } 1758 }; 1759 1760 root.templines_get_minimal_days = function (start, end) { 1761 var days; 1762 var dateFormat = templines_date_format; 1763 templines_minimal_days_error = ''; 1764 1765 if (!templines_isset(start) || !templines_isset(end)) { 1766 days = templines_wp_vars.minimumDays; 1767 templines_maximum_days = templines_wp_vars.maximumDays; 1768 } else if (templines_wp_vars.minimumDaysConditional) { 1769 days = 1; 1770 var start_text = start.format(dateFormat); 1771 var end_text = end.format(dateFormat); 1772 1773 $.ajax({ 1774 url : templines_wp_vars.ajaxUrl, 1775 type : 'POST', 1776 async : false, 1777 data : { 1778 action: 'templines_minimum', 1779 start : start_text, 1780 end : end_text, 1781 }, 1782 dataType: 'json', 1783 success : function (result) { 1784 days = parseInt(result.minimum_days); 1785 templines_maximum_days = parseInt(result.maximum_days); 1786 templines_minimal_days_error = result.error; 1787 } 1788 }); 1789 } else { 1790 days = templines_wp_vars.minimumDays; 1791 templines_maximum_days = templines_wp_vars.maximumDays; 1792 } 1793 return days > 1 ? days : 1; 1794 }; 1795
1796 root.templines_init_date_range_picker_filter = function () { 1797 moment.locale(templines_wp_vars.locale); 1798 var dateFormat = templines_date_format; 1799 1800 var today = moment(); 1801 var minDate = moment(templines_wp_vars.minDate, 'YYYY-MM-DD'); 1802 if (minDate < today) { 1803 minDate = today; 1804 } 1805 var minDateText = minDate.format(dateFormat); 1806 1807 $('.js-filter-date-start').each(function () { 1808 var $container = $(this).closest('.c-filter'); 1809 var $input_start = $('.js-filter-date-start', $container); 1810 var $input_end = $('.js-filter-date-end', $container); 1811 var $input_range = $('.js-filter-date-range', $container); 1812 if ($input_start.length && $input_end.length) { 1813 var startDate; 1814 var endDate; 1815 1816 var defaultStartDate = moment($input_start.data('value'), dateFormat); 1817 var defaultEndDate = moment($input_end.data('value'), dateFormat); 1818 if ( 1819 defaultStartDate.isValid() && 1820 defaultEndDate.isValid() && 1821 defaultStartDate >= minDate && 1822 (templines_is_day ? (defaultStartDate <= defaultEndDate) : (defaultStartDate < defaultEndDate)) 1823 ) { 1824 startDate = defaultStartDate; 1825 endDate = defaultEndDate; 1826 } else { 1827 startDate = minDate; 1828 endDate = startDate.clone().add(templines_is_night ? 1 : 0, 'd'); 1829 endDate = startDate.clone().add(templines_get_minimal_days(startDate, endDate) - (templines_is_day ? 1 : 0), 'd'); 1830 } 1831 1832 $input_start.val(startDate.format(dateFormat)); 1833 $input_end.val(endDate.format(dateFormat)); 1834 $input_range.val(startDate.format(dateFormat) + ' â ' + endDate.format(dateFormat)); 1835 1836 $input_range.daterangepicker({ 1837 locale : { 1838 format : dateFormat, 1839 applyLabel : templines_wp_vars.applyLabel, 1840 cancelLabel: templines_wp_vars.cancelLabel, 1841 }, 1842 opens : "center", 1843 alwaysShowCalendars: true, 1844 minDate : minDateText, 1845 startDate : startDate, 1846 endDate : endDate, 1847 autoApply : true, 1848 autoUpdateInput : false, 1849 isCustomDate : templines_get_date_class_avail 1850 }, function (start, end, label) { 1851 1852 if (templines_is_night && start.isSame(end, 'day')) { 1853 end = start.clone().add(1, 'day'); 1854 } 1855 1856 var not_avail_pickup = false; 1857 var not_avail_dropoff = false; 1858 1859 if (Object.keys(templines_wp_vars.holidays).length) { 1860 if (moment(start).format("YYYY-MM-DD") in templines_wp_vars.holidays) { 1861 not_avail_pickup = true; 1862 } 1863 if (moment(end).format("YYYY-MM-DD") in templines_wp_vars.holidays) { 1864 not_avail_dropoff = true; 1865 } 1866 } 1867 1868 if (templines_wp_vars.pickupDropoffDays.length < 7) { 1869 var pickup_dow = start.day(); 1870 if (!pickup_dow) { 1871 pickup_dow = 7; 1872 } 1873 if (!templines_wp_vars.pickupDropoffDays.includes(pickup_dow + '')) { 1874 not_avail_pickup = true; 1875 } 1876 1877 var dropoff_dow = end.day(); 1878 if (!dropoff_dow) { 1879 dropoff_dow = 7; 1880 } 1881 if (!templines_wp_vars.pickupDropoffDays.includes(dropoff_dow + '')) { 1882 not_avail_dropoff = true; 1883 } 1884 } 1885 1886 if (not_avail_pickup) { 1887 templines_show_notice_error(start.format(dateFormat) + ' ' + templines_wp_vars.pickupNotAvailMsg); 1888 $input_range.on('hide.daterangepicker.ip', function () { 1889 $input_range.off('hide.daterangepicker.ip'); 1890 setTimeout(function () { 1891 $input_range.trigger('click'); 1892 }, 100); 1893 }); 1894 } 1895 1896 if (not_avail_dropoff) { 1897 templines_show_notice_error(end.format(dateFormat) + ' ' + templines_wp_vars.dropoffNotAvailMsg); 1898 $input_range.on('hide.daterangepicker.ip', function () { 1899 $input_range.off('hide.daterangepicker.ip'); 1900 setTimeout(function () { 1901 $input_range.trigger('click'); 1902 }, 100); 1903 }); 1904 } 1905 1906 var days = end.diff(start, 'days') + (templines_is_day ? 1 : 0); 1907 var minDates = templines_get_minimal_days(start, end); 1908 $('.js-filter-button').prop('disabled', false); 1909 if (days < minDates || templines_minimal_days_error) { 1910 if (templines_minimal_days_error) { 1911 templines_show_notice_error(templines_minimal_days_error); 1912 $('.js-filter-button').prop('disabled', true); 1913 } else { 1914 end = start.clone().add(minDates - (templines_is_day ? 1 : 0), 'day'); 1915 templines_show_notice_error(templines_wp_vars.minimumDaysMsg + ' ' + minDates); 1916 } 1917 $input_range.on('hide.daterangepicker.ip', function () { 1918 $input_range.off('hide.daterangepicker.ip'); 1919 setTimeout(function () { 1920 $input_range.trigger('click'); 1921 }, 100); 1922 }); 1923 } 1924 1925 if (templines_maximum_days > 0 && days > templines_maximum_days) { 1926 end = start.clone().add(templines_maximum_days - (templines_is_day ? 1 : 0), 'day'); 1927 templines_show_notice_error(templines_wp_vars.maximumDaysMsg + ' ' + templines_maximum_days); 1928 $input_range.on('hide.daterangepicker.ip', function () { 1929 $input_range.off('hide.daterangepicker.ip'); 1930 setTimeout(function () { 1931 $input_range.trigger('click'); 1932 }, 100); 1933 }); 1934 } 1935 var selectedStartDate = start.format(dateFormat); 1936 var selectedEndDate = end.format(dateFormat); 1937 1938 $input_start.val(selectedStartDate); 1939 $input_end.val(selectedEndDate); 1940 $input_range.val(selectedStartDate + ' â ' + selectedEndDate); 1941 1942 $input_range.data('daterangepicker').setStartDate(selectedStartDate); 1943 $input_range.data('daterangepicker').setEndDate(selectedEndDate); 1944 }); 1945 $input_range 1946 .on('show.daterangepicker', function (ev, picker) { 1947 $input_range.addClass('opened'); 1948 }) 1949 .on('hide.daterangepicker', function (ev, picker) { 1950 $input_range.removeClass('opened'); 1951 }); 1952 1953 } // End Daterange Picker 1954 }); 1955 }; 1956
1957 root.templines_init_date_range_picker = function () { 1958 var $input_start = $('.js-book-date-start'); 1959 var $input_end = $('.js-book-date-end'); 1960 var $input_range = $('.js-book-date-range'); 1961 if ($input_start.length && $input_end.length) { 1962 moment.locale(templines_wp_vars.locale); 1963 1964 var dateFormat = templines_date_format; 1965 var minDate = moment(templines_wp_vars.minDate, 'YYYY-MM-DD'); 1966 var minDateText = minDate.format(dateFormat); 1967 1968 var today = moment(); 1969 if (minDate < today) { 1970 minDate = today; 1971 } 1972 1973 var startDate = moment($input_start.data('value'), dateFormat); 1974 var endDate = moment($input_end.data('value'), dateFormat); 1975 1976 if (startDate < minDate) { 1977 startDate = minDate.clone(); 1978 if (templines_is_night && startDate.isSame(endDate, 'day')) { 1979 endDate = startDate.clone().add(1, 'day'); 1980 } 1981 } 1982 1983 var startDateText = startDate.format(dateFormat); 1984 var endDateText = endDate.format(dateFormat); 1985 1986 $input_start.val(startDateText); 1987 $input_end.val(endDateText); 1988 $input_range.val(startDateText + ' â ' + endDateText); 1989 1990 templines_default_start = startDateText; 1991 templines_default_end = endDateText; 1992 1993 var params = { 1994 locale : { 1995 format : dateFormat, 1996 applyLabel : templines_wp_vars.applyLabel, 1997 cancelLabel: templines_wp_vars.cancelLabel, 1998 }, 1999 opens : "left", 2000 alwaysShowCalendars: false, 2001 minDate : minDateText, 2002 startDate : startDate, 2003 endDate : endDate, 2004 autoApply : !templines_wp_vars.pickup_dropoff_time, 2005 autoUpdateInput : false, 2006 isCustomDate : templines_wp_vars.show_date_class ? templines_get_date_class : templines_get_date_class_avail 2007 }; 2008 2009 if (templines_wp_vars.pickup_dropoff_time) { 2010 params.timePicker = true; 2011 params.timePicker24Hour = true; 2012 params.timePickerIncrement = parseInt(templines_wp_vars.time_increment); 2013 $input_range 2014 .on('showCalendar.daterangepicker', function (ev, picker) { 2015 var $calendars = $('body > .daterangepicker'); 2016 var $left = $calendars.find('.left'); 2017 var $right = $calendars.find('.right'); 2018 var from = $('.js-book-date-start-time').val(); 2019 var to = $('.js-book-date-end-time').val(); 2020 2021 var f_change = function () { 2022 var $this = $(this); 2023 var $calendar = $this.closest('.drp-calendar'); 2024 if ($this.val()) { 2025 var time = $this.val().split(':'); 2026 $('.hourselect', $calendar).val(parseInt(time[0]) + ''); 2027 $('.minuteselect', $calendar).val(parseInt(time[1]) + ''); 2028 if ($calendar.hasClass('left')) { 2029 $('.js-book-date-start-time').val($this.val()); 2030 } else { 2031 $('.js-book-date-end-time').val($this.val()); 2032 } 2033 } 2034 }; 2035 2036 $left.find('.calendar-time-range').remove(); 2037 $left 2038 .append('<div class="calendar-time-range"><label><span class="timeselect__title">' + templines_wp_vars.pickup_time_label + '</span> <select class="timeselect">' + templines_wp_vars.pickup_time_options + '</select></label></div>') 2039 .find('.timeselect') 2040 .on('change', f_change) 2041 .trigger('change'); 2042 if (from) { 2043 $left.find('.timeselect').val(from).trigger('change'); 2044 } 2045 2046 $right.find('.calendar-time-range').remove(); 2047 $right 2048 .append('<div class="calendar-time-range"><label><span class="timeselect__title">' + templines_wp_vars.dropoff_time_label + '</span> <select class="timeselect">' + templines_wp_vars.dropoff_time_options + '</select></label></div>') 2049 .find('.timeselect') 2050 .on('change', f_change) 2051 .trigger('change'); 2052 if (to) { 2053 $right.find('.timeselect').val(to).trigger('change'); 2054 } 2055 }); 2056 } 2057 2058 $input_range.daterangepicker(params, function (start, end, label) { 2059 2060 if (templines_is_night && start.isSame(end, 'day')) { 2061 end = start.clone().add(1, 'day'); 2062 } 2063 2064 var selectedStartDate = start.format(dateFormat); 2065 var selectedEndDate = end.format(dateFormat); 2066 2067 $input_start.val(selectedStartDate); 2068 $input_end.val(selectedEndDate); 2069 $input_range.val(selectedStartDate + ' â ' + selectedEndDate); 2070 2071 $input_range.data('daterangepicker').setStartDate(selectedStartDate); 2072 $input_range.data('daterangepicker').setEndDate(selectedEndDate); 2073 2074 templines_get_total(); 2075 templines_push_state(); 2076 }); 2077 2078 $input_range 2079 .on('apply.daterangepicker', function (ev, picker) { 2080 templines_push_state(); 2081 }) 2082 .on('show.daterangepicker', function (ev, picker) { 2083 $input_range.addClass('opened'); 2084 templines_daterangepicker_position(templines_sticky_sidebar_position); 2085 }) 2086 .on('showCalendar.daterangepicker', function (ev, picker) { 2087 templines_daterangepicker_position(); 2088 }) 2089 .on('show.daterangepicker', function (ev, picker) { 2090 $input_range.addClass('opened'); 2091 templines_daterangepicker_position(templines_sticky_sidebar_position); 2092 }); 2093 2094 $('.js-book-date-btn').click(function () { 2095 $(this).parent().find('input[type="text"]').trigger('click'); 2096 }); 2097 2098 templines_get_total(true); 2099 2100 var $calendar_info = $('.js-booking-calendar-input'); 2101 if ($calendar_info.length && templines_wp_vars.show_date_class) { 2102 var picker = $calendar_info.daterangepicker({ 2103 locale : { 2104 format : dateFormat, 2105 applyLabel : templines_wp_vars.applyLabel, 2106 cancelLabel: templines_wp_vars.cancelLabel, 2107 }, 2108 parentEl : ".js-booking-calendar-info", 2109 alwaysShowCalendars: true, 2110 minDate : minDate, 2111 autoApply : true, 2112 autoUpdateInput : false, 2113 singleDatePicker : false, 2114 isCustomDate : function (data) { 2115 return templines_get_date_class(data); 2116 } 2117 }).on('show.daterangepicker', function () { 2118 $('.js-booking-calendar-info .daterangepicker').addClass('inner-calendar'); 2119 }); 2120 picker.data('daterangepicker').hide = function (e) { 2121 var _this = picker.data('daterangepicker'); 2122 if (!_this.endDate) { 2123 _this.startDate = _this.oldStartDate.clone(); 2124 _this.endDate = _this.oldEndDate.clone(); 2125 } 2126 if (!_this.startDate.isSame(_this.oldStartDate) || !_this.endDate.isSame(_this.oldEndDate)) 2127 _this.callback(_this.startDate.clone(), _this.endDate.clone(), _this.chosenLabel); 2128 _this.updateElement(); 2129 _this.element.trigger('hide.daterangepicker', _this); 2130 }; 2131 picker.data('daterangepicker').show(); 2132 $(".js-booking-calendar-info").on('click', function (e) { 2133 if ($(e.target).attr('class') == 'calendar-table') { 2134 var offset = $(".js-book-date-range").offset().top - 25; 2135 $('html, body').animate({scrollTop: offset}, 500); 2136 setTimeout(function () { 2137 $(".js-book-date-range").trigger('click'); 2138 }, 500); 2139 } 2140 }).find('.active').removeClass('active in-range start-date end-date'); 2141 } 2142 2143 window.addEventListener('popstate', function (e) { 2144 if (e.state && e.state.start && e.state.end) { 2145 $input_start.val(e.state.start); 2146 $input_end.val(e.state.end); 2147 $input_range.val(e.state.start + ' â ' + e.state.end); 2148 } else { 2149 $input_start.val(templines_default_start); 2150 $input_end.val(templines_default_end); 2151 $input_range.val(templines_default_start + ' â ' + templines_default_end); 2152 } 2153 templines_get_total(); 2154 2155 }, true); 2156 2157 } // End Daterange Picker 2158 }; 2159
2160 root.templines_get_date_class_avail = function (date) { 2161 var result = ''; 2162 if (templines_wp_vars.pickupDropoffDays.length < 7) { 2163 var dow = moment(date).day(); 2164 if (!dow) { 2165 dow = 7; 2166 } 2167 result = templines_wp_vars.pickupDropoffDays.includes(dow + '') ? '' : 'not-avail'; 2168 } else { 2169 result = ''; 2170 } 2171 2172 if (!result && Object.keys(templines_wp_vars.holidays).length) { 2173 if (moment(date).format("YYYY-MM-DD") in templines_wp_vars.holidays) { 2174 result = 'not-avail'; 2175 } 2176 } 2177 2178 return result; 2179 }; 2180 2181 root.templines_get_date_class = function (date) { 2182 var date_text = moment(date).format("YYYY-MM-DD"); 2183 if (typeof templines_wp_vars.date_class === 'object' && !templines_empty(templines_wp_vars.date_class) && date_text in templines_wp_vars.date_class) { 2184 return templines_wp_vars.date_class[date_text]; 2185 } else { 2186 if (templines_date_class_lock) { 2187 return; 2188 } 2189 2190 $.ajax({ 2191 url : templines_wp_vars.ajaxUrl, 2192 type : 'POST', 2193 async : false, 2194 data : { 2195 action : 'templines_ajax_date_class', 2196 vehicle_id: $('.js-book-form').data('id'), 2197 date : date_text 2198 }, 2199 dataType: 'json', 2200 success : function (result) { 2201 if (typeof result.dates === 'object') { 2202 templines_wp_vars.date_class = Object.assign({}, templines_wp_vars.date_class, result.dates); 2203 } 2204 } 2205 }); 2206 2207 if (typeof templines_wp_vars.date_class === 'object' && !templines_empty(templines_wp_vars.date_class) && date_text in templines_wp_vars.date_class) { 2208 return templines_wp_vars.date_class[date_text]; 2209 } else { 2210 templines_date_class_lock = true; 2211 setTimeout(function () { 2212 templines_date_class_lock = false; 2213 }, 1000); 2214 } 2215 } 2216 }; 2217 2218 root.templines_get_total = function (not_popup) { 2219 var $block = $('.js-book-block'); 2220 var $price_block = $('.js-book-price-block'); 2221 var $loading = $('.js-book-loading'); 2222 var is_hidden = $price_block.hasClass('h-hidden'); 2223 $block.addClass('c-vehicle-book__block--loading'); 2224 if (is_hidden) { 2225 $('.js-book-space').templines_button('loading', 22); 2226 } else { 2227 $loading.addClass('c-vehicle-book__loading--active'); 2228 $loading.templines_button('loading', 22); 2229 } 2230 $('.js-book-action').val('templines_calc_total'); 2231 $.ajax({ 2232 url : templines_wp_vars.ajaxUrl, 2233 type : 'POST', 2234 data : $('.js-book-form').serialize(), 2235 dataType: 'json', 2236 success : function (results) { 2237 if (is_hidden) { 2238 $('.js-book-space').templines_button('reset'); 2239 } else { 2240 $loading.templines_button('reset'); 2241 $loading.removeClass('c-vehicle-book__loading--active'); 2242 } 2243 $block.removeClass('c-vehicle-book__block--loading'); 2244 if (results.price) { 2245 $('.c-vehicle-book__amount').html(results.price); 2246 } 2247 $('.js-book-cnt').text(results.days); 2248 $('.js-book-day-price').html(results.price_per_day); 2249 if (results.days > 1) { 2250 $('.c-vehicle-book__per').addClass('h-hidden'); 2251 $('.c-vehicle-book__cnt').removeClass('h-hidden'); 2252 } else { 2253 $('.c-vehicle-book__per').removeClass('h-hidden'); 2254 $('.c-vehicle-book__cnt').addClass('h-hidden'); 2255 } 2256 var $available_message = $('.js-book-dates-available'); 2257 var $not_available_message = $('.js-book-dates-not-available'); 2258 var $not_available_message_text = $('.js-not-available-message'); 2259 if (results.extra) { 2260 for (var option_id in results.extra) { 2261 $(".js-extra-price-" + option_id).html(results.extra[option_id]); 2262 } 2263 } 2264 if (results.total) { 2265 $('.js-book-total').html(results.total); 2266 $price_block.removeClass('h-hidden'); 2267 $available_message.removeClass('h-hidden'); 2268 $not_available_message.addClass('h-hidden'); 2269 } else { 2270 $price_block.addClass('h-hidden'); 2271 $('.js-book-total').html(''); 2272 $available_message.addClass('h-hidden'); 2273 $not_available_message.removeClass('h-hidden'); 2274 2275 var $input_range = $('.js-book-date-range'); 2276 var custom_message = ''; 2277 if (results.custom_message) { 2278 custom_message = results.custom_message; 2279 } else { 2280 if (results.minimal_days) { 2281 custom_message = templines_wp_vars.minimumDaysMsg + ' ' + results.minimal_days; 2282 } 2283 2284 if (results.maximum_days) { 2285 custom_message = templines_wp_vars.maximumDaysMsg + ' ' + results.maximum_days; 2286 } 2287 } 2288 2289 if (custom_message) { 2290 $not_available_message_text.html(custom_message); 2291 if (typeof not_popup === 'undefined' || !not_popup) { 2292 templines_show_notice_error(custom_message); 2293 $input_range.trigger('click'); 2294 } 2295 } else { 2296 $not_available_message_text.html($not_available_message_text.data('message')); 2297 } 2298 } 2299 } 2300 }); 2301 }; 2302
2303 root.templines_push_state = function () { 2304 if (window.history) { 2305 var new_start = $('.js-book-date-start').val(); 2306 var new_end = $('.js-book-date-end').val(); 2307 var current_title = $('title').text(); 2308 var new_href = location.href; 2309 new_href = templines_replace_url_param(new_href, 'start', new_start); 2310 new_href = templines_replace_url_param(new_href, 'end', new_end); 2311 2312 if (templines_wp_vars.pickup_dropoff_time) { 2313 var new_start_time = $('.js-book-date-start-time').val(); 2314 var new_end_time = $('.js-book-date-end-time').val(); 2315 new_href = templines_replace_url_param(new_href, 'start_time', new_start_time); 2316 new_href = templines_replace_url_param(new_href, 'end_time', new_end_time); 2317 } 2318 2319 var state = { 2320 start: new_start, 2321 end : new_end 2322 }; 2323 window.history.pushState(state, current_title, new_href); 2324 } 2325 }; 2326 2327 root.templines_init_price_filter = function () { 2328 2329 if (typeof templines_wp_vars.currency_format_symbol === 'undefined') { 2330 return false; 2331 } 2332 2333 if (typeof $.fn.slider !== 'function') { 2334 return; 2335 } 2336 2337 $(document).bind('templines.price.slider.create templines.price.slider.slide', function (event, min, max) { 2338 2339 $('.js-filter-price-amount span.from').html(accounting.formatMoney(min, { 2340 symbol : templines_wp_vars.currency_format_symbol, 2341 decimal : templines_wp_vars.currency_format_decimal_sep, 2342 thousand : templines_wp_vars.currency_format_thousand_sep, 2343 precision: templines_wp_vars.currency_format_num_decimals, 2344 format : templines_wp_vars.currency_format 2345 })); 2346 2347 $('.js-filter-price-amount span.to').html(accounting.formatMoney(max, { 2348 symbol : templines_wp_vars.currency_format_symbol, 2349 decimal : templines_wp_vars.currency_format_decimal_sep, 2350 thousand : templines_wp_vars.currency_format_thousand_sep, 2351 precision: templines_wp_vars.currency_format_num_decimals, 2352 format : templines_wp_vars.currency_format 2353 })); 2354 }); 2355 2356 $('.js-filter-price-slider, .js-filter-price-label').show(); 2357 2358 var min_price = $('.js-filter-price-min_price').data('min'), 2359 max_price = $('.js-filter-price-max_price').data('max'), 2360 step = $('.js-filter-price-amount').data('step') || 1, 2361 current_min_price = $('.js-filter-price-min_price').val(), 2362 current_max_price = $('.js-filter-price-max_price').val(); 2363 2364 $('.js-filter-price-slider:not(.ui-slider)').slider({ 2365 range : true, 2366 animate: true, 2367 min : min_price, 2368 max : max_price, 2369 step : step, 2370 values : [current_min_price, current_max_price], 2371 create : function () { 2372 2373 $('.js-filter-price-min_price').val(current_min_price); 2374 $('.js-filter-price-max_price').val(current_max_price); 2375 2376 $(document).trigger('templines.price.slider.create', [current_min_price, current_max_price]); 2377 }, 2378 slide : function (event, ui) { 2379 2380 $('.js-filter-price-min_price').val(ui.values[0]); 2381 $('.js-filter-price-max_price').val(ui.values[1]); 2382 2383 $(document).trigger('templines.price.slider.slide', [ui.values[0], ui.values[1]]); 2384 }, 2385 change : function (event, ui) { 2386 2387 $(document).trigger('templines.filter.update'); 2388 } 2389 }); 2390 }; 2391 2392 root.templines_filter_sticky = function () { 2393 if (templines_is_mobile_layout) { 2394 return; 2395 } 2396 var filter = document.getElementById('filter-sticky'); 2397 var sidebar = document.getElementById('sidebar'); 2398 if (filter) { 2399 var filter_buttons = document.getElementById('filter-bottom'); 2400 var offsets = filter_buttons.getBoundingClientRect(); 2401 var top = offsets.top; 2402 var diff = top + filter_buttons.offsetHeight - window.innerHeight; 2403 var is_top = sidebar.offsetHeight - filter.offsetHeight - diff - 25 <= 0; 2404 if (is_top && !filter.classList.contains('c-catalog-sidebar__sticky--top')) { 2405 filter.classList.add('c-catalog-sidebar__sticky--top'); 2406 filter.classList.remove('c-catalog-sidebar__sticky--bottom'); 2407 } else if (!is_top && diff < 0 && !filter.classList.contains('c-catalog-sidebar__sticky--bottom')) { 2408 filter.classList.add('c-catalog-sidebar__sticky--bottom'); 2409 filter.classList.remove('c-catalog-sidebar__sticky--top'); 2410 } else if (!is_top && diff >= 0 && (filter.classList.contains('c-catalog-sidebar__sticky--bottom') || filter.classList.contains('c-catalog-sidebar__sticky--top'))) { 2411 filter.classList.remove('c-catalog-sidebar__sticky--bottom'); 2412 filter.classList.remove('c-catalog-sidebar__sticky--top'); 2413 } 2414 } 2415 }; 2416 2417 root.templines_owl_hide_arrows = function (event) { 2418 var $element; 2419 if (event instanceof jQuery) { 2420 $element = event; 2421 } else { 2422 $element = $(event.target); 2423 } 2424 var $prev = $element.find('.owl-prev'); 2425 var $next = $element.find('.owl-next'); 2426 var dot_count = $element.find('.owl-dot').length; 2427 if (!$element.hasClass('h-carousel--dots-hide')) { 2428 if (dot_count > 1) { 2429 $element.find('.owl-dots').removeClass('disabled'); 2430 } else { 2431 $element.find('.owl-dots').addClass('disabled'); 2432 } 2433 } 2434 if (!$element.hasClass('h-carousel--nav-hide')) { 2435 $element.find('.owl-nav').removeClass('disabled'); 2436 if ($prev.length && $next.length) { 2437 if ($prev.hasClass('disabled') && $next.hasClass('disabled')) { 2438 $prev.addClass('h-hidden'); 2439 $next.addClass('h-hidden'); 2440 $element.find('.owl-nav').addClass('disabled'); 2441 } else { 2442 $prev.removeClass('h-hidden'); 2443 $next.removeClass('h-hidden'); 2444 } 2445 } 2446 } 2447 }; 2448 2449 root.templines_set_notice_offset = function (offset) { 2450 var $notice = $('.woocommerce-notices-wrapper--ajax'); 2451 if ($notice.length) { 2452 var position = 'fixed'; 2453 if (typeof offset !== 'number') { 2454 if (templines_is_mobile_layout) { 2455 if (templines_sticky_mobile_active) { 2456 offset = templines_adminbar_visible_height + $templines_mobile_sticky_row.outerHeight(); 2457 } else { 2458 offset = $templines_mobile_sticky_row.offset().top + $templines_mobile_sticky_row.outerHeight(); 2459 position = 'absolute'; 2460 } 2461 } else { 2462 offset = templines_adminbar_visible_height; 2463 } 2464 } 2465 $notice.css({ 2466 position : position, 2467 transform: 'translateY(' + offset + 'px)' 2468 }); 2469 } 2470 }; 2471 2472 root.templines_init_notice = function () { 2473 var $n1, $n2; 2474 var $wrapper = $('.woocommerce-notices-wrapper'); 2475 if ($wrapper.length && $wrapper.hasClass('woocommerce-notices-wrapper--ajax')) { 2476 } else { 2477 if ($wrapper.length) { 2478 if ($wrapper.text().trim() != '') { 2479 $n1 = $wrapper.find('.woocommerce-notice').detach(); 2480 } 2481 $wrapper.remove(); 2482 } 2483 2484 $n2 = $('.woocommerce .woocommerce-notice').detach(); 2485 2486 var $header = $('.c-page-header'); 2487 if (!$header.length) { 2488 $header = $('#main-header'); 2489 }
2490 $wrapper = $('<div class="woocommerce-notices-wrapper woocommerce-notices-wrapper--ajax"></div>'); 2491 $header.after($wrapper); 2492 } 2493 if ($n1 && $n1.length) { 2494 templines_show_notice($n1); 2495 } 2496 if ($n2 && $n2.length) { 2497 templines_show_notice($n2); 2498 } 2499 }; 2500 2501 root.templines_show_notice = function (notice) { 2502 if (templines_empty(notice)) { 2503 return; 2504 } 2505 templines_set_notice_offset(); 2506 var $wrapper = $('.woocommerce-notices-wrapper'); 2507 var $notices = notice instanceof jQuery ? notice : $(notice); 2508 var is_new = !$wrapper.find('.woocommerce-notice').length; 2509 if (is_new) { 2510 $wrapper.css({display: 'none'}); 2511 } 2512 $notices.addClass('shown'); 2513 $notices.each(function () { 2514 var $notice = $(this); 2515 if (!$notice.find('.js-notice-close').length) { 2516 $notice.append($('<button class="h-cb h-cb--svg woocommerce-notice-close js-notice-close"><i class="ip-close-small woocommerce-notice-close-svg"></i></button>')); 2517 } 2518 }); 2519 $wrapper.append($notices); 2520 if (is_new) { 2521 var dif = $wrapper.outerHeight() + 150; 2522 var top_orig = templines_is_mobile_layout ? 0 : parseInt($wrapper.css('top').replace('px', '')); 2523 $wrapper.css({top: (top_orig - dif) + 'px'}); 2524 $wrapper.css({display: ''}); 2525 $({y: top_orig}).animate({y: top_orig + dif}, { 2526 step : function (y) { 2527 $wrapper.css({ 2528 top: (y - dif) + 'px', 2529 }); 2530 }, 2531 duration: 500, 2532 complete: function () { 2533 $wrapper.css({ 2534 top: '', 2535 }); 2536 $wrapper.addClass('woocommerce-notices-wrapper--transition'); 2537 } 2538 }); 2539 } 2540 2541 $notices.find('.js-notice-close').each(function () { 2542 var $close = $(this); 2543 var $showlogin = $close.closest('.woocommerce-notice').find('.showlogin'); 2544 if ($showlogin.length) { 2545 $showlogin.one('click', function () { 2546 $close.trigger('click'); 2547 setTimeout(function () { 2548 var $form = $('.woocommerce-form-login'); 2549 if ($form.length === 1) { 2550 var offset = 0; 2551 if (templines_sticky_mobile_init && templines_is_mobile_layout) { 2552 offset = templines_adminbar_visible_height + $templines_mobile_sticky_row.outerHeight(); 2553 } else if (templines_sticky_desktop_init && !templines_is_mobile_layout) { 2554 offset = templines_adminbar_visible_height + $templines_desktop_sticky_row.outerHeight(); 2555 } 2556 2557 $('html, body').animate({scrollTop: $form.offset().top - offset - 20}, 800); 2558 } 2559 }, 500); 2560 }); 2561 setTimeout(function () { 2562 $close.trigger('click'); 2563 }, 10000); 2564 } else { 2565 setTimeout(function () { 2566 $close.trigger('click'); 2567 }, 5000); 2568 } 2569 }); 2570 }; 2571 2572 root.templines_show_notice_success = function (message) { 2573 templines_show_notice($('<div class="woocommerce-notice shown" role="alert">\n' + 2574 '\t\t<i class="ip-wc-success woocommerce-notice-success-svg"></i>\n' + 2575 '\t\t' + message + '\t\t<button class="h-cb h-cb--svg woocommerce-notice-close js-notice-close"><i class="ip-z-close-round woocommerce-notice-close-svg"></i></button>\n' + 2576 '\t</div>')); 2577 }; 2578 2579 root.templines_show_notice_error = function (message) { 2580 templines_show_notice($('<div class="woocommerce-notice shown" role="alert">\n' + 2581 '\t\t<i class="ip-wc-error woocommerce-notice-error-svg"></i>\n' + 2582 '\t\t' + message + '\t\t<button class="h-cb h-cb--svg woocommerce-notice-close js-notice-close"><i class="ip-z-close-round woocommerce-notice-close-svg"></i></button>\n' + 2583 '\t</div>')); 2584 }; 2585 2586 root.templines_init_image_list_2 = function () { 2587 $('.js-image-list-2-zoom').click(function (e) { 2588 e.preventDefault(); 2589 var $button = $(this); 2590 var $widget = $button.closest('.c-instagram'); 2591 var $button_loading = $button.find('.c-instagram__item_loading'); 2592 if ($button.hasClass('js-loading')) { 2593 return; 2594 } 2595 var index = 0; 2596 if (templines_isset($button.data('index'))) { 2597 $button_loading.templines_button('loading', 25); 2598 index = $button.data('index'); 2599 } else { 2600 $button_loading.templines_button('loading'); 2601 } 2602 2603 templines_require([ 2604 templines_wp_vars.themeUri + '/assets/js/photoswipe/photoswipe.min.js?v=' + templines_wp_vars.stylesHash, 2605 templines_wp_vars.themeUri + '/assets/js/photoswipe/photoswipe-ui-default.min.js?v=' + templines_wp_vars.stylesHash, 2606 templines_wp_vars.themeUri + '/assets/css/photoswipe/photoswipe.css', 2607 templines_wp_vars.themeUri + '/assets/css/photoswipe/default-skin/default-skin.css' 2608 ], function () { 2609 var images = $widget.data('images'); 2610 2611 $button_loading.templines_button('reset'); 2612 if (images && images.images && images.images.length) { 2613 var options = { 2614 index : index ? index : 0, 2615 showHideOpacity : true, 2616 bgOpacity : 1, 2617 loop : false, 2618 closeOnVerticalDrag: false, 2619 mainClass : '', 2620 barsSize : {top: 0, bottom: 0}, 2621 captionEl : false, 2622 fullscreenEl : false, 2623 zoomEl : true, 2624 shareEl : false, 2625 counterEl : false, 2626 tapToClose : true, 2627 tapToToggleControls: false, 2628 history : false 2629 }; 2630 2631 var pswpElement = $('.pswp')[0]; 2632 2633 templines_wpadminbar_resize(); 2634 2635 var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, images.images, options); 2636 gallery.init(); 2637 2638 gallery.listen('afterChange', function () { 2639 if (!templines_empty(gallery.currItem.html)) { 2640 $('.pswp__video-wrap').fitVids(); 2641 } 2642 }); 2643 2644 gallery.listen('close', function () { 2645 $('.pswp__video-wrap').html(''); 2646 }); 2647 2648 $('.pswp__video-wrap').fitVids(); 2649 } 2650 }); 2651 }); 2652 }; 2653
2654 root.templines_calc_header_element_height = function () { 2655 if (!templines_calc_header_element_height.initialized) { 2656 templines_calc_header_element_height.initialized = true; 2657 templines_calc_header_element_height.$store_notice_top = $('.woocommerce-store-notice--top'); 2658 templines_calc_header_element_height.$advert_bar_above = $('.c-header__advert_bar--above'); 2659 } 2660 2661 if (!templines_is_mobile_layout) { 2662 $templines_desktop_sticky_row.css({'height': ''}); 2663 } 2664 templines_before_header_height = ($templines_top_row.length && !templines_is_mobile_layout ? $templines_top_row.outerHeight() + $('.c-header__row-line').outerHeight() : 0) + (templines_calc_header_element_height.$advert_bar_above.length ? templines_calc_header_element_height.$advert_bar_above.outerHeight() : 0) + (templines_calc_header_element_height.$store_notice_top.length && templines_calc_header_element_height.$store_notice_top.css('display') !== 'none' ? templines_calc_header_element_height.$store_notice_top.outerHeight() : 0); 2665 templines_header_height = templines_is_mobile_layout ? $templines_mobile_sticky_row.outerHeight() : $templines_desktop_sticky_row.outerHeight(); 2666 }; 2667 2668 root.templines_header_sticky_init = function () { 2669 2670 // Desktop 2671 if (!templines_is_mobile_layout && templines_wp_vars.stickyMenuDesktop) { 2672 templines_calc_header_element_height(); 2673 $templines_header_outer_desktop.css({'min-height': templines_header_height + 'px'}); 2674 $templines_desktop_sticky_row.css({'height': templines_header_height + 'px'}); 2675 if (!templines_sticky_desktop_init) { 2676 $templines_desktop_sticky_row.addClass('c-header--init'); 2677 templines_sticky_desktop_active = false; 2678 templines_sticky_desktop_init = true; 2679 } 2680 } 2681 2682 // Mobile 2683 if (!templines_sticky_mobile_init && templines_is_mobile_layout && templines_wp_vars.stickyMenuMobile) { 2684 templines_calc_header_element_height(); 2685 $templines_header_outer_mobile.css({'min-height': templines_header_height + 'px'}); 2686 if (!templines_sticky_mobile_init) { 2687 $templines_mobile_sticky_row.addClass('c-header--init'); 2688 templines_sticky_mobile_active = false; 2689 templines_sticky_mobile_init = true; 2690 } 2691 } 2692 2693 $(document).off('templines.wpadminbar.scroll', templines_header_sticky); 2694 $(document).on('templines.wpadminbar.scroll', templines_header_sticky); 2695 }; 2696 2697 root.templines_header_sticky = function () { 2698 if (templines_sticky_animation) { 2699 return; 2700 } 2701 var sticky_height = templines_is_mobile_layout ? $templines_mobile_sticky_row.outerHeight() : $templines_desktop_sticky_row.outerHeight(), 2702 before = templines_before_header_height + (templines_adminbar_position === 'fixed' ? 0 : templines_adminbar_height), 2703 is_transparent = $templines_desktop_sticky_row.hasClass('c-header--tr'), 2704 is_sticky_area = window.scrollY > before + (is_transparent ? sticky_height * 2 : 0); 2705 2706 if (templines_sticky_desktop_init && !templines_is_mobile_layout) { 2707 if (templines_sticky_desktop_active) { 2708 if (!is_sticky_area) { 2709 if (is_transparent) { 2710 templines_sticky_animation = true; 2711 $templines_desktop_sticky_row.animate({ 2712 top: '-' + (sticky_height + templines_adminbar_height) + 'px' 2713 }, 200, function () { 2714 $templines_desktop_sticky_row.css({ 2715 top: '0' 2716 }); 2717 $templines_desktop_sticky_row.removeClass('c-header--sticky'); 2718 templines_sticky_animation = false; 2719 templines_header_sticky(); 2720 }); 2721 } else { 2722 $templines_desktop_sticky_row.css({ 2723 top: '0' 2724 }); 2725 $templines_desktop_sticky_row.removeClass('c-header--sticky'); 2726 } 2727 templines_sticky_desktop_active = false; 2728 $(document).trigger('templines.sticky'); 2729 setTimeout(function () { 2730 $(document).trigger('templines.sticky.late'); 2731 }, 600); 2732 } 2733 } else { 2734 if (is_sticky_area) { 2735 if (window.scrollY - (before + sticky_height) > 0 || is_transparent) { 2736 $templines_desktop_sticky_row.css({ 2737 top: '-' + (sticky_height + templines_adminbar_height) + 'px' 2738 }); 2739 $templines_desktop_sticky_row.addClass('c-header--sticky'); 2740 templines_sticky_animation = true; 2741 $templines_desktop_sticky_row.animate({ 2742 top: (templines_adminbar_position === 'fixed' ? templines_adminbar_height : 0) + 'px' 2743 }, 500, function () { 2744 templines_sticky_animation = false;
2745 templines_header_sticky(); 2746 }); 2747 } else { 2748 $templines_desktop_sticky_row.addClass('c-header--sticky'); 2749 $templines_desktop_sticky_row.css({ 2750 top: (templines_adminbar_position === 'fixed' ? templines_adminbar_height : 0) + 'px' 2751 }); 2752 } 2753 templines_sticky_desktop_active = true; 2754 $(document).trigger('templines.sticky'); 2755 setTimeout(function () { 2756 $(document).trigger('templines.sticky.late'); 2757 }, 600); 2758 } 2759 } 2760 } 2761 if (templines_sticky_mobile_init && templines_is_mobile_layout) { 2762 if (templines_sticky_mobile_active) { 2763 if (!is_sticky_area) { 2764 if (is_transparent) { 2765 templines_sticky_animation = true; 2766 $templines_mobile_sticky_row.animate({ 2767 top: '-' + (sticky_height + templines_adminbar_height) + 'px' 2768 }, 200, function () { 2769 $templines_mobile_sticky_row.css({ 2770 top: '0' 2771 }); 2772 $templines_mobile_sticky_row.removeClass('c-header--sticky'); 2773 templines_sticky_animation = false; 2774 templines_header_sticky(); 2775 }); 2776 } else { 2777 $templines_mobile_sticky_row.css({ 2778 top: '0' 2779 }); 2780 $templines_mobile_sticky_row.removeClass('c-header--sticky'); 2781 } 2782 templines_sticky_mobile_active = false; 2783 $(document).trigger('templines.sticky'); 2784 setTimeout(function () { 2785 $(document).trigger('templines.sticky.late'); 2786 }, 600); 2787 } 2788 } else { 2789 if (is_sticky_area) { 2790 if (window.scrollY - (before + sticky_height) > 0 || is_transparent) { 2791 $templines_mobile_sticky_row.css({ 2792 top: '-' + (sticky_height + templines_adminbar_height) + 'px' 2793 }); 2794 $templines_mobile_sticky_row.addClass('c-header--sticky'); 2795 templines_sticky_animation = true; 2796 $templines_mobile_sticky_row.animate({ 2797 top: (templines_adminbar_position === 'fixed' ? templines_adminbar_height : 0) + 'px' 2798 }, 500, function () { 2799 templines_sticky_animation = false; 2800 templines_header_sticky(); 2801 }); 2802 } else { 2803 $templines_mobile_sticky_row.addClass('c-header--sticky'); 2804 $templines_mobile_sticky_row.css({ 2805 top: (templines_adminbar_position === 'fixed' ? templines_adminbar_height : 0) + 'px' 2806 }); 2807 } 2808 templines_sticky_mobile_active = true; 2809 $(document).trigger('templines.sticky'); 2810 setTimeout(function () { 2811 $(document).trigger('templines.sticky.late'); 2812 }, 600); 2813 } 2814 } 2815 } 2816 }; 2817 2818 root.templines_init_anchor_smooth_scrolling = function () { 2819 $(document).on('click', 'a[href^="#"]:not(.js-ip-tabs-link):not(.woocommerce-review-link)', templines_hash_menu_animate); 2820 }; 2821 2822 $.fn.extend({ 2823 templines_button: function (option, size) { 2824 return this.each(function () { 2825 var $this = $(this); 2826 if (typeof size === 'undefined') { 2827 size = 16; 2828 } 2829 if (option === 'loading' && !$this.hasClass('js-loading')) { 2830 $this.data('button', $this.html()); 2831 $this.data('css-width', $this.css('width')); 2832 $this.data('css-height', $this.css('height')); 2833 $this.css('height', $this.outerHeight()); 2834 $this.css('width', $this.outerWidth()); 2835 var $loader = $('<i class="h-loading c-add-to-cart__loading"></i>'); 2836 $loader.css({ 2837 width : size + 'px', 2838 height: size + 'px', 2839 }); 2840 $this.html($loader); 2841 $this.addClass('h-after-before-hide js-loading'); 2842 } else if (option === 'reset' && $this.hasClass('js-loading')) { 2843 var css_width = $this.data('css-width'); 2844 var css_height = $this.data('css-height'); 2845 var content = $this.data('button'); 2846 $this.data('button', ''); 2847 $this.data('css-width', ''); 2848 $this.data('css-height', ''); 2849 $this.html(content); 2850 $this.removeClass('h-after-before-hide js-loading'); 2851 $this.css('width', css_width); 2852 $this.css('height', css_height); 2853 } 2854 }); 2855 } 2856 }); 2857 2858 $.parseParams = function (query) { 2859 var re = /([^&=]+)=?([^&]*)/g; 2860 var decodeRE = /\+/g; 2861 var decode = function (str) { 2862 return decodeURIComponent(str.replace(decodeRE, " ")); 2863 }; 2864 var params = {}, e; 2865 while (e = re.exec(query)) { // jshint ignore:line 2866 var k = decode(e[1]), v = decode(e[2]); 2867 if (k.substring(k.length - 2) === '[]') { 2868 k = k.substring(0, k.length - 2); 2869 (params[k] || (params[k] = [])).push(v); 2870 } else params[k] = v; 2871 } 2872 return params; 2873 }; 2874
2875 } 2876)(jQuery, window); 2877
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.