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