PageSourceSearch

https://saldaismirklis.lv/catalog/view/theme/journal3/js/journal.js?v=24340784

js saldaismirklis.lv collected 2026-10-02 00:22:23 UTC 49,699 bytes, 1,801 lines download raw bytes

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			$('.date', this).datetimepicker({
1019				pickTime: false
1020			});
1021
1022			$('.datetime', this).datetimepicker({
1023				pickDate: true,
1024				pickTime: true
1025			});
1026
1027			$('.time', this).datetimepicker({
1028				pickDate: false
1029			});
1030		}
1031
1032		$('.upload-btn', this).on('click', function () {
1033			var node = this;
1034
1035			$('#form-upload').remove();
1036
1037			$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" /></form>');
1038
1039			$('#form-upload input[name=\'file\']').trigger('click');
1040
1041			if (typeof timer != 'undefined') {
1042				clearInterval(timer);
1043			}
1044
1045			timer = setInterval(function () {
1046				if ($('#form-upload input[name=\'file\']').val() != '') {
1047					clearInterval(timer);
1048
1049					$.ajax({
1050						url: 'index.php?route=tool/upload',
1051						type: 'post',
1052						dataType: 'json',
1053						data: new FormData($('#form-upload')[0]),
1054						cache: false,
1055						contentType: false,
1056						processData: false,
1057						beforeSend: function () {
1058							$(node).button('loading');
1059						},
1060						complete: function () {
1061							$(node).button('reset');
1062						},
1063						success: function (json) {
1064							$('.text-danger').remove();
1065
1066							if (json['error']) {
1067								$(node).parent().find('input').after('<div class="text-danger">' + json['error'] + '</div>');
1068							}
1069
1070							if (json['success']) {
1071								alert(json['success']);
1072
1073								$(node).parent().find('input').val(json['code']);
1074							}
1075						},
1076						error: function (xhr, ajaxOptions, thrownError) {
1077							alert(thrownError + '\r\n' + xhr.statusText + '\r\n' + xhr.responseText);
1078						}
1079					});
1080				}
1081			}, 500);
1082		});
1083	});
1084
1085	$(document).delegate('.btn-extra', 'click', function () {
1086		parent.window.__popup_url = $(this).data('product_url') || '';
1087	});
1088
1089	$(document).delegate('.module-form .btn-primary', 'click', function (e) {
1090		e.preventDefault();
1091
1092		var $this = $(this);
1093		var $form = $this.closest('.module-form').find('form');
1094		$form.find('.has-error').removeClass('has-error');
1095		$form.find('.text-danger').remove();
1096
1097		var data = $form.serializeArray();
1098
1099		data.push({
1100			name: 'url',
1101			value: parent.window.__popup_url || parent.window.location.toString()
1102		});
1103
1104		$.ajax({
1105			url: $form.attr('action'),
1106			type: 'post',
1107			data: data,
1108			dataType: 'json',
1109			beforeSend: function () {
1110				$this.button('loading');
1111			},
1112			complete: function () {
1113				$this.button('reset');
1114			},
1115			success: function (response) {
1116				if (response.status === 'success') {
1117					alert(response.response.message);
1118					$form[0].reset();
1119					parent.window.__popup_url = undefined;
1120					parent.$('.module-popup-' + Journal['modulePopupId'] + ' .popup-close').trigger('click');
1121				}
1122
1123				if (response.status === 'error') {
1124					$.each(response.response.errors, function (field, error) {
1125						if (field === 'agree') {
1126							alert(error);
1127						} else if (field === 'captcha') {
1128							$form.find('.captcha').addClass('has-error');
1129						} else {
1130							$form.find('[name^="' + field + '"]').closest('.form-group').addClass('has-error').after('<div class="text-danger">' + error + '</div>');
1131						}
1132					});
1133				}
1134			},
1135			error: function (xhr, ajaxOptions, thrownError) {
1136				alert(thrownError + '\r\n' + xhr.statusText + '\r\n' + xhr.responseText);
1137			}
1138		});
1139	});
1140
1141	// Grid / List toggle
1142	$(document).delegate('.grid-list .view-btn', 'click', function () {
1143		var $this = $(this);
1144		var $products = $('.main-products');
1145		var view = $this.data('view');
1146		var current = $products.hasClass('product-grid') ? 'grid' : 'list';
1147
1148		$this.tooltip('hide');
1149
1150		if (view !== current) {
1151			$products.addClass('no-transitions').removeClass('product-' + current).addClass('product-' + view);
1152			setTimeout(function () {
1153				$products.removeClass('no-transitions');
1154			}, 1);
1155			Cookies.set('view', view, { expires: 365 });
1156		}
1157
1158		$('.grid-list .view-btn').removeClass('active');
1159		$this.addClass('active');
1160	});
1161
1162	// Main Menu Hover Site Overlay
1163	$('.desktop-main-menu-wrapper #main-menu > .j-menu > .main-menu-item').first().addClass('first-dropdown');
1164
1165	var $desktop_main_menu_wrapper = $('.desktop-main-menu-wrapper');
1166
1167	$desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .menu-item:not(.dropdown)', 'mouseover', function () {
1168		$body.addClass('menu-hover');
1169	});
1170
1171	$desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .menu-item:not(.dropdown)', 'mouseleave', function () {
1172		$body.removeClass('menu-hover');
1173	});
1174
1175	$desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .dropdown', 'mouseover', function () {
1176		$body.addClass('menu-open');
1177	});
1178
1179	$desktop_main_menu_wrapper.delegate('.main-menu', 'mouseleave', function () {
1180		$body.removeClass('menu-open');
1181	});
1182
1183	// $desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .mega-menu', 'mouseover', function () {
1184	// 	$(this).addClass('animation-delay');
1185	// });
1186	//
1187	// $desktop_main_menu_wrapper.delegate('.main-menu > .j-menu > .mega-menu', 'mouseleave', function () {
1188	// 	var $this = $(this);
1189	// 	setTimeout(function () {
1190	// 		$this.removeClass('animation-delay');
1191	// 	}, 250);
1192	// });
1193
1194	//$('head').append('<style>.desktop-main-menu-wrapper .menu-item.dropdown::before {height: ' + ($body.height() - $('header').height()) + 'px} </style>');
1195
1196	if (($html.hasClass('iphone') || $html.hasClass('ipad')) && !$html.hasClass('popup-open')) {
1197		iNoBounce.disable();
1198	}
1199
1200	// Mobile Menu Wrapper
1201	$(document).delegate('.menu-trigger', 'click', function (e) {
1202		e.stopPropagation();
1203
1204		$html.addClass('mobile-overlay mobile-main-menu-container-open');
1205
1206		if ($html.hasClass('mobile-menu-active')) {
1207			$('[data-is-open]').each(function () {
1208				$('> a > .open-menu', this).trigger('click');
1209				$(this).removeAttr('data-is-open');
1210			});
1211		}
1212
1213		var $container = $('.mobile-main-menu-container');
1214
1215		$container.outerWidth();
1216
1217		$container.addClass('animating');
1218
1219		if ($html.hasClass('iphone') || $html.hasClass('ipad')) {
1220			iNoBounce.enable();
1221		}
1222	});
1223
1224	// Mobile Cart Wrapper
1225	if ($html.hasClass('mobile-header-active')) {
1226		$('.cart-content > ul').appendTo('.mobile-cart-content-wrapper');
1227	}
1228
1229	$(document).delegate('.mobile-header-active .cart-heading', 'click', function (e) {
1230		e.stopPropagation();
1231
1232		$html.addClass('mobile-overlay mobile-cart-content-container-open');
1233
1234		var $totals = $('.cart-totals').outerHeight();
1235
1236		$('.cart-products').css('padding-bottom', $totals - 1);
1237
1238		var $container = $('.mobile-cart-content-container');
1239
1240		$container.outerWidth();
1241
1242		$container.addClass('animating');
1243
1244		if ($html.hasClass('iphone') || $html.hasClass('ipad')) {
1245			iNoBounce.enable();
1246		}
1247		return false;
1248	});
1249
1250	// Mobile Filter Wrapper
1251	if (Journal['isPhone'] || (Journal['isTablet'] && (!Journal['globalPageColumnLeftTabletStatus'] || !Journal['globalPageColumnRightTabletStatus']))) {
1252		if ($('.module-filter').length) {
1253			$('.module-filter h3 > *').prependTo('.mobile-filter-container .mobile-wrapper-header');
1254			$('.module-filter').appendTo('.mobile-filter-wrapper');
1255
1256			$('<a class="mobile-filter-trigger btn">' + Journal['mobileFilterButtonText'] + '</a>').appendTo('body');
1257		}
1258	}
1259
1260	$(document).delegate('.mobile-header-active .mobile-filter-trigger', 'click', function (e) {
1261		e.stopPropagation();
1262
1263		$html.addClass('mobile-overlay mobile-filter-container-open');
1264
1265		var $container = $('.mobile-filter-container');
1266
1267		$container.outerWidth();
1268
1269		$container.addClass('animating');
1270
1271		if ($html.hasClass('iphone') || $html.hasClass('ipad')) {
1272			iNoBounce.enable();
1273		}
1274
1275		return false;
1276	});
1277
1278	// Close Mobile Wrapper
1279	$(document).delegate('.x, .site-wrapper, .close-filter', 'click', function () {
1280		$('.mobile-container.animating').removeClass('animating');
1281
1282		$html.removeClass('mobile-overlay');
1283
1284		setTimeout(function () {
1285			$html.removeClass('mobile-main-menu-container-open mobile-cart-content-container-open mobile-filter-container-open');
1286		}, 300);
1287
1288		if ($html.hasClass('iphone') || $html.hasClass('ipad')) {
1289			iNoBounce.disable();
1290		}
1291	});
1292
1293	// Product Page
1294	if ($html.hasClass('route-product-product')) {
1295		// sync image carousels
1296		$(document).delegate('.additional-image', 'click', function () {
1297			$('.additional-image').removeClass('swiper-slide-active');
1298			$(this).addClass('swiper-slide-active');
1299
1300			var $s = $('.main-image').data('swiper');
1301
1302			if ($s.params.loop) {
1303				$s.slideToLoop($(this).data('index'), 0);
1304			} else {
1305				$s.slideTo($(this).data('index'), 0);
1306			}
1307		});
1308
1309		// image zoom
1310		if (!('ontouchstart' in document)) {
1311			if (Journal['isPopup'] ? Journal['quickviewPageStyleCloudZoomStatus'] : Journal['productPageStyleCloudZoomStatus']) {
1312				$('.main-image img').each(function () {
1313					var $this = $(this);
1314
1315					$this.ImageZoom({
1316						type: Journal['isPopup'] ? Journal['quickviewPageStyleCloudZoomPosition'] : Journal['productPageStyleCloudZoomPosition'],
1317						showDescription: false,
1318						offset: [0, 0],
1319						zoomSize: [$this.width(), $this.height()],
1320						bigImageSrc: $this.data('largeimg')
1321					});
1322				});
1323
1324				// delay mouseover
1325				$('.product-image').mouseover(function () {
1326					$('.zm-viewer').delay(200).queue(function (next) {
1327						$(this).css('opacity', '1');
1328						next();
1329					});
1330				}).mouseleave(function () {
1331					$('.zm-viewer').css('opacity', '0');
1332				});
1333			}
1334		}
1335
1336		// Select first option
1337		if ((Journal['isPopup'] ? Journal['quickviewPageStyleOptionsSelect'] : Journal['productPageStyleOptionsSelect']) === 'all') {
1338			$('.product-options .form-group .radio:first-child input, .product-options .form-group .checkbox:first-child input').prop('checked', true);
1339			$('.product-options .form-group select').each(function () {
1340				$(this).find('option').eq(1).prop('selected', true);
1341			});
1342		}
1343
1344		if ((Journal['isPopup'] ? Journal['quickviewPageStyleOptionsSelect'] : Journal['productPageStyleOptionsSelect']) === 'required') {
1345			$('.product-options .form-group.required .radio:first-child input, .product-options .form-group.required .checkbox:first-child input').prop('checked', true);
1346			$('.product-options .form-group.required select').each(function () {
1347				$(this).find('option').eq(1).prop('selected', true);
1348			});
1349		}
1350
1351		// Auto Update Price
1352		if (Journal['isPopup'] ? Journal['quickviewPageStylePriceUpdate'] : Journal['productPageStylePriceUpdate']) {
1353			function autoUpdatePrice() {
1354				$.ajax({
1355					url: 'index.php?route=journal3/price&popup=' + (Journal['isPopup'] ? 1 : 0),
1356					type: 'post',
1357					data: $('#product-id, #product-quantity, #product input[type="radio"]:checked, #product input[type="checkbox"]:checked, #product select'),
1358					dataType: 'json',
1359					beforeSend: function () {
1360						// $('#button-cart').button('loading');
1361					},
1362					complete: function () {
1363						// $('#button-cart').button('reset');
1364					},
1365					success: function (json) {
1366						if (json['response']['status'] === 'error') {
1367							alert(json['response']['message']);
1368						} else {
1369							if (Journal['isPopup'] ? Journal['quickviewPageStyleProductStockUpdate'] : Journal['productPageStyleProductStockUpdate']) {
1370								if (json['response']['stock']) {
1371									$('.product-stock span').html(json['response']['stock']);
1372								}
1373
1374								if (json['response']['in_stock']) {
1375									$('.product-stock').removeClass('out-of-stock').addClass('in-stock');
1376								} else {
1377									$('.product-stock').removeClass('in-stock').addClass('out-of-stock');
1378								}
1379							}
1380
1381							if (json['response']['tax']) {
1382								$('.product-tax').html(json['response']['tax']);
1383							}
1384
1385							if (json['response']['price']) {
1386								if (json['response']['special']) {
1387									$('.product-price-group .product-price-old').html(json['response']['price']);
1388									$('.product-price-group .product-price-new').html(json['response']['special']);
1389								} else {
1390									$('.product-price-group .product-price').html(json['response']['price']);
1391								}
1392							}
1393
1394							if (json['response']['discounts']) {
1395								$('.product-discount').each(function (index) {
1396									$(this).html(json['response']['discounts'][index]);
1397								});
1398							}
1399
1400							if (json['response']['weight']) {
1401								$('.product-stats .product-weight span').html(json['response']['weight']);
1402							}
1403						}
1404					}
1405				});
1406			}
1407
1408			$('.product-options input[type="radio"], .product-options input[type="checkbox"], .product-options select, #product-quantity').on('change', autoUpdatePrice);
1409
1410			autoUpdatePrice();
1411		}
1412
1413		// Push Option Radio
1414		// $('.push-option.product-option-radio').each(function () {
1415		// 	var $this = $(this);
1416		// 	var hasImages = $this.find('img').length > 0;
1417		// 	var options = $this.find('.radio').map(function (index) {
1418		// 		var text = $(this).text().trim();
1419		//
1420		// 		if (hasImages) {
1421		// 			$this.addClass('push-image');
1422		// 			var src = $(this).find('img').attr('src') || 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
1423		// 			return '<li class="' + ($(this).find('input').is(':checked') ? 'checked' : '') + '" data-index="' + index + '">
1423<img src="' + src + '" alt="' + text + '" title="' + text + '" data-tooltip-class="push-image-tooltip" /></li>';
1424		// 		}
1425		//
1426		// 		return '<li class="' + ($(this).find('input').is(':checked') ? 'checked' : '') + '" data-index="' + index + '">' + text + '</li>';
1427		// 	});
1428		//
1429		// 	$this.append('<ul>' + options.toArray().join('') + '</ul>');
1430		//
1431		// 	$this.find('li').on('click', function () {
1432		// 		$this.find('.radio').eq($(this).data('index')).find('input').trigger('click');
1433		// 		$this.find('li').not($(this)).removeClass('checked');
1434		// 		$(this).addClass('checked');
1435		// 	});
1436		//
1437		// 	$this.find('li img').tooltip({ container: 'body' });
1438		// });
1439
1440		// Push Option Checkbox
1441		// $('.push-option.product-option-checkbox').each(function () {
1442		// 	var $this = $(this);
1443		// 	var hasImages = $this.find('img').length;
1444		// 	var options = $this.find('.checkbox').map(function (index) {
1445		// 		var text = $(this).text().trim();
1446		//
1447		// 		if (hasImages) {
1448		// 			$this.addClass('push-image');
1449		// 			var src = $(this).find('img').attr('src') || 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
1450		// 			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>';
1451		// 		}
1452		//
1453		// 		return '<li class="' + ($(this).find('input').is(':checked') ? 'checked' : '') + '" data-index="' + index + '">
1453' + text + '</li>';
1454		// 	});
1455		//
1456		// 	$this.append('<ul>' + options.toArray().join('') + '</ul>');
1457		//
1458		// 	$this.find('li').on('click', function () {
1459		// 		$this.find('.checkbox').eq($(this).data('index')).find('input').trigger('click');
1460		// 		$(this).toggleClass('checked');
1461		// 	});
1462		//
1463		// 	$this.find('li img').tooltip({ container: 'body' });
1464		// });
1465
1466		// Push Option Select
1467		// $('.push-option.product-option-select').each(function () {
1468		// 	var $this = $(this);
1469		// 	var options = $this.find('option').slice(1).map(function (index) {
1470		// 		return '<li class="' + ($(this).is(':checked') ? 'checked' : '') + '" data-index="' + index + '">' + $(this).text() + '</li>';
1471		// 	});
1472		//
1473		// 	$this.append('<ul>' + options.toArray().join('') + '</ul>');
1474		//
1475		// 	$this.find('li').on('click', function () {
1476		// 		$this.find('option').eq($(this).data('index') + 1).prop('selected', true);
1477		// 		$this.find('select').trigger('change');
1478		// 		$this.find('li').not($(this)).removeClass('checked');
1479		// 		$(this).addClass('checked');
1480		// 	});
1481		// });
1482	}
1483
1484	// Iframe height
1485	if ($html.hasClass('route-journal3-popup-page')) {
1486		$(document).on('click', function () {
1487			parent.resize_iframe(Journal['popupModuleId'], $('.popup-content').height());
1488		});
1489	}
1490
1491	//Footer Links module collapse
1492	$('.links-menu .module-title').addClass('closed');
1493
1494	$('.links-menu .module-title').click(function () {
1495		$(this).toggleClass('closed');
1496	});
1497
1498	// Open popup links in new tab
1499	if (Journal.isPopup) {
1500		$('a[href]').each(function () {
1501			var $this = $(this);
1502
1503			if (!$this.attr('target')) {
1504				$this.attr('target', '_blank');
1505			}
1506
1507			if (Journal.isPhone || Journal.isTablet) {
1508				$this.removeClass('agree');
1509			}
1510		});
1511	}
1512});
1513
1514$(window).on('load', function () {
1515	var $html = $('html');
1516	var $body = $('body');
1517
1518	// Search
1519	var $search = $('#search').find('input[name=\'search\']');
1520
1521	$('.search-button').on('click', function () {
1522		var url = $(this).data('search-url');
1523		var value = $search.val();
1524		var category_id = parseInt($search.attr('data-category_id'));
1525
1526		if (value) {
1527			url += encodeURIComponent(value);
1528		}
1529
1530		if (Journal['searchStyleSearchAutoSuggestDescription']) {
1531			url += '&description=true';
1532		}
1533
1534		if (category_id) {
1535			url += '&category_id=' + category_id;
1536		}
1537
1538		location = url;
1539	});
1540
1541	$search.on('keydown', function (e) {
1542		if (e.keyCode === 13) {
1543			$('.search-button').trigger('click');
1544		}
1545	});
1546
1547	$('.search-categories li').on('click', function (e) {
1548		e.stopPropagation();
1549
1550		var $this = $(this);
1551		$('.search-categories-button').html($this.html());
1552		$search.attr('data-category_id', $this.attr('data-category_id'))
1553	});
1554
1555	// Autosuggest
1556	if (Journal['searchStyleSearchAutoSuggestStatus']) {
1557		$search.typeahead({
1558			hint: true,
1559			minLength: 1,
1560			autoSelect: true
1561		}, {
1562			async: true,
1563			display: 'name',
1564			limit: Infinity,
1565			source: function (query, processSync, processAsync) {
1566				var data = {
1567					search: query
1568				};
1569
1570				var category_id = parseInt($search.attr('data-category_id'));
1571
1572				if (category_id) {
1573					data.category_id = category_id;
1574				}
1575
1576				return $.ajax({
1577					url: 'index.php?route=journal3/search',
1578					data: data,
1579					dataType: 'json',
1580					success: function (json) {
1581						return processAsync(json['response']);
1582					}
1583				});
1584			},
1585			templates: {
1586				suggestion: function (data) {
1587					if (data['view_more']) {
1588						return '<div class="search-result view-more"><a href="' + data['href'] + '">' + data['name'] + '</a></div>';
1589					}
1590
1591					if (data['no_results']) {
1592						return '<div class="search-result no-results"><a>' + data['name'] + '</a></div>';
1593					}
1594
1595					var html = '';
1596
1597					html += '<div class="search-result"><a href="' + data['href'] + '">';
1598
1599					if (data['thumb']) {
1600						html += '<img src="' + data['thumb'] + '" srcset="' + data['thumb'] + ' 1x, ' + data['thumb2'] + ' 2x" />';
1601					}
1602
1603					var classes = [];
1604
1605					if (data['quantity'] <= 0) {
1606						classes.push('out-of-stock');
1607					}
1608
1609					if (!data['price_value']) {
1610						classes.push('has-zero-price');
1611					}
1612
1613					html += '<span class="' + classes.join(' ') + '">';
1614
1615					html += '<span class="product-name">' + data['name'] + '</span>';
1616
1617					if (data['price']) {
1618						if (data['special']) {
1619							html += '<span><span class="price-old">' + data['price'] + '</span><span class="price-new">' + data['special'] + '</span></span>';
1620						} else {
1621							html += '<span class="price">' + data['price'] + '</span>';
1622						}
1623					}
1624
1625					html += '</span>';
1626
1627					html += '</a></div>';
1628
1629					return html;
1630				}
1631			}
1632
1633		});
1634
1635		$('.header-search > span > div').addClass('.tt-empty');
1636
1637		// mobile page zoom fix
1638		$('.mobile .tt-menu').on('click', function (e) {
1639			e.stopPropagation();
1640		});
1641	}
1642
1643	// Sticky Desktop
1644	if (!Journal.isPopup && Journal['isDesktop'] && Journal['stickyStatus'] && (['classic', 'mega', 'default'].includes(Journal['headerType']))) {
1645		var holder = document.body;
1646		var headerHeightOffset = $('.desktop-main-menu-wrapper').offset().top + (parseInt(Journal['stickyAt'], 10) || 100);
1647		var menuHeight = $('.desktop-main-menu-wrapper').outerHeight();
1648
1649		function enableSticky() {
1650			if (Journal['headerType'] === 'classic' || Journal['headerType'] === 'mega') {
1651				$body.css('padding-top', menuHeight);
1652			}
1653		}
1654
1655		function disableSticky() {
1656			if (Journal['headerType'] === 'classic' || Journal['headerType'] === 'mega') {
1657				$body.css('padding-top', '');
1658			}
1659		}
1660
1661		function checkStickyOffset() {
1662			return headerHeightOffset <= window.scrollY;
1663		}
1664
1665		function checkSticky() {
1666			var old = holder.classList.contains('is-sticky');
1667
1668			holder.classList.toggle('is-sticky', checkStickyOffset());
1669
1670			var current = holder.classList.contains('is-sticky');
1671
1672			if (current !== old) {
1673				if (current) {
1674					enableSticky();
1675				} else {
1676					disableSticky();
1677				}
1678			}
1679		}
1680
1681		function checkStickyListener() {
1682			requestAnimationFrame(checkSticky)
1683		}
1684
1685		window.addEventListener('scroll', checkStickyListener, false);
1686	}
1687
1688	//Compact Sticky top bar
1689	if (!Journal.isPopup && Journal['isDesktop'] && Journal['stickyStatus'] && Journal['topB
1689arStatus'] && (['compact', 'slim'].includes(Journal['headerType']))) {
1690		var compact = $('.mid-bar');
1691		if (compact.length) {
1692			$(window).on('scroll', function () {
1693				var compactOffset = compact.offset().top;
1694				var scroll = $(this)[0].scrollY
1695				if (scroll >= compactOffset) {
1696					$('body').addClass('sticky-compact');
1697				} else {
1698					$('body').removeClass('sticky-compact');
1699				}
1700			});
1701		}
1702	}
1703
1704	//Compact Sticky no top bar
1705	if (!Journal.isPopup && Journal['isDesktop'] && Journal['stickyStatus'] && !Journal['topBarStatus'] && !Journal['stickyFullHomePadding'] && (['compact', 'slim'].includes(Journal['headerType']))) {
1706		var site = $('.site-wrapper');
1707		var header = $('.mid-bar').outerHeight();
1708		if (site.length) {
1709			$(window).on('scroll', function () {
1710				var siteOffset = site.offset().top - header + 1;
1711				var scroll = $(this)[0].scrollY
1712				if (scroll >= siteOffset) {
1713					$('body').addClass('sticky-compact');
1714				} else {
1715					$('body').removeClass('sticky-compact');
1716				}
1717			});
1718		}
1719	}
1720
1721	//Compact Sticky no top bar over hover
1722	if (!Journal.isPopup && Journal['isDesktop'] && Journal['stickyStatus'] && !Journal['topB
1722arStatus'] && Journal['stickyFullHomePadding'] && (['compact', 'slim'].includes(Journal['headerType']))) {
1723		var site = $('.site-wrapper');
1724		var header = $('html:not(.route-common-home) .mid-bar').outerHeight();
1725		if (site.length) {
1726			$(window).on('scroll', function () {
1727				var siteOffset = site.offset().top - header + 1;
1728				var scroll = $(this)[0].scrollY
1729				if (scroll >= siteOffset) {
1730					$('body').addClass('sticky-compact');
1731				} else {
1732					$('body').removeClass('sticky-compact');
1733				}
1734			});
1735		}
1736	}
1737
1738
1739	// Sticky Mobile
1740	if (!Journal['isDesktop'] && Journal['headerMobileStickyStatus'] && $html.hasClass('mobile-header-active')) {
1741		var mobileBar = $('.mobile-header .sticky-bar');
1742		if (mobileBar.length) {
1743			var mobileBarSticky = mobileBar.offset().top;
1744			var mobileBarHeight = mobileBar.outerHeight();
1745			$(window).on('scroll', function () {
1746				var scroll = $(this)[0].scrollY
1747				if (scroll >= mobileBarSticky) {
1748					mobileBar.addClass('mobile-bar-sticky');
1749					$body.css('padding-top', mobileBarHeight);
1750				} else {
1751					mobileBar.removeClass('mobile-bar-sticky');
1752					$body.css('padding-top', '');
1753				}
1754			});
1755		}
1756	}
1757
1758	//Focus mini search on click
1759	if (Journal['isDesktop'] && (Journal['headerMiniSearchDisplay'] === 'page')) {
1760		$('.search-trigger, .desktop .search-categories .j-menu > li > a').click(function () {
1761			$('.header-search input').focus();
1762		});
1763	}
1764
1765	// Scroll Top
1766	if (Journal['scrollTop']) {
1767		var scrollTopTimeout;
1768
1769		$(window).on('scroll', function () {
1770			clearTimeout(scrollTopTimeout);
1771			var scroll = $(this)[0].scrollY
1772			if (scroll > 500) {
1773				$('.scroll-top').addClass('scroll-top-active');
1774
1775				scrollTopTimeout = setTimeout(function () {
1776					$('.scroll-top').removeClass('scroll-top-active');
1777				}, 3000);
1778			} else {
1779				$('.scroll-top').removeClass('scroll-top-active');
1780			}
1781		});
1782
1783		$('.scroll-top').click(function () {
1784			anime({
1785				targets: 'html, body',
1786				scrollTop: 0,
1787				duration: 750,
1788				easing: 'easeInOutQuad'
1789			});
1790		});
1791	}
1792
1793	if ($html.hasClass('footer-reveal')) {
1794		var footerHeight = $('.desktop.footer-reveal footer').outerHeight();
1795		$('.desktop body').css('padding-bottom', footerHeight);
1796	}
1797});
1798
1799$('.block-map iframe').on('load', function () {
1800	$('.block-map .journal-loading').hide();
1801});

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.