1function journal_enable_countdown() { 2 $('.countdown').each(function () { 3 4 var $this = $(this); 5 6 if ($this.data('_isEnabled')) { 7 return; 8 } 9 10 $this.data('_isEnabled', true); 11 12 $this.countdown({ 13 date: $this.data('date'), 14 render: function (data) { 15 return $(this.el).html( 16 '<div>' + this.leadingZeros(data.days, 2) + ' <span>' + Journal['countdownDay'] + '</span></div>' + 17 '<div>' + this.leadingZeros(data.hours, 2) + ' <span>' + Journal['countdownHour'] + '</span></div>' + 18 '<div>' + this.leadingZeros(data.min, 2) + ' <span>' + Journal['countdownMin'] + '</span></div>' + 19 '<div>' + this.leadingZeros(data.sec, 2) + ' <span>' + Journal['countdownSec'] + '</span></div>'); 20 } 21 }); 22 }); 23} 24 25function journal_enable_stepper() { 26 $('.stepper').each(function () { 27 var $this = $(this); 28 29 if ($this.data('_isEnabled')) { 30 return; 31 } 32 33 $this.data('_isEnabled', true); 34 35 var $input = $this.find('input[name^="quantity"]'); 36 var value = $input.val(); 37 var minimum = parseInt($input.data('minimum')) || 1; 38 39 $this.find('.fa-angle-up').on('click', function () { 40 $input.val(parseInt($input.val()) + 1); 41 $input.trigger('change'); 42 }); 43 44 $this.find('.fa-angle-down').on('click', function () { 45 if (parseInt($input.val()) > minimum) { 46 $input.val(parseInt($input.val()) - 1); 47 $input.trigger('change'); 48 } 49 }); 50 51 $input.on('keypress', function (e) { 52 if ((e.which < 48 || e.which > 57) && [8].indexOf(e.which) === -1) { 53 e.preventDefault(); 54 } 55 }); 56 57 $input.on('keydown', function (e) { 58 if (e.which === 38) { 59 e.preventDefault(); 60 $input.val(parseInt($input.val()) + 1); 61 $input.trigger('change'); 62 } 63 64 if (e.which === 40) { 65 e.preventDefault(); 66 if (parseInt($input.val()) > minimum) { 67 $input.val(parseInt($input.val()) - 1); 68 $input.trigger('change'); 69 } 70 } 71 }); 72 73 $input.on('blur', function () { 74 if ($('html').hasClass('firefox')) { 75 // window.getSelection().removeAllRanges(); 76 } 77 78 if ((parseInt($input.val()) || 0) < minimum) { 79 $input.val(value); 80 $input.trigger('change'); 81 } 82 }); 83 }); 84} 85 86jQuery(function ($) { 87 var $html = $('html'); 88 var $body = $('body'); 89 var $content = $('#content'); 90 var $column_left = $('#column-left'); 91 var $column_right = $('#column-right'); 92 var $panel_group = $('.panel-group'); 93 var $main_products = $('.main-products'); 94 95 // lazyload 96 Journal.lazyLoadInstance = new LazyLoad({ 97 elements_selector: '.lazyload', 98 class_loading: 'lazyloading', 99 class_loaded: 'lazyloaded' 100 }); 101 102 // Tooltip class 103 $(document).on('show.bs.tooltip', function (e) { 104 if ($html.hasClass('touchevents')) { 105 e.preventDefault(); 106 } 107 108 var $target = $(e.target); 109 var cls = $target.data('tooltipClass'); 110 111 if (cls) { 112 $target.data('bs.tooltip').$tip.addClass(cls); 113 } 114 }); 115 116 // Popover class 117 $(document).on('show.bs.popover', function (e) { 118 if ($html.hasClass('touchevents')) { 119 e.preventDefault(); 120 } 121 122 var $target = $(e.target); 123 var cls = $target.data('popoverClass'); 124 125 if (cls) { 126 $target.data('bs.popover').$tip.addClass(cls); 127 } 128 }); 129 130 // Datepicker class 131 $(document).on('dp.show', function (e) { 132 var $target = $(e.target); 133 var cls = $target.data('pickerClass'); 134 135 if (cls) { 136 $target.data('DateTimePicker').widget.addClass(cls); 137 } 138 }); 139 140 // Dropdowns animation 141 $(document).on('shown.bs.dropdown', function (e) { 142 var $target = $(e.target); 143 var $toggle = $target.find('> .dropdown-toggle'); 144 145 $toggle.addClass('disabled'); 146 147 // reflow 148 $target.outerWidth(); 149 150 $target.addClass('animating'); 151 }); 152 153 $(document).on('hide.bs.dropdown', function (e) { 154 var $target = $(e.target); 155 var $toggle = $target.find('> .dropdown-toggle'); 156 157 $target.removeClass('animating'); 158 159 $toggle.removeClass('disabled'); 160 161 $('html.search-page').removeClass('search-page-open'); 162 }); 163 164 // Dropdowns 165 if ('ontouchstart' in document) { 166 $('.main-menu .dropdown .dropdown > .dropdown-toggle, .flyout-menu .dropdown .dropdown > .dropdown-toggle, .mini-search .search-categories-button').on('click', function (e) { 167 var $this = $(this); 168 var $parent = $this.parent(); 169 var isOpen = $parent.hasClass('open'); 170 var isLink = false;
171 172 // close other dropdowns 173 $parent.parent().find('.open').removeClass('open'); 174 175 // toggle current dropdown 176 if (isOpen) { 177 if ($this.attr('href')) { 178 isLink = true; 179 } else { 180 $parent.removeClass('open').trigger('hide.bs.dropdown'); 181 } 182 } else { 183 $parent.addClass('open').trigger('shown.bs.dropdown'); 184 } 185 186 if (!isLink) { 187 return false; 188 } 189 }); 190 } else { 191 // Dropdowns on hover 192 function mouseOver() { 193 var $this = $(this); 194 var $trigger = $('> .dropdown-toggle', this); 195 196 clearTimeout(this.__timeout); 197 198 $trigger.attr('aria-expanded', 'true').attr('data-toggle', ''); 199 200 $this.addClass('open'); 201 202 // reflow 203 $this.outerWidth(); 204 205 $this.addClass('animating'); 206 } 207 208 function mouseOut() { 209 var $this = $(this); 210 var $trigger = $('> .dropdown-toggle', this); 211 212 $this.removeClass('animating'); 213 214 clearTimeout(this.__timeout); 215 216 this.__timeout = setTimeout(function () { 217 $this.removeClass('open'); 218 219 $trigger.attr('aria-expanded', 'false'); 220 }, 300); 221 } 222 223 $('.dropdown').each(function () { 224 var $this = $(this); 225 226 if ($this.is($('.search-page #search'))) { 227 $('> .dropdown-toggle', this).on('click', function () { 228 $('html.search-page').addClass('search-page-open'); 229 230 var $this = $(this); 231 var $parent = $this.parent(); 232 var isOpen = $parent.hasClass('open'); 233 var isLink = false; 234 235 // close other dropdowns 236 $parent.parent().find('.open').removeClass('open'); 237 238 // toggle current dropdown 239 if (isOpen) { 240 if ($this.attr('href')) { 241 isLink = true; 242 } else { 243 $parent.removeClass('open').trigger('hide.bs.dropdown'); 244 } 245 } else { 246 $parent.addClass('open').trigger('shown.bs.dropdown'); 247 } 248 249 if (!isLink) { 250 return false; 251 } 252 }); 253 } else if ($this.hasClass('main-menu-item')) { 254 $this.hoverIntent(mouseOver, mouseOut); 255 } else { 256 $this.hover(mouseOver, mouseOut); 257 } 258 }); 259 } 260 261 // Collapse .panel-active toggle 262 $panel_group.on('show.bs.collapse', function (e) { 263 $(e.target).parent().addClass('panel-active'); 264 $(e.target).parent().removeClass('panel-collapsed'); 265 }); 266 267 $panel_group.on('hide.bs.collapse', function (e) { 268 $(e.target).parent().removeClass('panel-active'); 269 $(e.target).parent().addClass('panel-collapsing'); 270 }); 271 272 $panel_group.on('hidden.bs.collapse', function (e) { 273 $(e.target).parent().removeClass('panel-collapsing'); 274 $(e.target).parent().addClass('panel-collapsed'); 275 }); 276 277 // Accordion Menu Collapse .open toggle 278 $(document).delegate('.accordion-menu span[data-toggle="collapse"]', 'click', function (e) { 279 e.preventDefault(); 280 281 $(this).closest('.menu-item').toggleClass('open'); 282 }); 283 284 $(document).delegate('.mobile .accordion-menu li > a', 'click', function (e) { 285 var $this = $(this); 286 var $trigger = $this.find('.open-menu'); 287 288 if (!$trigger.length) { 289 return; 290 } 291 292 if ($trigger.attr('aria-expanded') === 'true' && $this.attr('href')) { 293 return; 294 } 295 296 e.preventDefault(); 297 298 $($trigger.data('target')).collapse('toggle'); 299 }); 300 301 // Infinite Scroll 302 if (Journal['infiniteScrollStatus'] && $.ias && $main_products.length) { 303 Journal.infiniteScrollInstance = $.ias({ 304 container: '.main-products', 305 item: '.product-layout', 306 pagination: '.pagination-results', 307 next: '.pagination a.next' 308 }); 309 310 Journal.infiniteScrollInstance.extension(new IASTriggerExtension({ 311 offset: parseInt(Journal['infiniteScrollOffset'], 10) || Infinity, 312 text: Journal['infiniteScrollLoadNext'], 313 textPrev: Journal['infiniteScrollLoadPrev'], 314 htmlPrev: '<div class="ias-trigger ias-trigger-prev"><a class="btn">{text}</a></div>', 315 html: '<div class="ias-trigger ias-trigger-next"><a class="btn">{text}</a></div>' 316 })); 317 318 Journal.infiniteScrollInstance.extension(new IASSpinnerExtension({ 319 html: '<div class="ias-spinner"><i class="fa fa-spinner fa-spin"></i></div>' 320 })); 321 322 Journal.infiniteScrollInstance.extension(new IASNoneLeftExtension({ 323 text: Journal['infiniteScrollNoneLeft'] 324 })); 325 326 Journal.infiniteScrollInstance.extension(new IASPagingExtension()); 327 328 Journal.infiniteScrollInstance.extension(new IASHistoryExtension({ 329 prev: '.pagination a.prev' 330 })); 331 332 Journal.infiniteScrollInstance.on('load', function (event) { 333 try { 334 var u = new URL(event.url); 335 336 u.host = window.location.host; 337 u.hostname = window.location.hostname; 338 u.protocol = window.location.protocol; 339 340 event.url = u.toString(); 341 } catch (e) { 342 } 343 }); 344 345 Journal.infiniteScrollInstance.on('loaded', function (data) { 346 $('.pagination-results').html($(data).find('.pagination-results')); 347 }); 348 349 Journal.infiniteScrollInstance.on('rendered', function (data) {
350 Journal.lazyLoadInstance && Journal.lazyLoadInstance.update(); 351 352 journal_enable_countdown(); 353 354 journal_enable_stepper(); 355 }); 356 } 357 358 // Revolution Slider 359 $('.revolution').each(function () { 360 var $this = $(this); 361 var $img = $('>img', this); 362 363 $this.css('height', $img.height()); 364 365 var options = $.extend(true, { 366 spinner: 'off', 367 sliderType: 'standard', 368 sliderLayout: 'auto', 369 autoHeight: 'on', 370 navigation: { 371 arrows: { enable: true } 372 } 373 }, $this.data('options')); 374 375 var $slider = $('.rev_slider', this).revolution(options); 376 377 $slider.on('revolution.slide.onloaded', function () { 378 $img.remove(); 379 $this.removeClass('rev_hide_navigation'); 380 381 $this.find('.tp-caption-hotspot').popover({ 382 container: 'body', 383 trigger: 'hover', 384 html: true, 385 template: '<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>' 386 }); 387 }); 388 389 $slider.on('revolution.slide.onchange', function () { 390 $this.removeAttr('style'); 391 }); 392 393 $this.data('slider', $slider); 394 }); 395 396 // Layer Slider 397 $('.layerslider').each(function () { 398 var $this = $(this); 399 400 var $img = $('>img', this); 401 402 $this.css({ 403 width: $this.width(), 404 height: $this.height() 405 }); 406 407 // var props = [ 408 // 'border-top-width', 409 // 'border-bottom-width', 410 // 'border-left-width', 411 // 'border-right-width' 412 // ]; 413 // 414 // $this.find('.ls-layer').each(function () { 415 // var $this = $(this); 416 // var css = {}; 417 // 418 // props.forEach(function (prop) { 419 // css[prop] = $this.css(prop); 420 // }); 421 // 422 // $this.css(css); 423 // }); 424 425 var options = $.extend(true, { 426 sliderVersion: '6.1.0', 427 skin: 'v6', 428 maxRatio: 1, 429 navStartStop: false, 430 showCircleTimer: false, 431 tnContainerWidth: '100%', 432 skinsPath: 'catalog/view/theme/journal3/lib/layerslider/skins/' 433 }, $this.data('options')); 434 435 $this.on('sliderDidLoad', function () { 436 $img.remove(); 437 }); 438 439 var $slider = $this.layerSlider(options); 440 441 $slider.on('slideTimelineDidCreate', function () { 442 $this.find('.ls-layer-hotspot').each(function () { 443 var $this = $(this); 444 445 if (!$this.data('bs.popover')) { 446 $this.popover({ 447 container: 'body', 448 trigger: 'hover', 449 html: true, 450 template: '<div class="popover" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>' 451 }); 452 } 453 }); 454 }); 455 }); 456 457 // Master Slider 458 $('.master-slider').each(function () { 459 var $this = $(this); 460 461 var options = $.extend(true, { 462 loop: true, 463 mobileBGVideo: true 464 }, $this.data('options')); 465 466 var $slider = $this.masterslider(options); 467 468 var $img = $('>img', $(this).parent()); 469 470 $slider.masterslider('slider').api.addEventListener(MSSliderEvent.INIT, function () { 471 472 $slider.parent().find('.journal-loading').remove(); 473 474 $img.css({ 475 position: 'absolute', 476 'z-index': -1 477 }); 478 479 setTimeout(function () { 480 $img.remove(); 481 $this.parent().css('background-image', 'none'); 482 }, 1500); 483 }); 484 485 $slider.masterslider('slider').api.addEventListener(MSSliderEvent.CHANGE_START, function () { 486 $this.find('video').each(function () { 487 $(this)[0].pause(); 488 }); 489 }); 490 491 // var $current = null; 492 493 // $slider.masterslider('slider').api.addEventListener(MSSliderEvent.CHANGE_START, function (e) { 494 // $('.no-animation').removeClass('no-animation'); 495 // $('.ms-prev').removeClass('ms-prev'); 496 // $('.ms-next').removeClass('ms-next').addClass('ms-prev'); 497 // $(e.target.currentSlide.$element).addClass('ms-next'); 498 // $('.ms-slide').not($(e.target.currentSlide.$element)).not($current).each(function () { 499 // $(this).addClass('no-animation'); 500 // }); 501 // }); 502 // 503 // $slider.masterslider('slider').api.addEventListener(MSSliderEvent.CHANGE_END, function (e) { 504 // $('.no-animation').removeClass('no-animation'); 505 // $current = $(e.target.currentSlide.$element); 506 // }); 507 508 if ($this.data('parallax')) { 509 MSScrollParallax.setup($slider.masterslider('slider'), 0, $this.data('parallax'), false); 510 } 511 }); 512 513 // Isotope 514 $('.isotope').each(function () { 515 var $this = $(this); 516 var filter = $this.find('ul .active a').attr('data-filter') || null; 517 518 var $isotope = $this.find('.isotope-grid').isotope({ 519 itemSelector: '.isotope-item', 520 filter: filter 521 }); 522 523 $this.find('ul a').on('click', function () { 524 var $this2 = $(this); 525 526 $this.find('ul li').removeClass('active'); 527 $this2.closest('li').addClass('active'); 528 529 $isotope.isotope({ 530 filter: $this2.attr('data-filter') 531 }); 532 }); 533 }); 534 535 // Swiper 536 $('.swiper').each(function () { 537 var $this = $(this); 538 var c = 'c0'; 539 540 if ($content.has($this).length) { 541 c = 'c' + window['Journal']['columnsCount']; 542 } else if ($column_left.has($this).length || $column_right.has($this).length) { 543 c = 'sc'; 544 } 545 546 var itemsPerRow = $this.data('items-per-row') ? $this.data('items-per-row')[c] : { 0: { items: 1, spacing: 0 } }; 547 var breakpoints = {}; 548 549 $.each(itemsPerRow, function (v, k) { 550 breakpoints[v] = { 551 slidesPerView: parseInt(k.items, 10), 552 slidesPerGroup: parseInt(k.items, 10), 553 spaceBetween: parseInt(k.spacing, 10) 554 } 555 }); 556 557 var options = $.extend({ 558 init: false, 559 slidesPerView: parseInt(itemsPerRow[0].items, 10), 560 slidesPerGroup: parseInt(itemsPerRow[0].items, 10), 561 spaceBetween: parseInt(itemsPerRow[0].spacing, 10), 562 breakpoints: breakpoints, 563 observer: true, 564 observeParents: true, 565 paginationClickable: true, 566 preventClicks: false, 567 preventClicksPropagation: false, 568 simulateTouch: true, 569 watchSlidesProgress: true, 570 watchSlidesVisibility: true, 571 navigation: { 572 nextEl: $this.find('.swiper-button-next'), 573 prevEl: $this.find('.swiper-button-prev') 574 }, 575 pagination: { 576 el: $this.find('.swiper-pagination'), 577 type: 'bullets', 578 clickable: true 579 }, 580 scrollbar: $this.find('.swiper-scrollbar'), 581 scrollbarHide: false, 582 scrollbarDraggable: true 583 }, $this.data('options')); 584 585 if (options.loop && ($(this).find('.swiper-slide').length < 2)) { 586 options.loop = false;
587 } 588 589 if (!Journal.isDesktop) { 590 options.a11y = false; 591 } 592 593 var swiper = new Swiper($('.swiper-container', this), options); 594 595 function checkPages() { 596 if ($('.product-image').hasClass('direction-vertical') && $this.hasClass('additional-images')) { 597 var height = Journal['isPopup'] ? Journal['quickviewPageStyleAdditionalImagesHeightAdjustment'] : Journal['productPageStyleAdditionalImagesHeightAdjustment']; 598 599 var interval = setInterval(function () { 600 var imageHeight = $('.main-image .swiper-slide-visible img').outerHeight(); 601 602 if (imageHeight) { 603 $this.css('height', imageHeight + (parseInt(height, 10) || 0)); 604 605 swiper.update(); 606 607 clearInterval(interval); 608 609 $('.product-image').addClass('additional-images-loaded'); 610 } 611 }, 1000); 612 } 613 614 if (swiper.isBeginning && swiper.isEnd) { 615 $this.removeClass('swiper-has-pages'); 616 } else { 617 $this.addClass('swiper-has-pages'); 618 } 619 } 620 621 swiper.on('init', checkPages); 622 623 swiper.on('resize', checkPages); 624 625 swiper.init(); 626 627 if (options.autoplay) { 628 // pause on hover 629 if (options.pauseOnHover) { 630 $('.swiper-container', this).hover(function () { 631 swiper.autoplay.stop(); 632 }, function () { 633 swiper.autoplay.start(); 634 }); 635 } 636 637 // stop autoplay for elements not in viewport 638 swiper.on('observerUpdate', function () { 639 var visible = $(swiper.$el).is(':visible'); 640 var running = swiper.autoplay.running; 641 642 if (visible && !running) { 643 swiper.autoplay.start(); 644 } 645 646 if (!visible && running) { 647 swiper.autoplay.stop(); 648 } 649 }); 650 } 651 652 swiper.on('observerUpdate', function () { 653 Journal.lazyLoadInstance && Journal.lazyLoadInstance.update(); 654 }); 655 656 $this.data('swiper', swiper); 657 }); 658 659 // Gallery 660 $(document).delegate('[data-gallery]', 'click', function () { 661 var $this = $(this); 662 var $gallery = $($this.data('gallery')); 663 var index = parseInt($this.data('index'), 10) || 0; 664 665 if ($gallery.data('lightGallery')) { 666 $gallery.data('lightGallery').s.index = index; 667 } 668 669 $gallery.lightGallery($.extend({ 670 dynamic: true, 671 dynamicEl: $gallery.data('images'), 672 index: index, 673 download: false, 674 loadYoutubeThumbnail: false, 675 loadVimeoThumbnail: false, 676 share: false, 677 pager: false, 678 fullScreen: false, 679 autoplay: false, 680 autoplayControls: false, 681 thumbWidth: 100, 682 thumbContHeight: 100, 683 thumbMargin: 0, 684 showThumbByDefault: true, 685 hash: false 686 }, $gallery.data('options'))); 687 688 $gallery.on('onAfterOpen.lg', function () { 689 $('.lg-backdrop').addClass($gallery.data('lightGallery').s.addClass); 690 }); 691 692 return false; 693 }); 694 695 // Catalog 696 $('.module-catalog.image-on-hover .subitem').hover(function () { 697 var $this = $(this); 698 var $img = $this.closest('.item-content').find('.catalog-image img'); 699 700 if ($img.length) { 701 $img[0]._src = $img.attr('src'); 702 $img[0]._srcSet = $img.attr('srcset'); 703 704 $img.attr('src', $this.data('image')); 705 $img.attr('srcset', $this.data('image2x')); 706 } 707 }, function () { 708 var $this = $(this); 709 var $img = $this.closest('.item-content').find('.catalog-image img'); 710 711 if ($img.length) { 712 $img.attr('src', $img[0]._src); 713 $img.attr('srcset', $img[0]._srcSet); 714 } 715 }); 716 717 // Module Blocks Tab Expand 718 $('.block-expand').on('click', function () { 719 $(this).closest('.expand-block').find('.expand-content').toggleClass('block-expanded'); 720 }); 721 722 //Search focus 723 $('.search-input').focus( 724 function () { 725 $(this).closest('.header-search').addClass('focused'); 726 }).blur( 727 function () { 728 $(this).closest('.header-search').removeClass('focused'); 729 }); 730 731 // Stepper 732 journal_enable_stepper(); 733 734 // Countdown 735 journal_enable_countdown(); 736 737 // Blog Search 738 $('.module-blog_search').each(function () { 739 var $this = $(this); 740 var $input = $this.find('input'); 741 var $button = $this.find('button'); 742 743 $button.on('click', function () { 744 var search = $input.val().trim(); 745 746 if (search) { 747 parent.window.location = $this.data('url') + encodeURIComponent(search); 748 } 749 }); 750 751 $input.on('keydown', function (e) { 752 if (e.keyCode === 13) { 753 var search = $input.val().trim(); 754 755 if (search) { 756 parent.window.location = $this.data('url') + encodeURIComponent(search); 757 } 758 } 759 }); 760 }); 761 762 // Newsletter Module 763 $(document).delegate('.module-newsletter .btn-primary', 'click', function (e) { 764 e.preventDefault(); 765 766 var $this = $(this); 767 var $form = $this.closest('form'); 768 769 function ajax(unsubscribe) { 770 $.ajax({ 771 url: $form.attr('action') + (unsubscribe ? '&unsubscribe=1' : ''), 772 type: 'post', 773 dataType: 'json', 774 data: $form.serialize(), 775 beforeSend: function () { 776 $this.button('loading'); 777 }, 778 complete: function () { 779 $this.button('reset'); 780 }, 781 success: function (json) { 782 if (json.status === 'success') { 783 if (json.response.unsubscribe) { 784 if (confirm(json.response.message)) { 785 ajax(true); 786 } 787 } else { 788 alert(json.response.message); 789 } 790 } else { 791 alert(json.response); 792 } 793 }, 794 error: function (xhr, ajaxOptions, thrownError) { 795 alert(thrownError + '\r\n' + xhr.statusText + '\r\n' + xhr.responseText); 796 } 797 }) 798 } 799 800 ajax(); 801 }); 802 803 // Header Notice 804 $('.module-header_notice').each(function () { 805 var $this = $(this); 806 var options = $this.data('options'); 807 var cookie = 'hn-' + options['cookie']; 808 809 if (!Cookies.get(cookie)) { 810 $this.slideDown(); 811 } 812 813 $this.find('.header-notice-close-button button').on('click', function () { 814 anime({ 815 targets: $this[0], 816 height: 0, 817 duration: parseInt(options['duration']), 818 easing: options['ease'], 819 complete: function () { 820 $this.remove(); 821 } 822 }); 823 824 Cookies.set(cookie, '1', { expires: 365 }); 825 }); 826 }); 827 828 // Layout Notice 829 $('.module-layout_notice').each(function () { 830 var $this = $(this); 831 var options = $this.data('options'); 832 var cookie = 'ln-' + options['cookie']; 833 834 if (!Cookies.get(cookie)) { 835 $this.slideDown(); 836 } 837 838 $this.find('.layout-notice-close-button button').on('click', function () { 839 anime({ 840 targets: $this[0], 841 height: 0, 842 duration: parseInt(options['duration']), 843 easing: options['ease'], 844 complete: function () { 845 $this.remove(); 846 } 847 }); 848 849 Cookies.set(cookie, '1', { expires: 365 }); 850 }); 851 }); 852 853 // Notification Module 854 $('.module-notification').each(function () { 855 var $this = $(this); 856 var options = $this.data('options'); 857 var cookie = 'n-' + options['cookie']; 858 859 if (!Cookies.get(cookie)) { 860 $this.find('.notification-close').on('click', function () { 861 Cookies.set(cookie, '1', { expires: 365 }); 862 }); 863 } 864 }); 865 866 $(document).delegate('.notification-close', 'click', function () { 867 var $this = $(this); 868 var height = $this.parent().outerHeight(); 869 870 $this.parent().next('div').css('margin-top', -height); 871 872 $('.removed').removeClass('removed'); 873 874 $this.parent().addClass('fade-out').on('transitionend MSTransitionEnd webkitTransitionEnd oTransitionEnd', function () { 875 $(this).next('div').addClass('removed').css('margin-top', ''); 876 $(this).remove(); 877 }); 878 }); 879 880 // Popup Module 881 $('.module-popup').each(function () { 882 var $this = $(this); 883 var options = $.extend({ 884 message: $this.html(), 885 timeout: 0 886 }, $this.data('options')); 887 var cookie = 'p-' + options['cookie']; 888 889 if (!Cookies.get(cookie)) { 890 setTimeout(function () { 891 $('html').addClass('popup-open popup-center'); 892 893 var $checkbox = $this.find('.popup-dont-show input[type="checkbox"]'); 894 895 $checkbox.on('change', function () { 896 if ($(this).is(':checked')) { 897 Cookies.set(cookie, '1', { expires: 365 }); 898 } else { 899 Cookies.remove(cookie); 900 } 901 }); 902 903 if ($checkbox.is(':checked')) { 904 Cookies.set(cookie, '1', { expires: 365 }); 905 } 906 }, parseInt(options['showAfter'], 10) || 1); 907 } 908 909 var hideAfter = parseInt(options['hideAfter'], 10) || 0; 910 911 if (hideAfter) { 912 setTimeout(function () { 913 $html.removeClass('popup-open popup-center'); 914 915 if ($html.hasClass('iphone') || $html.hasClass('ipad')) { 916 iNoBounce.disable(); 917 } 918
919 $('.popup-wrapper').attr('removing', true); 920 921 setTimeout(function () { 922 if ($('.popup-wrapper').attr('removing')) { 923 $('.popup-wrapper').remove(); 924 } 925 }, 5000); 926 }, hideAfter); 927 } 928 }); 929 930 $(document).delegate('.popup-close, .popup-bg-closable, .btn-popup:not([href])', 'click', function () { 931 $html.removeClass('popup-open popup-center'); 932 933 if ($html.hasClass('iphone') || $html.hasClass('ipad')) { 934 iNoBounce.disable(); 935 } 936 937 $('.popup-wrapper').attr('removing', true); 938 939 setTimeout(function () { 940 if ($('.popup-wrapper').attr('removing')) { 941 $('.popup-wrapper').remove(); 942 } 943 }, 5000); 944 }); 945 946 $(document).on('keydown', function (e) { 947 if (e.keyCode === 27) { 948 parent.$('.popup-bg-closable').trigger('click'); 949 } 950 }); 951 952 // Login / Register Popup 953 $(document).delegate('html.popup-login .login-form button, html.popup-register .register-form .buttons button', 'click', function (e) { 954 e.preventDefault(); 955 956 var $this = $(this); 957 var $form = $this.closest('form'); 958 959 $form.find('.has-error').removeClass('has-error'); 960 $form.find('.text-danger').remove(); 961 $this.button('loading'); 962 963 $.ajax({ 964 url: $form.attr('action').replace('https:', location.protocol), 965 type: 'post', 966 data: $form.serialize(), 967 dataType: 'json', 968 error: function () { 969 $this.button('reset'); 970 }, 971 success: function (json) { 972 if (json.status === 'success') { 973 if ($form.hasClass('login-form')) { 974 if (parent.$('html').hasClass('route-account-logout')) { 975 parent.window.location = $('base').attr('href'); 976 } else { 977 parent.window.location.reload(); 978 } 979 } else { 980 if (json.customer) { 981 parent.window.location = $('base').attr('href'); 982 } else { 983 parent.window.location = 'index.php?route=account/success'; 984 } 985 } 986 } else { 987 $this.button('reset'); 988 989 $.each(json.response, function (field, value) { 990 if (field === 'custom_field') { 991 $.each(value, function (key, val) { 992 $('#custom-field' + key).addClass('has-error').find('input').after('<div class="text-danger">' + val + '</div>'); 993 }); 994 } else { 995 $form.find('[name="' + field + '"]').closest('.form-group').addClass('has-error').after('<div class="text-danger">' + value + '</div>'); 996 } 997 }); 998 999 if (json.response.warning) { 1000 var $span = $('<span style="display: none !important;"></span>').html(json.response.warning); 1001 1002 $span.appendTo($('body')); 1003 1004 var msg = $span.html(); 1005 1006 $span.remove(); 1007 1008 alert(msg); 1009 } 1010 } 1011 } 1012 }); 1013 }); 1014 1015 // Contact Form 1016 $('.module-form').each(function () { 1017 if ($.fn.datetimepicker) { 1018 var language = $('form', this).data('language'); 1019 1020 $('.date', this).datetimepicker({ 1021 language: language, 1022 pickTime: false 1023 }); 1024 1025 $('.datetime', this).datetimepicker({ 1026 language: language, 1027 pickDate: true, 1028 pickTime: true 1029 }); 1030 1031 $('.time', this).datetimepicker({ 1032 language: language, 1033 pickDate: false 1034 }); 1035 } 1036 1037 $('.upload-btn', this).on('click', function () { 1038 var node = this; 1039 1040 $('#form-upload').remove(); 1041 1042 $('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>'); 1043 1044 $('#form-upload input[name=\'file\']').trigger('click'); 1045 1046 if (typeof timer != 'undefined') { 1047 clearInterval(timer); 1048 } 1049 1050 timer = setInterval(function () { 1051 if ($('#form-upload input[name=\'file\']').val() != '') { 1052 clearInterval(timer); 1053 1054 $.ajax({ 1055 url: 'index.php?route=tool/upload', 1056 type: 'post', 1057 dataType: 'json', 1058 data: new FormData($('#form-upload')[0]), 1059 cache: false, 1060 contentType: false, 1061 processData: false, 1062 beforeSend: function () { 1063 $(node).button('loading'); 1064 }, 1065 complete: function () { 1066 $(node).button('reset'); 1067 }, 1068 success: function (json) { 1069 $('.text-danger').remove(); 1070 1071 if (json['error']) { 1072 $(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>'); 1073 } 1074 1075 if (json['success']) { 1076 alert(json['success']); 1077 1078 $(node).parent().find('input').val(json['code']); 1079 } 1080 }, 1081 error: function (xhr, ajaxOptions, thrownError) { 1082 alert(thrownError + '\r\n' + xhr.statusText + '\r\n' + xhr.responseText); 1083 } 1084 }); 1085 } 1086 }, 500); 1087 }); 1088 }); 1089 1090 $(document).delegate('.btn-extra', 'click', function () { 1091 parent.window.__popup_url = $(this).data('product_url') || ''; 1092 }); 1093 1094 $(document).delegate('.module-form .btn-primary', 'click', function (e) { 1095 e.preventDefault(); 1096 1097 var $this = $(this); 1098 var $form = $this.closest('.module-form').find('form'); 1099 $form.find('.has-error').removeClass('has-error'); 1100 $form.find('.text-danger').remove(); 1101 1102 var data = $form.serializeArray(); 1103 1104 data.push({ 1105 name: 'url', 1106 value: parent.window.__popup_url || parent.window.location.toString() 1107 }); 1108 1109 $.ajax({ 1110 url: $form.attr('action'), 1111 type: 'post', 1112 data: data, 1113 dataType: 'json', 1114 beforeSend: function () { 1115 $this.button('loading'); 1116 },
1117 complete: function () { 1118 $this.button('reset'); 1119 }, 1120 success: function (response) { 1121 if (response.status === 'success') { 1122 alert(response.response.message); 1123 $form[0].reset(); 1124 parent.window.__popup_url = undefined; 1125 parent.$('.module-popup-' + Journal['modulePopupId'] + ' .popup-close').trigger('click'); 1126 } 1127 1128 if (response.status === 'error') { 1129 $.each(response.response.errors, function (field, error) { 1130 if (field === 'agree') { 1131 alert(error); 1132 } else if (field === 'captcha') { 1133 $form.find('.captcha').addClass('has-error'); 1134 } else { 1135 $form.find('[name^="' + field + '"]').closest('.form-group').addClass('has-error').after('<div class="text-danger">' + error + '</div>'); 1136 } 1137 }); 1138 } 1139 }, 1140 error: function (xhr, ajaxOptions, thrownError) { 1141 alert(thrownError + '\r\n' + xhr.statusText + '\r\n' + xhr.responseText); 1142 } 1143 }); 1144 }); 1145 1146 // Grid / List toggle 1147 $(document).delegate('.grid-list .view-btn', 'click', function () { 1148 var $this = $(this); 1149 var $products = $('.main-products'); 1150 var view = $this.data('view'); 1151 var current = $products.hasClass('product-grid') ? 'grid' : 'list'; 1152 1153 $this.tooltip('hide'); 1154 1155 if (view !== current) { 1156 $products.addClass('no-transitions').removeClass('product-' + current).addClass('product-' + view); 1157 setTimeout(function () { 1158 $products.removeClass('no-transitions'); 1159 }, 1); 1160 Cookies.set('view', view, { expires: 365 }); 1161 } 1162 1163 $('.grid-list .view-btn').removeClass('active'); 1164 $this.addClass('active'); 1165 }); 1166 1167 // Main Menu Hover Site Overlay 1168 $('.desktop-main-menu-wrapper #main-menu > .j-menu > .main-menu-item').first().addClass('first-dropdown'); 1169 1170 var $desktop_main_menu_wrapper = $('.desktop-main-menu-wrapper'); 1171 1172 $desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .menu-item:not(.dropdown)', 'mouseover', function () { 1173 $body.addClass('menu-hover'); 1174 }); 1175 1176 $desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .menu-item:not(.dropdown)', 'mouseleave', function () { 1177 $body.removeClass('menu-hover'); 1178 }); 1179 1180 $desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .dropdown', 'mouseover', function () { 1181 $body.addClass('menu-open'); 1182 }); 1183 1184 $desktop_main_menu_wrapper.delegate('.main-menu', 'mouseleave', function () { 1185 $body.removeClass('menu-open'); 1186 }); 1187 1188 // $desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .mega-menu', 'mouseover', function () { 1189 // $(this).addClass('animation-delay'); 1190 // }); 1191 // 1192 // $desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .mega-menu', 'mouseleave', function () { 1193 // var $this = $(this); 1194 // setTimeout(function () { 1195 // $this.removeClass('animation-delay'); 1196 // }, 250); 1197 // }); 1198 1199 //$('head').append('<style>.desktop-main-menu-wrapper .menu-item.dropdown::before {height: ' + ($body.height() - $('header').height()) + 'px} </style>'); 1200 1201 if (($html.hasClass('iphone') || $html.hasClass('ipad')) && !$html.hasClass('popup-open')) { 1202 iNoBounce.disable(); 1203 } 1204 1205 // Mobile Menu Wrapper 1206 $(document).delegate('.menu-trigger', 'click', function (e) { 1207 e.stopPropagation(); 1208 1209 $html.addClass('mobile-overlay mobile-main-menu-container-open'); 1210 1211 if ($html.hasClass('mobile-menu-active')) { 1212 $('[data-is-open]').each(function () { 1213 $('> a > .open-menu', this).trigger('click'); 1214 $(this).removeAttr('data-is-open'); 1215 }); 1216 } 1217 1218 var $container = $('.mobile-main-menu-container'); 1219 1220 $container.outerWidth(); 1221 1222 $container.addClass('animating'); 1223 1224 if ($html.hasClass('iphone') || $html.hasClass('ipad')) { 1225 iNoBounce.enable(); 1226 } 1227 }); 1228 1229 // Mobile Cart Wrapper 1230 if ($html.hasClass('mobile-header-active')) { 1231 $('.cart-content > ul').appendTo('.mobile-cart-content-wrapper'); 1232 } 1233 1234 $(document).delegate('.mobile-header-active .cart-heading', 'click', function (e) { 1235 e.stopPropagation(); 1236 1237 $html.addClass('mobile-overlay mobile-cart-content-container-open'); 1238 1239 var $totals = $('.cart-totals').outerHeight(); 1240 1241 $('.cart-products').css('padding-bottom', $totals - 1); 1242 1243 var $container = $('.mobile-cart-content-container'); 1244 1245 $container.outerWidth(); 1246 1247 $container.addClass('animating'); 1248 1249 if ($html.hasClass('iphone') || $html.hasClass('ipad')) { 1250 iNoBounce.enable(); 1251 } 1252 return false;
1253 }); 1254 1255 // Mobile Filter Wrapper 1256 if (Journal['isPhone'] || (Journal['isTablet'] && (!Journal['globalPageColumnLeftTabletStatus'] || !Journal['globalPageColumnRightTabletStatus']))) { 1257 if ($('.module-filter').length) { 1258 $('.module-filter h3 > *').prependTo('.mobile-filter-container .mobile-wrapper-header'); 1259 $('.module-filter').appendTo('.mobile-filter-wrapper'); 1260 1261 $('<a class="mobile-filter-trigger btn">' + Journal['mobileFilterButtonText'] + '</a>').appendTo('body'); 1262 } 1263 } 1264 1265 $(document).delegate('.mobile-header-active .mobile-filter-trigger', 'click', function (e) { 1266 e.stopPropagation(); 1267 1268 $html.addClass('mobile-overlay mobile-filter-container-open'); 1269 1270 var $container = $('.mobile-filter-container'); 1271 1272 $container.outerWidth(); 1273 1274 $container.addClass('animating'); 1275 1276 if ($html.hasClass('iphone') || $html.hasClass('ipad')) { 1277 iNoBounce.enable(); 1278 } 1279 1280 return false; 1281 }); 1282 1283 // Close Mobile Wrapper 1284 $(document).delegate('.x, .site-wrapper, .close-filter', 'click', function () { 1285 $('.mobile-container.animating').removeClass('animating'); 1286 1287 $html.removeClass('mobile-overlay'); 1288 1289 setTimeout(function () { 1290 $html.removeClass('mobile-main-menu-container-open mobile-cart-content-container-open mobile-filter-container-open'); 1291 }, 300); 1292 1293 if ($html.hasClass('iphone') || $html.hasClass('ipad')) { 1294 iNoBounce.disable(); 1295 } 1296 }); 1297 1298 // Product Page 1299 if ($html.hasClass('route-product-product')) { 1300 // sync image carousels 1301 $(document).delegate('.additional-image', 'click', function () { 1302 $('.additional-image').removeClass('swiper-slide-active'); 1303 $(this).addClass('swiper-slide-active'); 1304 1305 var $s = $('.main-image').data('swiper'); 1306 1307 if ($s.params.loop) { 1308 $s.slideToLoop($(this).data('index'), 0); 1309 } else { 1310 $s.slideTo($(this).data('index'), 0); 1311 } 1312 }); 1313 1314 // image zoom 1315 if (!('ontouchstart' in document)) { 1316 if (Journal['isPopup'] ? Journal['quickviewPageStyleCloudZoomStatus'] : Journal['productPageStyleCloudZoomStatus']) { 1317 $('.main-image img').each(function () { 1318 var $this = $(this); 1319 1320 $this.ImageZoom({ 1321 type: Journal['isPopup'] ? Journal['quickviewPageStyleCloudZoomPosition'] : Journal['productPageStyleCloudZoomPosition'], 1322 showDescription: false, 1323 offset: [0, 0], 1324 zoomSize: [$this.width(), $this.height()], 1325 bigImageSrc: $this.data('largeimg') 1326 }); 1327 }); 1328 1329 // delay mouseover 1330 $('.product-image').mouseover(function () { 1331 $('.zm-viewer').delay(200).queue(function (next) { 1332 $(this).css('opacity', '1'); 1333 next(); 1334 }); 1335 }).mouseleave(function () { 1336 $('.zm-viewer').css('opacity', '0'); 1337 }); 1338 } 1339 } 1340 1341 // Select first option 1342 if ((Journal['isPopup'] ? Journal['quickviewPageStyleOptionsSelect'] : Journal['productPageStyleOptionsSelect']) === 'all') { 1343 $('.product-options .form-group .radio:first-child input, .product-options .form-group .checkbox:first-child input').prop('checked', true); 1344 $('.product-options .form-group select').each(function () { 1345 $(this).find('option').eq(1).prop('selected', true); 1346 }); 1347 } 1348 1349 if ((Journal['isPopup'] ? Journal['quickviewPageStyleOptionsSelect'] : Journal['productPageStyleOptionsSelect']) === 'required') { 1350 $('.product-options .form-group.required .radio:first-child input, .product-options .form-group.required .checkbox:first-child input').prop('checked', true); 1351 $('.product-options .form-group.required select').each(function () { 1352 $(this).find('option').eq(1).prop('selected', true); 1353 }); 1354 } 1355 1356 // Auto Update Price 1357 if (Journal['isPopup'] ? Journal['quickviewPageStylePriceUpdate'] : Journal['productPageStylePriceUpdate']) { 1358 function autoUpdatePrice() { 1359 $.ajax({ 1360 url: 'index.php?route=journal3/price&popup=' + (Journal['isPopup'] ? 1 : 0), 1361 type: 'post', 1362 data: $('#product-id, #product-quantity, #product input[type="radio"]:checked, #product input[type="checkbox"]:checked, #product select'), 1363 dataType: 'json', 1364 beforeSend: function () { 1365 // $('#button-cart').button('loading'); 1366 }, 1367 complete: function () { 1368 // $('#button-cart').button('reset'); 1369 }, 1370 success: function (json) { 1371 if (json['response']['status'] === 'error') { 1372 alert(json['response']['message']); 1373 } else { 1374 if (Journal['isPopup'] ? Journal['quickviewPageStyleProductStockUpdate'] : Journal['productPageStyleProductStockUpdate']) { 1375 if (json['response']['stock']) { 1376 $('.product-stock span').html(json['response']['stock']); 1377 } 1378 1379 if (json['response']['in_stock']) { 1380 $('.product-stock').removeClass('out-of-stock').addClass('in-stock'); 1381 } else { 1382 $('.product-stock').removeClass('in-stock').addClass('out-of-stock'); 1383 } 1384 } 1385 1386 if (json['response']['tax']) { 1387 $('.product-tax').html(json['response']['tax']); 1388 } 1389 1390 if (json['response']['price']) { 1391 if (json['response']['special']) { 1392 $('.product-price-group .product-price-old').html(json['response']['price']); 1393 $('.product-price-group .product-price-new').html(json['response']['special']); 1394 } else { 1395 $('.product-price-group .product-price').html(json['response']['price']); 1396 } 1397 } 1398 1399 if (json['response']['discounts']) { 1400 $('.product-discount').each(function (index) { 1401 $(this).html(json['response']['discounts'][index]); 1402 }); 1403 } 1404 1405 if (json['response']['weight']) { 1406 $('.product-stats .product-weight span').html(json['response']['weight']); 1407 } 1408 } 1409 } 1410 }); 1411 } 1412 1413 $('.product-options input[type="radio"], .product-options input[type="checkbox"], .product-options select, #product-quantity').on('change', autoUpdatePrice); 1414 1415 autoUpdatePrice(); 1416 } 1417 1418 // Push Option Radio 1419 // $('.push-option.product-option-radio').each(function () { 1420 // var $this = $(this); 1421 // var hasImages = $this.find('img').length > 0; 1422 // var options = $this.find('.radio').map(function (index) { 1423 // var text = $(this).text().trim(); 1424 // 1425 // if (hasImages) { 1426 // $this.addClass('push-image'); 1427 // var src = $(this).find('img').attr('src') || 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; 1428 // return '<li class="' + ($(this).find('input').is(':checked') ? 'checked' : '') + '" data-index="' + index + '">
1428<img src="' + src + '" alt="' + text + '" title="' + text + '" data-tooltip-class="push-image-tooltip" /></li>'; 1429 // } 1430 // 1431 // return '<li class="' + ($(this).find('input').is(':checked') ? 'checked' : '') + '" data-index="' + index + '">' + text + '</li>'; 1432 // }); 1433 // 1434 // $this.append('<ul>' + options.toArray().join('') + '</ul>'); 1435 // 1436 // $this.find('li').on('click', function () { 1437 // $this.find('.radio').eq($(this).data('index')).find('input').trigger('click'); 1438 // $this.find('li').not($(this)).removeClass('checked'); 1439 // $(this).addClass('checked'); 1440 // }); 1441 // 1442 // $this.find('li img').tooltip({ container: 'body' }); 1443 // }); 1444 1445 // Push Option Checkbox 1446 // $('.push-option.product-option-checkbox').each(function () { 1447 // var $this = $(this); 1448 // var hasImages = $this.find('img').length; 1449 // var options = $this.find('.checkbox').map(function (index) { 1450 // var text = $(this).text().trim(); 1451 // 1452 // if (hasImages) { 1453 // $this.addClass('push-image'); 1454 // var src = $(this).find('img').attr('src') || 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='; 1455 // return '<li class="' + ($(this).find('input').is(':checked') ? 'checked' : '') + '" data-index="' + index + '"><img src="' + src + '" alt="' + text + '" title="' + text + '" data-tooltip-class="push-image-tooltip" /></li>'; 1456 // } 1457 // 1458 // return '<li class="' + ($(this).find('input').is(':checked') ? 'checked' : '') + '" data-index="' + index + '">
1458' + text + '</li>'; 1459 // }); 1460 // 1461 // $this.append('<ul>' + options.toArray().join('') + '</ul>'); 1462 // 1463 // $this.find('li').on('click', function () { 1464 // $this.find('.checkbox').eq($(this).data('index')).find('input').trigger('click'); 1465 // $(this).toggleClass('checked'); 1466 // }); 1467 // 1468 // $this.find('li img').tooltip({ container: 'body' }); 1469 // }); 1470 1471 // Push Option Select 1472 // $('.push-option.product-option-select').each(function () { 1473 // var $this = $(this); 1474 // var options = $this.find('option').slice(1).map(function (index) { 1475 // return '<li class="' + ($(this).is(':checked') ? 'checked' : '') + '" data-index="' + index + '">' + $(this).text() + '</li>'; 1476 // }); 1477 // 1478 // $this.append('<ul>' + options.toArray().join('') + '</ul>'); 1479 // 1480 // $this.find('li').on('click', function () { 1481 // $this.find('option').eq($(this).data('index') + 1).prop('selected', true); 1482 // $this.find('select').trigger('change'); 1483 // $this.find('li').not($(this)).removeClass('checked'); 1484 // $(this).addClass('checked'); 1485 // }); 1486 // }); 1487 } 1488 1489 // Iframe height 1490 if ($html.hasClass('route-journal3-popup-page')) { 1491 $(document).on('click', function () { 1492 parent.resize_iframe(Journal['popupModuleId'], $('.popup-content').height()); 1493 }); 1494 } 1495 1496 //Footer Links module collapse 1497 $('.links-menu .module-title').addClass('closed'); 1498 1499 $('.links-menu .module-title').click(function () { 1500 $(this).toggleClass('closed'); 1501 }); 1502 1503 // Open popup links in new tab 1504 if (Journal.isPopup) { 1505 $('a[href]').each(function () { 1506 var $this = $(this); 1507 1508 if (!$this.attr('target')) { 1509 $this.attr('target', '_blank'); 1510 } 1511 1512 if (Journal.isPhone || Journal.isTablet) { 1513 $this.removeClass('agree'); 1514 } 1515 }); 1516 } 1517}); 1518 1519$(window).on('load', function () { 1520 var $html = $('html'); 1521 var $body = $('body'); 1522 1523 // Search 1524 var $search = $('#search').find('input[name=\'search\']'); 1525 1526 $('.search-button').on('click', function () { 1527 var url = $(this).data('search-url'); 1528 var value = $search.val().trim(); 1529 1530 if (!value) { 1531 return false; 1532 } 1533 1534 var category_id = parseInt($search.attr('data-category_id')); 1535 1536 if (value) { 1537 url += encodeURIComponent(value); 1538 } 1539 1540 if (Journal['searchStyleSearchAutoSuggestDescription']) { 1541 url += '&description=true'; 1542 } 1543 1544 if (category_id) { 1545 url += '&category_id=' + category_id; 1546 1547 if (Journal['searchStyleSearchAutoSuggestSubCategories']) { 1548 url += '&sub_category=true'; 1549 } 1550 } 1551 1552 location = url; 1553 }); 1554 1555 $search.on('keydown', function (e) { 1556 if (e.keyCode === 13) { 1557 $('.search-button').trigger('click'); 1558 } 1559 }); 1560 1561 $('.search-categories li').on('click', function (e) { 1562 e.stopPropagation(); 1563 1564 var $this = $(this); 1565 $('.search-categories-button').html($this.html()); 1566 $search.attr('data-category_id', $this.attr('data-category_id')) 1567 }); 1568 1569 // Autosuggest 1570 if (Journal['searchStyleSearchAutoSuggestStatus']) { 1571 $search.typeahead({ 1572 hint: true, 1573 minLength: 1, 1574 autoSelect: true 1575 }, { 1576 async: true, 1577 display: 'name', 1578 limit: Infinity, 1579 source: function (query, processSync, processAsync) { 1580 var data = { 1581 search: query 1582 }; 1583 1584 var category_id = parseInt($search.attr('data-category_id')); 1585 1586 if (category_id) { 1587 data.category_id = category_id; 1588 1589 if (Journal['searchStyleSearchAutoSuggestSubCategories']) { 1590 data.sub_category = true; 1591 } 1592 } 1593 1594 return $.ajax({ 1595 url: 'index.php?route=journal3/search', 1596 data: data, 1597 dataType: 'json', 1598 success: function (json) { 1599 return processAsync(json['response']); 1600 } 1601 }); 1602 }, 1603 templates: { 1604 suggestion: function (data) { 1605 if (data['view_more']) { 1606 return '<div class="search-result view-more"><a href="' + data['href'] + '">' + data['name'] + '</a></div>'; 1607 } 1608 1609 if (data['no_results']) { 1610 return '<div class="search-result no-results"><a>' + data['name'] + '</a></div>'; 1611 } 1612 1613 var html = ''; 1614 1615 html += '<div class="search-result"><a href="' + data['href'] + '">'; 1616 1617 if (data['thumb']) { 1618 html += '<img src="' + data['thumb'] + '" srcset="' + data['thumb'] + ' 1x, ' + data['thumb2'] + ' 2x" />'; 1619 } 1620 1621 var classes = []; 1622 1623 if (data['quantity'] <= 0) { 1624 classes.push('out-of-stock'); 1625 } 1626 1627 if (!data['price_value']) { 1628 classes.push('has-zero-price'); 1629 } 1630 1631 html += '<span class="' + classes.join(' ') + '">'; 1632 1633 html += '<span class="product-name">' + data['name'] + '</span>'; 1634 1635 if (data['price']) { 1636 if (data['special']) { 1637 html += '<span><span class="price-old">' + data['price'] + '</span><span class="price-new">' + data['special'] + '</span></span>'; 1638 } else { 1639 html += '<span class="price">' + data['price'] + '</span>'; 1640 } 1641 } 1642 1643 html += '</span>'; 1644 1645 html += '</a></div>'; 1646 1647 return html; 1648 } 1649 } 1650 1651 }); 1652 1653 $('.header-search > span > div').addClass('.tt-empty'); 1654 1655 // mobile page zoom fix 1656 $('.mobile .tt-menu').on('click', function (e) { 1657 e.stopPropagation(); 1658 }); 1659 } 1660 1661 // Sticky Desktop
1662 if (!Journal.isPopup && Journal['isDesktop'] && Journal['stickyStatus'] && (['classic', 'mega', 'default'].includes(Journal['headerType']))) { 1663 var holder = document.body; 1664 var headerHeightOffset = $('.desktop-main-menu-wrapper').offset().top + (parseInt(Journal['stickyAt'], 10) || 100); 1665 var menuHeight = $('.desktop-main-menu-wrapper').outerHeight(); 1666 1667 function enableSticky() { 1668 if (Journal['headerType'] === 'classic' || Journal['headerType'] === 'mega') { 1669 $body.css('padding-top', menuHeight); 1670 } 1671 } 1672 1673 function disableSticky() { 1674 if (Journal['headerType'] === 'classic' || Journal['headerType'] === 'mega') { 1675 $body.css('padding-top', ''); 1676 } 1677 } 1678 1679 function checkStickyOffset() { 1680 return headerHeightOffset <= window.scrollY; 1681 } 1682 1683 function checkSticky() { 1684 var old = holder.classList.contains('is-sticky'); 1685 1686 holder.classList.toggle('is-sticky', checkStickyOffset()); 1687 1688 var current = holder.classList.contains('is-sticky'); 1689 1690 if (current !== old) { 1691 if (current) { 1692 enableSticky(); 1693 } else { 1694 disableSticky(); 1695 } 1696 } 1697 } 1698 1699 function checkStickyListener() { 1700 requestAnimationFrame(checkSticky) 1701 } 1702 1703 window.addEventListener('scroll', checkStickyListener, false); 1704 } 1705 1706 //Compact Sticky top bar 1707 if (!Journal.isPopup && Journal['isDesktop'] && Journal['stickyStatus'] && Journal['topB
1707arStatus'] && (['compact', 'slim'].includes(Journal['headerType']))) { 1708 var compact = $('.mid-bar'); 1709 if (compact.length) { 1710 $(window).on('scroll', function () { 1711 var compactOffset = compact.offset().top; 1712 var scroll = $(this)[0].scrollY 1713 if (scroll >= compactOffset) { 1714 $('body').addClass('sticky-compact'); 1715 } else { 1716 $('body').removeClass('sticky-compact'); 1717 } 1718 }); 1719 } 1720 } 1721 1722 //Compact Sticky no top bar 1723 if (!Journal.isPopup && Journal['isDesktop'] && Journal['stickyStatus'] && !Journal['topBarStatus'] && !Journal['stickyFullHomePadding'] && (['compact', 'slim'].includes(Journal['headerType']))) { 1724 var site = $('.site-wrapper'); 1725 var header = $('.mid-bar').outerHeight(); 1726 if (site.length) { 1727 $(window).on('scroll', function () { 1728 var siteOffset = site.offset().top - header + 1; 1729 var scroll = $(this)[0].scrollY 1730 if (scroll >= siteOffset) { 1731 $('body').addClass('sticky-compact'); 1732 } else { 1733 $('body').removeClass('sticky-compact'); 1734 } 1735 }); 1736 } 1737 } 1738 1739 //Compact Sticky no top bar over hover 1740 if (!Journal.isPopup && Journal['isDesktop'] && Journal['stickyStatus'] && !Journal['topB
1740arStatus'] && Journal['stickyFullHomePadding'] && (['compact', 'slim'].includes(Journal['headerType']))) { 1741 var site = $('.site-wrapper'); 1742 var header = $('html:not(.route-common-home) .mid-bar').outerHeight(); 1743 if (site.length) { 1744 $(window).on('scroll', function () { 1745 var siteOffset = site.offset().top - header + 1; 1746 var scroll = $(this)[0].scrollY 1747 if (scroll >= siteOffset) { 1748 $('body').addClass('sticky-compact'); 1749 } else { 1750 $('body').removeClass('sticky-compact'); 1751 } 1752 }); 1753 } 1754 } 1755 1756 1757 // Sticky Mobile 1758 if (!Journal['isDesktop'] && Journal['headerMobileStickyStatus'] && $html.hasClass('mobile-header-active')) { 1759 var mobileBar = $('.mobile-header .sticky-bar'); 1760 if (mobileBar.length) { 1761 var mobileBarSticky = mobileBar.offset().top; 1762 var mobileBarHeight = mobileBar.outerHeight(); 1763 $(window).on('scroll', function () { 1764 var scroll = $(this)[0].scrollY 1765 if (scroll >= mobileBarSticky) { 1766 mobileBar.addClass('mobile-bar-sticky'); 1767 $body.css('padding-top', mobileBarHeight); 1768 } else { 1769 mobileBar.removeClass('mobile-bar-sticky'); 1770 $body.css('padding-top', ''); 1771 } 1772 }); 1773 } 1774 } 1775 1776 //Focus mini search on click 1777 if (Journal['isDesktop'] && (Journal['headerMiniSearchDisplay'] === 'page')) { 1778 $('.search-trigger, .desktop .search-categories .j-menu > li > a').click(function () { 1779 $('.header-search input').focus(); 1780 }); 1781 } 1782 1783 // Scroll Top 1784 if (Journal['scrollTop']) { 1785 var scrollTopTimeout; 1786 1787 $(window).on('scroll', function () { 1788 clearTimeout(scrollTopTimeout); 1789 var scroll = $(this)[0].scrollY 1790 if (scroll > 500) { 1791 $('.scroll-top').addClass('scroll-top-active'); 1792 1793 scrollTopTimeout = setTimeout(function () { 1794 $('.scroll-top').removeClass('scroll-top-active'); 1795 }, 3000); 1796 } else { 1797 $('.scroll-top').removeClass('scroll-top-active'); 1798 } 1799 }); 1800 1801 $('.scroll-top').click(function () { 1802 anime({ 1803 targets: 'html, body', 1804 scrollTop: 0, 1805 duration: 750, 1806 easing: 'easeInOutQuad' 1807 }); 1808 }); 1809 } 1810 1811 if ($html.hasClass('footer-reveal')) { 1812 var footerHeight = $('.desktop.footer-reveal footer').outerHeight(); 1813 $('.desktop body').css('padding-bottom', footerHeight); 1814 } 1815}); 1816 1817$('.block-map iframe').on('load', function () { 1818 $('.block-map .journal-loading').hide(); 1819});
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.