1(function($) { 2 FWP.hooks.addAction('facetwp/refresh/color', function($this, facet_name) { 3 var selected_values = []; 4 $this.find('.facetwp-color.checked').each(function() { 5 selected_values.push($(this).attr('data-value')); 6 }); 7 FWP.facets[facet_name] = selected_values; 8 }); 9 10 FWP.hooks.addFilter('facetwp/selections/color', function(output, params) { 11 var choices = []; 12 $.each(params.selected_values, function(val) { 13 var $item = params.el.find('.facetwp-color[data-value="' + val + '"]'); 14 var $display_value = $item.attr('title').length > 0 ? $item.attr('title') : val; 15 choices.push({ 16 value: val, 17 label: $display_value 18 }); 19 }); 20 return choices; 21 }); 22 23 $().on('click', '.facetwp-facet .facetwp-color:not(.disabled)', function(e) { 24 if (true === e.handled) { 25 return false; 26 } 27 e.handled = true; 28 $(this).toggleClass('checked'); 29 FWP.autoload(); 30 }); 31 32 $().on('click', '.facetwp-type-color .facetwp-toggle', function() { 33 var $parent = $(this).closest('.facetwp-facet'); 34 $parent.find('.facetwp-toggle').toggleClass('facetwp-hidden'); 35 $parent.find('.facetwp-overflow').toggleClass('facetwp-hidden'); 36 }); 37 38 $().on('facetwp-loaded', function() { 39 $('.facetwp-color').each(function() { 40 var $this = $(this); 41 var el = $this.nodes[0]; 42 el.style.backgroundColor = $this.attr('data-color'); 43 if (null !== $this.attr('data-img')) { 44 el.style.backgroundImage = 'url("' + $this.attr('data-img') + '")'; 45 el.style.backgroundPosition = 'center'; 46 el.style.backgroundSize = 'cover'; 47 } 48 }); 49 50 $('.facetwp-type-color').each(function() { 51 var num = $(this).find('.facetwp-color.facetwp-overflow').len(); 52 var $el = $(this).find('.facetwp-toggle-wrap .facetwp-toggle').first(); 53 if ( undefined != $el.text() ) $el.text($el.text().replace('{num}', num)); 54 55 // auto-expand if a color within the overflow is checked 56 if (0 < $(this).find('.facetwp-color.checked').len()) { 57 $el.trigger('click'); 58 } 59 }); 60 }); 61})(fUtil);
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.