1var nes_filters = { 2 working: false, 3 4 args: { 5 action: '', 6 paged: 1, 7 init: false, 8 scrolled: 0 9 }, 10 11 init: function () { 12 var self = this; 13 14 jQuery('.filter-dropdown').click( function ( ev,el ) { 15 jQuery(this).closest('.filterbar-wrap').toggleClass('show-filter'); 16 }); 17 18 jQuery('#filter-bar-search input').on('keyup', function (e) { 19 if (e.keyCode == 13) { 20 jQuery(this).next().click(); 21 } 22 }); 23 24 if( filters_ajax_vars !== null ) { 25 26 var post_type = ''; 27 jQuery.each(filters_ajax_vars, function(key, value) { 28 self.args.action = value; 29 post_type = key; 30 }); 31 32 var height = jQuery('#filter-results').height() - jQuery('header').height(); 33 34 35 if (jQuery('.form-filter').length) { 36 37 jQuery('.filterbar-checkbox').on('click', function (ev) { 38 self.select_choose(ev, jQuery(this)); 39 }); 40 41 jQuery('.filterbar-checkbox ins').on('click', function (ev) { 42 self.select_choose(ev, jQuery(this)); 43 }); 44 45 jQuery('.filterbar-checkbox label').on('click', function (ev) { 46 self.select_choose(ev, jQuery(this)); 47 }); 48 49 jQuery('#filter-bar-search label').on('click', function (ev) { 50 self.choose_search(ev, jQuery(this)); 51 }); 52 } 53 54 55 jQuery('#filter-results').on('click', '#more-posts', function (ev) { 56 self.more_posts(ev, jQuery(this)); 57 }); 58 59 60 if (jQuery('.post-type-archive-'+ post_type ).length) { 61 self.get_hash(); 62 63 jQuery(window).scroll(function () { 64 self.set_hash(); 65 if(jQuery(window).scrollTop() == jQuery(document).height() - jQuery(window).height()) { 66 jQuery('#more-posts').click(); 67 } 68 }); 69 } 70 } 71 }, 72 73 choose_search: function (ev, el) 74 { 75 var self = this; 76 77 ev.preventDefault(); 78 79 self.args.filter_input = jQuery('#filter-bar-search input').val(); 80 81 self.form_change(); 82 }, 83 more_posts: function (ev, el) 84 { 85 var self = this; 86 87 ev.preventDefault(); 88 89 self.args.paged++; 90 91 el.remove(); 92 93 self.form_change(true); 94 95 }, 96 select_choose: function (ev, el) 97 { 98 var self = this; 99 ev.preventDefault(); 100 101 var val = el.parent().find('input').val(); 102 var type = el.parent().find('input').data('name'); 103 104 if (!jQuery.isArray(self.args[type]) ) { 105 self.args[type] = []; 106 } 107 108 var add = true; 109 110 for (key in self.args[type]) { 111 if (self.args[type][key]) { 112 if (self.args[type][key] == val) { 113 add = false; 114 break; 115 } 116 } 117 } 118 119 if (add) { 120 self.args[type].push(val); 121 self.form_change(); 122 } 123 else{ 124 self.remove_checkbox(ev,el); 125 } 126 }, 127 remove_checkbox: function (ev, el) 128 { 129 var self = this; 130 131 ev.preventDefault(); 132 133 var val = el.parent().find('input').val(); 134 var type = el.parent().find('input').data('name'); 135 136 if (jQuery.isArray(self.args[type])) { 137 for (key in self.args[type]) { 138 if (self.args[type][key] == val) { 139 self.args[type].splice(key, 1); 140 } 141 } 142 } 143 else { 144 self.args[type] = ''; 145 } 146 147 self.form_change(); 148 }, 149 form_change: function (reset) 150 { 151 var self = this; 152 153 self.setFiltersFromHash(); 154 155 if (typeof reset == 'undefined') { 156 self.args.paged = 1; 157 jQuery('#filter-results').empty(); 158 } 159 160 self.set_hash(); 161 jQuery( '#filter-results' ).append( '<div id="spin-load" class="flex-container justify-content-center width-fill"><i class="fas fa-sync fa-spin text-primary" style="font-size:50px; margin:50px 0px;"></i></div>' ); 162 163 self.ajax(self.args, self.form_result); 164 165 }, 166 setFiltersFromHash: function() 167 { 168 var self = this; 169 170 for(type in self.args) 171 { 172 if (jQuery.isArray(self.args[type])) { 173 174 var aFilter = jQuery('.icheckbox_custom input[data-type='+type+']'); 175 176 177 for(i=0; i<aFilter.length; i++){ 178 179 if( jQuery.inArray(jQuery(aFilter[i]).val(), self.args[type]) !== -1 ){ 180 jQuery(aFilter[i]).closest('.icheckbox_custom').addClass('checked'); 181 } 182 else{ 183 jQuery(aFilter[i]).closest('.icheckbox_custom').removeClass('checked'); 184 } 185 } 186 } 187 else if( type != 'action' && type != 'paged' && type != 'init' && type != 'scrolled' ){ 188 var aFilter = jQuery('.icheckbox_custom input[data-type='+type+']'); 189 190 for(i=0; i<aFilter.length; i++){ 191 192 if( jQuery(aFilter[i]).val() == self.args[type] ){ 193 jQuery(aFilter[i]).closest('.icheckbox_custom').addClass('checked'); 194 } 195 else{ 196 jQuery(aFilter[i]).closest('.icheckbox_custom').removeClass('checked'); 197 } 198 } 199 } 200 } 201 }, 202 form_result: function (data) 203 { 204 var self = nes_filters; 205 206 jQuery('#filter-results').append(data); 207 208 jQuery( '#spin-load' ).remove(); 209 210 platform_product.init(); 211 212 self.args.init = false;
213 }, 214 215 get_hash: function () 216 { 217 var self = this; 218 219 var hash = window.location.hash.replace('#', ''); 220 221 if (hash) { 222 hash = hash.split('&'); 223 224 for (key in hash) { 225 var hash_arg = hash[key].split('='); 226 227 if (hash_arg[1].indexOf(',') != -1) { 228 hash_arg[1] = hash_arg[1].split(','); 229 } 230 231 self.args[hash_arg[0]] = hash_arg[1]; 232 } 233 234 self.args.init = true; 235 236 jQuery('#filter-results').empty(); 237 238 self.form_change(false); 239 } 240 }, 241 242 set_hash: function () 243 { 244 var self = this; 245 246 if (!self.args.init) { 247 var hash = ''; 248 249 self.args.scrolled = jQuery(window).scrollTop(); 250 251 for (key in self.args) { 252 hash += key + '=' + self.args[key] + '&'; 253 } 254 255 hash = hash.substring(0, hash.length - 1); 256 257 window.location.hash = hash; 258 } 259 }, 260 261 ajax: function (args, succes) { 262 var self = this; 263 264 if (self.working) { 265 self.working.abort(); 266 } 267 268 self.working = jQuery.ajax({ 269 url: ajax_object['ajax_url'], 270 dataType: 'html', 271 type: 'GET', 272 data: args, 273 // async:false, 274 success: function (data) { 275 succes(data); 276 } 277 }); 278 } 279 280} 281 282jQuery(function ($) { 283 nes_filters.init(); 284}); 285
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.