1"use strict"; 2 3(function ($) { 4 5 $(document).on('click', '.archive-listing-page .stm-blog-pagination a', function(){ 6 if($('.archive-listing-page').length) { 7 $('html, body').animate({ 8 scrollTop: $(".archive-listing-page").offset().top 9 }, 500); 10 } 11 }); 12 13 STMListings.Filter.prototype.ajaxBefore = function () { 14 /*Add filter preloader*/ 15 $('.stm-ajax-row').addClass('stm-loading'); 16 17 /*Add selects preloader*/ 18 $('.classic-filter-row .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').addClass('stm-preloader'); 19 }; 20 21 STMListings.Filter.prototype.ajaxSuccess = function (res) { 22 23 /*Remove preloader*/ 24 $('.stm-ajax-row').removeClass('stm-loading'); 25 26 /*Remove select preloaders*/ 27 $('.classic-filter-row .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').removeClass('stm-preloader'); 28 $('.classic-filter-row .filter-sidebar select').prop("disabled", false); 29 30 /*Disable useless selects*/ 31 this.disableOptions(res); 32 33 /*Append new html*/ 34 this.appendData(res); 35 36 if (res.url) { 37 this.pushState(res.url); 38 } 39 40 /*Reinit js functions*/ 41 this.reInitJs(); 42 }; 43 44 STMListings.Filter.prototype.disableOptions = function (res) { 45 var form = this.form; 46 if (typeof res.options != 'undefined') { 47 $.each(res.options, function (key, options) { 48 var value = $('select[name=' + key + ']', form).val(); 49 $('select[name=' + key + '] > option', form).each(function () { 50 var slug = $(this).val(); 51 if (options.hasOwnProperty(slug) && value !== slug) { 52 $(this).prop('disabled', options[slug].disabled); 53 } 54 }); 55 }); 56 } 57 58 $('select', form).select2('destroy'); 59 $('select', form).select2(); 60 61 $('.stm-select-sorting select').select2('destroy'); 62 $('.stm-select-sorting select').html(''); 63 $('.stm-select-sorting select').select2({ 64 data: res.sorts 65 }); 66 67 if($('body').hasClass('stm-template-aircrafts')) { 68 $.each(res.filter_links, function (key, link) { 69 $.each(res.options[link['slug']], function (key, linkOption) { 70 if(key) $('label[data-taxonomy="stm-iwf-'+link['slug']+'"] span[data-slug="stm-iwf-'+key+'"]').text('('+linkOption['count']+')'); 71 }) 72 }) 73 } 74 75 $.each(res.filter_links, function (key, link) { 76 $.each(res.options[link['slug']], function (key, linkOption) { 77 if(key) 78 $('#stm-filter-link-'+link['slug']+' li[data-value="'+key+'"] span').text('('+linkOption['count']+')'); 79 }) 80 }) 81 82 }; 83 84 STMListings.Filter.prototype.appendData = function (data) { 85 this.getTarget().html(data.html); 86 87 /*Listing functions*/ 88 if ($('.stm-listing-directory-title .title').length > 0) { 89 if (typeof(data.listing_title) !== 'undefined') { 90 $('.stm-listing-directory-title .title').text(data.listing_title); 91 } 92 93 if (typeof(data.total) !== 'undefined') { 94 $('.stm-listing-directory-title .total > span').text(data.total); 95 } 96 } 97 98 if($('body').hasClass('stm-template-motorcycle')) { 99 $('.stm-car-listing-sort-units .stm-listing-directory-title .stm-listing-directory-total-matches > span').text(data.total); 100 } 101 }; 102 103 STMListings.Filter.prototype.reInitJs = function () { 104 //stButtons.locateElements(); 105 $("img.lazy").lazyload(); 106 $('.stm-tooltip-link, div[data-toggle="tooltip"]').tooltip(); 107 STMListings.initVideoIFrame(); 108 109 $('.stm-shareble').on({ 110 mouseenter: function () { 111 $(this).parent().find('.stm-a2a-popup').addClass('stm-a2a-popup-active'); 112 }, 113 mouseleave: function () { 114 $(this).parent().find('.stm-a2a-popup').removeClass('stm-a2a-popup-active'); 115 } 116 }); 117 118 $(".a2a_dd").each(function() { 119 a2a.init('page'); 120 }); 121 122 if ($('body').hasClass('logged-in')) { 123 $.getJSON(ajaxurl, {action: 'stm_ajax_get_favourites', security: getFav}, function (data) { 124 window.stm_favourites.ids = data; 125 window.stm_favourites.activateLinks(); 126 }); 127 } 128 129 window.stm_compare.activateLinks(); 130 }; 131 132 $(document).on('click', '#stm-classic-filter-submit', function (e) { 133 if ($(this).hasClass('stm-classic-filter-submit-boats')) { 134 e.preventDefault(); 135 stm_disable_rest_filters($(this), 'listings-items'); 136 } 137 }); 138 139 // Listing price 140 $(document).on('slidestop', '.stm-filter-listing-directory-price .stm-price-range', function (event, ui) { 141 $(this).closest('form').trigger('submit'); 142 }); 143 144 145 //Checkboxed area listing trigger 146 $(document).on('click', '.stm-ajax-checkbox-button .button, .stm-ajax-checkbox-instant .stm-option-label input', function (e) { 147 148 if ($(this)[0].className == 'button') { 149 e.preventDefault(); 150 } 151 152 $(this).closest('form').trigger('submit'); 153 154 }); 155 156 $(document).on('click', '.stm-view-by a', function (e) { 157 158 if(!$(this).hasClass('stm-modern-view')) { 159 if(!$('body').hasClass('author')) e.preventDefault(); 160 161 var viewType = $(this).data('view'); 162 163 $('.stm-view-by a').removeClass('active'); 164 $(this).addClass('active'); 165 166 $('#stm_view_type').val(viewType).closest('form').trigger('submit'); 167 } 168 }); 169 170 /*Remove badge*/ 171 $(document).on('click', 'ul.stm-filter-chosen-units-list li > i', function () { 172 var stmUrl = $(this).data('url'); 173 var stmFilter = $('form[data-trigger=filter]').data('Filter'); 174 stmFilter.performAjax(stmUrl); 175 176 /*Reset field*/ 177 var stmType = $(this).data('type'); 178 var stmSlug = $(this).data('slug'); 179 180 $('input[name="' + stmSlug + '[]"]:checked').each( function() { 181 $('input[name="' + stmSlug + '[]"]:checked').parent().removeClass("checked"); 182 $('input[name="' + stmSlug + '[]"]:checked').prop('checked', false); 183 } ); 184 185 if(stmType == 'select') { 186 $('select[name="' + stmSlug + '"]').val(''); 187 $('select[name="' + stmSlug + '"]').find('option').prop('disabled', false); 188 $('select[name="' + stmSlug + '"]').select2('destroy').select2().select2('val', ''); 189 } 190 }); 191 192 $(document).on('click', '.stm_boats_view_by ul li a', function (e) { 193 e.preventDefault(); 194 var stmUrl = $(this).attr('href'); 195 var stmFilter = $('form[data-trigger=filter]').data('Filter'); 196 stmFilter.performAjax(stmUrl); 197 198 $('.stm_boats_view_by ul li').removeClass('active'); 199 $(this).closest('li').addClass('active'); 200 }); 201 202 /*Location*/
203 var delay = (function () { 204 var timer = 0; 205 return function (callback, ms) { 206 clearTimeout(timer); 207 timer = setTimeout(callback, ms); 208 }; 209 })(); 210 211 $(document).on('keyup', '#ca_location_listing_filter', function () { 212 delay(function () { 213 $('#ca_location_listing_filter').closest('form').trigger('submit'); 214 }, 500); 215 }); 216 217 $(document).on('change', '#ca_location_listing_filter', function () { 218 delay(function () { 219 220 var address_search = $('#ca_location_listing_filter').val(); 221 var geocoder = new google.maps.Geocoder(); 222 223 geocoder.geocode({'address': address_search}, function (results, status) { 224 if (status === google.maps.GeocoderStatus.OK) { 225 var lat = results[0].geometry.location.lat(); 226 var lng = results[0].geometry.location.lng(); 227 228 $('#ca_location_listing_filter').closest('.stm-location-search-unit').find('input[name="stm_lat"]').val(lat); 229 $('#ca_location_listing_filter').closest('.stm-location-search-unit').find('input[name="stm_lng"]').val(lng); 230 231 $('input[name="sort_order"]').val('distance_nearby'); 232 $('#ca_location_listing_filter').closest('form').trigger('submit'); 233 } else if(status === google.maps.GeocoderStatus.REQUEST_DENIED) { 234 $('#ca_location_listing_filter').val(''); 235 $('#ca_location_listing_filter').closest('.stm-location-search-unit').find('input[name="stm_lat"]').val(0); 236 $('#ca_location_listing_filter').closest('.stm-location-search-unit').find('input[name="stm_lng"]').val(0); 237 238 $('#ca_location_listing_filter').closest('form').trigger('submit'); 239 } 240 }); 241 242 }, 500); 243 }); 244 245 /*Boats Filter res*/ 246 $(document).on('change', 'body.stm-template-boats .archive-listing-page form input, body.stm-template-boats .archive-listing-page form select', function () { 247 stm_disable_rest_filters($(this), 'listings-binding'); 248 }); 249 250 $(document).on('slidestop', '.stm-filter-sidebar-boats .stm-filter-type-slider', function (event, ui) { 251 stm_disable_rest_filters($(this), 'listings-binding'); 252 }); 253 254 $(document).on('click', '.stm_motorcycle_pp a', function(e){ 255 e.preventDefault(); 256 e.stopPropagation(); 257 }); 258 259 function stm_disable_rest_filters($_this, action) { 260 var $_form = $_this.closest('form'); 261 262 var data = [], 263 url = $_form.attr('action'), 264 sign = url.indexOf('?') < 0 ? '?' : '&'; 265 266 $.each($_form.serializeArray(), function (i, field) { 267 if (field.value != '') { 268 data.push(field.name + '=' + field.value) 269 } 270 }); 271 272 url = url + sign + data.join('&'); 273 274 $.ajax({ 275 url: url, 276 dataType: 'json', 277 context: this, 278 data: '&ajax_action=' + action, 279 beforeSend: function () { 280 if (action == 'listings-items') { 281 $('.stm-ajax-row').addClass('stm-loading'); 282 } else { 283 $('.classic-filter-row .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').addClass('stm-preloader'); 284 } 285 }, 286 success: function (res) { 287 if (action == 'listings-items') { 288 $('.stm-ajax-row').removeClass('stm-loading'); 289 $('#listings-result').html(res.html); 290 $("img.lazy").lazyload(); 291 $('.stm-tooltip-link, div[data-toggle="tooltip"]').tooltip(); 292 293 window.history.pushState('', '', decodeURI(url)); 294 } else { 295 /*Remove select preloaders*/ 296 $('.classic-filter-row .filter-sidebar .select2-container--default .select2-selection--single .select2-selection__arrow b').removeClass('stm-preloader'); 297 $('.classic-filter-row .filter-sidebar select').prop("disabled", false); 298 299 /*Disable options*/ 300 if (typeof res.options != 'undefined') { 301 $.each(res.options, function (key, options) { 302 $('select[name=' + key + '] > option', $_form).each(function () { 303 var slug = $(this).val(); 304 if (options.hasOwnProperty(slug)) { 305 $(this).prop('disabled', options[slug].disabled); 306 } 307 }); 308 }); 309 } 310 311 $('select', $_form).select2('destroy'); 312 $('select', $_form).select2(); 313 314 /*Change total*/ 315 $('.stm-filter-sidebar-boats #stm-classic-filter-submit span').text(res.total); 316 } 317 } 318 }); 319 } 320 321 // Reset fields 322 STMListings.resetFields = function() { 323 $(document).on('reset', 'select', function(e){ 324 $(this).val(''); 325 $(this).find('option').prop('disabled', false); 326 $(this).select2('destroy').select2().select2('val', ''); 327 }); 328 }; 329 330})(jQuery); 331 332function stm_get_price_view(price, currency, currencyPos, priceDel) { 333 return price; 334}
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.