PageSourceSearch

https://www.owlaboutkids.gr/catalog/view/theme/journal3/js/journal.js?v=b61f0b8d

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

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.