1function journal_filter_url() { 2 var f = {}; 3 4 $('input[data-filter-trigger]:checked, select[data-filter-trigger]').each(function () { 5 var $this = $(this); 6 7 var name = 'f' + $this.attr('name'); 8 var value = $this.val().trim(); 9 10 f[name] = f[name] || []; 11 f[name].push(value); 12 }); 13 14 if ($('.filter-price').length) { 15 var min = $('.filter-price-min').data('min'); 16 var max = $('.filter-price-max').data('max'); 17 var from = parseInt($('.filter-price-min').val(), 10); 18 var to = parseInt($('.filter-price-max').val(), 10); 19 20 if (((from !== '') && (from !== min)) || ((to !== '') && (to !== max))) { 21 f['fmin'] = [from]; 22 f['fmax'] = [to]; 23 } 24 } 25 26 var sort = $('#input-sort').data('filter-sort'); 27 var order = $('#input-sort').data('filter-order'); 28 29 if (sort && order) { 30 f['sort'] = [sort]; 31 f['order'] = [order]; 32 } 33 34 var limit = $('#input-limit').data('filter-limit'); 35 36 if (limit) { 37 f['limit'] = [limit]; 38 } 39 40 var url = []; 41 42 $.each(f, function (k, v) { 43 url.push(k + '=' + v.join(Journal['filterUrlValuesSeparator'] || ',')); 44 }); 45 46 url = url.join('&'); 47 48 if (!url) { 49 return Journal['filterBase']; 50 } 51 52 if (Journal['filterBase'].indexOf('?') === -1) { 53 return Journal['filterBase'] + '?' + url; 54 } 55 56 return Journal['filterBase'] + '&' + url; 57} 58 59function journal_filter_price_slider() { 60 $('.filter-price .range-slider input').ionRangeSlider({ 61 type: 'double', 62 min: $('.filter-price-min').data('min'), 63 max: $('.filter-price-max').data('max'), 64 from: $('.filter-price-min').val(), 65 to: $('.filter-price-max').val(), 66 onChange: function (data) { 67 $('.filter-price-min').val(data.from); 68 $('.filter-price-max').val(data.to); 69 }, 70 onFinish: function (data) { 71 $('.filter-price-min').trigger('blur'); 72 }, 73 prettify: function (value) { 74 if (Journal['currency_left']) { 75 return accounting.formatMoney(value, Journal['currency_left'], 0, Journal['currency_thousand'], Journal['currency_decimal'], '%s%v'); 76 } 77 78 return accounting.formatMoney(value, Journal['currency_right'], 0, Journal['currency_thousand'], Journal['currency_decimal'], '%v%s'); 79 } 80 }); 81} 82 83function journal_filter(url, opts) { 84 opts = opts || {}; 85 86 var source = opts.source; 87 var updateHistory = opts.updateHistory; 88 89 try { 90 var u = new URL(url); 91 92 u.host = window.location.host; 93 u.hostname = window.location.hostname; 94 u.protocol = window.location.protocol; 95 96 url = u.toString(); 97 } catch (e) { 98 } 99 100 if (updateHistory !== false && window.history && window.history.pushState) { 101 var state = { Title: document.title, Url: url }; 102 103 window.history.pushState(state, state.Title, state.Url); 104 } 105 106 if (Journal['infiniteScrollInstance']) { 107 Journal['infiniteScrollInstance'].destroy(); 108 } 109 110 $.ajax({ 111 url: url, 112 dataType: 'html', 113 headers: { 'Filter-Module': 1 }, 114 beforeSend: function () { 115 $('[data-toggle="tooltip"]').tooltip('hide'); 116 117 loader('.container > .row', true); 118 }, 119 complete: function () { 120 loader('.container > .row', false); 121 122 if (Journal['filterScrollTop'] || (source === 'pagination')) { 123 $('html, body').animate({ scrollTop: 0 }, 700); 124 } 125 }, 126 success: function (response) { 127 var $response = $(response); 128 129 Journal['filterCollapsed'] = {}; 130 131 $('.module-filter .module-item .panel-heading a').each(function () { 132 var $this = $(this); 133 Journal['filterCollapsed'][$this.data('filter')] = $this.hasClass('collapsed'); 134 }); 135 136 var $slider = $('.filter-price .range-slider input'); 137 138 if ($slider.length && $slider.data('ionRangeSlider')) { 139 $slider.data('ionRangeSlider').destroy(); 140 } 141 142 $('.module-filter').replaceWith($response.find('.module-filter')); 143 $('.main-products-wrapper').replaceWith($response.find('.main-products-wrapper')); 144 $('#input-sort, #input-limit').removeAttr('onchange'); 145 146 var $panel_group = $('.panel-group'); 147 148 $panel_group.on('show.bs.collapse', function (e) { 149 $(e.target).parent().addClass('panel-active'); 150 $(e.target).parent().removeClass('panel-collapsed'); 151 }); 152 153 $panel_group.on('hide.bs.collapse', function (e) { 154 $(e.target).parent().removeClass('panel-active'); 155 $(e.target).parent().addClass('panel-collapsing'); 156 }); 157 158 $panel_group.on('hidden.bs.collapse', function (e) { 159 $(e.target).parent().removeClass('panel-collapsing'); 160 $(e.target).parent().addClass('panel-collapsed'); 161 }); 162
163 Object.keys(Journal['filterCollapsed']).forEach(function (key) { 164 var $collapse = $($('.module-filter .module-item .panel-heading a[data-filter="' + key + '"]').attr('href')); 165 166 if (Journal['filterCollapsed'][key] === true) { 167 $collapse.collapse('hide'); 168 } 169 170 if (Journal['filterCollapsed'][key] === false) { 171 $collapse.collapse('show'); 172 } 173 }); 174 175 journal_filter_price_slider(); 176 177 Journal.lazy(); 178 179 if (Journal['infiniteScrollInstance']) { 180 $('.ias-trigger').remove(); 181 setTimeout(function () { 182 Journal['infiniteScrollInstance'].reinitialize(); 183 }, 100); 184 } 185 } 186 }); 187} 188 189jQuery(function ($) { 190 // price slider 191 journal_filter_price_slider(); 192 193 // handle price change 194 var old; 195 196 $(document).delegate('.filter-price-min, .filter-price-max', 'focus', function (e) { 197 old = e.target.value; 198 }); 199 200 $(document).delegate('.filter-price-min, .filter-price-max', 'blur keydown', function (e) { 201 if ((e.type === 'keydown' && e.keyCode === 13) || (e.type === 'focusout')) { 202 var value = e.target.value.trim(); 203 204 if ($.isNumeric(value) && (old !== value)) { 205 journal_filter(journal_filter_url()); 206 207 return false; 208 } 209 } 210 }); 211 212 // handle filters changes 213 $(document).delegate('[data-filter-trigger]', 'change', function () { 214 journal_filter(journal_filter_url()); 215 216 return false; 217 }); 218 219 // handle pagination changes 220 $(document).delegate('.pagination a', 'click', function () { 221 journal_filter($(this).attr('href'), { source: 'pagination' }); 222 223 return false; 224 }); 225 226 // handle sort and limit changes 227 $('#input-sort, #input-limit').removeAttr('onchange'); 228 229 $(document).delegate('#input-sort, #input-limit', 'change', function () { 230 journal_filter($(this).val()); 231 232 return false; 233 }); 234 235 // handle back button 236 $(window).on('popstate', function (e) { 237 // journal_filter(window.location.href, { updateHistory: false }); 238 window.location.reload(); 239 }); 240 241 // handle reset button 242 $(document).delegate('.reset-filter', 'click', function () { 243 journal_filter(Journal['filterBase']); 244 }); 245});
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.