PageSourceSearch

https://www.kaosalonpartner.se/_ui/responsive/common/js/acc.refinements.js

js kaosalonpartner.se collected 2026-10-08 23:15:23 UTC 9,511 bytes, 321 lines download raw bytes

1ACC.refinements = {
2
3	_autoload: [
4		["bindMoreLessToggles", $(".js-facet-form").length != 0],
5		["bindMoreStoresToggles", $(".js-facet-form").length != 0],
6		["init", $("#findStoresNearMeAjax").length != 0],
7		["bindSearch", $(".js-facet-form").length != 0],
8		"scrollToTheSpecifiedPosition",
9		"bindLandingCategoryFacet",
10		"bindSelectFilter",
11		"bindToggleFilterDisplay",
12		"bindToggleSearchedItemList",
13		"bindCloseFilterList",
14		"bindScrollFacetButtons",
15		"setFacetDropDownHeight"
16	],
17
18
19	coords:{},
20	storeSearchData:{},
21
22
23	init:function(){
24		navigator.geolocation.getCurrentPosition(
25			function (position){
26				ACC.refinements.coords = position.coords;
27			},
28			function (error)
29			{
30				console.log("An error occurred... The error code and message are: " + error.code + "/" + error.message);
31			}
32		);
33
34	},
35	
36	/*implemented as part of web-1786 scroll to search results on selecting filter*/
37	bindLandingCategoryFacet: function(){
38		$(document).on('click','.js-facet-values .landingCategoryFacet.removeResult', function(){
39				ACC.refinements.storePagePosition();
40		});
41	},
42	/*implemented as part of web-1786 scroll to search results on selecting filter*/
43	storePagePosition: function() {
44		    console.log("offset top : "+$(".product-list.plp-heading").offset().top);
45			localStorage.setItem("page_y", $(".product-list.plp-heading").offset().top);
46			},
47	/*implemented as part of web-1786 scroll to search results on selecting filter*/
48	scrollToTheSpecifiedPosition:function(){
49		$(document).ready(function() {
50			var currentPageY;
51			var isPromoScroll;
52			console.log("Inside BindSearvh1");
53			try {
54			currentPageY = localStorage.getItem("page_y");
55			isPromoScroll = localStorage.getItem("scrollPromoPage");
56			if (currentPageY != undefined && currentPageY != null) {
57				setTimeout(function () {
58					$([document.documentElement, document.body]).animate({
59						scrollTop: currentPageY-140
60					}, 1000);
61				}, 1500);
62			}
63			else if(isPromoScroll != undefined && isPromoScroll != null) {
64				$([document.documentElement, document.body]).animate({
65					scrollTop: $('#'+isPromoScroll).offset().top-50
66				}, 1000);
67			} 
68			localStorage.removeItem("page_y");
69			localStorage.removeItem("scrollPromoPage");
70			} catch (e) {
71			console.log("no local storage available");
72			}
73		})
74},
75
76
77	bindSearch:function(){
78
79		$(document).on("submit",'#user_location_form', function(e){
80			e.preventDefault()
81			var q = $(".js-shop-stores-facet .js-shop-store-search-input").val();
82			 if(q.length>0){
83				 ACC.refinements.getInitStoreData(q);				
84			 }
85		})
86
87
88		$(document).on("click",'#findStoresNearMeAjax', function(e){
89			e.preventDefault()
90			ACC.refinements.getInitStoreData(null,ACC.refinements.coords.latitude,ACC.refinements.coords.longitude);
91		})
92
93
94	},
95
96
97	getInitStoreData: function(q,latitude,longitude){
98		$(".alert").remove();
99		data ={
100			"q":"" ,
101			"page":"0"
102		}
103
104		if(q != null){
105			data.q = q;
106		}
107		
108
109		if(latitude != null){
110			data.latitude = latitude;
111		}
112
113		if(longitude != null){
114			data.longitude = longitude;
115		}
116
117		ACC.refinements.storeSearchData = data;
118		ACC.refinements.getStoreData();
119	},
120
121
122	getStoreData: function(){
123		url= $(".js-facet-form").data("url");
124		$.ajax({
125			url: url,
126			data: ACC.refinements.storeSearchData,
127			type: "get",
128			success: function (response){
129				window.location.reload();
130			}
131		});
132	},
133	
134	submitFacetForm: function(element, url, textSearch) {
135		var form = element.closest('.js-refinement-section').find("form");
136		ACC.refinements.appendLandingCategoryToURL(form);
137		form.find("input[name='q']").val(url);
138		form.find("input[name='text']").val(textSearch);
139		form.submit();
140	},
141	
142	bindSelectFilter: function() {
143		$('.facet__checkbox-item input:checkbox:checked').change(function() {
144			ACC.refinements.submitFacetForm($(this), $(this).data('url'), '');
145		});
146		
147		
148		$(document).on("click",".js-apply-facet-button",function(){
149			ACC.refinements.storePagePosition();
150			var selected=$(this).parents('.js-refinement-section').find(':checked');
151			var url;
152			var textSearch;
153			if(selected==undefined || selected==null || selected==""){
154				//nothing to do
155				return;
156			}
157
158			selected.each(function() {
159				var selectedFilterUrl = $(this).data('url');
160				if (url) {
161					var urlParams = selectedFilterUrl.split(',');
162					var filterValue = $(this).val().split(',')[0];
163					var listUrlLength = urlParams.length;
164
165					if (listUrlLength) {
166						url += ":" + filterValue + "," + urlParams[urlParams.length - 1];
167					}
168
169				} else {
170					url = selectedFilterUrl;
171				}
172				textSearch = $(selected).data('textSearch');
173			});
174
175			if(url==undefined || url==null || url==""){
176				//no url to redirect, returning
177				return;
178			}
179
180			if(textSearch==undefined || textSearch==null ){
181				//no url to redirect, returning
182				textSearch="";
183			}
184			ACC.refinements.submitFacetForm($(this), url, textSearch);
185			
186		});
187		$(document).on("click","#showAllFilters",function(){
188			$(".hideFilterOnload").show();
189			$(".sortbySection").css("width","100%");
190			$(".sortbySection").css("margin-bottom","8px");
191			$(".sortbySection #sortForm1").css("width","16.5%");
192			$(this).hide();
193		})
194	},
195
196	
197	bindMoreLessToggles: function (){
198
199		$(document).on("click",".js-shop-stores-facet .js-facet-change-link",function(e){
200			e.preventDefault();
201			$(".js-shop-stores-facet .js-facet-container").hide();
202			$(".js-shop-stores-facet .js-facet-form").show();
203		})
204
205
206		$(document).on("change",".js-product-facet .js-facet-checkbox",function(){
207			$(this).parents("form").submit();
208		})
209		
210		$(document).on("click",".js-product-facet .js-more-facet-values-link",function(e){
211			e.preventDefault();
212			$(this).parents(".js-facet").find(".js-facet-top-values").hide();
213			$(this).parents(".js-facet").find(".js-facet-list-hidden").show();
214
215			$(this).parents(".js-facet").find(".js-more-facet-values").hide();
216			$(this).parents(".js-facet").find(".js-less-facet-values").show();
217		})
218
219		$(document).on("click",".js-product-facet .js-less-facet-values-link",function(e){
220			e.preventDefault();
221			$(this).parents(".js-facet").find(".js-facet-top-values").show();
222			$(this).parents(".js-facet").find(".js-facet-list-hidden").hide();
223
224			$(this).parents(".js-facet").find(".js-more-facet-values").show();
225			$(this).parents(".js-facet").find(".js-less-facet-values").hide();
226		})
227
228	},
229	
230	bindMoreStoresToggles: function ()
231	{
232		$(document).on("click",".js-shop-stores-facet .js-more-stores-facet-values",function(e){
233			e.preventDefault();
234			$(".js-shop-stores-facet ul.js-facet-list li.hidden").slice(0, 5).removeClass('hidden').first().find('.js-facet-checkbox').focus();
235			if($(".js-shop-stores-facet ul.js-facet-list li.hidden").length==0){
236				$(".js-shop-stores-facet .js-more-stores-facet-values").hide()
237			}
238		})
239		
240	},
241	
242	appendLandingCategoryToURL: function(form)
243	{
244		var landingCategory = ACC.global.geturlParam("landingCategory");
245		
246		if(landingCategory==null || landingCategory==undefined){
247			form.find("input[name='landingCategory']").remove();
248		}
249		else{
250			form.find("input[name='landingCategory']").val(landingCategory);
251		}
252		console.log("The landing category is: "+landingCategory);
253	},
254	
255	hideAllFacets: function() {
256		var checkBoxList = $('.facet__checkbox-list');
257		checkBoxList.hide();
258		checkBoxList.removeClass('open');
259		checkBoxList.parent().find('.facet__icon-select').removeClass('facet__icon-select--in');
260		checkBoxList.parent().find('.js-product-facet-selectbox').removeClass('facet-open');
261
262	},
263
264	bindToggleFilterDisplay: function() {
265		$(document).on('click','.js-product-facet-selectbox', function(event) {
266			var parentElement = $(this).closest('.js-refinement-section');
267			var isOpenElement = $(event.target)
268				.parents('.js-refinement-section')
269				.find('.facet__checkbox-list')
270				.hasClass('open');
271			if (isOpenElement) {
272				ACC.refinements.hideAllFacets();
273				return;
274			}
275
276			ACC.refinements.hideAllFacets();
277			parentElement.find('.facet__checkbox-list').toggle();
278			parentElement.find('.facet__checkbox-list').toggleClass('open');
279			parentElement.find('.facet__icon-select').toggleClass('facet__icon-select--in');
280			parentElement.find('.js-product-facet-selectbox').toggleClass('facet-open');
281
282		});
283	},
284
285
286	bindCloseFilterList: function() {
287		$(document).click(function(event) {
288			var checkBoxList = $('.facet__checkbox-list');
289			if (!$('.js-product-facet-selectbox').is(event.target)
290				&& !$('.facet__icon-select').is(event.target)
291				&& checkBoxList.hasClass('open')
292				&& $(event.target).closest(".facet__checkbox-list").length === 0) {
293				checkBoxList.hide();
294				checkBoxList.removeClass('open');
295				checkBoxList.parent().find('.facet__icon-select').removeClass('facet__icon-select--in');
296				checkBoxList.parent().find('.js-product-facet-selectbox').removeClass('facet-open');
297			}
298		});
299	},
300	
301	bindToggleSearchedItemList: function() {
302		if ($('.facet__scroll-list .searchFilter').length >= 7) {
303			$('.facet__search-right-scroll').show();
304		}
305	},
306	
307	bindScrollFacetButtons: function () {
308		$('.js-scroll-facet-search-right').click(function() {
309			var leftPos = $('.facet__scroll-list').scrollLeft();
310			$('.facet__scroll-list').animate({scrollLeft: leftPos + 200}, 800);
311		});
312	},
313
314	setFacetDropDownHeight: function() {
315		$(document).ready(function() {
316			var productListingHeight = $('.product__listing').height();
317			var facetCheckboxListHeight = productListingHeight < 520 ? productListingHeight : 520;
318			$('.facet__checkbox-list-wrapper').css('max-height', facetCheckboxListHeight);
319		});
320	}
321};

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.