1// ----------------------------------------------------------------------- 2// Copyright 2017-2018 Sitecore Corporation A/S 3// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 4// except in compliance with the License. You may obtain a copy of the License at 5// http://www.apache.org/licenses/LICENSE-2.0 6// 7// Unless required by applicable law or agreed to in writing, software distributed under the 8// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 9// either express or implied. See the License for the specific language governing permissions 10// and limitations under the License. 11// ------------------------------------------------------------------------------------------- 12 13(function (root, factory) { 14 'use strict'; 15 if (typeof define === 'function' && define.amd) { 16 // use AMD define funtion to support AMD modules if in use 17 define(['exports'], factory); 18 } else if (typeof exports === 'object') { 19 // to support CommonJS 20 factory(exports); 21 } 22 var CatalogFacetComponent = {}; 23 root.CatalogFacetComponent = CatalogFacetComponent; 24 25 factory(CatalogFacetComponent); 26})(this, function (catalogFacetComponent) { 27 var toggleFacet = function (facetName, facetValue, isApplied, url) { 28 var data = { 29 facetValue: facetName + '=' + facetValue, 30 isApplied: isApplied 31 }; 32 33 AjaxService.Post('/api/cxa/catalog/facetapplied', data, function () { 34 // reload page after toggling facets 35 window.location.href = url; 36 }); 37 }; 38 39 catalogFacetComponent.Init = function (element) { 40 $(element) 41 .find('.product-facets ul li a') 42 .click(function () { 43 var $facet = $(this); 44 var facetName = $facet.data('facet-name'); 45 var facetValue = $facet.data('facet-value'); 46 var facetIsActive = $facet.data('facet-is-active'); 47 var facetUrl = $facet.data('facet-url'); 48 49 toggleFacet(facetName, facetValue, facetIsActive, facetUrl); 50 }); 51 52 $(element) 53 .find(".facet-title") 54 .click(function () { 55 var $obj = $(this); 56 var clicks = $obj.data('clicks'); 57 if (clicks == undefined && $obj.hasClass('arrow_active')) { 58 clicks = 1; 59 } 60 var $list = $obj.next().filter("div[class$=-list]"); 61 if (!clicks) { 62 $list.fadeTo("fast", 0).hide(); 63 $obj.data('clicks', 1); 64 } else { 65 $list.show().fadeTo("fast", 1); 66 $obj.removeData(); 67 } 68 }); 69 }; 70 71 self.loadMoreProducts = function () { 72 self.isShowMoreProducts(true); 73 self.loadProducts(); 74 }; 75});
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.