File: /storage/v6964/testingff/public_html/fdfctr/wp-content/plugins/directorist/assets/js/search-form.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
/******/ ({
/***/ "./assets/src/js/global/components/select2-custom-control.js":
/*!*******************************************************************!*\
!*** ./assets/src/js/global/components/select2-custom-control.js ***!
\*******************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var $ = jQuery;
window.addEventListener('load', waitAndInit);
window.addEventListener('directorist-search-form-nav-tab-reloaded', waitAndInit);
window.addEventListener('directorist-type-change', waitAndInit);
window.addEventListener('directorist-instant-search-reloaded', waitAndInit);
function waitAndInit() {
setTimeout(init, 0);
} // Initialize
function init() {
// Add custom dropdown toggle button
selec2_add_custom_dropdown_toggle_button(); // Add custom close button where needed
selec2_add_custom_close_button_if_needed(); // Add custom close button if field contains value on change
$('.select2-hidden-accessible').on('change', function (e) {
var value = $(this).children("option:selected").val();
if (!value) {
return;
}
selec2_add_custom_close_button($(this));
});
}
function selec2_add_custom_dropdown_toggle_button() {
// Remove Default
$('.select2-selection__arrow').css({
'display': 'none'
});
var addon_container = selec2_get_addon_container('.select2-hidden-accessible');
if (!addon_container) {
return;
}
var dropdown = addon_container.find('.directorist-select2-dropdown-toggle');
if (!dropdown.length) {
// Add Dropdown Toggle Button
var iconURL = directorist.assets_url + 'icons/font-awesome/svgs/solid/chevron-down.svg';
var iconHTML = directorist.icon_markup.replace('##URL##', iconURL).replace('##CLASS##', '');
var dropdownHTML = "<span class=\"directorist-select2-addon directorist-select2-dropdown-toggle\">".concat(iconHTML, "</span>");
addon_container.append(dropdownHTML);
}
var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); // Toggle --is-open class
$('.select2-hidden-accessible').on('select2:open', function (e) {
var dropdown_btn = $(this).next().find('.directorist-select2-dropdown-toggle');
dropdown_btn.addClass('--is-open');
});
$('.select2-hidden-accessible').on('select2:close', function (e) {
var dropdown_btn = $(this).next().find('.directorist-select2-dropdown-toggle');
dropdown_btn.removeClass('--is-open');
}); // Toggle Dropdown
selec2_custom_dropdown.on('click', function (e) {
var isOpen = $(this).hasClass('--is-open');
var field = $(this).closest(".select2-container").siblings('select:enabled');
if (isOpen) {
field.select2('close');
} else {
field.select2('open');
}
}); // Adjust space for addons
selec2_adjust_space_for_addons();
}
function selec2_add_custom_close_button_if_needed() {
var select2_fields = $('.select2-hidden-accessible');
if (!select2_fields && !select2_fields.length) {
return;
}
var _iterator = _createForOfIteratorHelper(select2_fields),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var field = _step.value;
var value = $(field).children('option:selected').val();
if (!value) {
continue;
}
selec2_add_custom_close_button(field);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
function selec2_add_custom_close_button(field) {
// Remove Default
$('.select2-selection__clear').css({
'display': 'none'
});
var addon_container = selec2_get_addon_container(field);
if (!(addon_container && addon_container.length)) {
return;
} // Remove if already exists
addon_container.find('.directorist-select2-dropdown-close').remove(); // Add
var iconURL = directorist.assets_url + 'icons/font-awesome/svgs/solid/times.svg';
var iconHTML = directorist.icon_markup.replace('##URL##', iconURL).replace('##CLASS##', '');
addon_container.prepend("<span class=\"directorist-select2-addon directorist-select2-dropdown-close\">".concat(iconHTML, "</span>"));
var selec2_custom_close = addon_container.find('.directorist-select2-dropdown-close');
selec2_custom_close.on('click', function (e) {
var field = $(this).closest('.select2-container').siblings('select:enabled');
field.val(null).trigger('change');
addon_container.find('.directorist-select2-dropdown-close').remove();
selec2_adjust_space_for_addons();
}); // Adjust space for addons
selec2_adjust_space_for_addons();
}
function selec2_remove_custom_close_button(field) {
var addon_container = selec2_get_addon_container(field);
if (!(addon_container && addon_container.length)) {
return;
} // Remove
addon_container.find('.directorist-select2-dropdown-close').remove(); // Adjust space for addons
selec2_adjust_space_for_addons();
}
function selec2_get_addon_container(field) {
var container = field ? $(field).next('.select2-container') : $('.select2-container');
container = $(container).find('.directorist-select2-addons-area');
if (!container.length) {
$('.select2-container').append('<span class="directorist-select2-addons-area"></span>');
container = $('.select2-container').find('.directorist-select2-addons-area');
}
var container = field ? $(field).next('.select2-container') : null;
if (!container) {
return null;
}
var addonsArea = $(container).find('.directorist-select2-addons-area');
if (!addonsArea.length) {
container.append('<span class="directorist-select2-addons-area"></span>');
return container.find('.directorist-select2-addons-area');
}
return addonsArea;
}
function selec2_adjust_space_for_addons() {
var container = $('.select2-container').find('.directorist-select2-addons-area');
if (!container.length) {
return;
}
var width = container.outerWidth();
$('.select2-container').find('.select2-selection__rendered').css({
'padding-right': width + 'px'
});
}
/***/ }),
/***/ "./assets/src/js/global/components/setup-select2.js":
/*!**********************************************************!*\
!*** ./assets/src/js/global/components/setup-select2.js ***!
\**********************************************************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ "./node_modules/@babel/runtime/helpers/toConsumableArray.js");
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js");
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _lib_helper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../../lib/helper */ "./assets/src/js/lib/helper.js");
/* harmony import */ var _select2_custom_control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./select2-custom-control */ "./assets/src/js/global/components/select2-custom-control.js");
/* harmony import */ var _select2_custom_control__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_select2_custom_control__WEBPACK_IMPORTED_MODULE_3__);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var $ = jQuery;
window.addEventListener('load', initSelect2);
document.body.addEventListener('directorist-search-form-nav-tab-reloaded', initSelect2);
document.body.addEventListener('directorist-reload-select2-fields', initSelect2); // Init Static Select 2 Fields
function initSelect2() {
var select_fields = [{
elm: $('.directorist-select').find('select')
}, {
elm: $('#directorist-select-js')
}, {
elm: $('#directorist-search-category-js')
}, {
elm: $('#directorist-select-st-s-js')
}, {
elm: $('#directorist-select-sn-s-js')
}, {
elm: $('#directorist-select-mn-e-js')
}, {
elm: $('#directorist-select-tu-e-js')
}, {
elm: $('#directorist-select-wd-s-js')
}, {
elm: $('#directorist-select-wd-e-js')
}, {
elm: $('#directorist-select-th-e-js')
}, {
elm: $('#directorist-select-fr-s-js')
}, {
elm: $('#directorist-select-fr-e-js')
}, // { elm: $('#directorist-location-select') },
// { elm: $('#directorist-category-select') },
{
elm: $('.select-basic')
}, {
elm: $('#loc-type')
}, {
elm: $('.bdas-location-search')
}, // { elm: $('.directorist-location-select') },
{
elm: $('#at_biz_dir-category')
}, {
elm: $('#cat-type')
}, {
elm: $('.bdas-category-search')
} // { elm: $('.directorist-category-select') },
];
select_fields.forEach(function (field) {
Object(_lib_helper__WEBPACK_IMPORTED_MODULE_2__["convertToSelect2"])(field);
});
var lazy_load_taxonomy_fields = directorist.lazy_load_taxonomy_fields;
if (lazy_load_taxonomy_fields) {
// Init Select2 Ajax Fields
initSelect2AjaxFields();
}
} // Init Select2 Ajax Fields
function initSelect2AjaxFields() {
var rest_base_url = "".concat(directorist.rest_url, "directorist/v1"); // Init Select2 Ajax Category Field
initSelect2AjaxTaxonomy({
selector: $('.directorist-search-category').find('select'),
url: "".concat(rest_base_url, "/listings/categories")
}); // Init Select2 Ajax Category Field
initSelect2AjaxTaxonomy({
selector: $('.directorist-search-location').find('select'),
url: "".concat(rest_base_url, "/listings/locations")
});
} // initSelect2AjaxTaxonomy
function initSelect2AjaxTaxonomy(args) {
var defaultArgs = {
selector: '',
url: '',
perPage: 10
};
args = _objectSpread(_objectSpread({}, defaultArgs), args);
if (!args.selector.length) {
return;
}
_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(args.selector).forEach(function (item, index) {
var directory_type_id = 0;
var search_form_parent = $(item).closest('.directorist-search-form');
var archive_page_parent = $(item).closest('.directorist-archive-contents');
var nav_list_item = []; // If search page
if (search_form_parent.length) {
nav_list_item = search_form_parent.find('.directorist-listing-type-selection__link--current');
} // If archive page
if (archive_page_parent.length) {
nav_list_item = archive_page_parent.find('.directorist-type-nav__list li.current .directorist-type-nav__link');
} // If has nav item
if (nav_list_item.length) {
directory_type_id = nav_list_item ? nav_list_item.data('listing_type_id') : 0;
}
var currentPage = 1;
$(item).select2({
allowClear: true,
width: '100%',
escapeMarkup: function escapeMarkup(text) {
return text;
},
ajax: {
url: args.url,
dataType: 'json',
cache: true,
data: function data(params) {
currentPage = params.page || 1;
var search_term = params.term ? params.term : '';
var query = {
search: search_term,
page: currentPage,
per_page: args.perPage
};
if (directory_type_id) {
query.directory = directory_type_id;
}
return query;
},
processResults: function processResults(data) {
return {
results: data.items,
pagination: {
more: data.paginationMore
}
};
},
transport: function transport(params, success, failure) {
var $request = $.ajax(params);
$request.then(function (data, textStatus, jqXHR) {
var totalPage = parseInt(jqXHR.getResponseHeader('x-wp-totalpages'));
var paginationMore = currentPage < totalPage;
var items = data.map(function (item) {
return {
id: item.id,
text: item.name
};
});
return {
items: items,
paginationMore: paginationMore
};
}).then(success);
$request.fail(failure);
return $request;
}
}
}); // Setup Preselected Option
var selected_item_id = $(item).data('selected-id');
var selected_item_label = $(item).data('selected-label');
if (selected_item_id) {
var option = new Option(selected_item_label, selected_item_id, true, true);
$(item).append(option);
$(item).trigger({
type: 'select2:select',
params: {
data: {
id: selected_item_id,
text: selected_item_label
}
}
});
}
});
}
/***/ }),
/***/ "./assets/src/js/lib/helper.js":
/*!*************************************!*\
!*** ./assets/src/js/lib/helper.js ***!
\*************************************/
/*! exports provided: get_dom_data, convertToSelect2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "get_dom_data", function() { return get_dom_data; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convertToSelect2", function() { return convertToSelect2; });
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @babel/runtime/helpers/toConsumableArray */ "./node_modules/@babel/runtime/helpers/toConsumableArray.js");
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_1__);
var $ = jQuery;
function get_dom_data(key, parent) {
// var elmKey = 'directorist-dom-data-' + key;
var elmKey = 'directorist-dom-data-' + key;
var dataElm = parent ? parent.getElementsByClassName(elmKey) : document.getElementsByClassName(elmKey);
if (!dataElm) {
return '';
}
var is_script_debugging = directorist && directorist.script_debugging && directorist.script_debugging == '1' ? true : false;
try {
var dataValue = atob(dataElm[0].dataset.value);
dataValue = JSON.parse(dataValue);
return dataValue;
} catch (error) {
if (is_script_debugging) {
console.warn({
key: key,
dataElm: dataElm,
error: error
});
}
return '';
}
}
function convertToSelect2(field) {
if (!field) {
return;
}
if (!field.elm) {
return;
}
if (!field.elm.length) {
return;
}
_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_1___default()(field.elm).forEach(function (item) {
var default_args = {
allowClear: true,
width: '100%',
templateResult: function templateResult(data) {
// We only really care if there is an field to pull classes from
if (!data.field) {
return data.text;
}
var $field = $(data.field);
var $wrapper = $('<span></span>');
$wrapper.addClass($field[0].className);
$wrapper.text(data.text);
return $wrapper;
}
};
var args = field.args && _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(field.args) === 'object' ? Object.assign(default_args, field.args) : default_args;
var options = $(item).find('option');
var placeholder = options.length ? options[0].innerHTML : '';
if (placeholder.length) {
args.placeholder = placeholder;
}
$(item).select2(args);
});
}
/***/ }),
/***/ "./assets/src/js/public/components/colorPicker.js":
/*!********************************************************!*\
!*** ./assets/src/js/public/components/colorPicker.js ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
/* Initialize wpColorPicker */
(function ($) {
// Make sure the codes in this file runs only once, even if enqueued twice
if (typeof window.directorist_colorPicker_executed === 'undefined') {
window.directorist_colorPicker_executed = true;
} else {
return;
}
$(document).ready(function () {
/* Initialize wp color picker */
function colorPickerInit() {
var wpColorPicker = document.querySelectorAll('.directorist-color-picker-wrap');
wpColorPicker.forEach(function (elm) {
if (elm !== null) {
var dColorPicker = $('.directorist-color-picker');
dColorPicker.value !== '' ? dColorPicker.wpColorPicker() : dColorPicker.wpColorPicker().empty();
}
});
}
colorPickerInit();
/* Initialize on Directory type change */
document.body.addEventListener('directorist-search-form-nav-tab-reloaded', colorPickerInit);
});
})(jQuery);
/***/ }),
/***/ "./assets/src/js/public/components/directoristSelect.js":
/*!**************************************************************!*\
!*** ./assets/src/js/public/components/directoristSelect.js ***!
\**************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
window.addEventListener('DOMContentLoaded', function () {
// Make sure the codes in this file runs only once, even if enqueued twice
if (typeof window.directorist_select_executed === 'undefined') {
window.directorist_select_executed = true;
} else {
return;
} //custom select
var atbdSelect = document.querySelectorAll('.atbd-drop-select');
if (atbdSelect !== null) {
atbdSelect.forEach(function (el) {
el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) {
item.addEventListener('click', function (e) {
e.preventDefault();
el.querySelector('.atbd-dropdown-toggle').textContent = item.textContent;
el.querySelectorAll('.atbd-dropdown-item').forEach(function (elm) {
elm.classList.remove('atbd-active');
});
item.classList.add('atbd-active');
});
});
});
} // select data-status
var atbdSelectData = document.querySelectorAll('.atbd-drop-select.with-sort');
atbdSelectData.forEach(function (el) {
el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) {
var ds = el.querySelector('.atbd-dropdown-toggle');
var itemds = item.getAttribute('data-status');
item.addEventListener('click', function (e) {
ds.setAttribute('data-status', "".concat(itemds));
});
});
});
});
/***/ }),
/***/ "./assets/src/js/public/range-slider.js":
/*!**********************************************!*\
!*** ./assets/src/js/public/range-slider.js ***!
\**********************************************/
/*! exports provided: directorist_range_slider, directorist_callingSlider */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "directorist_range_slider", function() { return directorist_range_slider; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "directorist_callingSlider", function() { return directorist_callingSlider; });
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__);
/* range slider */
var directorist_range_slider = function directorist_range_slider(selector, obj) {
var isDraging = false,
max = obj.maxValue,
min = obj.minValue,
down = 'mousedown',
up = 'mouseup',
move = 'mousemove',
div = "\n <div class=\"directorist-range-slider1\" draggable=\"true\"></div>\n <input type='hidden' class=\"directorist-range-slider-minimum\" name=\"minimum\" value=".concat(min, " />\n <div class=\"directorist-range-slider-child\"></div>\n\t\t");
var touch = ("ontouchstart" in document.documentElement);
if (touch) {
down = 'touchstart';
up = 'touchend';
move = 'touchmove';
} //RTL
var isRTL = directorist.rtl === 'true';
var direction;
if (isRTL) {
direction = 'right';
} else {
direction = 'left';
}
var slider = document.querySelectorAll(selector);
slider.forEach(function (id, index) {
var sliderDataMin = min;
var sliderDataUnit = id.getAttribute('data-slider-unit');
id.setAttribute('style', "max-width: ".concat(obj.maxWidth, "; border: ").concat(obj.barBorder, "; width: 100%; height: 4px; background: ").concat(obj.barColor, "; position: relative; border-radius: 2px;"));
id.innerHTML = div;
var slide1 = id.querySelector('.directorist-range-slider1'),
width = id.clientWidth;
slide1.style.background = obj.pointerColor;
slide1.style.border = obj.pointerBorder;
id.closest('.directorist-range-slider-wrap').querySelector('.directorist-range-slider-current-value').innerHTML = "<span>".concat(min, "</span> ").concat(sliderDataUnit);
var x = null,
count = 0,
slid1_val = 0,
slid1_val2 = sliderDataMin,
count2 = width;
if (window.outerWidth < 600) {
id.classList.add('m-device');
slide1.classList.add('m-device2');
}
slide1.addEventListener(down, function (event) {
if (!touch) {
event.preventDefault();
event.stopPropagation();
}
x = event.clientX;
if (touch) {
x = event.touches[0].clientX;
}
isDraging = true;
event.target.classList.add('directorist-rs-active');
});
document.body.addEventListener(up, function (event2) {
if (!touch) {
event2.preventDefault();
event2.stopPropagation();
}
isDraging = false;
slid1_val2 = slid1_val;
slide1.classList.remove('directorist-rs-active');
});
slide1.classList.add('directorist-rs-active1');
count = width / max;
if (slide1.classList.contains('directorist-rs-active1')) {
var onLoadValue = count * min;
id.closest('.directorist-range-slider-wrap').querySelector('.directorist-range-slider-current-value span').innerHTML = sliderDataMin;
id.querySelector('.directorist-range-slider-minimum').value = sliderDataMin;
id.querySelector('.directorist-rs-active1').style[direction] = onLoadValue <= 0 ? 0 : onLoadValue + 'px';
id.querySelector('.directorist-range-slider-child').style.width = onLoadValue <= 0 ? 0 : onLoadValue + 'px';
}
document.body.addEventListener(move, function (e) {
if (isDraging) {
count = !isRTL ? e.clientX + slid1_val2 * width / max - x : -e.clientX + slid1_val2 * width / max + x;
if (touch) {
count = !isRTL ? e.touches[0].clientX + slid1_val2 * width / max - x : -e.touches[0].clientX + slid1_val2 * width / max + x;
}
if (count < 0) {
count = 0;
} else if (count > count2 - 18) {
count = count2 - 18;
}
}
if (slide1.classList.contains('directorist-rs-active')) {
slid1_val = Math.floor(max / (width - 18) * count);
id.closest('.directorist-range-slider-wrap').querySelector('.directorist-range-slider-current-value').innerHTML = "<span>".concat(slid1_val, "</span> ").concat(sliderDataUnit);
id.querySelector('.directorist-range-slider-minimum').value = slid1_val;
id.closest('.directorist-range-slider-wrap').querySelector('.directorist-range-slider-value').value = slid1_val;
id.querySelector('.directorist-rs-active').style[direction] = count + 'px';
id.querySelector('.directorist-range-slider-child').style.width = count + 'px';
}
});
});
};
function directorist_callingSlider() {
var minValueWrapper = document.querySelector('.directorist-range-slider-value');
var default_args = {
maxValue: 1000,
minValue: parseInt(minValueWrapper && minValueWrapper.value),
maxWidth: '100%',
barColor: '#d4d5d9',
barBorder: 'none',
pointerColor: '#fff',
pointerBorder: '4px solid #444752'
};
var config = directorist.slider_config && _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(directorist.slider_config) === 'object' ? Object.assign(default_args, directorist.slider_config) : default_args;
directorist_range_slider('.directorist-range-slider', config);
}
window.addEventListener("load", function () {
directorist_callingSlider();
});
/***/ }),
/***/ "./assets/src/js/public/search-form.js":
/*!*********************************************!*\
!*** ./assets/src/js/public/search-form.js ***!
\*********************************************/
/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _components_directoristSelect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/directoristSelect */ "./assets/src/js/public/components/directoristSelect.js");
/* harmony import */ var _components_directoristSelect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_components_directoristSelect__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _components_colorPicker__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/colorPicker */ "./assets/src/js/public/components/colorPicker.js");
/* harmony import */ var _components_colorPicker__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_components_colorPicker__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _global_components_setup_select2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../global/components/setup-select2 */ "./assets/src/js/global/components/setup-select2.js");
/* harmony import */ var _global_components_select2_custom_control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./../global/components/select2-custom-control */ "./assets/src/js/global/components/select2-custom-control.js");
/* harmony import */ var _global_components_select2_custom_control__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_global_components_select2_custom_control__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _range_slider__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./range-slider */ "./assets/src/js/public/range-slider.js");
//import './components/directoristDropdown';
(function ($) {
window.addEventListener('DOMContentLoaded', function () {
/* ----------------
Search Listings
------------------ */
//ad search js
$(".bads-custom-checks").parent(".form-group").addClass("ads-filter-tags");
function defaultTags() {
$('.directorist-btn-ml').each(function (index, element) {
var item = $(element).siblings('.atbdp_cf_checkbox, .direcorist-search-field-tag, .directorist-search-tags');
var abc2 = $(item).find('.directorist-checkbox');
$(abc2).slice(4, abc2.length).fadeOut();
if (abc2.length <= 4) {
$(element).css('display', 'none');
}
});
}
$(window).on('load', defaultTags);
window.addEventListener('triggerSlice', defaultTags);
$('body').on('click', '.directorist-btn-ml', function (event) {
event.preventDefault();
var item = $(this).siblings('.atbdp_cf_checkbox, .direcorist-search-field-tag, .directorist-search-tags');
var abc2 = $(item).find('.directorist-checkbox ');
$(abc2).slice(4, abc2.length).fadeOut();
$(this).toggleClass('active');
if ($(this).hasClass('active')) {
$(this).text(directorist.i18n_text.show_less);
$(abc2).slice(4, abc2.length).fadeIn();
} else {
$(this).text(directorist.i18n_text.show_more);
$(abc2).slice(4, abc2.length).fadeOut();
}
});
/* Advanced search */
var ad = $(".directorist-search-float .directorist-advanced-filter");
ad.css({
visibility: 'hidden',
height: '0'
});
var adsFilterHeight = function adsFilterHeight() {
return $('.directorist-advanced-filter .directorist-advanced-filter__action').innerHeight();
};
var adsItemsHeight;
function getItemsHeight(selector) {
var advElmHeight;
var basicElmHeight;
var adsAdvItemHeight = function adsAdvItemHeight() {
return $(selector).closest('.directorist-search-form-box, .directorist-archive-contents, .directorist-search-form').find('.directorist-advanced-filter__advanced--element');
};
var adsBasicItemHeight = function adsBasicItemHeight() {
return $(selector).closest('.directorist-search-form-box, .directorist-archive-contents').find('.directorist-advanced-filter__basic');
};
for (var i = 0; i <= adsAdvItemHeight().length; i++) {
adsAdvItemHeight().length <= 1 ? advElmHeight = adsAdvItemHeight().innerHeight() : advElmHeight = adsAdvItemHeight().innerHeight() * i;
}
if (isNaN(advElmHeight)) {
advElmHeight = 0;
}
var basicElmHeights = adsBasicItemHeight().innerHeight();
basicElmHeights === undefined ? basicElmHeight = 0 : basicElmHeight = basicElmHeights;
return adsItemsHeight = advElmHeight + basicElmHeight;
}
getItemsHeight('.directorist-filter-btn');
var count = 0;
$('body').on('click', '.directorist-listing-type-selection .search_listing_types, .directorist-type-nav .directorist-type-nav__link', function () {
count = 0;
});
/* Toggle overlapped advanced filter wrapper */
$('body').on("click", '.directorist-filter-btn', function (e) {
count++;
e.preventDefault();
var _this = $(this);
setTimeout(function () {
getItemsHeight(_this);
}, 500);
_this.toggleClass('directorist-filter-btn--active');
var currentPos = e.clientY,
displayPos = window.innerHeight,
height = displayPos - currentPos;
var advFilterWrap = $(e.currentTarget).closest('.directorist-search-form, .directorist-archive-contents').find('.directorist-search-float').find('.directorist-advanced-filter');
if (count % 2 === 0) {
$(advFilterWrap).css({
visibility: 'hidden',
opacity: '0',
height: '0',
transition: '.3s ease'
});
} else {
$(advFilterWrap).css({
visibility: 'visible',
height: adsItemsHeight + adsFilterHeight() + 50 + 'px',
transition: '0.3s ease',
opacity: '1',
display: 'block'
});
}
});
/* Hide overlapped advanced filter */
var directoristAdvFilter = function directoristAdvFilter() {
return $('.directorist-search-float .directorist-advanced-filter');
};
var ad_slide = $(".directorist-search-slide .directorist-advanced-filter");
ad_slide.hide().slideUp();
$(document).on('click', function (e) {
if (!e.target.closest('.directorist-search-form-top, .directorist-listings-header, .directorist-search-form, .select2-container') && !e.target.closest('.directorist-search-float .directorist-advanced-filter')) {
count = 0;
directoristAdvFilter().css({
visibility: 'hidden',
opacity: '0',
height: '0',
transition: '.3s ease'
});
}
});
$('body').on('click', '.directorist-sortby-dropdown > a, .directorist-viewas-dropdown > a', function () {
count = 0;
directoristAdvFilter().css({
visibility: 'hidden',
opacity: '0',
height: '0',
transition: '.3s ease'
});
ad_slide.hide().slideUp();
});
$('body').on("click", '.directorist-filter-btn', function (e) {
e.preventDefault();
var miles = parseInt($('.directorist-range-slider-value').val());
var default_args = {
maxValue: 1000,
minValue: miles,
maxWidth: '100%',
barColor: '#d4d5d9',
barBorder: 'none',
pointerColor: '#fff',
pointerBorder: '4px solid #444752'
};
var config = default_args;
$(this).closest('.directorist-search-form, .directorist-archive-contents').find('.directorist-search-slide').find('.directorist-advanced-filter').slideToggle().show();
$(this).closest('.directorist-search-form, .directorist-archive-contents').find('.directorist-search-slide').find('.directorist-advanced-filter').toggleClass("directorist-advanced-filter--show");
if ($(this).closest('.directorist-search-form, .directorist-archive-contents').find('.direcorist-search-field-radius_search').length) {
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_callingSlider"])();
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_range_slider"])('.directorist-range-slider', config);
}
});
$(".directorist-advanced-filter").parents("div").css("overflow", "visible"); //remove preload after window load
$(window).on('load', function () {
$("body").removeClass("directorist-preload");
$('.button.wp-color-result').attr('style', ' ');
}); //reset fields
function resetFields() {
var inputArray = document.querySelectorAll('.search-area input');
inputArray.forEach(function (input) {
if (input.getAttribute("type") !== "hidden" || input.getAttribute("id") === "atbd_rs_value") {
input.value = "";
}
});
var textAreaArray = document.querySelectorAll('.search-area textArea');
textAreaArray.forEach(function (textArea) {
textArea.innerHTML = "";
});
var range = document.querySelector(".atbdpr-range .ui-slider-horizontal .ui-slider-range");
var rangePos = document.querySelector(".atbdpr-range .ui-slider-horizontal .ui-slider-handle");
var rangeAmount = document.querySelector(".atbdpr_amount");
if (range) {
range.setAttribute("style", "width: 0;");
}
if (rangePos) {
rangePos.setAttribute("style", "left: 0;");
}
if (rangeAmount) {
rangeAmount.innerText = "0 Mile";
}
var checkBoxes = document.querySelectorAll('.directorist-advanced-filter input[type="checkbox"]');
checkBoxes.forEach(function (el, ind) {
el.checked = false;
});
var radios = document.querySelectorAll('.directorist-advanced-filter input[type="radio"]');
radios.forEach(function (el, ind) {
el.checked = false;
});
$('.search-area select').prop('selectedIndex', 0);
$(".bdas-location-search, .bdas-category-search").val('').trigger('change');
}
$("body").on("click", ".atbd_widget .directorist-advanced-filter #atbdp_reset", function (e) {
e.preventDefault();
resetFields();
});
/* advanced search form reset */
function adsFormReset(searchForm) {
searchForm.querySelectorAll("input[type='text']").forEach(function (el) {
el.value = "";
});
searchForm.querySelectorAll("input[type='date']").forEach(function (el) {
el.value = "";
});
searchForm.querySelectorAll("input[type='time']").forEach(function (el) {
el.value = "";
});
searchForm.querySelectorAll("input[type='url']").forEach(function (el) {
el.value = "";
});
searchForm.querySelectorAll("input[type='number']").forEach(function (el) {
el.value = "";
});
searchForm.querySelectorAll("input[type='hidden']:not(.listing_type)").forEach(function (el) {
if (el.getAttribute('name') === "directory_type") return;
if (el.getAttribute('name') === "miles") {
var radiusDefaultValue = searchForm.querySelector('.directorist-range-slider').dataset.defaultRadius;
el.value = radiusDefaultValue;
return;
}
el.value = "";
});
searchForm.querySelectorAll("input[type='radio']").forEach(function (el) {
el.checked = false;
});
searchForm.querySelectorAll("input[type='checkbox']").forEach(function (el) {
el.checked = false;
});
searchForm.querySelectorAll("select").forEach(function (el) {
el.selectedIndex = 0;
$('.directorist-select2-dropdown-close').click();
$(el).val(null).trigger('change');
});
var irisPicker = searchForm.querySelector("input.wp-picker-clear");
if (irisPicker !== null) {
irisPicker.click();
}
var rangeValue = searchForm.querySelector(".directorist-range-slider-current-value span");
if (rangeValue !== null) {
rangeValue.innerHTML = "0";
}
handleRadiusVisibility();
}
/* Advance Search Filter For Search Home Short Code */
if ($(".directorist-search-form .directorist-btn-reset-js") !== null) {
$("body").on("click", ".directorist-search-form .directorist-btn-reset-js", function (e) {
e.preventDefault();
if (this.closest('.directorist-search-contents')) {
var searchForm = this.closest('.directorist-search-contents').querySelector('.directorist-search-form');
if (searchForm) {
adsFormReset(searchForm);
}
}
if ($(this).closest('.directorist-search-contents').find('.direcorist-search-field-radius_search').length) {
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_callingSlider"])(0);
}
});
}
/* All Listing Advance Filter */
if ($(".directorist-advanced-filter__form .directorist-btn-reset-js") !== null) {
$("body").on("click", ".directorist-advanced-filter__form .directorist-btn-reset-js", function (e) {
e.preventDefault();
if (this.closest('.directorist-advanced-filter')) {
var searchForm = this.closest('.directorist-advanced-filter').querySelector('.directorist-advanced-filter__form');
if (searchForm) {
adsFormReset(searchForm);
}
}
if ($(this).closest('.directorist-advanced-filter').find('.direcorist-search-field-radius_search').length) {
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_callingSlider"])(0);
}
});
}
if ($("#bdlm-search-area #atbdp_reset") !== null) {
$("body").on("click", "#bdlm-search-area #atbdp_reset", function (e) {
e.preventDefault();
if (this.closest('.directorist-search-contents')) {
var searchForm = this.closest('.directorist-search-contents').querySelector('.directorist-search-form');
if (searchForm) {
adsFormReset(searchForm);
}
}
if (this.closest('.directorist-advanced-filter')) {
var _searchForm = this.closest('.directorist-advanced-filter').querySelector('.directorist-advanced-filter__form');
if (_searchForm) {
adsFormReset(_searchForm);
}
}
if ($(this).closest('.directorist-search-contents').find('.direcorist-search-field-radius_search').length) {
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_callingSlider"])(0);
}
});
}
/* Map Listing Search Form */
if ($("#directorist-search-area .directorist-btn-reset-js") !== null) {
$("body").on("click", "#directorist-search-area .directorist-btn-reset-js", function (e) {
e.preventDefault();
if (this.closest('#directorist-search-area')) {
var searchForm = this.closest('#directorist-search-area').querySelector('#directorist-search-area-form');
if (searchForm) {
adsFormReset(searchForm);
}
}
if ($(this).closest('#directorist-search-area').find('.direcorist-search-field-radius_search').length) {
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_callingSlider"])(0);
}
});
}
/* Single Listing widget Form */
if ($(".atbd_widget .search-area .directorist-btn-reset-js") !== null) {
$("body").on("click", ".atbd_widget .search-area .directorist-btn-reset-js", function (e) {
e.preventDefault();
if (this.closest('.search-area')) {
var searchForm = this.closest('.search-area').querySelector('.directorist-advanced-filter__form');
if (searchForm) {
adsFormReset(searchForm);
}
}
if ($(this).closest('.search-area').find('.direcorist-search-field-radius_search').length) {
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_callingSlider"])(0);
}
});
}
/* ----------------
Search-form-listing
------------------- */
$('body').on('click', '.search_listing_types', function (event) {
event.preventDefault();
var parent = $(this).closest('.directorist-search-contents');
var listing_type = $(this).attr('data-listing_type');
var type_current = parent.find('.directorist-listing-type-selection__link--current');
if (type_current.length) {
type_current.removeClass('directorist-listing-type-selection__link--current');
$(this).addClass('directorist-listing-type-selection__link--current');
}
parent.find('.listing_type').val(listing_type);
var form_data = new FormData();
form_data.append('action', 'atbdp_listing_types_form');
form_data.append('nonce', directorist.directorist_nonce);
form_data.append('listing_type', listing_type);
var atts = parent.attr('data-atts');
var atts_decoded = btoa(atts);
form_data.append('atts', atts_decoded);
parent.find('.directorist-search-form-box').addClass('atbdp-form-fade');
$.ajax({
method: 'POST',
processData: false,
contentType: false,
url: directorist.ajax_url,
data: form_data,
success: function success(response) {
if (response) {
// Add Temp Element
var new_inserted_elm = '<div class="directorist_search_temp"><div>';
parent.before(new_inserted_elm); // Remove Old Parent
parent.remove(); // Insert New Parent
$('.directorist_search_temp').after(response['search_form']);
var newParent = $('.directorist_search_temp').next(); // Toggle Active Class
newParent.find('.directorist-listing-type-selection__link--current').removeClass('directorist-listing-type-selection__link--current');
newParent.find("[data-listing_type='" + listing_type + "']").addClass('directorist-listing-type-selection__link--current'); // Remove Temp Element
$('.directorist_search_temp').remove();
var events = [new CustomEvent('directorist-search-form-nav-tab-reloaded'), new CustomEvent('directorist-reload-select2-fields'), new CustomEvent('directorist-reload-map-api-field'), new CustomEvent('triggerSlice')];
events.forEach(function (event) {
document.body.dispatchEvent(event);
window.dispatchEvent(event);
});
handleRadiusVisibility();
}
var parentAfterAjax = $(this).closest('.directorist-search-contents');
parentAfterAjax.find('.directorist-search-form-box').removeClass('atbdp-form-fade');
if (parentAfterAjax.find('.directorist-search-form-box').find('.direcorist-search-field-radius_search').length) {
handleRadiusVisibility();
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_callingSlider"])();
}
},
error: function error(_error2) {
console.log(_error2);
}
});
}); // Advance search
// Populate atbdp child terms dropdown
$('.bdas-terms').on('change', 'select', function (e) {
e.preventDefault();
var $this = $(this);
var taxonomy = $this.data('taxonomy');
var parent = $this.data('parent');
var value = $this.val();
var classes = $this.attr('class');
$this.closest('.bdas-terms').find('input.bdas-term-hidden').val(value);
$this.parent().find('div:first').remove();
if (parent != value) {
$this.parent().append('<div class="bdas-spinner"></div>');
var data = {
action: 'bdas_public_dropdown_terms',
taxonomy: taxonomy,
parent: value,
class: classes,
security: directorist.ajaxnonce
};
$.post(directorist.ajax_url, data, function (response) {
$this.parent().find('div:first').remove();
$this.parent().append(response);
});
}
});
if ($('.directorist-search-contents').length) {
$('body').on('change', '.directorist-category-select', function (event) {
var $this = $(this);
var $container = $this.parents('form');
var cat_id = $this.val();
var directory_type = $container.find('.listing_type').val();
var $search_form_box = $container.find('.directorist-search-form-box-wrap');
var form_data = new FormData();
form_data.append('action', 'directorist_category_custom_field_search');
form_data.append('nonce', directorist.directorist_nonce);
form_data.append('listing_type', directory_type);
form_data.append('cat_id', cat_id);
form_data.append('atts', JSON.stringify($container.data('atts')));
$search_form_box.addClass('atbdp-form-fade');
$.ajax({
method: 'POST',
processData: false,
contentType: false,
url: directorist.ajax_url,
data: form_data,
success: function success(response) {
if (response) {
$search_form_box.html(response['search_form']);
$container.find('.directorist-category-select option').data('custom-field', 1);
$container.find('.directorist-category-select').val(cat_id);
[new CustomEvent('directorist-search-form-nav-tab-reloaded'), new CustomEvent('directorist-reload-select2-fields'), new CustomEvent('directorist-reload-map-api-field'), new CustomEvent('triggerSlice')].forEach(function (event) {
document.body.dispatchEvent(event);
window.dispatchEvent(event);
});
}
$search_form_box.removeClass('atbdp-form-fade');
},
error: function error(_error) {//console.log(_error);
}
});
});
} // load custom fields of the selected category in the search form
$('body').on('change', '.bdas-category-search, .directorist-category-select', function () {
var $search_elem = $(this).closest('form').find('.atbdp-custom-fields-search');
if ($search_elem.length) {
$search_elem.html('<div class="atbdp-spinner"></div>');
var data = {
action: 'atbdp_custom_fields_search',
term_id: $(this).val(),
security: directorist.ajaxnonce
};
$.post(directorist.ajax_url, data, function (response) {
$search_elem.html(response);
var item = $('.custom-control').closest('.bads-custom-checks');
item.each(function (index, el) {
var count = 0;
var abc = $(el)[0];
var abc2 = $(abc).children('.custom-control');
if (abc2.length <= 4) {
$(abc2).closest('.bads-custom-checks').next('a.more-or-less').hide();
}
$(abc2).slice(4, abc2.length).hide();
});
});
}
}); // Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function directorist_debounce(func, wait, immediate) {
var timeout;
return function () {
var context = this,
args = arguments;
var later = function later() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
}
;
$('body').on("keyup", '.zip-radius-search', directorist_debounce(function () {
var zipcode = $(this).val();
var zipcode_search = $(this).closest('.directorist-zipcode-search');
var country_suggest = zipcode_search.find('.directorist-country');
$('.directorist-country').css({
display: 'block'
});
if (zipcode === '') {
$('.directorist-country').css({
display: 'none'
});
}
var res = '';
$.ajax({
url: "https://nominatim.openstreetmap.org/?postalcode=+".concat(zipcode, "+&format=json&addressdetails=1"),
type: "POST",
data: {},
success: function success(data) {
if (data.length === 1) {
var lat = data[0].lat;
var lon = data[0].lon;
zipcode_search.find('.zip-cityLat').val(lat);
zipcode_search.find('.zip-cityLng').val(lon);
} else {
for (var i = 0; i < data.length; i++) {
res += "<li><a href=\"#\" data-lat=".concat(data[i].lat, " data-lon=").concat(data[i].lon, ">").concat(data[i].address.country, "</a></li>");
}
}
$(country_suggest).html("<ul>".concat(res, "</ul>"));
if (res.length) {
$('.directorist-country').show();
} else {
$('.directorist-country').hide();
}
}
});
}, 250)); // hide country result when click outside the zipcode field
$(document).on('click', function (e) {
if (!$(e.target).closest('.directorist-zip-code').length) {
$('.directorist-country').hide();
}
});
$('body').on('click', '.directorist-country ul li a', function (event) {
event.preventDefault();
var zipcode_search = $(this).closest('.directorist-zipcode-search');
var lat = $(this).data('lat');
var lon = $(this).data('lon');
zipcode_search.find('.zip-cityLat').val(lat);
zipcode_search.find('.zip-cityLng').val(lon);
$('.directorist-country').hide();
});
$('.address_result').hide();
window.addEventListener('load', init_map_api_field);
document.body.addEventListener('directorist-reload-map-api-field', init_map_api_field);
function init_map_api_field() {
if (directorist.i18n_text.select_listing_map === 'google') {
function initialize() {
var opt = {
types: ['geocode'],
componentRestrictions: {
country: directorist.restricted_countries
}
};
var options = directorist.countryRestriction ? opt : '';
var input_fields = [{
input_class: '.directorist-location-js',
lat_id: 'cityLat',
lng_id: 'cityLng',
options: options
}, {
input_id: 'address_widget',
lat_id: 'cityLat',
lng_id: 'cityLng',
options: options
}];
var setupAutocomplete = function setupAutocomplete(field) {
var input = document.querySelectorAll(field.input_class);
input.forEach(function (elm) {
if (!elm) {
return;
}
var autocomplete = new google.maps.places.Autocomplete(elm, field.options);
google.maps.event.addListener(autocomplete, 'place_changed', function () {
var place = autocomplete.getPlace();
elm.closest('.directorist-search-field').querySelector("#".concat(field.lat_id)).value = place.geometry.location.lat();
elm.closest('.directorist-search-field').querySelector("#".concat(field.lng_id)).value = place.geometry.location.lng();
});
});
};
input_fields.forEach(function (field) {
setupAutocomplete(field);
});
}
initialize();
} else if (directorist.i18n_text.select_listing_map === 'openstreet') {
var getResultContainer = function getResultContainer(context, field) {
return $(context).next(field.search_result_elm);
};
var getWidgetResultContainer = function getWidgetResultContainer(context, field) {
return $(context).parent().next(field.search_result_elm);
};
var input_fields = [{
input_elm: '.directorist-location-js',
search_result_elm: '.address_result',
getResultContainer: getResultContainer
}, {
input_elm: '#q_addressss',
search_result_elm: '.address_result',
getResultContainer: getResultContainer
}, {
input_elm: '.atbdp-search-address',
search_result_elm: '.address_result',
getResultContainer: getResultContainer
}, {
input_elm: '#address_widget',
search_result_elm: '#address_widget_result',
getResultContainer: getWidgetResultContainer
}];
input_fields.forEach(function (field) {
if (!$(field.input_elm).length) {
return;
}
$(field.input_elm).on('keyup', directorist_debounce(function (event) {
event.preventDefault();
var blockedKeyCodes = [16, 17, 18, 19, 20, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 91, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 144, 145]; // Return early when blocked key is pressed.
if (blockedKeyCodes.includes(event.keyCode)) {
return;
}
var locationAddressField = $(this).parent('.directorist-search-field');
var result_container = field.getResultContainer(this, field);
var search = $(this).val();
if (search.length < 3) {
result_container.css({
display: 'none'
});
} else {
locationAddressField.addClass('atbdp-form-fade');
result_container.css({
display: 'block'
});
$.ajax({
url: "https://nominatim.openstreetmap.org/?q=%27+".concat(search, "+%27&format=json"),
type: 'POST',
data: {},
success: function success(data) {
var res = '';
for (var i = 0, len = data.length; i < len; i++) {
res += "<li><a href=\"#\" data-lat=".concat(data[i].lat, " data-lon=").concat(data[i].lon, ">").concat(data[i].display_name, "</a></li>");
}
result_container.html("<ul>".concat(res, "</ul>"));
if (res.length) {
result_container.show();
} else {
result_container.hide();
}
locationAddressField.removeClass('atbdp-form-fade');
},
error: function error(_error3) {
console.log({
error: _error3
});
}
});
}
}, 750));
}); // hide address result when click outside the input field
$(document).on('click', function (e) {
if (!$(e.target).closest('.directorist-location-js, #q_addressss, .atbdp-search-address').length) {
$('.address_result').hide();
}
});
var syncLatLngData = function syncLatLngData(context, event, args) {
event.preventDefault();
var text = $(context).text();
var lat = $(context).data('lat');
var lon = $(context).data('lon');
var _this = event.target;
$(_this).closest('.address_result').siblings('input[name="cityLat"]').val(lat);
$(_this).closest('.address_result').siblings('input[name="cityLng"]').val(lon);
var inp = $(context).closest(args.result_list_container).parent().find('.directorist-location-js, #address_widget, #q_addressss, .atbdp-search-address');
inp.val(text);
$(args.result_list_container).hide();
};
$('body').on('click', '.address_result ul li a', function (event) {
syncLatLngData(this, event, {
result_list_container: '.address_result'
});
});
$('body').on('click', '#address_widget_result ul li a', function (event) {
syncLatLngData(this, event, {
result_list_container: '#address_widget_result'
});
});
}
if ($('.directorist-location-js, #q_addressss,.atbdp-search-address').val() === '') {
$(this).parent().next('.address_result').css({
display: 'none'
});
}
}
$(".directorist-search-contents").each(function () {
if ($(this).next().length === 0) {
$(this).find(".directorist-search-country").css("max-height", "175px");
$(this).find(".directorist-search-field .address_result").css("max-height", "175px");
}
});
/* When location field is empty we need to hide Radius Search */
function handleRadiusVisibility() {
$('.directorist-range-slider-wrap').closest('.directorist-search-field').addClass('direcorist-search-field-radius_search');
$('.directorist-location-js').each(function (index, locationDom) {
if ($(locationDom).val() === '') {
$(locationDom).closest('.directorist-search-form, .directorist-advanced-filter__form').find('.direcorist-search-field-radius_search').css({
display: "none"
});
} else {
$(locationDom).closest('.directorist-search-form, .directorist-advanced-filter__form').find('.direcorist-search-field-radius_search').css({
display: "block"
});
Object(_range_slider__WEBPACK_IMPORTED_MODULE_4__["directorist_callingSlider"])();
}
});
}
$('body').on('keyup keydown input change focus', '.directorist-location-js', function (e) {
handleRadiusVisibility();
}); // DOM Mutation observer
function initObserver() {
var targetNode = document.querySelector('.directorist-location-js');
if (targetNode) {
var observer = new MutationObserver(handleRadiusVisibility);
observer.observe(targetNode, {
attributes: true
});
}
}
initObserver();
handleRadiusVisibility();
});
})(jQuery);
/***/ }),
/***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js":
/*!*****************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/arrayLikeToArray.js ***!
\*****************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ "./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js":
/*!******************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js ***!
\******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return arrayLikeToArray(arr);
}
module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ "./node_modules/@babel/runtime/helpers/defineProperty.js":
/*!***************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***!
\***************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ "./node_modules/@babel/runtime/helpers/iterableToArray.js":
/*!****************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/iterableToArray.js ***!
\****************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ "./node_modules/@babel/runtime/helpers/nonIterableSpread.js":
/*!******************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/nonIterableSpread.js ***!
\******************************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
module.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ "./node_modules/@babel/runtime/helpers/toConsumableArray.js":
/*!******************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/toConsumableArray.js ***!
\******************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var arrayWithoutHoles = __webpack_require__(/*! ./arrayWithoutHoles.js */ "./node_modules/@babel/runtime/helpers/arrayWithoutHoles.js");
var iterableToArray = __webpack_require__(/*! ./iterableToArray.js */ "./node_modules/@babel/runtime/helpers/iterableToArray.js");
var unsupportedIterableToArray = __webpack_require__(/*! ./unsupportedIterableToArray.js */ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js");
var nonIterableSpread = __webpack_require__(/*! ./nonIterableSpread.js */ "./node_modules/@babel/runtime/helpers/nonIterableSpread.js");
function _toConsumableArray(arr) {
return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
}
module.exports = _toConsumableArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ "./node_modules/@babel/runtime/helpers/typeof.js":
/*!*******************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/typeof.js ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _typeof(obj) {
"@babel/helpers - typeof";
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
}
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ "./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js":
/*!***************************************************************************!*\
!*** ./node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js ***!
\***************************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var arrayLikeToArray = __webpack_require__(/*! ./arrayLikeToArray.js */ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js");
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
}
module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
/***/ }),
/***/ 2:
/*!***************************************************!*\
!*** multi ./assets/src/js/public/search-form.js ***!
\***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! ./assets/src/js/public/search-form.js */"./assets/src/js/public/search-form.js");
/***/ })
/******/ });
//# sourceMappingURL=search-form.js.map