PageSourceSearch

https://www.maennlichen.ch/files/themes/hb/js/base/components-shop.js

js maennlichen.ch collected 2026-10-02 11:21:11 UTC 4,845 bytes, 181 lines download raw bytes

1/**
2 Core Shop layout handlers and wrappers
3 **/
4
5// BEGIN: Layout Brand
6var LayoutQtySpinner = function () {
7
8	return {
9		//main function to initiate the module
10		init: function () {
11			$('.c-spinner .btn:first-of-type').on('click', function () {
12				var data_input = $(this).attr('data_input');
13				var data_max = ($(this).data('maximum')) ? $(this).data('maximum') : 10;
14				if ($('.c-spinner input.' + data_input).val() < data_max) {
15					$('.c-spinner input.' + data_input).val(parseInt($('.c-spinner input.' + data_input).val(), 10) + 1);
16				}			
17			});
18
19			$('.c-spinner .btn:last-of-type').on('click', function () {
20				var data_input = $(this).attr('data_input');
21				if ($('.c-spinner input.' + data_input).val() != 0) {
22					$('.c-spinner input.' + data_input).val(parseInt($('.c-spinner input.' + data_input).val(), 10) - 1);
23				}
24			});
25		}
26
27	};
28}();
29// END
30
31// BEGIN: Layout Checkbox Visibility Toggle
32var LayoutCheckboxVisibilityToggle = function () {
33
34	return {
35		//main function to initiate the module
36		init: function () {
37			$('.c-toggle-hide').each(function () {
38				var $checkbox = $(this).find('input.c-check'),
39					$speed = $(this).data('animation-speed'),
40					$object = $('.' + $(this).data('object-selector'));
41
42				$object.hide();
43
44				if (typeof $speed === 'undefined') {
45					$speed = 'slow';
46				}
47
48				$($checkbox).on('change', function () {
49					if ($($object).is(':hidden')) {
50						$($object).show($speed);
51					} else {
52						$($object).slideUp($speed);
53					}
54				});
55			});
56		}
57	};
58
59}();
60// END
61
62// BEGIN: Layout Shipping Calculator
63var LayoutShippingCalculator = function () {
64
65	return {
66		//main function to initiate the module
67		init: function () {
68			var $shipping_calculator = $('.c-shipping-calculator'),
69				$radio_name = $($shipping_calculator).data('name'),
70				$total_placeholder = $($shipping_calculator).data('total-selector'),
71				$subtotal_placeholder = $($shipping_calculator).data('subtotal-selector'),
72				$subtotal = parseFloat($('.' + $subtotal_placeholder).text());
73
74			$('input[name=' + $radio_name + ']', $shipping_calculator).on('change', function () {
75				var $price = parseFloat($('input[name=' + $radio_name + ']:checked', $shipping_calculator).val()),
76					$overall_total = $subtotal + $price;
77				$('.' + $total_placeholder).text($overall_total.toFixed(2));
78			});
79		}
80	};
81
82}();
83// END
84
85// PRODUCT GALLERY
86var LayoutProductGallery = function () {
87	return {
88		//main function to initiate the module
89		init: function () {
90			$('.c-product-gallery-content .c-zoom').toggleClass('c-hide'); // INIT FUNCTION - HIDE ALL IMAGES
91
92			// SET GALLERY ORDER
93			var i = 1;
94			$('.c-product-gallery-content .c-zoom').each(function(){
95				$(this).attr('img_order', i);
96				i++;
97			});
98
99			// INIT ZOOM MASTER PLUGIN
100			$('.c-zoom').each(function(){
101				$(this).zoom();
102			});
103
104			// ASSIGN THUMBNAIL TO IMAGE
105			var i = 1;
106			$('.c-product-thumb img').each(function(){
107				$(this).attr('img_order', i);
108				i++;
109			});
110
111			// INIT FIRST IMAGE
112			$('.c-product-gallery-content .c-zoom[img_order="1"]').toggleClass('c-hide');
113
114			// CHANGE IMAGES ON THUMBNAIL CLICK
115			$('.c-product-thumb img').click(function(){
116				var img_target = $(this).attr('img_order');
117
118				$('.c-product-gallery-content .c-zoom').addClass('c-hide');
119				$('.c-product-gallery-content .c-zoom[img_order="'+img_target+'"]').removeClass('c-hide');
120			});
121        
122        	// SET THUMBNAIL HEIGHT
123        	var thumb_width = $('.c-product-thumb').width();
124        	$('.c-product-thumb').height(thumb_width);
125
126	    }
127	}
128}();
129
130// BEGIN: Price Slider
131var PriceSlider = function () {
132
133	return {
134		//main function to initiate the module
135		init: function () {
136			$('.c-price-slider').slider();
137		}
138
139	};
140
141}();
142// END
143
144// BEGIN : OFFER NOTIFICATION BAR
145var LayoutTopbarOffer = function () {
146
147	var _initInstances = function () {
148
149		$('.c-shop-topbar-close').click(function(){
150			$('.c-shop-topbar-offer').animate({
151				opacity: 0,
152			  }, 200, function() {
153			    $('.c-shop-topbar-offer').css('display', 'none');
154			    var offer_height = $(this).outerHeight(true);
155			    offer_height = (parseInt($('.c-layout-page').css('margin-top')) - offer_height);
156			    $('.c-layout-page').css('margin-top', (offer_height+'px'));
157			  });
158		});
159	};
160
161	return {
162
163		//main function to initiate the module
164		init: function () {
165			_initInstances();
166		}
167
168	};
169}();
170// END : OFFER NOTIFICATION BAR
171
172// Main theme initialization
173$(document).ready(function () {
174	// init layout handlers
175	LayoutQtySpinner.init();
176	LayoutCheckboxVisibilityToggle.init();
177	LayoutShippingCalculator.init();
178	LayoutProductGallery.init();
179	PriceSlider.init();
180	LayoutTopbarOffer.init();
181});

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.