| 1 |
(function( $ ) { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
/** |
| 5 |
* All of the code for your public-facing JavaScript source |
| 6 |
* should reside in this file. |
| 7 |
* |
| 8 |
* Note: It has been assumed you will write jQuery code here, so the |
| 9 |
* $ function reference has been prepared for usage within the scope |
| 10 |
* of this function. |
| 11 |
* |
| 12 |
* This enables you to define handlers, for when the DOM is ready: |
| 13 |
* |
| 14 |
* $(function() { |
| 15 |
* |
| 16 |
* }); |
| 17 |
* |
| 18 |
* When the window is loaded: |
| 19 |
* |
| 20 |
* $( window ).load(function() { |
| 21 |
* |
| 22 |
* }); |
| 23 |
* |
| 24 |
* ...and/or other possibilities. |
| 25 |
* |
| 26 |
* Ideally, it is not considered best practise to attach more than a |
| 27 |
* single DOM-ready or window-load handler for a particular page. |
| 28 |
* Although scripts in the WordPress core, Plugins and Themes may be |
| 29 |
* practising this, we should strive to set a better example in our own work. |
| 30 |
*/ |
| 31 |
|
| 32 |
$(function () { |
| 33 |
$('.wdk-click-load-animation').on('click', function () { |
| 34 |
$(this).find('.fa-ajax-indicator').css('display', 'inline-block'); |
| 35 |
|
| 36 |
if ($(this).closest('form').length) { |
| 37 |
if (!$(this).closest('form')[0].checkValidity()) { |
| 38 |
$(this).find('.fa-ajax-indicator').css('display', 'none'); |
| 39 |
} |
| 40 |
} |
| 41 |
}); |
| 42 |
|
| 43 |
$('.wdk-form-animation').on('submit', function () { |
| 44 |
var form, indicator; |
| 45 |
form = $(this); |
| 46 |
indicator = form.find('.fa-ajax-indicator'); |
| 47 |
indicator.css('display', 'inline-block'); |
| 48 |
|
| 49 |
if(form[0].checkValidity()) |
| 50 |
indicator.css('display', 'none'); |
| 51 |
}); |
| 52 |
|
| 53 |
|
| 54 |
$('.wdk-submit-loading').on('click', function () { |
| 55 |
var form; |
| 56 |
form = $(this).closest('form'); |
| 57 |
|
| 58 |
if( $(this).hasClass('wdk_btn_load_indicator')) { |
| 59 |
console.log('disabled') |
| 60 |
return false; |
| 61 |
} |
| 62 |
|
| 63 |
$(this).addClass('wdk_btn_load_indicator disabled'); |
| 64 |
}); |
| 65 |
|
| 66 |
$('.wdk-click-loading').on('click', function (e) { |
| 67 |
|
| 68 |
if( $(this).hasClass('wdk_btn_load_indicator')) { |
| 69 |
return false; |
| 70 |
} |
| 71 |
$(this).addClass('wdk_btn_load_indicator disabled'); |
| 72 |
}); |
| 73 |
|
| 74 |
const wdk_start_search = (form) => { |
| 75 |
var url,scrollTo, data = {}; |
| 76 |
url = form.attr('action').replace(/#results/, ''); |
| 77 |
if (url.indexOf('?') == -1) { |
| 78 |
url += '?'; |
| 79 |
} else { |
| 80 |
url += '&'; |
| 81 |
} |
| 82 |
var str_parameters = ""; |
| 83 |
$.each($("form.wdk-search-form:visible").serializeArray(), function (i, k) { |
| 84 |
if (k.value != '' && k.name.indexOf('skip') == -1) { |
| 85 |
if (str_parameters != "") { |
| 86 |
str_parameters += "&"; |
| 87 |
} |
| 88 |
str_parameters += k.name + "=" + encodeURIComponent(k.value); |
| 89 |
} |
| 90 |
}); |
| 91 |
|
| 92 |
$.each($(".wdk-search-popup .toggle-btn:visible"), function (i, k) { |
| 93 |
let el = $($(this).attr('data-wdk-target')); |
| 94 |
if(el && el.length) { |
| 95 |
$.each(el.find('.wdk-search-form').serializeArray(), function (i, k) { |
| 96 |
if (k.value != '' && k.name.indexOf('skip') == -1) { |
| 97 |
if (str_parameters != "") { |
| 98 |
str_parameters += "&"; |
| 99 |
} |
| 100 |
str_parameters += k.name + "=" + encodeURIComponent(k.value); |
| 101 |
} |
| 102 |
}); |
| 103 |
} |
| 104 |
}); |
| 105 |
|
| 106 |
/* view_type */ |
| 107 |
if($('.wmvc-view-type .nav-link.active').length) { |
| 108 |
str_parameters += "&wmvc_view_type="+$('.wmvc-view-type .nav-link.active').attr('data-id'); |
| 109 |
} |
| 110 |
|
| 111 |
/* order by */ |
| 112 |
if($('.wdk-order').val() != '' && $('.wdk-order').val()) { |
| 113 |
str_parameters += "&order_by="+$('.wdk-order').val(); |
| 114 |
} |
| 115 |
|
| 116 |
if ($('.wdk-search-form[data-scrollto]').length) |
| 117 |
scrollTo = '#'+$('.wdk-search-form[data-scrollto]').attr('data-scrollto'); |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
var setCookie = (cname, cvalue, exdays) => { |
| 122 |
var d = new Date(); |
| 123 |
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); |
| 124 |
var expires = "expires="+d.toUTCString(); |
| 125 |
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; |
| 126 |
} |
| 127 |
setCookie('wdk_last_search', str_parameters); |
| 128 |
|
| 129 |
return url+str_parameters+scrollTo; |
| 130 |
} |
| 131 |
|
| 132 |
/* set current page for search results if exists results widget and enabled in setttings*/ |
| 133 |
if($('form.wdk-search-form').length && $('.wdk-listings-results').length && $("form.wdk-search-form").attr('data-current-link') != '') { |
| 134 |
$('form.wdk-search-form').attr('action', $("form.wdk-search-form").attr('data-current-link')); |
| 135 |
} |
| 136 |
|
| 137 |
$("form.wdk-search-form").on('submit', function (e) { |
| 138 |
e.preventDefault(); |
| 139 |
var url = wdk_start_search($(this)); |
| 140 |
$(this).closest('form').addClass('loading') |
| 141 |
if (decodeURI(window.location.href) == decodeURI(url)) { |
| 142 |
window.location.reload(); |
| 143 |
} else { |
| 144 |
window.location.href = url; |
| 145 |
} |
| 146 |
return false; |
| 147 |
}); |
| 148 |
|
| 149 |
$("form.wdk-search-form.auto_search").find('input, select').on('input', function (e) { |
| 150 |
$("form.wdk-search-form").first().trigger('submit') |
| 151 |
}); |
| 152 |
|
| 153 |
$("form.wdk-search-form .wdk-search-start").on('click', function (e) { |
| 154 |
e.preventDefault(); |
| 155 |
var url = wdk_start_search($(this).closest('form')); |
| 156 |
$(this).closest('form').addClass('loading') |
| 157 |
|
| 158 |
if($(this).closest('.ajax_results_enabled').length) { |
| 159 |
if (typeof wdk_ajax_loading_listings == 'function') { |
| 160 |
wdk_ajax_loading_listings(url); |
| 161 |
} |
| 162 |
} else if (decodeURI(window.location.href) == decodeURI(url)) { |
| 163 |
window.location.reload(url); |
| 164 |
} else { |
| 165 |
window.location.href = url; |
| 166 |
} |
| 167 |
return false; |
| 168 |
}) |
| 169 |
|
| 170 |
$('.wdk-listings-results.ajax_results_enabled .wdk-pagination .page-numbers').on('click', function (e) { |
| 171 |
e.preventDefault(); |
| 172 |
if (typeof wdk_ajax_loading_listings == 'function') { |
| 173 |
wdk_ajax_loading_listings($(this).attr('href')); |
| 174 |
} |
| 175 |
}) |
| 176 |
|
| 177 |
/* elementor popup */ |
| 178 |
jQuery( document ).on( 'elementor/popup/show', () => { |
| 179 |
wdk_reset_form(); |
| 180 |
} ); |
| 181 |
|
| 182 |
const wdk_reset_form = () => { |
| 183 |
$("form.wdk-search-form .wdk-search-reset").off().on('click', function (e) { |
| 184 |
e.preventDefault(); |
| 185 |
let this_form = jQuery(this).closest('form'); |
| 186 |
this_form.find('input:not([type="checkbox"]):not([name="element_id"]):not([type="radio"]):not([type="hidden"]),textarea,select').val(''); |
| 187 |
this_form.find('select').val(jQuery(this).find('option:first').val()).trigger('change') |
| 188 |
this_form.find('input[type="checkbox"]').prop('checked', false); |
| 189 |
this_form.find('input[type="radio"]').prop('checked', false); |
| 190 |
this_form.find('.wdk-field.LOCATION .wdk_dropdown_tree button:first-child').html(this_form.find('.wdk-field.LOCATION .list_items li:first').text()); |
| 191 |
this_form.find('.wdk-field.CATEGORY .wdk_dropdown_tree button:first-child').html(this_form.find('.wdk-field.CATEGORY .list_items li:first').text()); |
| 192 |
|
| 193 |
return false; |
| 194 |
}) |
| 195 |
}; |
| 196 |
wdk_reset_form(); |
| 197 |
|
| 198 |
/* date time fields init */ |
| 199 |
if ($('.wdk-fielddate').length && typeof $.datepicker != 'undefined') { |
| 200 |
|
| 201 |
$('.wdk-fielddate').each(function () { |
| 202 |
let dateFormat = script_parameters.format_date_js; |
| 203 |
var self = $(this); |
| 204 |
|
| 205 |
if (self.attr('date-format')) |
| 206 |
dateFormat = self.attr('date-format'); |
| 207 |
|
| 208 |
self.datepicker({ dateFormat: dateFormat, onSelect: function() { |
| 209 |
self.parent().find('.db-date').val(wdk_date_sql_normalize(self.val(), self)).trigger('input'); |
| 210 |
} |
| 211 |
}).on( "change", function() { |
| 212 |
self.parent().find('.db-date').val(wdk_date_sql_normalize(self.val(), self)); |
| 213 |
}); |
| 214 |
|
| 215 |
if(self.parent().find('.db-date').val() == '') { |
| 216 |
self.parent().find('.db-date').val(wdk_date_notime_sql_normalize()); |
| 217 |
} |
| 218 |
}) |
| 219 |
} ; |
| 220 |
|
| 221 |
|
| 222 |
if ($('.wdk-fielddatetime').length && typeof $.datepicker != 'undefined') { |
| 223 |
|
| 224 |
$('.wdk-fielddatetime').each(function () { |
| 225 |
let dateFormat = script_parameters.format_datetime_js; |
| 226 |
|
| 227 |
var self = $(this); |
| 228 |
if (self.attr('date-format')) |
| 229 |
dateFormat = self.attr('date-format'); |
| 230 |
|
| 231 |
self.datepicker({ dateFormat: dateFormat, onSelect: function() { |
| 232 |
var datetime = wdk_date_notime_sql_normalize(self.val(), self); |
| 233 |
if(self.parent().find('[name="hours_mask"]').val() !='') { |
| 234 |
datetime += ' '+wdk_pad(self.parent().find('[name="hours_mask"]').val()); |
| 235 |
} else { |
| 236 |
datetime += ' 00'; |
| 237 |
} |
| 238 |
if(self.parent().find('[name="minutes_mask"]').val() !='') { |
| 239 |
datetime += ':'+wdk_pad(self.parent().find('[name="minutes_mask"]').val()); |
| 240 |
} else { |
| 241 |
datetime += ':00'; |
| 242 |
} |
| 243 |
datetime += ':00'; |
| 244 |
|
| 245 |
self.parent().find('.db-date').val(datetime).trigger('input'); |
| 246 |
} |
| 247 |
}).on( "change", function() { |
| 248 |
|
| 249 |
var datetime = wdk_date_notime_sql_normalize(self.val(), self); |
| 250 |
if(self.parent().find('[name="hours_mask"]').val() !='') { |
| 251 |
datetime += ' '+wdk_pad(self.parent().find('[name="hours_mask"]').val()); |
| 252 |
} else { |
| 253 |
datetime += ' 00'; |
| 254 |
} |
| 255 |
if(self.parent().find('[name="minutes_mask"]').val() !='') { |
| 256 |
datetime += ':'+wdk_pad(self.parent().find('[name="minutes_mask"]').val()); |
| 257 |
} else { |
| 258 |
datetime += ':00'; |
| 259 |
} |
| 260 |
datetime += ':00'; |
| 261 |
self.parent().find('.db-date').val(datetime); |
| 262 |
}); |
| 263 |
|
| 264 |
if(self.parent().find('.db-date').val() == '') { |
| 265 |
self.parent().find('.db-date').val(wdk_date_sql_normalize()); |
| 266 |
} |
| 267 |
|
| 268 |
self.parent().find('[name="hours_mask"],[name="minutes_mask"]').on('input', function(){ |
| 269 |
var datetime = wdk_date_notime_sql_normalize(self.val(), self); |
| 270 |
if(self.parent().find('[name="hours_mask"]').val() !='') { |
| 271 |
datetime += ' '+wdk_pad(self.parent().find('[name="hours_mask"]').val()); |
| 272 |
} else { |
| 273 |
datetime += ' 00'; |
| 274 |
} |
| 275 |
if(self.parent().find('[name="minutes_mask"]').val() !='') { |
| 276 |
datetime += ':'+wdk_pad(self.parent().find('[name="minutes_mask"]').val()); |
| 277 |
} else { |
| 278 |
datetime += ':00'; |
| 279 |
} |
| 280 |
datetime += ':00'; |
| 281 |
self.parent().find('.db-date').val(datetime); |
| 282 |
}); |
| 283 |
}) |
| 284 |
}; |
| 285 |
|
| 286 |
if ($('.wdk-fielddate_from').length && $('.wdk-fielddate_to').length && typeof $.datepicker != 'undefined') { |
| 287 |
var dateFormat, from, to; |
| 288 |
const getDate = ( element ) => { |
| 289 |
var date; |
| 290 |
try { |
| 291 |
date = $.datepicker.parseDate( dateFormat, element.value ); |
| 292 |
} catch( error ) { |
| 293 |
date = null; |
| 294 |
} |
| 295 |
return date; |
| 296 |
} |
| 297 |
|
| 298 |
dateFormat = script_parameters.format_date_js; |
| 299 |
if ($('.wdk-fielddate_from').attr('date-format')) |
| 300 |
dateFormat = $('.wdk-fielddate_from').attr('date-format'); |
| 301 |
|
| 302 |
from = $('.wdk-fielddate_from') |
| 303 |
.datepicker({ |
| 304 |
dateFormat: dateFormat, |
| 305 |
onSelect: function( selectedDate ) { |
| 306 |
to.datepicker("option", "minDate", selectedDate ); |
| 307 |
setTimeout(function(){ |
| 308 |
to.datepicker('show'); |
| 309 |
}, 16); |
| 310 |
|
| 311 |
from.parent().find('.db-date').val(wdk_date_sql_normalize(from.val(), from)); |
| 312 |
wdk_date_add_hours(from); |
| 313 |
} |
| 314 |
}).on( "change", function() { |
| 315 |
from.parent().find('.db-date').val(wdk_date_sql_normalize(from.val(), from)).trigger('input'); |
| 316 |
}); |
| 317 |
|
| 318 |
to = $('.wdk-fielddate_to').datepicker({ |
| 319 |
dateFormat: dateFormat |
| 320 |
}) |
| 321 |
.on( "change", function() { |
| 322 |
from.datepicker( "option", "maxDate", getDate( this ) ); |
| 323 |
to.parent().find('.db-date').val(wdk_date_sql_normalize(to.val(), to)).trigger('input'); |
| 324 |
wdk_date_add_hours(to); |
| 325 |
}); |
| 326 |
|
| 327 |
if(to.parent().find('.db-date').val() == '') { |
| 328 |
to.parent().find('.db-date').val(wdk_date_sql_normalize()); |
| 329 |
} |
| 330 |
|
| 331 |
if(from.parent().find('.db-date').val() == '') { |
| 332 |
from.parent().find('.db-date').val(wdk_date_sql_normalize()); |
| 333 |
} |
| 334 |
|
| 335 |
from.parent().find('[name="hours_mask"],[name="minutes_mask"]').on('input', function(){ |
| 336 |
wdk_date_add_hours(from); |
| 337 |
}); |
| 338 |
|
| 339 |
to.parent().find('[name="hours_mask"],[name="minutes_mask"]').on('input', function(){ |
| 340 |
wdk_date_add_hours(to); |
| 341 |
}); |
| 342 |
} |
| 343 |
if(typeof $.fn.wdkSuggestion == 'function') { |
| 344 |
|
| 345 |
if(typeof script_parameters.settings_wdk_field_search_suggestion_disable != 'undefined' && script_parameters.settings_wdk_field_search_suggestion_disable == 1) { |
| 346 |
|
| 347 |
} else { |
| 348 |
$('#wdk_field_search').wdkSuggestion({ |
| 349 |
ajax_url: script_parameters.ajax_url, |
| 350 |
ajax_param: { |
| 351 |
"action": 'wdk_public_action', |
| 352 |
"page": 'wdk_frontendajax', |
| 353 |
"function": 'search_suggestion', |
| 354 |
}, |
| 355 |
language_id: '', |
| 356 |
text_search: 'Search', |
| 357 |
callback_selected: function(key) { |
| 358 |
|
| 359 |
} |
| 360 |
}); |
| 361 |
} |
| 362 |
|
| 363 |
} |
| 364 |
|
| 365 |
$('.wdk-control[type="number"]').on('change',function(){ |
| 366 |
let val = $(this).val(); |
| 367 |
let step = 1; |
| 368 |
if(val.length>=7){ |
| 369 |
step = 10000; |
| 370 |
} else if(val.length>=4) { |
| 371 |
step = 10; |
| 372 |
} |
| 373 |
$(this).attr('step', step); |
| 374 |
}) |
| 375 |
|
| 376 |
|
| 377 |
if(typeof $.fn.fieldSliderRange == 'function' && typeof $.fn.ionRangeSlider == 'function') { |
| 378 |
$('.wdk-slider-range-field').fieldSliderRange(); |
| 379 |
} |
| 380 |
|
| 381 |
wdk_result_listings_thumbnail_slider(); |
| 382 |
|
| 383 |
/* if video exists on thumbnail css trick */ |
| 384 |
$('.wdk-listing-card .wdk-thumbnail .wdk-image.media').find('iframe,video').css('padding-bottom', +($('.wdk-listing-card .wdk-thumbnail .wdk-over-image-bottom').outerHeight())+'px'); |
| 385 |
|
| 386 |
|
| 387 |
if(typeof $.fn.WdkScrollMobileSwipe == 'function') { |
| 388 |
$('.WdkScrollMobileSwipe_enable').WdkScrollMobileSwipe(); |
| 389 |
$('.WdkScrollMobileSwipe_elementor_enable .elementor-container').WdkScrollMobileSwipe(); |
| 390 |
} |
| 391 |
|
| 392 |
if($('.wl-menu-toggle').length) { |
| 393 |
$('.wdk-footer-menu .wdk_mobile_footer_menu_gumb-open').addClass('trigger') |
| 394 |
$('.wdk-footer-menu .wdk_mobile_footer_menu_gumb-open').on('click', function(e){ |
| 395 |
e.preventDefault(); |
| 396 |
$('.wl-menu-toggle').trigger('click'); |
| 397 |
}); |
| 398 |
} |
| 399 |
}); |
| 400 |
|
| 401 |
})(jQuery); |
| 402 |
|
| 403 |
/* slider for result listings thumbnails */ |
| 404 |
if (typeof wdk_result_listings_thumbnail_slider != 'function') { |
| 405 |
var wdk_result_listings_thumbnail_slider = ($wrapper = 'body') => { |
| 406 |
if(typeof jQuery.fn.slick == 'function') { |
| 407 |
jQuery('.wdk_js_gallery_slider_box', $wrapper).each(function(){ |
| 408 |
var _this = jQuery(this); |
| 409 |
|
| 410 |
if(_this.closest('.slick-slide').hasClass('slick-cloned')){return true;} |
| 411 |
|
| 412 |
if(_this.find('.wdk_js_gallery_slider').hasClass('slick-initialized')) { |
| 413 |
_this.find('.wdk_js_gallery_slider').slick("unslick"); |
| 414 |
} |
| 415 |
|
| 416 |
_this.find('.wdk_js_gallery_slider').slick({ |
| 417 |
dots: true, |
| 418 |
infinite: true, |
| 419 |
speed: 500, |
| 420 |
fade: true, |
| 421 |
arrows: true, |
| 422 |
cssEase: 'linear', |
| 423 |
nextArrow: _this.find('.wdk_js_gallery_slider-carousel_arrows .wdk-slider-next'), |
| 424 |
prevArrow: _this.find('.wdk_js_gallery_slider-carousel_arrows .wdk-slider-prev'), |
| 425 |
}); |
| 426 |
}); |
| 427 |
} |
| 428 |
}; |
| 429 |
} |
| 430 |
/* |
| 431 |
Fix for slick slider, event after init slick |
| 432 |
|
| 433 |
@param object el slick object |
| 434 |
@param function callback |
| 435 |
*/ |
| 436 |
|
| 437 |
if (typeof wdk_slick_slider_init != 'function') { |
| 438 |
var wdk_slick_slider_init = (el, callback) => { |
| 439 |
try { |
| 440 |
el.slick("slickGoTo", 0, true); |
| 441 |
} |
| 442 |
catch(error) { |
| 443 |
setTimeout(wdk_slick_slider_init, 1000); |
| 444 |
return; |
| 445 |
} |
| 446 |
|
| 447 |
if(callback) { |
| 448 |
callback.call(); |
| 449 |
} |
| 450 |
}; |
| 451 |
} |
| 452 |
if (typeof wdk_pad != 'function') { |
| 453 |
var wdk_pad = (num = '') => { |
| 454 |
return ('00'+num).slice(-2); |
| 455 |
}; |
| 456 |
} |
| 457 |
|
| 458 |
if (typeof wdk_date_add_hours != 'function') { |
| 459 |
var wdk_date_add_hours = (selector = '') => { |
| 460 |
if(typeof selector !='undefined' && selector.parent().find('[name="hours_mask"]').length) { |
| 461 |
var datetime = wdk_date_notime_sql_normalize(selector.val(), selector); |
| 462 |
if(selector.parent().find('[name="hours_mask"]').val() !='') { |
| 463 |
datetime += ' '+wdk_pad(selector.parent().find('[name="hours_mask"]').val()); |
| 464 |
} else { |
| 465 |
datetime += ' 00'; |
| 466 |
} |
| 467 |
if(selector.parent().find('[name="minutes_mask"]').val() !='') { |
| 468 |
datetime += ':'+wdk_pad(selector.parent().find('[name="minutes_mask"]').val()); |
| 469 |
} else { |
| 470 |
datetime += ':00'; |
| 471 |
} |
| 472 |
datetime += ':00'; |
| 473 |
selector.parent().find('.db-date').val(datetime); |
| 474 |
} |
| 475 |
}; |
| 476 |
} |
| 477 |
/* |
| 478 |
Convert date to sql format |
| 479 |
|
| 480 |
@param string $date, string of date |
| 481 |
|
| 482 |
@return string normalize date or Current date/time |
| 483 |
*/ |
| 484 |
if (typeof wdk_date_sql_normalize != 'function') { |
| 485 |
var wdk_date_sql_normalize = (date = '', datepicker_el = null) => { |
| 486 |
if(date == '') { |
| 487 |
var d = new Date(); |
| 488 |
} else { |
| 489 |
var d = new Date(date); |
| 490 |
} |
| 491 |
|
| 492 |
if(d == 'Invalid Date' && datepicker_el) { |
| 493 |
var d = new Date(+(jQuery.datepicker.formatDate("@", datepicker_el.datepicker("getDate")))); |
| 494 |
} |
| 495 |
|
| 496 |
d = d.getUTCFullYear() + '-' + |
| 497 |
wdk_pad(d.getMonth() + 1) + '-' + |
| 498 |
wdk_pad(d.getDate()) + ' ' + |
| 499 |
wdk_pad(d.getHours()) + ':' + |
| 500 |
wdk_pad(d.getMinutes()) + ':' + |
| 501 |
wdk_pad(d.getSeconds()); |
| 502 |
return d; |
| 503 |
}; |
| 504 |
} |
| 505 |
|
| 506 |
if (typeof wdk_date_notime_sql_normalize != 'function') { |
| 507 |
var wdk_date_notime_sql_normalize = (date = '', datepicker_el = null) => { |
| 508 |
if(date == '') { |
| 509 |
var d = new Date(); |
| 510 |
} else { |
| 511 |
var d = new Date(date); |
| 512 |
} |
| 513 |
|
| 514 |
if(d == 'Invalid Date' && datepicker_el) { |
| 515 |
var d = new Date(+(jQuery.datepicker.formatDate("@", datepicker_el.datepicker("getDate")))); |
| 516 |
} |
| 517 |
|
| 518 |
d = d.getUTCFullYear() + '-' + |
| 519 |
wdk_pad(d.getMonth() + 1) + '-' + |
| 520 |
wdk_pad(d.getDate()); |
| 521 |
return d; |
| 522 |
}; |
| 523 |
} |
| 524 |
|
| 525 |
if (typeof wdk_generate_marker_ajax_popup != 'function') { |
| 526 |
var wdk_generate_marker_ajax_popup = (ajax_url, listing_post_id, lat, lng,innerMarker, wdk_jpopup_customOptions, auto = false, clusters_enabled = true) => { |
| 527 |
|
| 528 |
if(auto) { |
| 529 |
var marker = L.marker( |
| 530 |
[lat, lng], |
| 531 |
{icon: L.divIcon({ |
| 532 |
html: innerMarker, |
| 533 |
className: 'open_steet_map_marker', |
| 534 |
iconSize: 'auto', |
| 535 |
}) |
| 536 |
} |
| 537 |
); |
| 538 |
} else { |
| 539 |
var marker = L.marker( |
| 540 |
[lat, lng], |
| 541 |
{icon: L.divIcon({ |
| 542 |
html: innerMarker, |
| 543 |
className: 'open_steet_map_marker', |
| 544 |
iconSize: [40, 60], |
| 545 |
popupAnchor: [-1, -35], |
| 546 |
iconAnchor: [25, 60], |
| 547 |
}) |
| 548 |
} |
| 549 |
); |
| 550 |
} |
| 551 |
|
| 552 |
var data = { |
| 553 |
"action": 'wdk_public_action', |
| 554 |
"page": 'wdk_frontendajax', |
| 555 |
"function": 'map_infowindow', |
| 556 |
"listing_post_id": listing_post_id |
| 557 |
}; |
| 558 |
|
| 559 |
let favorite_init = false; |
| 560 |
let compare_init = false; |
| 561 |
marker.bindPopup(function () { |
| 562 |
var content = '<div class="infobox"><div class="map_infowindow"><div class="loading_content animated-background"><div class="box_line m170"></div><div class="box_line m20"></div><div class="box_line m20"></div><div class="box_line m20"></div><div class="box_line m20"></div><div class="box_line m20"></div></div></div></div>'; |
| 563 |
marker.getPopup().setContent(content); |
| 564 |
marker.getPopup().update(); |
| 565 |
jQuery.ajax({ |
| 566 |
url : ajax_url, |
| 567 |
type : "POST", |
| 568 |
data: data, |
| 569 |
success: function (data) { |
| 570 |
marker.getPopup().setContent(data.popup_content); |
| 571 |
marker.getPopup().update(); |
| 572 |
if (!favorite_init && typeof wdk_favorite == 'function') |
| 573 |
wdk_favorite('.infobox'); |
| 574 |
|
| 575 |
favorite_init = false; |
| 576 |
|
| 577 |
if (!compare_init && typeof wdk_init_compare_elem == 'function') |
| 578 |
wdk_init_compare_elem(); |
| 579 |
|
| 580 |
compare_init = false; |
| 581 |
}, |
| 582 |
}); |
| 583 |
return content; |
| 584 |
}, wdk_jpopup_customOptions); |
| 585 |
|
| 586 |
if (typeof wdk_favorite == 'function') |
| 587 |
marker.on('popupopen', function (popup) { |
| 588 |
if (!favorite_init) |
| 589 |
wdk_favorite('.infobox'); |
| 590 |
}); |
| 591 |
|
| 592 |
if (typeof wdk_init_compare_elem == 'function') |
| 593 |
marker.on('popupopen', function (popup) { |
| 594 |
if (!compare_init) |
| 595 |
wdk_init_compare_elem(); |
| 596 |
}); |
| 597 |
|
| 598 |
if (typeof wdk_favorite == 'function') |
| 599 |
marker.on('popupclose', function (popup) { |
| 600 |
marker.getPopup().setContent(jQuery('.leaflet-popup-content-wrapper .leaflet-popup-content').html()); |
| 601 |
marker.getPopup().update(); |
| 602 |
}); |
| 603 |
|
| 604 |
if(clusters_enabled) { |
| 605 |
wdk_clusters.addLayer(marker); |
| 606 |
} else { |
| 607 |
wdk_map.addLayer(marker); |
| 608 |
} |
| 609 |
return marker; |
| 610 |
} |
| 611 |
} |
| 612 |
|
| 613 |
if (typeof wdk_generate_marker_basic_popup != 'function') { |
| 614 |
var wdk_generate_marker_basic_popup = (lat, lng, innerMarker, wdk_jpopup_content, wdk_jpopup_customOptions) => { |
| 615 |
var marker = L.marker( |
| 616 |
[lat, lng], |
| 617 |
{icon: L.divIcon({ |
| 618 |
html: innerMarker, |
| 619 |
className: 'open_steet_map_marker', |
| 620 |
iconSize: [40, 60], |
| 621 |
popupAnchor: [-1, -35], |
| 622 |
iconAnchor: [25, 60], |
| 623 |
}) |
| 624 |
} |
| 625 |
); |
| 626 |
|
| 627 |
marker.bindPopup(wdk_jpopup_content, wdk_jpopup_customOptions); |
| 628 |
|
| 629 |
return marker; |
| 630 |
} |
| 631 |
} |
| 632 |
|
| 633 |
if (typeof wdk_generate_marker_nopopup != 'function') { |
| 634 |
var wdk_generate_marker_nopopup = (lat, lng,innerMarker) => { |
| 635 |
var marker = L.marker( |
| 636 |
[lat, lng], |
| 637 |
{icon: L.divIcon({ |
| 638 |
html: innerMarker, |
| 639 |
className: 'open_steet_map_marker', |
| 640 |
iconSize: [40, 60], |
| 641 |
popupAnchor: [-1, -35], |
| 642 |
iconAnchor: [25, 60], |
| 643 |
}) |
| 644 |
} |
| 645 |
); |
| 646 |
|
| 647 |
return marker; |
| 648 |
} |
| 649 |
} |
| 650 |
|