diff --git a/assets/js/account.js b/assets/js/account.js index 83216d8d5f..82f8fc2e7e 100644 --- a/assets/js/account.js +++ b/assets/js/account.js @@ -94,7 +94,6 @@ /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // Recovery Password Modal @@ -102,14 +101,16 @@ $(".atbdp_recovery_pass").on("click", function (e) { e.preventDefault(); $("#recover-pass-modal").slideToggle().show(); - }); // Contact form [on modal closed] + }); + // Contact form [on modal closed] $('#atbdp-contact-modal').on('hidden.bs.modal', function (e) { $('#atbdp-contact-message').val(''); $('#atbdp-contact-message-display').html(''); - }); // Template Restructured - // Modal + }); + // Template Restructured + // Modal var directoristModal = document.querySelector('.directorist-modal-js'); $('body').on('click', '.directorist-btn-modal-js', function (e) { e.preventDefault(); @@ -138,7 +139,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_alert_executed === 'undefined') { @@ -146,12 +146,10 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* Directorist alert dismiss */ var getUrl = window.location.href; var newUrl = getUrl.replace('notice=1', ''); - if ($('.directorist-alert__close') !== null) { $('.directorist-alert__close').each(function (i, e) { $(e).on('click', function (e) { @@ -174,7 +172,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_loginjs_executed === 'undefined') { @@ -182,7 +179,6 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { // Perform AJAX login on form submit $('form#login').on('submit', function (e) { @@ -205,7 +201,6 @@ if ('nonce_faild' in data && data.nonce_faild) { $('p.status').html('
' + data.message + '
'); } - if (data.loggedin == true) { $('p.status').html('
' + data.message + '
'); document.location.href = directorist.redirect_url; @@ -217,7 +212,6 @@ if ('nonce_faild' in data && data.nonce_faild) { $('p.status').html('
' + data.message + '
'); } - $('p.status').show().html('
' + directorist.login_error_message + '
'); } }); @@ -225,7 +219,6 @@ }); $('form#login .status').on('click', 'a', function (e) { e.preventDefault(); - if ($(this).attr('href') === '#atbdp_recovery_pass') { $("#recover-pass-modal").slideDown().show(); window.scrollTo({ @@ -235,22 +228,24 @@ } else { location.href = href; } - }); // Alert users to login (only if applicable) + }); + // Alert users to login (only if applicable) $('.atbdp-require-login, .directorist-action-report-not-loggedin').on('click', function (e) { e.preventDefault(); alert(directorist.login_alert_message); return false; - }); // Remove URL params to avoid show message again and again + }); + // Remove URL params to avoid show message again and again var current_url = location.href; var url = new URL(current_url); url.searchParams.delete('registration_status'); - url.searchParams.delete('errors'); // url.searchParams.delete('key'); - + url.searchParams.delete('errors'); + // url.searchParams.delete('key'); url.searchParams.delete('password_reset'); - url.searchParams.delete('confirm_mail'); // url.searchParams.delete('user'); - + url.searchParams.delete('confirm_mail'); + // url.searchParams.delete('user'); url.searchParams.delete('verification'); url.searchParams.delete('send_verification_email'); window.history.pushState(null, null, url.toString()); @@ -269,12 +264,10 @@ jQuery(function ($) { $('.directorist-ResetPassword').on('submit', function () { var form = $(this); - if (form.find('#password_1').val() != form.find('#password_2').val()) { form.find('.password-not-match').show(); return false; } - form.find('.password-not-match').hide(); return true; }); diff --git a/assets/js/add-listing-google-map.js b/assets/js/add-listing-google-map.js index 991fd43fd8..c59fb0d0d0 100644 --- a/assets/js/add-listing-google-map.js +++ b/assets/js/add-listing-google-map.js @@ -102,8 +102,9 @@ __webpack_require__.r(__webpack_exports__); (function ($) { $(document).ready(function () { if ($('#gmap').length) { - var localized_data = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('map_data'); // initialize all vars here to avoid hoisting related misunderstanding. + var localized_data = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('map_data'); + // initialize all vars here to avoid hoisting related misunderstanding. var placeSearch; var map; var autocomplete; @@ -113,8 +114,9 @@ __webpack_require__.r(__webpack_exports__); var $manual_lat; var $manual_lng; var saved_lat_lng; - var info_content; // Localized Data + var info_content; + // Localized Data var loc_default_latitude = parseFloat(localized_data.default_latitude); var loc_default_longitude = parseFloat(localized_data.default_longitude); var loc_manual_lat = parseFloat(localized_data.manual_lat); @@ -127,24 +129,27 @@ __webpack_require__.r(__webpack_exports__); saved_lat_lng = { lat: loc_manual_lat, lng: loc_manual_lng - }; // default is London city + }; - info_content = localized_data.info_content, markers = [], // initialize the array to keep track all the marker + // default is London city + info_content = localized_data.info_content, markers = [], + // initialize the array to keep track all the marker info_window = new google.maps.InfoWindow({ content: info_content, maxWidth: 400 - }); // if(address_input){ + }); + + // if(address_input){ // address_input = document.getElementById('address'); // address_input.addEventListener('focus', geolocate); // } address_input = document.getElementById('address'); - if (address_input !== null) { address_input.addEventListener('focus', geolocate); - } // this function will work on sites that uses SSL, it applies to Chrome especially, other browsers may allow location sharing without securing. - + } + // this function will work on sites that uses SSL, it applies to Chrome especially, other browsers may allow location sharing without securing. function geolocate() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { @@ -160,7 +165,6 @@ __webpack_require__.r(__webpack_exports__); }); } } - function initAutocomplete() { // Create the autocomplete object, restricting the search to geographical var opt = { @@ -171,31 +175,34 @@ __webpack_require__.r(__webpack_exports__); }; var options = directorist.countryRestriction ? opt : { types: [] - }; // location types. + }; - autocomplete = new google.maps.places.Autocomplete(address_input, options); // When the user selects an address from the dropdown, populate the necessary input fields and draw a marker + // location types. + autocomplete = new google.maps.places.Autocomplete(address_input, options); + // When the user selects an address from the dropdown, populate the necessary input fields and draw a marker autocomplete.addListener('place_changed', fillInAddress); } - function fillInAddress() { // Get the place details from the autocomplete object. - var place = autocomplete.getPlace(); // set the value of input field to save them to the database + var place = autocomplete.getPlace(); + // set the value of input field to save them to the database $manual_lat.val(place.geometry.location.lat()); $manual_lng.val(place.geometry.location.lng()); map.setCenter(place.geometry.location); var marker = new google.maps.Marker({ map: map, position: place.geometry.location - }); // marker.addListener('click', function () { + }); + + // marker.addListener('click', function () { // info_window.open(map, marker); // }); - // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. + // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. markers.push(marker); } - initAutocomplete(); // start google map place auto complete API call function initMap() { @@ -209,40 +216,41 @@ __webpack_require__.r(__webpack_exports__); position: saved_lat_lng, draggable: true, title: localized_data.marker_title - }); // marker.addListener('click', function () { + }); + // marker.addListener('click', function () { // info_window.open(map, marker); // }); // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. + markers.push(marker); - markers.push(marker); // create a Geocode instance - + // create a Geocode instance var geocoder = new google.maps.Geocoder(); document.getElementById('generate_admin_map').addEventListener('click', function (e) { e.preventDefault(); geocodeAddress(geocoder, map); - }); // This event listener calls addMarker() when the map is clicked. + }); + // This event listener calls addMarker() when the map is clicked. google.maps.event.addListener(map, 'click', function (event) { deleteMarker(); // at first remove previous marker and then set new marker; // set the value of input field to save them to the database - $manual_lat.val(event.latLng.lat()); - $manual_lng.val(event.latLng.lng()); // add the marker to the given map. - + $manual_lng.val(event.latLng.lng()); + // add the marker to the given map. addMarker(event.latLng, map); - }); // This event listener update the lat long field of the form so that we can add the lat long to the database when the MARKER is drag. - + }); + // This event listener update the lat long field of the form so that we can add the lat long to the database when the MARKER is drag. google.maps.event.addListener(marker, 'dragend', function (event) { // set the value of input field to save them to the database $manual_lat.val(event.latLng.lat()); $manual_lng.val(event.latLng.lng()); }); } + /* * Geocode and address using google map javascript api and then populate the input fields for storing lat and long * */ - function geocodeAddress(geocoder, resultsMap) { var address = address_input.value; var lat = parseFloat(document.getElementById('manual_lat').value); @@ -261,54 +269,53 @@ __webpack_require__.r(__webpack_exports__); var marker = new google.maps.Marker({ map: resultsMap, position: results[0].geometry.location - }); // marker.addListener('click', function () { + }); + + // marker.addListener('click', function () { // info_window.open(map, marker); // }); - deleteMarker(); // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. - + deleteMarker(); + // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. markers.push(marker); } else { alert(localized_data.geocode_error_msg + status); } }); } + initMap(); - initMap(); // adding features of creating marker manually on the map on add listing page. - + // adding features of creating marker manually on the map on add listing page. /* var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var labelIndex = 0; */ - // Adds a marker to the map. + // Adds a marker to the map. function addMarker(location, map) { // Add the marker at the clicked location, and add the next-available label // from the array of alphabetical characters. var marker = new google.maps.Marker({ position: location, - /* label: labels[labelIndex++ % labels.length], */ draggable: true, title: localized_data.marker_title, map: map - }); // marker.addListener('click', function () { + }); + // marker.addListener('click', function () { // info_window.open(map, marker); // }); // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. - markers.push(marker); - } // Delete Marker - + } + // Delete Marker $('#delete_marker').on('click', function (e) { e.preventDefault(); deleteMarker(); }); - function deleteMarker() { for (var i = 0; i < markers.length; i++) { markers[i].setMap(null); } - markers = []; } } @@ -335,18 +342,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -359,24 +362,19 @@ function get_dom_data(key, parent) { 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, @@ -386,7 +384,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -397,17 +394,14 @@ function convertToSelect2(field) { 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); }); } - /***/ }), /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": @@ -419,14 +413,9 @@ function convertToSelect2(field) { 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]; - } - + 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; /***/ }), @@ -439,11 +428,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -458,7 +445,6 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex 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; /***/ }), @@ -473,7 +459,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -486,17 +471,12 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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; /***/ }), @@ -508,16 +488,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -530,7 +509,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -539,7 +517,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/add-listing-openstreet-map.js b/assets/js/add-listing-openstreet-map.js index a1d9827d9d..e9ea374cd8 100644 --- a/assets/js/add-listing-openstreet-map.js +++ b/assets/js/add-listing-openstreet-map.js @@ -98,12 +98,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _lib_helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../../lib/helper */ "./assets/src/js/lib/helper.js"); /* Add listing OSMap */ -; +; (function ($) { $(document).ready(function () { - var mapData = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('map_data'); // Localized Data + var mapData = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('map_data'); + // Localized Data var loc_default_latitude = parseFloat(mapData.default_latitude); var loc_default_longitude = parseFloat(mapData.default_longitude); var loc_manual_lat = parseFloat(mapData.manual_lat); @@ -112,13 +113,11 @@ __webpack_require__.r(__webpack_exports__); var loc_map_icon = mapData.map_icon; loc_manual_lat = isNaN(loc_manual_lat) ? loc_default_latitude : loc_manual_lat; loc_manual_lng = isNaN(loc_manual_lng) ? loc_default_longitude : loc_manual_lng; - function mapLeaflet(lat, lon) { // @todo @kowsar / remove later. fix js error if ($("#gmap").length == 0) { return; } - var fontAwesomeIcon = L.icon({ iconUrl: loc_map_icon, iconSize: [20, 25] @@ -145,39 +144,34 @@ __webpack_require__.r(__webpack_exports__); attribution: '© OpenStreetMap contributors' }).addTo(mymap); } - function directorist_debounce(func, wait, immediate) { var timeout; return function () { var context = this, - args = arguments; - + 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); }; } - ; $('.directorist-location-js').each(function (id, elm) { var result_container = $(elm).siblings('.address_result'); $(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. + 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-form-address-field'); var search = $(elm).val(); - if (search.length < 3) { result_container.css({ 'display': 'none' @@ -193,19 +187,15 @@ __webpack_require__.r(__webpack_exports__); data: {}, success: function success(data) { var res = ''; - for (var i = 0; i < data.length; i++) { res += "
  • ").concat(data[i].display_name, "
  • "); } - result_container.find('ul').html(res); - if (res.length) { result_container.show(); } else { result_container.hide(); } - locationAddressField.removeClass('atbdp-form-fade'); } }); @@ -213,17 +203,16 @@ __webpack_require__.r(__webpack_exports__); }, 750)); }); var lat = loc_manual_lat, - lon = loc_manual_lng; + lon = loc_manual_lng; mapLeaflet(lat, lon); $('body').on('click', '.directorist-form-address-field .address_result ul li a', function (event) { if (document.getElementById('osm')) { document.getElementById('osm').innerHTML = "
    "; } - event.preventDefault(); var text = $(this).text(), - lat = $(this).data('lat'), - lon = $(this).data('lon'); + lat = $(this).data('lat'), + lon = $(this).data('lon'); $('#manual_lat').val(lat); $('#manual_lng').val(lon); $(this).closest('.address_result').siblings('.directorist-location-js').val(text); @@ -244,33 +233,28 @@ __webpack_require__.r(__webpack_exports__); event.preventDefault(); document.getElementById('osm').innerHTML = "
    "; mapLeaflet($('#manual_lat').val(), $('#manual_lng').val()); - }); // Popup controller by keyboard + }); + // Popup controller by keyboard var index = 0; $('.directorist-location-js').on('keyup', function (event) { event.preventDefault(); var length = $('#directorist.atbd_wrapper .address_result ul li a').length; - if (event.keyCode === 40) { index++; - if (index > length) { index = 0; } } else if (event.keyCode === 38) { index--; - if (index < 0) { index = length; } - ; } - if ($('#directorist.atbd_wrapper .address_result ul li a').length > 0) { $('#directorist.atbd_wrapper .address_result ul li a').removeClass('active'); $($('#directorist.atbd_wrapper .address_result ul li a')[index]).addClass('active'); - if (event.keyCode === 13) { $($('#directorist.atbd_wrapper .address_result ul li a')[index]).click(); event.preventDefault(); @@ -278,9 +262,10 @@ __webpack_require__.r(__webpack_exports__); return false; } } - ; - }); // $('#post').on('submit', function (event) { + }); + + // $('#post').on('submit', function (event) { // event.preventDefault(); // return false; // }); @@ -307,18 +292,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -331,24 +312,19 @@ function get_dom_data(key, parent) { 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, @@ -358,7 +334,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -369,17 +344,14 @@ function convertToSelect2(field) { 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); }); } - /***/ }), /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": @@ -391,14 +363,9 @@ function convertToSelect2(field) { 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]; - } - + 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; /***/ }), @@ -411,11 +378,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -430,7 +395,6 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex 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; /***/ }), @@ -445,7 +409,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -458,17 +421,12 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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; /***/ }), @@ -480,16 +438,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -502,7 +459,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -511,7 +467,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/add-listing.js b/assets/js/add-listing.js index 3cea86fcba..a8a65641cf 100644 --- a/assets/js/add-listing.js +++ b/assets/js/add-listing.js @@ -105,22 +105,19 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _public_components_colorPicker__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_public_components_colorPicker__WEBPACK_IMPORTED_MODULE_3__); /* harmony import */ var _global_components_setup_select2__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../global/components/setup-select2 */ "./assets/src/js/global/components/setup-select2.js"); - 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; } - +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; } // General Components -/* eslint-disable */ +/* eslint-disable */ var $ = jQuery; var localized_data = directorist.add_listing_data; + /** * Join Query String * @@ -128,22 +125,18 @@ var localized_data = directorist.add_listing_data; * @param string queryString * @return string */ - function joinQueryString(url, queryString) { return url.match(/[?]/) ? "".concat(url, "&").concat(queryString) : "".concat(url, "?").concat(queryString); } - function scrollTo(selector) { var _document$querySelect; - - (_document$querySelect = document.querySelector(selector)) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.scrollIntoView({ + (_document$querySelect = document.querySelector(selector)) === null || _document$querySelect === void 0 || _document$querySelect.scrollIntoView({ block: 'start', behavior: 'smooth' }); } -/* Show and hide manual coordinate input field */ - +/* Show and hide manual coordinate input field */ $(window).on('load', function () { if ($('input#manual_coordinate').length) { $('input#manual_coordinate').each(function (index, element) { @@ -152,9 +145,9 @@ $(window).on('load', function () { $('.directorist-map-coordinates').hide(); } }); - } //initialize color picker - + } + //initialize color picker if ($('.directorist-color-field-js').length) { $('.directorist-color-field-js').wpColorPicker().empty(); } @@ -168,25 +161,26 @@ $(document).ready(function () { $('.directorist-map-coordinates').hide(); $('#hide_if_no_manual_cor').hide(); } - }); // SOCIAL SECTION - // Rearrange the IDS and Add new social field + }); + // SOCIAL SECTION + // Rearrange the IDS and Add new social field $('body').on('click', '#addNewSocial', function (e) { var social_wrap = $('#social_info_sortable_container'); // cache it - var currentItems = $('.directorist-form-social-fields').length; var ID = "id=".concat(currentItems); // eg. 'id=3' + var iconBindingElement = jQuery('#addNewSocial'); - var iconBindingElement = jQuery('#addNewSocial'); // arrange names ID in order before adding new elements - + // arrange names ID in order before adding new elements $('.directorist-form-social-fields').each(function (index, element) { var e = $(element); e.attr('id', "socialID-".concat(index)); e.find('select').attr('name', "social[".concat(index, "][id]")); e.find('.atbdp_social_input').attr('name', "social[".concat(index, "][url]")); e.find('.directorist-form-social-fields__remove').attr('data-id', index); - }); // now add the new elements. we could do it here without using ajax but it would require more markup here. + }); + // now add the new elements. we could do it here without using ajax but it would require more markup here. atbdp_do_ajax(iconBindingElement, 'atbdp_social_info_handler', ID, function (data) { social_wrap.append(data); }); @@ -195,13 +189,13 @@ $(document).ready(function () { if ($('.directorist-color-field-js').length) { $('.directorist-color-field-js').wpColorPicker().empty(); } - }); // remove the social field and then reset the ids while maintaining position + }); + // remove the social field and then reset the ids while maintaining position $('body').on('click', '.directorist-form-social-fields__remove', function (e) { var id = $(this).data('id'); var elementToRemove = $("div#socialID-".concat(id)); /* Act on the event */ - swal({ title: localized_data.i18n_text.confirmation_text, text: localized_data.i18n_text.ask_conf_sl_lnk_del_txt, @@ -214,8 +208,8 @@ $(document).ready(function () { if (isConfirm) { // user has confirmed, no remove the item and reset the ids elementToRemove.slideUp('fast', function () { - elementToRemove.remove(); // reorder the index - + elementToRemove.remove(); + // reorder the index $('.directorist-form-social-fields').each(function (index, element) { var e = $(element); e.attr('id', "socialID-".concat(index)); @@ -223,8 +217,9 @@ $(document).ready(function () { e.find('.atbdp_social_input').attr('name', "social[".concat(index, "][url]")); e.find('.directorist-form-social-fields__remove').attr('data-id', index); }); - }); // show success message + }); + // show success message swal({ title: localized_data.i18n_text.deleted, // text: "Item has been deleted.", @@ -235,21 +230,20 @@ $(document).ready(function () { } }); }); - /* This function handles all ajax request */ + /* This function handles all ajax request */ function atbdp_do_ajax(ElementToShowLoadingIconAfter, ActionName, arg, CallBackHandler) { var data; if (ActionName) data = "action=".concat(ActionName); if (arg) data = "".concat(arg, "&action=").concat(ActionName); - if (arg && !ActionName) data = arg; // data = data ; + if (arg && !ActionName) data = arg; + // data = data ; var n = data.search(localized_data.nonceName); - if (n < 0) { var nonce = typeof directorist !== 'undefined' ? directorist.directorist_nonce : directorist_admin.directorist_nonce; data = "".concat(data, "&", 'directorist_nonce', "=").concat(nonce); } - jQuery.ajax({ type: 'post', url: localized_data.ajaxurl, @@ -262,14 +256,13 @@ $(document).ready(function () { CallBackHandler(data); } }); - } // Select2 js code - + } + // Select2 js code if (!localized_data.is_admin) { // Location var createLoc = $('#at_biz_dir-location').attr("data-allow_new"); var maxLocationLength = $('#at_biz_dir-location').attr("data-max"); - if (createLoc) { $("#at_biz_dir-location").select2({ tags: true, @@ -288,12 +281,11 @@ $(document).ready(function () { maximumSelectionLength: maxLocationLength, tokenSeparators: [","] }); - } // Tags - + } + // Tags var createTag = $('#at_biz_dir-tags').attr("data-allow_new"); var maxTagLength = $('#at_biz_dir-tags').attr("data-max"); - if (createTag) { $('#at_biz_dir-tags').select2({ tags: true, @@ -306,12 +298,11 @@ $(document).ready(function () { maximumSelectionLength: maxTagLength, tokenSeparators: [','] }); - } //Category - + } + //Category var createCat = $('#at_biz_dir-categories').attr("data-allow_new"); var maxCatLength = $('#at_biz_dir-categories').attr("data-max"); - if (createCat) { $('#at_biz_dir-categories').select2({ allowClear: true, @@ -325,57 +316,60 @@ $(document).ready(function () { allowClear: true }); } - } // price range - - - if ($('.directorist-form-pricing-field').hasClass('price-type-both')) { - $('#price').show(); - $('#price_range').hide(); } - $('.directorist-form-pricing-field__options .directorist-checkbox__label').on('click', function () { - var $this = $(this); - - if ($this.parent('.directorist-checkbox').children('input[type=checkbox]').prop('checked') === true) { - $("#".concat($this.data('option'))).hide(); + /** + * Price field. + */ + function getPriceTypeInput(typeId) { + return $("#".concat($("[for=\"".concat(typeId, "\"]")).data('option'))); + } + $('.directorist-form-pricing-field__options').on('change', 'input', function () { + var $otherOptions = $(this).parent().siblings('.directorist-checkbox').find('input'); + $otherOptions.prop('checked', false); + getPriceTypeInput($otherOptions.attr('id')).hide(); + if (this.checked) { + getPriceTypeInput(this.id).show(); } else { - $("#".concat($this.data('option'))).show(); + getPriceTypeInput(this.id).hide(); } - - var $sibling = $this.parent().siblings('.directorist-checkbox'); - $sibling.children('input[type=checkbox]').prop('checked', false); - $("#".concat($sibling.children('.directorist-checkbox__label').data('option'))).hide(); }); + if ($('.directorist-form-pricing-field').hasClass('price-type-both')) { + $('#price_range, #price').hide(); + var $selectedPriceType = $('.directorist-form-pricing-field__options input:checked'); + if ($selectedPriceType.length) { + getPriceTypeInput($selectedPriceType.attr('id')).show(); + } else { + $($('.directorist-form-pricing-field__options input').get(0)).prop('checked', true).trigger('change'); + } + } var has_tagline = $('#has_tagline').val(); var has_excerpt = $('#has_excerpt').val(); - if (has_excerpt && has_tagline) { $('.atbd_tagline_moto_field').fadeIn(); } else { $('.atbd_tagline_moto_field').fadeOut(); } - $('#atbd_optional_field_check').on('change', function () { $(this).is(':checked') ? $('.atbd_tagline_moto_field').fadeIn() : $('.atbd_tagline_moto_field').fadeOut(); - }); // it shows the hidden term and conditions + }); + // it shows the hidden term and conditions $('#listing_t_c').on('click', function (e) { e.preventDefault(); $('#tc_container').toggleClass('active'); - }); // Load custom fields of the selected category in the custom post type "atbdp_listings" + }); + // Load custom fields of the selected category in the custom post type "atbdp_listings" var qs = function (a) { if (a == '') return {}; var b = {}; - for (var i = 0; i < a.length; ++i) { var p = a[i].split('=', 2); if (p.length == 1) b[p[0]] = '';else b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, ' ')); } - return b; }(window.location.search.substr(1).split('&')); - function render_category_based_fields() { if (directorist.is_admin) { var directory_type = $('select[name="directory_type"]').val(); @@ -383,13 +377,11 @@ $(document).ready(function () { directory_type = directory_type ? directory_type : from_single_directory; var length = $('#at_biz_dir-categorychecklist input:checked'); var id = []; - if (length) { length.each(function (el, index) { id.push($(index).val()); }); } - var post_id = $('#post_ID').val(); } else { var directory_type = $('input[name="directory_type"]').val(); @@ -400,7 +392,6 @@ $(document).ready(function () { }); var post_id = $('input[name="listing_id"]').val(); } - var data = { action: 'atbdp_custom_fields_listings', directorist_nonce: directorist.directorist_nonce, @@ -413,11 +404,9 @@ $(document).ready(function () { $('.atbdp_category_custom_fields').empty(); $.each(response, function (id, content) { var $newMarkup = $(content); - if ($newMarkup.find('.directorist-form-element')[0] !== undefined) { $newMarkup.find('.directorist-form-element')[0].setAttribute('data-id', "".concat(id)); } - if ($($newMarkup[0]).find('.directorist-radio input, .directorist-checkbox input').length) { $($newMarkup[0]).find('.directorist-radio input, .directorist-checkbox input').each(function (i, item) { $(item).attr('id', "directorist-cf-".concat(id, "-").concat(i)); @@ -428,18 +417,15 @@ $(document).ready(function () { $(item).attr('for', "directorist-cf-".concat(id, "-").concat(i)); }); } - $('.atbdp_category_custom_fields').append($newMarkup); }); $('.atbdp_category_custom_fields-wrapper').show(); customFieldSeeMore(); formData.forEach(function (item) { var fieldSingle = document.querySelector("[data-id=\"".concat(item.id, "\"]")); - if (fieldSingle !== null && fieldSingle.classList.contains('directorist-form-element')) { fieldSingle.value = item.value; } - if (fieldSingle !== null && !fieldSingle.classList.contains('directorist-form-element')) { fieldSingle.checked = item.checked; } @@ -449,20 +435,19 @@ $(document).ready(function () { $('.atbdp_category_custom_fields-wrapper').hide(); } }); - } // Create container div after category (in frontend) - + } - $('.directorist-form-categories-field').after('
    '); // Render category based fields in first load + // Create container div after category (in frontend) + $('.directorist-form-categories-field').after('
    '); + // Render category based fields in first load render_category_based_fields(); - /* Store custom fields data */ + /* Store custom fields data */ var formData = []; - function storeCustomFieldsData() { var customFields = document.querySelectorAll(".atbdp_category_custom_fields .directorist-form-element"); var checksField = document.querySelectorAll('.atbdp_category_custom_fields .directorist-form-checks'); - if (customFields.length) { customFields.forEach(function (elm) { var elmValue = elm.value; @@ -473,7 +458,6 @@ $(document).ready(function () { }); }); } - if (checksField.length) { checksField.forEach(function (elm) { var elmChecked = elm.checked; @@ -484,39 +468,33 @@ $(document).ready(function () { }); }); } - } // Render category based fields on category change (frontend) - + } + // Render category based fields on category change (frontend) $('#at_biz_dir-categories').on('change', function () { render_category_based_fields(); storeCustomFieldsData(); - }); // Render category based fields on category change (backend) + }); + // Render category based fields on category change (backend) $('#at_biz_dir-categorychecklist').on('change', function (event) { render_category_based_fields(); storeCustomFieldsData(); }); - function atbdp_element_value(element) { var field = $(element); - if (field.length) { return field.val(); } - return ''; } - var mediaUploaders = []; - if (localized_data.media_uploader) { var _iterator = _createForOfIteratorHelper(localized_data.media_uploader), - _step; - + _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var uploader = _step.value; - if ($('.' + uploader.element_id).length) { var EzUploader = new EzMediaUploader({ containerClass: uploader.element_id @@ -525,7 +503,8 @@ $(document).ready(function () { media_uploader: EzUploader, uploaders_data: uploader }); - EzUploader.init(); // mediaUploaders[i].media_uploader.init(); + EzUploader.init(); + // mediaUploaders[i].media_uploader.init(); } } } catch (err) { @@ -534,14 +513,14 @@ $(document).ready(function () { _iterator.f(); } } - var on_processing = false; var has_media = true; var quick_login_modal__success_callback = null; - var $notification = $('#listing_notifier'); // ----------------------------- + var $notification = $('#listing_notifier'); + + // ----------------------------- // Submit The Form // ----------------------------- - var uploadedImages = []; $('body').on('submit', '#directorist-add-listing-form', function (e) { e.preventDefault(); @@ -549,58 +528,40 @@ $(document).ready(function () { var error_count = 0; var err_log = {}; var $submitButton = $('.directorist-form-submit__btn'); - if (on_processing) { return; } - function disableSubmitButton() { on_processing = true; $submitButton.addClass('atbd_loading').attr('disabled', true); } - function enableSubmitButton() { on_processing = false; $submitButton.removeClass('atbd_loading').attr('disabled', false); - } // images - + } + // images var selectedImages = []; - if (mediaUploaders.length) { - var _iterator2 = _createForOfIteratorHelper(mediaUploaders), - _step2; - - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var uploader = _step2.value; - - if (!uploader.media_uploader || $(uploader.media_uploader.container).parents('form').get(0) !== $form.get(0)) { - continue; - } - - if (!uploader.media_uploader.hasValidFiles()) { - $submitButton.removeClass('atbd_loading'); - err_log.listing_gallery = { - msg: uploader.uploaders_data['error_msg'] - }; - error_count++; - scrollTo('.' + uploader.uploaders_data.element_id); - break; - } - - selectedImages = uploader.media_uploader.getTheFiles(); + for (var _i = 0, _mediaUploaders = mediaUploaders; _i < _mediaUploaders.length; _i++) { + var uploader = _mediaUploaders[_i]; + if (!uploader.media_uploader || $(uploader.media_uploader.container).parents('form').get(0) !== $form.get(0)) { + continue; } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); + if (!uploader.media_uploader.hasValidFiles()) { + $submitButton.removeClass('atbd_loading'); + err_log.listing_gallery = { + msg: uploader.uploaders_data['error_msg'] + }; + error_count++; + scrollTo('.' + uploader.uploaders_data.element_id); + break; + } + selectedImages = uploader.media_uploader.getTheFiles(); } } - if (selectedImages.length) { var counter = 0; - function uploadImage() { var formData = new FormData(); formData.append('action', 'directorist_upload_listing_image'); @@ -615,7 +576,6 @@ $(document).ready(function () { beforeSend: function beforeSend() { disableSubmitButton(); var totalImages = selectedImages.length; - if (totalImages === 1) { $notification.show().html("".concat(localized_data.i18n_text.image_uploading_msg, "")); } else { @@ -629,10 +589,8 @@ $(document).ready(function () { $notification.show().html("".concat(response.data, "")); return; } - uploadedImages.push(response.data); counter++; - if (counter < selectedImages.length) { uploadImage(); } else { @@ -645,7 +603,6 @@ $(document).ready(function () { } }); } - if (uploadedImages.length === selectedImages.length) { submitForm($form, uploadedImages); } else { @@ -654,7 +611,6 @@ $(document).ready(function () { } else { submitForm($form); } - function submitForm($form) { var uploadedImages = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var error_count = 0; @@ -664,98 +620,77 @@ $(document).ready(function () { form_data.append('directorist_nonce', directorist.directorist_nonce); form_data.append('listing_img', uploadedImages); disableSubmitButton(); - var fieldValuePairs = $form.serializeArray(); // Append Form Fields Values - - var _iterator3 = _createForOfIteratorHelper(fieldValuePairs), - _step3; + var fieldValuePairs = $form.serializeArray(); + // Append Form Fields Values + var _iterator2 = _createForOfIteratorHelper(fieldValuePairs), + _step2; try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var field = _step3.value; + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var field = _step2.value; form_data.append(field.name, field.value); - } //images + } + //images } catch (err) { - _iterator3.e(err); + _iterator2.e(err); } finally { - _iterator3.f(); + _iterator2.f(); } - if (mediaUploaders.length) { - var _iterator4 = _createForOfIteratorHelper(mediaUploaders), - _step4; - - try { - for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { - var uploader = _step4.value; - - if (!uploader.media_uploader || $(uploader.media_uploader.container).parents('form').get(0) !== $form.get(0)) { - continue; - } - - if (uploader.media_uploader.hasValidFiles()) { - var files_meta = uploader.media_uploader.getFilesMeta(); - - if (files_meta) { - for (var i = 0; i < files_meta.length; i++) { - form_data.append("listing_img_old[".concat(i, "]"), files_meta[i].attachmentID); - } - } - } else { - err_log.listing_gallery = { - msg: uploader.uploaders_data['error_msg'] - }; - error_count++; - - if ($('.' + uploader.uploaders_data.element_id).length) { - scrollTo('.' + uploader.uploaders_data.element_id); + for (var _i2 = 0, _mediaUploaders2 = mediaUploaders; _i2 < _mediaUploaders2.length; _i2++) { + var uploader = _mediaUploaders2[_i2]; + if (!uploader.media_uploader || $(uploader.media_uploader.container).parents('form').get(0) !== $form.get(0)) { + continue; + } + if (uploader.media_uploader.hasValidFiles()) { + var files_meta = uploader.media_uploader.getFilesMeta(); + if (files_meta) { + for (var i = 0; i < files_meta.length; i++) { + form_data.append("listing_img_old[".concat(i, "]"), files_meta[i].attachmentID); } } + } else { + err_log.listing_gallery = { + msg: uploader.uploaders_data['error_msg'] + }; + error_count++; + if ($('.' + uploader.uploaders_data.element_id).length) { + scrollTo('.' + uploader.uploaders_data.element_id); + } } - } catch (err) { - _iterator4.e(err); - } finally { - _iterator4.f(); } - } // categories - + } + // categories var categories = $form.find('#at_biz_dir-categories').val(); - if (Array.isArray(categories) && categories.length) { for (var key in categories) { form_data.append('tax_input[at_biz_dir-category][]', categories[key]); } } - if (typeof categories === 'string') { form_data.append('tax_input[at_biz_dir-category][]', categories); } - if (form_data.has('admin_category_select[]')) { form_data.delete('admin_category_select[]'); } - if (form_data.has('directory_type')) { form_data.delete('directory_type'); } - var form_directory_type = $form.find("input[name='directory_type']"); var form_directory_type_value = form_directory_type !== undefined ? form_directory_type.val() : ''; var directory_type = qs.directory_type ? qs.directory_type : form_directory_type_value; form_data.append('directory_type', directory_type); - if (qs.plan) { form_data.append('plan_id', qs.plan); } - if (error_count) { enableSubmitButton(); console.log('Form has invalid data'); console.log(error_count, err_log); return; } - $.ajax({ method: 'POST', processData: false, @@ -769,23 +704,23 @@ $(document).ready(function () { success: function success(response) { var redirect_url = response && response.redirect_url ? response.redirect_url : ''; redirect_url = redirect_url && typeof redirect_url === 'string' ? response.redirect_url.replace(/:\/\//g, '%3A%2F%2F') : ''; - if (response.error === true) { enableSubmitButton(); $notification.show().html("".concat(response.error_msg, "")); - if (response.quick_login_required) { var modal = $('#directorist-quick-login'); - var email = response.email; // Prepare fields + var email = response.email; + // Prepare fields modal.find('input[name="email"]').val(email); - modal.find('input[name="email"]').prop('disabled', true); // Show alert + modal.find('input[name="email"]').prop('disabled', true); + // Show alert var alert = '
    ' + response.error_msg + '
    '; - modal.find('.directorist-modal-alerts-area').html(alert); // Show the modal + modal.find('.directorist-modal-alerts-area').html(alert); + // Show the modal modal.addClass('show'); - quick_login_modal__success_callback = function quick_login_modal__success_callback(args) { $('#guest_user_email').prop('disabled', true); $notification.hide().html(''); @@ -802,19 +737,17 @@ $(document).ready(function () { window.location.href = joinQueryString(response.preview_url, "preview=1&redirect=".concat(redirect_url)); } else { $notification.show().html("".concat(response.success_msg, "")); - if (qs.redirect) { window.location.href = joinQueryString(response.preview_url, "post_id=".concat(response.id, "&preview=1&payment=1&edited=1&redirect=").concat(qs.redirect)); } else { window.location.href = joinQueryString(response.preview_url, "preview=1&edited=1&redirect=".concat(redirect_url)); } - } // preview mode active and need payment - + } + // preview mode active and need payment } else if (response.preview_mode === true && response.need_payment === true) { window.location.href = joinQueryString(response.preview_url, "preview=1&payment=1&redirect=".concat(redirect_url)); } else { var is_edited = response.edited_listing ? "listing_id=".concat(response.id, "&edited=1") : ''; - if (response.need_payment === true) { $notification.show().html("".concat(response.success_msg, "")); window.location.href = decodeURIComponent(redirect_url); @@ -831,22 +764,21 @@ $(document).ready(function () { } }); } - }); // Custom Field Checkbox Button More + }); + // Custom Field Checkbox Button More function customFieldSeeMore() { if ($('.directorist-custom-field-btn-more').length) { $('.directorist-custom-field-btn-more').each(function (index, element) { var fieldWrapper = $(element).closest('.directorist-custom-field-checkbox, .directorist-custom-field-radio'); var customField = $(fieldWrapper).find('.directorist-checkbox, .directorist-radio'); $(customField).slice(20, customField.length).hide(); - if (customField.length <= 20) { $(element).hide(); } }); } } - $(window).on('load', function () { customFieldSeeMore(); }); @@ -856,7 +788,6 @@ $(document).ready(function () { var customField = $(fieldWrapper).find('.directorist-checkbox, .directorist-radio'); $(customField).slice(20, customField.length).slideUp(); $(this).toggleClass('active'); - if ($(this).hasClass('active')) { $(this).text(localized_data.i18n_text.see_less_text); $(customField).slice(20, customField.length).slideDown(); @@ -864,10 +795,11 @@ $(document).ready(function () { $(this).text(localized_data.i18n_text.see_more_text); $(customField).slice(20, customField.length).slideUp(); } - }); // ------------------------------ + }); + + // ------------------------------ // Quick Login // ------------------------------ - $('#directorist-quick-login .directorist-toggle-modal').on("click", function (e) { e.preventDefault(); $("#directorist-quick-login").removeClass("show"); @@ -882,14 +814,12 @@ $(document).ready(function () { var email = $(form).find('input[name="email"]'); var password = $(form).find('input[name="password"]'); var security = $(form).find('input[name="directorist-quick-login-security"]'); - var form_data = _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({ action: 'directorist_ajax_quick_login', username: email.val(), password: password.val(), rememberme: false }, 'directorist-quick-login-security', security.val()); - var submit_button = $(this); var submit_button_default_html = submit_button.html(); $.ajax({ @@ -903,13 +833,11 @@ $(document).ready(function () { }, success: function success(response) { submit_button.html(submit_button_default_html); - if (response.loggedin) { password.prop('disabled', true); var message = 'Successfully logged in, please continue to the listing submission'; var msg = '
    ' + message + '
    '; form_feedback.html(msg); - if (quick_login_modal__success_callback) { var args = { elements: { @@ -949,52 +877,44 @@ $(document).ready(function () { /***/ (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; } - +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 - +} +// Initialize function init() { // Add custom dropdown toggle button - selec2_add_custom_dropdown_toggle_button(); // Add custom close button where needed + selec2_add_custom_dropdown_toggle_button(); - selec2_add_custom_close_button_if_needed(); // Add custom close button if field contains value on change + // 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'; @@ -1002,9 +922,9 @@ function selec2_add_custom_dropdown_toggle_button() { var dropdownHTML = "".concat(iconHTML, ""); addon_container.append(dropdownHTML); } + var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); - var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); // Toggle --is-open class - + // 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'); @@ -1012,41 +932,36 @@ function selec2_add_custom_dropdown_toggle_button() { $('.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 + }); + // 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 + }); + // 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; - + _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) { @@ -1055,21 +970,20 @@ function selec2_add_custom_close_button_if_needed() { _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 + // 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("".concat(iconHTML, "")); @@ -1079,56 +993,46 @@ function selec2_add_custom_close_button(field) { field.val(null).trigger('change'); addon_container.find('.directorist-select2-dropdown-close').remove(); selec2_adjust_space_for_addons(); - }); // 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 + // 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(''); 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(''); 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' @@ -1155,18 +1059,16 @@ __webpack_require__.r(__webpack_exports__); /* 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; } - +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } 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 +document.body.addEventListener('directorist-reload-select2-fields', initSelect2); +// Init Static Select 2 Fields function initSelect2() { var select_fields = [{ elm: $('.directorist-select').find('select') @@ -1192,7 +1094,8 @@ function initSelect2() { elm: $('#directorist-select-fr-s-js') }, { elm: $('#directorist-select-fr-e-js') - }, // { elm: $('#directorist-location-select') }, + }, + // { elm: $('#directorist-location-select') }, // { elm: $('#directorist-category-select') }, { elm: $('.select-basic') @@ -1200,30 +1103,33 @@ function initSelect2() { elm: $('#loc-type') }, { elm: $('.bdas-location-search') - }, // { elm: $('.directorist-location-select') }, + }, + // { elm: $('.directorist-location-select') }, { elm: $('#at_biz_dir-category') }, { elm: $('#cat-type') }, { elm: $('.bdas-category-search') - } // { elm: $('.directorist-category-select') }, + } + // { 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 - +} +// Init Select2 Ajax Fields function initSelect2AjaxFields() { - var rest_base_url = "".concat(directorist.rest_url, "directorist/v1"); // Init Select2 Ajax Category Field + 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") @@ -1231,8 +1137,9 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-categories-field').find('select'), url: "".concat(rest_base_url, "/listings/categories") - }); // Init Select2 Ajax Location Field + }); + // Init Select2 Ajax Location Field initSelect2AjaxTaxonomy({ selector: $('.directorist-search-location').find('select'), url: "".concat(rest_base_url, "/listings/locations") @@ -1240,17 +1147,18 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-location-field').find('select'), url: "".concat(rest_base_url, "/listings/locations") - }); // Init Select2 Ajax Tag Field + }); + // Init Select2 Ajax Tag Field initSelect2AjaxTaxonomy({ selector: $('.directorist-form-tag-field').find('select'), url: "".concat(rest_base_url, "/listings/tags") }, { has_directory_type: false }); -} // initSelect2AjaxTaxonomy - +} +// initSelect2AjaxTaxonomy function initSelect2AjaxTaxonomy(args, terms_options) { var defaultArgs = { selector: '', @@ -1262,46 +1170,42 @@ function initSelect2AjaxTaxonomy(args, terms_options) { has_directory_type: true }; terms_options = terms_options ? _objectSpread(_objectSpread({}, default_terms_options), terms_options) : default_terms_options; - 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 createNew = item.getAttribute("data-allow_new"); var maxLength = item.getAttribute("data-max"); - if (terms_options.has_directory_type) { var search_form_parent = $(item).closest('.directorist-search-form'); var archive_page_parent = $(item).closest('.directorist-archive-contents'); var add_listing_form_hidden_input = $(item).closest('.directorist-add-listing-form').find('input[name="directory_type"]'); - var nav_list_item = []; // If search page + 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 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 has nav item if (nav_list_item.length) { directory_type_id = nav_list_item ? nav_list_item.data('listing_type_id') : 0; - } // If has nav item - + } + // If has nav item if (add_listing_form_hidden_input.length) { directory_type_id = add_listing_form_hidden_input.val(); } - if (directory_type_id) { directory_type_id = parseInt(directory_type_id); } } - var currentPage = 1; $(item).select2({ allowClear: true, @@ -1323,11 +1227,9 @@ function initSelect2AjaxTaxonomy(args, terms_options) { page: currentPage, per_page: args.perPage }; - if (directory_type_id) { query.directory = directory_type_id; } - return query; }, processResults: function processResults(data) { @@ -1358,16 +1260,15 @@ function initSelect2AjaxTaxonomy(args, terms_options) { return $request; } } - }); // Setup Preselected Option + }); + // Setup Preselected Option var selected_item_id = $(item).data('selected-id'); var selected_item_label = $(item).data('selected-label'); - var setup_selected_items = function setup_selected_items(element, selected_id, selected_label) { if (!element || !selected_id) { return; } - var selected_ids = "".concat(selected_id).split(','); var selected_labels = selected_label ? "".concat(selected_label).split(',') : []; selected_ids.forEach(function (id, index) { @@ -1385,7 +1286,6 @@ function initSelect2AjaxTaxonomy(args, terms_options) { }); }); }; - setup_selected_items(item, selected_item_id, selected_item_label); }); } @@ -1410,18 +1310,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -1434,24 +1330,19 @@ function get_dom_data(key, parent) { 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, @@ -1461,7 +1352,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -1472,17 +1362,14 @@ function convertToSelect2(field) { 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": @@ -1500,7 +1387,6 @@ function convertToSelect2(field) { } else { return; } - $(document).ready(function () { /* Initialize wp color picker */ function colorPickerInit() { @@ -1512,10 +1398,8 @@ function convertToSelect2(field) { } }); } - colorPickerInit(); /* Initialize on Directory type change */ - document.body.addEventListener('directorist-search-form-nav-tab-reloaded', colorPickerInit); }); })(jQuery); @@ -1530,7 +1414,6 @@ function convertToSelect2(field) { /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_dropdown_executed === 'undefined') { @@ -1538,19 +1421,17 @@ function convertToSelect2(field) { } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* custom dropdown */ - var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); // toggle dropdown + var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); + // toggle dropdown var clickCount = 0; - if (atbdDropdown !== null) { atbdDropdown.forEach(function (el) { el.querySelector('.directorist-dropdown-select-toggle').addEventListener('click', function (e) { e.preventDefault(); clickCount++; - if (clickCount % 2 === 1) { document.querySelectorAll('.directorist-dropdown-select-items').forEach(function (elem) { elem.classList.remove('directorist-dropdown-select-show'); @@ -1563,9 +1444,9 @@ function convertToSelect2(field) { } }); }); - } // remvoe toggle when click outside - + } + // remvoe toggle when click outside document.body.addEventListener('click', function (e) { if (e.target.getAttribute('data-drop-toggle') !== 'directorist-dropdown-select-toggle') { clickCount = 0; @@ -1573,10 +1454,10 @@ function convertToSelect2(field) { el.classList.remove('directorist-dropdown-select-show'); }); } - }); //custom select + }); + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.directorist-dropdown-select-items').forEach(function (item) { @@ -1590,27 +1471,30 @@ function convertToSelect2(field) { }); }); }); - } // Dropdown - + } + // Dropdown $('body').on('click', '.directorist-dropdown .directorist-dropdown-toggle', function (e) { e.preventDefault(); $(this).siblings('.directorist-dropdown-option').toggle(); - }); // Select Option after click + }); + // Select Option after click $('body').on('click', '.directorist-dropdown .directorist-dropdown-option ul li a', function (e) { e.preventDefault(); var optionText = $(this).html(); $(this).children('.directorist-dropdown-toggle__text').html(optionText); $(this).closest('.directorist-dropdown-option').siblings('.directorist-dropdown-toggle').children('.directorist-dropdown-toggle__text').html(optionText); $('.directorist-dropdown-option').hide(); - }); // Hide Clicked Anywhere + }); + // Hide Clicked Anywhere $(document).bind('click', function (e) { var clickedDom = $(e.target); if (!clickedDom.parents().hasClass('directorist-dropdown')) $('.directorist-dropdown-option').hide(); - }); //atbd_dropdown + }); + //atbd_dropdown $(document).on("click", '.atbd_dropdown', function (e) { if ($(this).attr("class") === "atbd_dropdown") { e.preventDefault(); @@ -1626,15 +1510,14 @@ function convertToSelect2(field) { }); $('body').on('click', '.atbd_dropdown-toggle', function (e) { e.preventDefault(); - }); // Directorist Dropdown + }); + // Directorist Dropdown $('body').on('click', '.directorist-dropdown-js .directorist-dropdown__toggle-js', function (e) { e.preventDefault(); - if (!$(this).siblings('.directorist-dropdown__links-js').is(':visible')) { $('.directorist-dropdown__links').hide(); } - $(this).siblings('.directorist-dropdown__links-js').toggle(); }); $('body').on('click', function (e) { @@ -1660,11 +1543,9 @@ window.addEventListener('DOMContentLoaded', function () { window.directorist_select_executed = true; } else { return; - } //custom select - - + } + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -1678,9 +1559,9 @@ window.addEventListener('DOMContentLoaded', function () { }); }); }); - } // select data-status - + } + // select data-status var atbdSelectData = document.querySelectorAll('.atbd-drop-select.with-sort'); atbdSelectData.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -1704,14 +1585,9 @@ window.addEventListener('DOMContentLoaded', function () { 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]; - } - + 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; /***/ }), @@ -1724,11 +1600,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -1738,9 +1612,11 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! \***************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperty(obj, key, value) { + key = toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, @@ -1751,10 +1627,8 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } - module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -1769,7 +1643,6 @@ module.exports = _defineProperty, module.exports.__esModule = true, module.expor 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; /***/ }), @@ -1784,7 +1657,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -1797,21 +1669,55 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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/toPrimitive.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPropertyKey.js": +/*!**************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js"); +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} +module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + /***/ "./node_modules/@babel/runtime/helpers/typeof.js": /*!*******************************************************!*\ !*** ./node_modules/@babel/runtime/helpers/typeof.js ***! @@ -1819,16 +1725,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -1841,7 +1746,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -1850,7 +1754,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/admin-builder-archive.js b/assets/js/admin-builder-archive.js index 45c77658f2..102e2e4d5c 100644 --- a/assets/js/admin-builder-archive.js +++ b/assets/js/admin-builder-archive.js @@ -94,14 +94,16 @@ /***/ (function(module, exports) { window.addEventListener('DOMContentLoaded', function () { - var $ = jQuery; // Open Delete Modal + var $ = jQuery; + // Open Delete Modal $('.atbdp-directory-delete-link-action').on('click', function (e) { e.preventDefault(); var delete_link = $(this).data('delete-link'); $('.atbdp-directory-delete-link').prop('href', delete_link); - }); // Delete Action + }); + // Delete Action $('.atbdp-directory-delete-link').on('click', function (e) { // e.preventDefault(); $(this).prepend(' '); @@ -121,10 +123,9 @@ window.addEventListener('DOMContentLoaded', function () { window.addEventListener('DOMContentLoaded', function () { var $ = jQuery; + var axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js").default; - var axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js").default; // Migration Link - - + // Migration Link $('.atbdp-directory-migration-link').on('click', function (e) { e.preventDefault(); var self = this; @@ -133,38 +134,37 @@ window.addEventListener('DOMContentLoaded', function () { $(this).html(' Migrating'); $(this).addClass('atbdp-disabled'); var form_data = new FormData(); - form_data.append('action', 'directorist_force_migrate'); // Response Success Callback + form_data.append('action', 'directorist_force_migrate'); + // Response Success Callback var responseSuccessCallback = function responseSuccessCallback(response) { var _response$data; - // console.log( { response } ); + if (response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.success) { var _response$data$messag, _response$data2; - - var msg = (_response$data$messag = response === null || response === void 0 ? void 0 : (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.message) !== null && _response$data$messag !== void 0 ? _response$data$messag : 'Migration Successful'; + var msg = (_response$data$messag = response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.message) !== null && _response$data$messag !== void 0 ? _response$data$messag : 'Migration Successful'; var alert_content = "\n
    \n
    \n \n
    \n\n
    ".concat(msg, "
    \n
    \n "); $('.cptm-directory-migration-form').find('.cptm-comfirmation-text').html(alert_content); $(self).remove(); location.reload(); return; } - responseFaildCallback(response); - }; // Response Error Callback - + }; + // Response Error Callback var responseFaildCallback = function responseFaildCallback(response) { var _response$data$messag2, _response$data3; - // console.log( { response } ); - var msg = (_response$data$messag2 = response === null || response === void 0 ? void 0 : (_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : _response$data3.message) !== null && _response$data$messag2 !== void 0 ? _response$data$messag2 : 'Something went wrong please try again'; + + var msg = (_response$data$messag2 = response === null || response === void 0 || (_response$data3 = response.data) === null || _response$data3 === void 0 ? void 0 : _response$data3.message) !== null && _response$data$messag2 !== void 0 ? _response$data$messag2 : 'Something went wrong please try again'; var alert_content = "\n
    \n
    \n \n
    \n\n
    ".concat(msg, "
    \n
    \n "); $('.cptm-directory-migration-form').find('.cptm-comfirmation-text').html(alert_content); $(self).remove(); - }; // Send Request - + }; + // Send Request axios.post(directorist_admin.ajax_url, form_data).then(function (response) { responseSuccessCallback(response); }).catch(function (response) { @@ -183,16 +183,13 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports, __webpack_require__) { 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; } - +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; } window.addEventListener('DOMContentLoaded', function () { var axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js").default; + var $ = jQuery; - var $ = jQuery; // cptm-import-directory-form - + // cptm-import-directory-form var term_id = 0; $('.cptm-import-directory-form').on('submit', function (e) { e.preventDefault(); @@ -202,32 +199,27 @@ window.addEventListener('DOMContentLoaded', function () { var form_data = new FormData(); form_data.append('action', 'save_imported_post_type_data'); form_data.append('directorist_nonce', directorist_admin.directorist_nonce); - if (Number.isInteger(term_id) && term_id > 0) { form_data.append('term_id', term_id); } - var form_fields = $(this).find('.cptm-form-field'); var general_fields = ['text', 'number']; $(this).find('button[type=submit] .cptm-loading-icon').removeClass('cptm-d-none'); - var _iterator = _createForOfIteratorHelper(form_fields), - _step; - + _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var field = _step.value; - if (!field.name.length) { continue; - } // General fields - + } + // General fields if (general_fields.includes(field.type)) { form_data.append(field.name, $(field).val()); - } // Media fields - + } + // Media fields if ('file' === field.type) { form_data.append(field.name, field.files[0]); } @@ -237,30 +229,31 @@ window.addEventListener('DOMContentLoaded', function () { } finally { _iterator.f(); } - var self = this; form_feedback.html(''); axios.post(directorist_admin.ajax_url, form_data).then(function (response) { // console.log( { response } ); - $(self).find('button[type=submit] .cptm-loading-icon').addClass('cptm-d-none'); // Store term ID if exist + $(self).find('button[type=submit] .cptm-loading-icon').addClass('cptm-d-none'); + // Store term ID if exist if (response.data.term_id && Number.isInteger(response.data.term_id) && response.data.term_id > 0) { - term_id = response.data.term_id; // console.log( 'Term ID has been updated' ); - } // Show status log - + term_id = response.data.term_id; + // console.log( 'Term ID has been updated' ); + } + // Show status log if (response.data && response.data.status.status_log) { var status_log = response.data.status.status_log; - for (var status in status_log) { var alert = '
    ' + status_log[status].message + '
    '; form_feedback.append(alert); } - } // Reload the page if success - + } + // Reload the page if success if (response.data && response.data.status && response.data.status.success) { // console.log( 'reloading...' ); + modal_content.addClass('cptm-d-none'); modal_alert.removeClass('cptm-d-none'); $(self).trigger("reset"); diff --git a/assets/js/admin-custom-field.js b/assets/js/admin-custom-field.js index ffaca73077..d2b08c14c0 100644 --- a/assets/js/admin-custom-field.js +++ b/assets/js/admin-custom-field.js @@ -117,7 +117,6 @@ window.addEventListener('DOMContentLoaded', function () { }); } }); - var fixHelper = function fixHelper(e, ui) { ui.children().children().each(function () { $(this).width($(this).width()); diff --git a/assets/js/admin-import-export.js b/assets/js/admin-import-export.js index 558ddae9c0..c91accd3e0 100644 --- a/assets/js/admin-import-export.js +++ b/assets/js/admin-import-export.js @@ -102,19 +102,15 @@ jQuery(document).ready(function ($) { var query_string = function (a) { if (a == '') return {}; var b = {}; - for (var i = 0; i < a.length; ++i) { var p = a[i].split('=', 2); if (p.length == 1) b[p[0]] = '';else b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, ' ')); } - return b; }(window.location.search.substr(1).split('&')); - $('body').on('change', '.directorist_directory_type_in_import', function () { admin_listing_form($(this).val()); }); - function admin_listing_form(directory_type) { var file_id = query_string.file_id; var delimiter = query_string.delimiter; @@ -138,7 +134,6 @@ jQuery(document).ready(function ($) { }); return; } - $('.atbdp-importer-mapping-table').remove(); $('.directory_type_wrapper').after(response); }, @@ -147,10 +142,8 @@ jQuery(document).ready(function ($) { } }); } - $('#atbdp_ie_download_sample').on('click', function (e) { var ie_file = $(this).attr('data-sample-csv'); - if (ie_file) { window.location.href = ie_file; return false; @@ -169,14 +162,15 @@ jQuery(document).ready(function ($) { var imported = 0; var configFields = $('.directorist-listings-importer-config-field'); var counter = 0; - var run_import = function run_import() { - var form_data = new FormData(); // ajax action + var form_data = new FormData(); + // ajax action form_data.append('action', 'atbdp_import_listing'); form_data.append('position', position); - form_data.append('directorist_nonce', directorist_admin.directorist_nonce); // Get Config Fields Value + form_data.append('directorist_nonce', directorist_admin.directorist_nonce); + // Get Config Fields Value if (configFields.length) { configFields.each(function (index, item) { var key = $(item).attr('name'); @@ -184,23 +178,17 @@ jQuery(document).ready(function ($) { form_data.append(key, value); }); } - var map_elm = null; - if ($('select.atbdp_map_to').length) { map_elm = $('select.atbdp_map_to'); } - if ($('input.atbdp_map_to').length) { map_elm = $('input.atbdp_map_to'); } - var directory_type = $('#directory_type').val(); - if (directory_type) { form_data.append('directory_type', directory_type); } - if (map_elm) { var log = []; map_elm.each(function () { @@ -208,7 +196,6 @@ jQuery(document).ready(function ($) { var value = $(this).val(); var postFields = ['listing_status', 'listing_title', 'listing_content', 'listing_img', 'directory_type']; var taxonomyFields = ['category', 'location', 'tag']; - if (postFields.includes(value)) { form_data.append(value, name); log.push(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()({}, value, name)); @@ -221,7 +208,6 @@ jQuery(document).ready(function ($) { } }); } - $.ajax({ method: 'POST', processData: false, @@ -236,12 +222,10 @@ jQuery(document).ready(function ($) { }); return; } - imported += response.imported; failed += response.failed; $('.importer-details').html("Imported ".concat(response.next_position, " out of ").concat(response.total)); $('.directorist-importer-progress').val(response.percentage); - if (response.percentage != '100') { position = response.next_position; run_import(); @@ -249,7 +233,6 @@ jQuery(document).ready(function ($) { } else { window.location = "".concat(response.url, "&listing-imported=").concat(imported, "&listing-failed=").concat(failed); } - $('.directorist-importer-length').css('width', response.percentage + '%'); }, error: function error(response) { @@ -257,11 +240,9 @@ jQuery(document).ready(function ($) { } }); }; - run_import(); }); /* csv upload */ - $('#upload').change(function (e) { var filename = e.target.files[0].name; $('.csv-upload .file-name').html(filename); @@ -275,9 +256,11 @@ jQuery(document).ready(function ($) { !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! \***************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperty(obj, key, value) { + key = toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, @@ -288,12 +271,69 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } - module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPrimitive.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPropertyKey.js": +/*!**************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js"); +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} +module.exports = _toPropertyKey, 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(o) { + "@babel/helpers - typeof"; + + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); +} +module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; + /***/ }) /******/ }); diff --git a/assets/js/admin-main.js b/assets/js/admin-main.js index 551393b586..2b79d52f82 100644 --- a/assets/js/admin-main.js +++ b/assets/js/admin-main.js @@ -112,19 +112,22 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _components_admin_user__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_components_admin_user__WEBPACK_IMPORTED_MODULE_7__); /* harmony import */ var _components_subscriptionManagement__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./components/subscriptionManagement */ "./assets/src/js/admin/components/subscriptionManagement.js"); /* harmony import */ var _components_subscriptionManagement__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_components_subscriptionManagement__WEBPACK_IMPORTED_MODULE_8__); - // Global - // Blocks +// Global +// Blocks - // subscriptionManagement + +// subscriptionManagement + + /***/ }), /***/ "./assets/src/js/admin/components/admin-user.js": @@ -195,34 +198,31 @@ __webpack_require__.r(__webpack_exports__); window.addEventListener('DOMContentLoaded', function () { var $ = jQuery; - var content = ''; // Category icon selection + var content = ''; + // Category icon selection function selecWithIcon(selected) { if (!selected.id) { return selected.text; } - var $elem = $(" ").concat(selected.text, "")); return $elem; } - if ($("[data-toggle='tooltip']").length) { $("[data-toggle='tooltip']").tooltip(); - } // price range - + } + // price range var pricerange = $('#pricerange_val').val(); - if (pricerange) { $('#pricerange').fadeIn(100); } - $('#price_range_option').on('click', function () { $('#pricerange').fadeIn(500); - }); // enable sorting if only the container has any social or skill field + }); + // enable sorting if only the container has any social or skill field var $s_wrap = $('#social_info_sortable_container'); // cache it - if (window.outerWidth > 1700) { if ($s_wrap.length) { $s_wrap.sortable({ @@ -230,9 +230,9 @@ window.addEventListener('DOMContentLoaded', function () { opacity: '0.7' }); } - } // SOCIAL SECTION + } + // SOCIAL SECTION // Rearrange the IDS and Add new social field - /* $('body').on('click', '#addNewSocial', function () { const social_wrap = $('#social_info_sortable_container'); // cache it const currentItems = $('.directorist-form-social-fields').length; @@ -251,15 +251,13 @@ window.addEventListener('DOMContentLoaded', function () { //social_wrap.append(data); }); }); */ - // remove the social field and then reset the ids while maintaining position - + // remove the social field and then reset the ids while maintaining position $(document).on('click', '.directorist-form-social-fields__remove', function (e) { var id = $(this).data('id'); var elementToRemove = $("div#socialID-".concat(id)); e.preventDefault(); /* Act on the event */ - swal({ title: directorist_admin.i18n_text.confirmation_text, text: directorist_admin.i18n_text.ask_conf_sl_lnk_del_txt, @@ -272,8 +270,8 @@ window.addEventListener('DOMContentLoaded', function () { if (isConfirm) { // user has confirmed, no remove the item and reset the ids elementToRemove.slideUp('fast', function () { - elementToRemove.remove(); // reorder the index - + elementToRemove.remove(); + // reorder the index $('.directorist-form-social-fields').each(function (index, element) { var e = $(element); e.attr('id', "socialID-".concat(index)); @@ -281,8 +279,9 @@ window.addEventListener('DOMContentLoaded', function () { e.find('.atbdp_social_input').attr('name', "social[".concat(index, "][url]")); e.find('.directorist-form-social-fields__remove').attr('data-id', index); }); - }); // show success message + }); + // show success message swal({ title: directorist_admin.i18n_text.deleted, // text: "Item has been deleted.", @@ -292,26 +291,28 @@ window.addEventListener('DOMContentLoaded', function () { }); } }); - }); // upgrade old listing + }); + // upgrade old listing $('#upgrade_directorist').on('click', function (event) { event.preventDefault(); - var $this = $(this); // display a notice to user to wait + var $this = $(this); + // display a notice to user to wait // send an ajax request to the back end - atbdp_do_ajax($this, 'atbdp_upgrade_old_listings', null, function (response) { if (response.success) { $this.after("

    ".concat(response.data, "

    ")); } }); - }); // upgrade old pages + }); + // upgrade old pages $('#shortcode-updated input[name="shortcode-updated"]').on('change', function (event) { event.preventDefault(); $('#success_msg').hide(); - var $this = $(this); // display a notice to user to wait + var $this = $(this); + // display a notice to user to wait // send an ajax request to the back end - atbdp_do_ajax($this, 'atbdp_upgrade_old_pages', null, function (response) { if (response.success) { $('#shortcode-updated').after("

    ".concat(response.data, "

    ")); @@ -320,26 +321,26 @@ window.addEventListener('DOMContentLoaded', function () { $('.atbdp_ajax_loading').css({ display: 'none' }); - }); // redirect to import import_page_link + }); + // redirect to import import_page_link $('#csv_import input[name="csv_import"]').on('change', function (event) { event.preventDefault(); window.location = directorist_admin.import_page_link; }); - /* This function handles all ajax request */ + /* This function handles all ajax request */ function atbdp_do_ajax(ElementToShowLoadingIconAfter, ActionName, arg, CallBackHandler) { var data; if (ActionName) data = "action=".concat(ActionName); if (arg) data = "".concat(arg, "&action=").concat(ActionName); - if (arg && !ActionName) data = arg; // data = data ; + if (arg && !ActionName) data = arg; + // data = data ; var n = data.search(directorist_admin.nonceName); - if (n < 0) { data = "".concat(data, "&").concat(directorist_admin.nonceName, "=").concat(directorist_admin.nonce); } - jQuery.ajax({ type: 'post', url: directorist_admin.ajaxurl, @@ -365,23 +366,20 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { window.addEventListener('DOMContentLoaded', function () { - var $ = jQuery; // Set all variables to be used in scope - + var $ = jQuery; + // Set all variables to be used in scope var has_tagline = $('#has_tagline').val(); var has_excerpt = $('#has_excerpt').val(); - if (has_excerpt && has_tagline) { $('.atbd_tagline_moto_field').fadeIn(); } else { $('.atbd_tagline_moto_field').fadeOut(); } - $('#atbd_optional_field_check').on('change', function () { $(this).is(':checked') ? $('.atbd_tagline_moto_field').fadeIn() : $('.atbd_tagline_moto_field').fadeOut(); }); var avg_review = $('#average_review_for_popular').hide(); var logged_count = $('#views_for_popular').hide(); - if ($('#listing_popular_by select[name="listing_popular_by"]').val() === 'average_rating') { avg_review.show(); logged_count.hide(); @@ -392,7 +390,6 @@ window.addEventListener('DOMContentLoaded', function () { avg_review.show(); logged_count.show(); } - $('#listing_popular_by select[name="listing_popular_by"]').on('change', function () { if ($(this).val() === 'average_rating') { avg_review.show(); @@ -405,6 +402,7 @@ window.addEventListener('DOMContentLoaded', function () { logged_count.show(); } }); + /* // Display the media uploader when "Upload Image" button clicked in the custom taxonomy "atbdp_categories" (function ($) { "use strict"; @@ -429,11 +427,9 @@ window.addEventListener('DOMContentLoaded', function () { templateResult: selecWithIcon, }); /* Show and hide manual coordinate input field */ - if (!$('input#manual_coordinate').is(':checked')) { $('.directorist-map-coordinates').hide(); } - $('#manual_coordinate').on('click', function (e) { if ($('input#manual_coordinate').is(':checked')) { $('.directorist-map-coordinates').show(); @@ -441,24 +437,21 @@ window.addEventListener('DOMContentLoaded', function () { $('.directorist-map-coordinates').hide(); } }); - if ($("[data-toggle='tooltip']").length) { $("[data-toggle='tooltip']").tooltip(); - } // price range - + } + // price range var pricerange = $('#pricerange_val').val(); - if (pricerange) { $('#pricerange').fadeIn(100); } - $('#price_range_option').on('click', function () { $('#pricerange').fadeIn(500); - }); // enable sorting if only the container has any social or skill field + }); + // enable sorting if only the container has any social or skill field var $s_wrap = $('#social_info_sortable_container'); // cache it - if (window.outerWidth > 1700) { if ($s_wrap.length) { $s_wrap.sortable({ @@ -466,9 +459,10 @@ window.addEventListener('DOMContentLoaded', function () { opacity: '0.7' }); } - } // SOCIAL SECTION - // Rearrange the IDS and Add new social field + } + // SOCIAL SECTION + // Rearrange the IDS and Add new social field /* $('body').on('click', '#addNewSocial', function () { const currentItems = $('.directorist-form-social-fields').length; const ID = `id=${currentItems}`; // eg. 'id=3' @@ -486,15 +480,13 @@ window.addEventListener('DOMContentLoaded', function () { //$s_wrap.append(data); }); }); */ - // remove the social field and then reset the ids while maintaining position - + // remove the social field and then reset the ids while maintaining position $(document).on('click', '.directorist-form-social-fields__remove', function (e) { var id = $(this).data('id'); var elementToRemove = $("div#socialID-".concat(id)); event.preventDefault(); /* Act on the event */ - swal({ title: directorist_admin.i18n_text.confirmation_text, text: directorist_admin.i18n_text.ask_conf_sl_lnk_del_txt, @@ -507,8 +499,8 @@ window.addEventListener('DOMContentLoaded', function () { if (isConfirm) { // user has confirmed, no remove the item and reset the ids elementToRemove.slideUp('fast', function () { - elementToRemove.remove(); // reorder the index - + elementToRemove.remove(); + // reorder the index $('.directorist-form-social-fields').each(function (index, element) { var e = $(element); e.attr('id', "socialID-".concat(index)); @@ -516,8 +508,9 @@ window.addEventListener('DOMContentLoaded', function () { e.find('.atbdp_social_input').attr('name', "social[".concat(index, "][url]")); e.find('.directorist-form-social-fields__remove').attr('data-id', index); }); - }); // show success message + }); + // show success message swal({ title: directorist_admin.i18n_text.deleted, // text: "Item has been deleted.", @@ -527,26 +520,28 @@ window.addEventListener('DOMContentLoaded', function () { }); } }); - }); // upgrade old listing + }); + // upgrade old listing $('#upgrade_directorist').on('click', function (event) { event.preventDefault(); - var $this = $(this); // display a notice to user to wait + var $this = $(this); + // display a notice to user to wait // send an ajax request to the back end - atbdp_do_ajax($this, 'atbdp_upgrade_old_listings', null, function (response) { if (response.success) { $this.after("

    ".concat(response.data, "

    ")); } }); - }); // upgrade old pages + }); + // upgrade old pages $('#shortcode-updated input[name="shortcode-updated"]').on('change', function (event) { event.preventDefault(); $('#success_msg').hide(); - var $this = $(this); // display a notice to user to wait + var $this = $(this); + // display a notice to user to wait // send an ajax request to the back end - atbdp_do_ajax($this, 'atbdp_upgrade_old_pages', null, function (response) { if (response.success) { $('#shortcode-updated').after("

    ".concat(response.data, "

    ")); @@ -555,26 +550,23 @@ window.addEventListener('DOMContentLoaded', function () { $('.atbdp_ajax_loading').css({ display: 'none' }); - }); // send system info to admin + }); + // send system info to admin $('#atbdp-send-system-info-submit').on('click', function (event) { event.preventDefault(); - if (!$('#atbdp-email-subject').val()) { alert('The Subject field is required'); return; } - if (!$('#atbdp-email-address').val()) { alert('The Email field is required'); return; } - if (!$('#atbdp-email-message').val()) { alert('The Message field is required'); return; } - $.ajax({ type: 'post', url: directorist_admin.ajaxurl, @@ -602,10 +594,10 @@ window.addEventListener('DOMContentLoaded', function () { } }); }); + /** * Generate new Remote View URL and display it on the admin page */ - $('#generate-url').on('click', function (e) { e.preventDefault(); $.ajax({ @@ -621,7 +613,8 @@ window.addEventListener('DOMContentLoaded', function () { $('#system-info-url, #atbdp-system-info-url').val(response.data.url); $('#system-info-url-text-link').attr('href', response.data.url).css('display', 'inline-block'); }, - error: function error(response) {// $('#atbdp-remote-response').val(response.data.error); + error: function error(response) { + // $('#atbdp-remote-response').val(response.data.error); } }); return false; @@ -641,30 +634,31 @@ window.addEventListener('DOMContentLoaded', function () { $('#system-info-url, #atbdp-system-info-url').val(''); $('#system-info-url-text-link').attr('href', '#').css('display', 'none'); }, - error: function error(response) {// $('#atbdp-remote-response').val(response.data.error); + error: function error(response) { + // $('#atbdp-remote-response').val(response.data.error); } }); return false; - }); // redirect to import import_page_link + }); + // redirect to import import_page_link $('#csv_import input[name="csv_import"]').on('change', function (event) { event.preventDefault(); window.location = directorist_admin.import_page_link; }); - /* This function handles all ajax request */ + /* This function handles all ajax request */ function atbdp_do_ajax(ElementToShowLoadingIconAfter, ActionName, arg, CallBackHandler) { var data; if (ActionName) data = "action=".concat(ActionName); if (arg) data = "".concat(arg, "&action=").concat(ActionName); - if (arg && !ActionName) data = arg; // data = data ; + if (arg && !ActionName) data = arg; + // data = data ; var n = data.search(directorist_admin.nonceName); - if (n < 0) { data = "".concat(data, "&").concat(directorist_admin.nonceName, "=").concat(directorist_admin.nonce); } - jQuery.ajax({ type: 'post', url: directorist_admin.ajaxurl, @@ -690,36 +684,39 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { window.addEventListener('DOMContentLoaded', function () { - var $ = jQuery; // Custom Image uploader for listing image - // Set all variables to be used in scope + var $ = jQuery; + + // Custom Image uploader for listing image + // Set all variables to be used in scope var frame; var selection; var multiple_image = true; var metaBox = $('#gallery_upload'); // meta box id here - var addImgLink = metaBox.find('#listing_image_btn'); var delImgLink = metaBox.find('#delete-custom-img'); - var imgContainer = metaBox.find('.listing-img-container'); // toggle_section + var imgContainer = metaBox.find('.listing-img-container'); + // toggle_section function toggle_section(show_if_value, subject_elm, terget_elm) { if (show_if_value === subject_elm.val()) { terget_elm.show(); } else { terget_elm.hide(); } - } // ADD IMAGE LINK - + } + // ADD IMAGE LINK $('body').on('click', '#listing_image_btn', function (event) { - event.preventDefault(); // If the media frame already exists, reopen it. + event.preventDefault(); + // If the media frame already exists, reopen it. if (frame) { frame.open(); return; - } // Create a new media frame - + } + // Create a new media frame frame = wp.media({ title: directorist_admin.i18n_text.upload_image, button: { @@ -730,27 +727,25 @@ window.addEventListener('DOMContentLoaded', function () { }, // only allow image upload only multiple: multiple_image // Set to true to allow multiple files to be selected. it will be set based on the availability of Multiple Image extension + }); - }); // When an image is selected in the media frame... - + // When an image is selected in the media frame... frame.on('select', function () { /* get the image collection array if the MI extension is active */ - /* One little hints: a constant can not be defined inside the if block */ if (multiple_image) { selection = frame.state().get('selection').toJSON(); } else { selection = frame.state().get('selection').first().toJSON(); } - var data = ''; // create a placeholder to save all our image from the selection of media uploader - // if no image exist then remove the place holder image before appending new image + // if no image exist then remove the place holder image before appending new image if ($('.single_attachment').length === 0) { $('.listing-img-container').html(''); - } // handle multiple image uploading....... - + } + // handle multiple image uploading....... if (multiple_image) { $(selection).each(function () { // here el === this @@ -765,6 +760,7 @@ window.addEventListener('DOMContentLoaded', function () { }); } else { // Handle single image uploading + // add the id to the input field of the image uploader and then save the ids in the database as a post meta // so check if the attachment is really an image and reject other types if (selection.type === 'image') { @@ -774,35 +770,36 @@ window.addEventListener('DOMContentLoaded', function () { data += ""); data += "\"Listing "); } - } // If MI extension is active then append images to the listing, else only add one image replacing previous upload - + } + // If MI extension is active then append images to the listing, else only add one image replacing previous upload if (multiple_image) { $('.listing-img-container').append(data); } else { $('.listing-img-container').html(data); - } // Un-hide the remove image link - + } + // Un-hide the remove image link delImgLink.removeClass('hidden'); - }); // Finally, open the modal on click - + }); + // Finally, open the modal on click frame.open(); - }); // DELETE ALL IMAGES LINK + }); + // DELETE ALL IMAGES LINK delImgLink.on('click', function (event) { - event.preventDefault(); // Clear out the preview image and set no image as placeholder - - $('.listing-img-container').html("\"Listing")); // Hide the delete image link - + event.preventDefault(); + // Clear out the preview image and set no image as placeholder + $('.listing-img-container').html("\"Listing")); + // Hide the delete image link delImgLink.addClass('hidden'); }); - /* REMOVE SINGLE IMAGE */ + /* REMOVE SINGLE IMAGE */ $(document).on('click', '.remove_image', function (e) { e.preventDefault(); - $(this).parent().remove(); // if no image exist then add placeholder and hide remove image button - + $(this).parent().remove(); + // if no image exist then add placeholder and hide remove image button if ($('.single_attachment').length === 0) { $('.listing-img-container').html("\"Listing

    No images

    ") + "(allowed formats jpeg. png. gif)"); delImgLink.addClass('hidden'); @@ -810,43 +807,49 @@ window.addEventListener('DOMContentLoaded', function () { }); var has_tagline = $('#has_tagline').val(); var has_excerpt = $('#has_excerpt').val(); - if (has_excerpt && has_tagline) { $('.atbd_tagline_moto_field').fadeIn(); } else { $('.atbd_tagline_moto_field').fadeOut(); } - if ($('.directorist-form-pricing-field').hasClass('price-type-both')) { - $('#price').show(); - $('#price_range').hide(); - } + /** + * Price field. + */ + // if ( $( '.directorist-form-pricing-field' ).hasClass( 'price-type-both' ) ) { + // $('#price, #price_range').hide(); + // } + + // $( '.directorist_pricing_options label' ).on( 'click', function() { + // const $this = $(this); + // $this.children('input[type=checkbox]').prop('checked') == true + // ? $(`#${$this.data('option')}`).show() + // : $(`#${$this.data('option')}`).hide(); + // const $sibling = $this.siblings('label'); + // $sibling.children('input[type=checkbox]').prop('checked', false); + // $(`#${$sibling.data('option')}`).hide(); + // } ); + + // $('.directorist_pricing_options label').on( 'click', function () { + // const self = $( this ); + + // const current_input = self.attr( 'for' ); + // const current_field = `#${self.data('option')}`; + + // $( '.directorist_pricing_options input[type=checkbox]' ).prop( 'checked', false ); + // $( '.directorist_pricing_options input[id='+ current_input +']' ).attr( 'checked', true ); + + // $('.directory_pricing_field').hide(); + // $( current_field ).show(); + // }); - $('.directorist_pricing_options label').on('click', function () { - var $this = $(this); - $this.children('input[type=checkbox]').prop('checked') == true ? $("#".concat($this.data('option'))).show() : $("#".concat($this.data('option'))).hide(); - var $sibling = $this.siblings('label'); - $sibling.children('input[type=checkbox]').prop('checked', false); - $("#".concat($sibling.data('option'))).hide(); - }); - $('.directorist_pricing_options label').on('click', function () { - var self = $(this); - var current_input = self.attr('for'); - var current_field = "#".concat(self.data('option')); - $('.directorist_pricing_options input[type=checkbox]').prop('checked', false); - $('.directorist_pricing_options input[id=' + current_input + ']').attr('checked', true); - $('.directory_pricing_field').hide(); - $(current_field).show(); - }); $('#atbd_optional_field_check').on('change', function () { $(this).is(':checked') ? $('.atbd_tagline_moto_field').fadeIn() : $('.atbd_tagline_moto_field').fadeOut(); }); var imageUpload; - if (imageUpload) { imageUpload.open(); } - $('.upload-header').on('click', function (element) { element.preventDefault(); imageUpload = wp.media.frames.file_frame = wp.media({ @@ -873,13 +876,13 @@ window.addEventListener('DOMContentLoaded', function () { $('.change_listing_prv_img').attr('src', ''); e.preventDefault(); }); - if ($('.change_listing_prv_img').attr('src') === '') { $('.remove_prev_img').hide(); } else if ($('.change_listing_prv_img').attr('src') !== '') { $('.remove_prev_img').show(); - } // price range + } + // price range /* $('#price_range').hide(); const is_checked = $('#atbd_listing_pricing').val(); if (is_checked === 'range') { @@ -896,10 +899,8 @@ window.addEventListener('DOMContentLoaded', function () { $(`#${$sibling.data('option')}`).hide(); }); */ - var avg_review = $('#average_review_for_popular').hide(); var logged_count = $('#views_for_popular').hide(); - if ($('#listing_popular_by select[name="listing_popular_by"]').val() === 'average_rating') { avg_review.show(); logged_count.hide(); @@ -910,7 +911,6 @@ window.addEventListener('DOMContentLoaded', function () { avg_review.show(); logged_count.show(); } - $('#listing_popular_by select[name="listing_popular_by"]').on('change', function () { if ($(this).val() === 'average_rating') { avg_review.show(); @@ -923,6 +923,7 @@ window.addEventListener('DOMContentLoaded', function () { logged_count.show(); } }); + /* // Display the media uploader when "Upload Image" button clicked in the custom taxonomy "atbdp_categories" $( '#atbdp-categories-upload-image' ).on( 'click', function( e ) { if (frame) { @@ -940,39 +941,38 @@ window.addEventListener('DOMContentLoaded', function () { }); frame.open(); }); */ - /** * Display the media uploader for selecting an image. * * @since 1.0.0 */ - function atbdp_render_media_uploader(page) { var file_frame; var image_data; - var json; // If an instance of file_frame already exists, then we can open it rather than creating a new instance + var json; + // If an instance of file_frame already exists, then we can open it rather than creating a new instance if (undefined !== file_frame) { file_frame.open(); return; - } // Here, use the wp.media library to define the settings of the media uploader - - + } + // Here, use the wp.media library to define the settings of the media uploader file_frame = wp.media.frames.file_frame = wp.media({ frame: 'post', state: 'insert', multiple: false - }); // Setup an event handler for what to do when an image has been selected + }); + // Setup an event handler for what to do when an image has been selected file_frame.on('insert', function () { // Read the JSON data returned from the media uploader - json = file_frame.state().get('selection').first().toJSON(); // First, make sure that we have the URL of an image to display + json = file_frame.state().get('selection').first().toJSON(); + // First, make sure that we have the URL of an image to display if ($.trim(json.url.length) < 0) { return; - } // After that, set the properties of the image and display it - - + } + // After that, set the properties of the image and display it if (page == 'listings') { var html = "".concat('' + '' + '' + '") + "") + "" + "".concat(json.url, "
    ") + "").concat(atbdp.edit, " | ") + "").concat(atbdp.delete_permanently, "") + "" + ""; $('#atbdp-images').append(html); @@ -980,12 +980,13 @@ window.addEventListener('DOMContentLoaded', function () { $('#atbdp-categories-image-id').val(json.id); $('#atbdp-categories-image-wrapper').html("")); } - }); // Now display the actual file_frame + }); + // Now display the actual file_frame file_frame.open(); - } // Display the media uploader when "Upload Image" button clicked in the custom taxonomy "atbdp_categories" - + } + // Display the media uploader when "Upload Image" button clicked in the custom taxonomy "atbdp_categories" $('#atbdp-categories-upload-image').on('click', function (e) { e.preventDefault(); atbdp_render_media_uploader('categories'); @@ -999,10 +1000,11 @@ window.addEventListener('DOMContentLoaded', function () { $(this).hide(); $(this).prev('img').remove(); $('#atbdp-categories-image-id').attr('value', ''); - }); // Announcement + }); + + // Announcement // ---------------------------------------------------------------------------------- // Display Announcement Recepents - var announcement_to = $('select[name="announcement_to"]'); var announcement_recepents_section = $('#announcement_recepents'); toggle_section('selected_user', announcement_to, announcement_recepents_section); @@ -1012,14 +1014,14 @@ window.addEventListener('DOMContentLoaded', function () { var submit_button = $('#announcement_submit .vp-input ~ span'); var form_feedback = $('#announcement_submit .field'); form_feedback.prepend('
    '); - var announcement_is_sending = false; // Send Announcement + var announcement_is_sending = false; + // Send Announcement submit_button.on('click', function () { if (announcement_is_sending) { console.log('Please wait...'); return; } - var to = $('select[name="announcement_to"]'); var recepents = $('select[name="announcement_recepents"]'); var subject = $('input[name="announcement_subject"]'); @@ -1057,16 +1059,16 @@ window.addEventListener('DOMContentLoaded', function () { value: send_to_email.val(), default: 1 } - }; // Send the form + }; - var form_data = new FormData(); // Fillup the form + // Send the form + var form_data = new FormData(); + // Fillup the form form_data.append('action', 'atbdp_send_announcement'); - for (field in fields_elm) { form_data.append(field, fields_elm[field].value); } - announcement_is_sending = true; jQuery.ajax({ type: 'post', @@ -1081,7 +1083,6 @@ window.addEventListener('DOMContentLoaded', function () { success: function success(response) { // console.log( {response} ); announcement_is_sending = false; - if (response.message) { form_feedback.find('.announcement-feedback').html("
    ".concat(response.message, "
    ")); } @@ -1092,41 +1093,45 @@ window.addEventListener('DOMContentLoaded', function () { }); announcement_is_sending = false; } - }); // Reset Form + }); + // Reset Form /* for ( var field in fields_elm ) { $( fields_elm[ field ].elm ).val( fields_elm[ field ].default ); } */ - }); // ---------------------------------------------------------------------------------- - // Custom Tab Support Status + }); + // ---------------------------------------------------------------------------------- + + // Custom Tab Support Status $('.atbds_wrapper a.nav-link').on('click', function (e) { - e.preventDefault(); //console.log($(this).data('tabarea')); + e.preventDefault(); + //console.log($(this).data('tabarea')); var atbds_tabParent = $(this).parent().parent().find('a.nav-link'); var $href = $(this).attr('href'); $(atbds_tabParent).removeClass('active'); - $(this).addClass('active'); //console.log($(".tab-content[data-tabarea='atbds_system-info-tab']")); + $(this).addClass('active'); + //console.log($(".tab-content[data-tabarea='atbds_system-info-tab']")); switch ($(this).data('tabarea')) { case 'atbds_system-status-tab': $(".tab-content[data-tabarea='atbds_system-status-tab'] >.tab-pane").removeClass('active show'); $(".tab-content[data-tabarea='atbds_system-status-tab'] ".concat($href)).addClass('active show'); break; - case 'atbds_system-info-tab': $(".tab-content[data-tabarea='atbds_system-info-tab'] >.tab-pane").removeClass('active show'); $(".tab-content[data-tabarea='atbds_system-info-tab'] ".concat($href)).addClass('active show'); break; - default: break; } - }); // Custom Tooltip Support Added + }); + // Custom Tooltip Support Added $('.atbds_tooltip').on('hover', function () { - var toolTipLabel = $(this).data('label'); //console.log(toolTipLabel); - + var toolTipLabel = $(this).data('label'); + //console.log(toolTipLabel); $(this).find('.atbds_tooltip__text').text(toolTipLabel); $(this).find('.atbds_tooltip__text').addClass('show'); }); @@ -1134,90 +1139,73 @@ window.addEventListener('DOMContentLoaded', function () { $('.atbds_tooltip__text').removeClass('show'); }); var directory_type = $('select[name="directory_type"]').val(); - if (directory_type) { admin_listing_form(directory_type); } - var localized_data = directorist_admin.add_listing_data; $('body').on('change', 'select[name="directory_type"]', function () { $(this).parent('.inside').append(""); admin_listing_form($(this).val()); $(this).closest('#poststuff').find('#publishing-action').addClass('directorist_disable'); - if (!localized_data.is_admin) { if ($('#directorist-select-st-s-js').length) { pureScriptSelect('#directorist-select-st-s-js'); } - if ($('#directorist-select-st-e-js').length) { pureScriptSelect('#directorist-select-st-e-js'); } - if ($('#directorist-select-sn-s-js').length) { pureScriptSelect('#directorist-select-sn-s-js'); } - if ($('#directorist-select-mn-e-js').length) { pureScriptSelect('#directorist-select-sn-e-js'); } - if ($('#directorist-select-mn-s-js').length) { pureScriptSelect('#directorist-select-mn-s-js'); } - if ($('#directorist-select-mn-e-js').length) { pureScriptSelect('#directorist-select-mn-e-js'); } - if ($('#directorist-select-tu-s-js').length) { pureScriptSelect('#directorist-select-tu-s-js'); } - if ($('#directorist-select-tu-e-js').length) { pureScriptSelect('#directorist-select-tu-e-js'); } - if ($('#directorist-select-wd-s-js').length) { pureScriptSelect('#directorist-select-wd-s-js'); } - if ($('#directorist-select-wd-e-js').length) { pureScriptSelect('#directorist-select-wd-e-js'); } - if ($('#directorist-select-th-s-js').length) { pureScriptSelect('#directorist-select-th-s-js'); } - if ($('#directorist-select-th-e-js').length) { pureScriptSelect('#directorist-select-th-e-js'); } - if ($('#directorist-select-fr-s-js').length) { pureScriptSelect('#directorist-select-fr-s-js'); } - if ($('#directorist-select-fr-e-js').length) { pureScriptSelect('#directorist-select-fr-e-js'); } } - }); // Custom Field Checkbox Button More + }); + // Custom Field Checkbox Button More function customFieldSeeMore() { if ($('.directorist-custom-field-btn-more').length) { $('.directorist-custom-field-btn-more').each(function (index, element) { var fieldWrapper = $(element).closest('.directorist-custom-field-checkbox, .directorist-custom-field-radio'); var customField = $(fieldWrapper).find('.directorist-checkbox, .directorist-radio'); $(customField).slice(20, customField.length).slideUp(); - if (customField.length <= 20) { $(element).slideUp(); } }); } } - function admin_listing_form(directory_type) { $.ajax({ type: 'post', @@ -1235,7 +1223,6 @@ window.addEventListener('DOMContentLoaded', function () { }); return; } - $('#directiost-listing-fields_wrapper').empty().append(response.data['listing_meta_fields']); assetsNeedToWorkInVirtualDom(); $('#at_biz_dir-locationchecklist').empty().html(response.data['listing_locations']); @@ -1245,31 +1232,24 @@ window.addEventListener('DOMContentLoaded', function () { $('.misc-pub-atbdp-expiration-time').empty().html(response.data['listing_expiration']); $('#listing_form_info').find('.directorist_loader').remove(); $('select[name="directory_type"]').closest('#poststuff').find('#publishing-action').removeClass('directorist_disable'); - if ($('.directorist-color-field-js').length) { $('.directorist-color-field-js').wpColorPicker().empty(); } - window.dispatchEvent(new CustomEvent('directorist-reload-plupload')); window.dispatchEvent(new CustomEvent('directorist-type-change')); - if (response.data['required_js_scripts']) { var scripts = response.data['required_js_scripts']; - for (var script_id in scripts) { var old_script = document.getElementById(script_id); - if (old_script) { old_script.remove(); } - var script = document.createElement('script'); script.id = script_id; script.src = scripts[script_id]; document.body.appendChild(script); } } - customFieldSeeMore(); }, error: function error(_error2) { @@ -1278,9 +1258,9 @@ window.addEventListener('DOMContentLoaded', function () { }); } }); - } // default directory type - + } + // default directory type $('body').on('click', '.submitdefault', function (e) { e.preventDefault(); $(this).children('.submitDefaultCheckbox').prop('checked', true); @@ -1303,39 +1283,60 @@ window.addEventListener('DOMContentLoaded', function () { } }); }); - function assetsNeedToWorkInVirtualDom() { - // price range - - /* $('#price_range').hide(); - const pricing = $('#atbd_listing_pricing').val(); - if (pricing === 'range') { - $('#price').hide(); - $('#price_range').show(); - } */ - $('.atbd_pricing_options label').on('click', function () { - var $this = $(this); - $this.children('input[type=checkbox]').prop('checked') == true ? $("#".concat($this.data('option'))).show() : $("#".concat($this.data('option'))).hide(); - var $sibling = $this.siblings('label'); - $sibling.children('input[type=checkbox]').prop('checked', false); - $("#".concat($sibling.data('option'))).hide(); - }); - $('.directorist_pricing_options label').on('click', function () { - var self = $(this); - var current_input = self.attr('for'); - var current_field = "#".concat(self.data('option')); - $('.directorist_pricing_options input[type=checkbox]').prop('checked', false); - $('.directorist_pricing_options input[id=' + current_input + ']').attr('checked', true); - $('.directory_pricing_field').hide(); - $(current_field).show(); + function getPriceTypeInput(typeId) { + return $("#".concat($("[for=\"".concat(typeId, "\"]")).data('option'))); + } + $('.directorist-form-pricing-field__options').on('change', 'input', function () { + var $otherOptions = $(this).parent().siblings('.directorist-checkbox').find('input'); + $otherOptions.prop('checked', false); + getPriceTypeInput($otherOptions.attr('id')).hide(); + if (this.checked) { + getPriceTypeInput(this.id).show(); + } else { + getPriceTypeInput(this.id).hide(); + } }); - var imageUpload; + // Must be placed after the event listener. + if ($('.directorist-form-pricing-field').hasClass('price-type-both')) { + $('#price_range, #price').hide(); + var $selectedPriceType = $('.directorist-form-pricing-field__options input:checked'); + if ($selectedPriceType.length) { + getPriceTypeInput($selectedPriceType.attr('id')).show(); + } else { + $($('.directorist-form-pricing-field__options input').get(0)).prop('checked', true).trigger('change'); + } + } + + // $('.atbd_pricing_options label').on('click', function () { + // const $this = $(this); + // $this.children('input[type=checkbox]').prop('checked') == true ? + // $(`#${$this.data('option')}`).show() : + // $(`#${$this.data('option')}`).hide(); + // const $sibling = $this.siblings('label'); + // $sibling.children('input[type=checkbox]').prop('checked', false); + // $(`#${$sibling.data('option')}`).hide(); + // }); + + // $('.directorist_pricing_options label').on('click', function () { + // const self = $(this); + + // const current_input = self.attr('for'); + // const current_field = `#${self.data('option')}`; + + // $('.directorist_pricing_options input[type=checkbox]').prop('checked', false); + // $('.directorist_pricing_options input[id=' + current_input + ']').attr('checked', true); + + // $('.directory_pricing_field').hide(); + // $(current_field).show(); + // }); + + var imageUpload; if (imageUpload) { imageUpload.open(); return; } - $('.upload-header').on('click', function (element) { element.preventDefault(); imageUpload = wp.media.frames.file_frame = wp.media({ @@ -1362,19 +1363,16 @@ window.addEventListener('DOMContentLoaded', function () { $('.change_listing_prv_img').attr('src', ''); e.preventDefault(); }); - if ($('.change_listing_prv_img').attr('src') === '') { $('.remove_prev_img').hide(); } else if ($('.change_listing_prv_img').attr('src') !== '') { $('.remove_prev_img').show(); } - /* Show and hide manual coordinate input field */ - + /* Show and hide manual coordinate input field */ if (!$('input#manual_coordinate').is(':checked')) { $('.directorist-map-coordinates').hide(); } - $('#manual_coordinate').on('click', function (e) { if ($('input#manual_coordinate').is(':checked')) { $('.directorist-map-coordinates').show(); @@ -1399,6 +1397,7 @@ window.addEventListener('DOMContentLoaded', function () { Version: 1.0.0 License: MIT */ + var pureScriptTab = function pureScriptTab(selector1) { var selector = document.querySelectorAll(selector1); selector.forEach(function (el, index) { @@ -1426,7 +1425,6 @@ var pureScriptTab = function pureScriptTab(selector1) { }); }); }; - pureScriptTab('.directorist_builder--tab'); /***/ }), @@ -1439,22 +1437,19 @@ pureScriptTab('.directorist_builder--tab'); /***/ (function(module, exports) { window.addEventListener('DOMContentLoaded', function () { - var $ = jQuery; // Init Category Icon Picker + var $ = jQuery; + // Init Category Icon Picker function initCategoryIconPicker() { var iconPickerContainer = document.querySelector('.directorist-category-icon-picker'); - if (!iconPickerContainer) { return; } - var iconValueElm = document.querySelector('.category_icon_value'); var iconValue = iconValueElm ? iconValueElm.value : ''; - var onSelectIcon = function onSelectIcon(value) { iconValueElm.setAttribute('value', value); }; - var args = {}; args.container = iconPickerContainer; args.onSelect = onSelectIcon; @@ -1467,18 +1462,16 @@ window.addEventListener('DOMContentLoaded', function () { var iconPicker = new IconPicker(args); iconPicker.init(); } + initCategoryIconPicker(); - initCategoryIconPicker(); // Category icon selection - + // Category icon selection function selecWithIcon(selected) { if (!selected.id) { return selected.text; } - var $elem = $(" ").concat(selected.text, "")); return $elem; } - if ($('#category_icon').length) { $('#category_icon').select2({ placeholder: directorist_admin.i18n_text.icon_choose_text, @@ -1486,7 +1479,6 @@ window.addEventListener('DOMContentLoaded', function () { templateResult: selecWithIcon }); } - $('body').on('click', '.directorist_settings-trigger', function () { $('.setting-left-sibebar').toggleClass('active'); $('.directorist_settings-panel-shade').toggleClass('active'); @@ -1494,8 +1486,9 @@ window.addEventListener('DOMContentLoaded', function () { $('body').on('click', '.directorist_settings-panel-shade', function () { $('.setting-left-sibebar').removeClass('active'); $(this).removeClass('active'); - }); // Directorist More Dropdown + }); + // Directorist More Dropdown $('body').on('click', '.directorist_more-dropdown-toggle', function (e) { e.preventDefault(); $(this).toggleClass('active'); @@ -1509,50 +1502,53 @@ window.addEventListener('DOMContentLoaded', function () { $('.directorist_more-dropdown-option').removeClass('active'); $('.directorist_more-dropdown-toggle').removeClass('active'); } - }); // Select Dropdown + }); + // Select Dropdown $('body').on('click', '.directorist_dropdown .directorist_dropdown-toggle', function (e) { e.preventDefault(); $(this).siblings('.directorist_dropdown-option').toggle(); - }); // Select Option after click + }); + // Select Option after click $('body').on('click', '.directorist_dropdown .directorist_dropdown-option ul li a', function (e) { e.preventDefault(); var optionText = $(this).html(); $(this).children('.directorist_dropdown-toggle__text').html(optionText); $(this).closest('.directorist_dropdown-option').siblings('.directorist_dropdown-toggle').children('.directorist_dropdown-toggle__text').html(optionText); $('.directorist_dropdown-option').hide(); - }); // Hide Clicked Anywhere + }); + // Hide Clicked Anywhere $(document).bind('click', function (e) { var clickedDom = $(e.target); - if (!clickedDom.parents().hasClass('directorist_dropdown')) { $('.directorist_dropdown-option').hide(); } }); $('.directorist-type-slug-content').each(function (id, element) { - var findElmSlug = $(element).find('.directorist_listing-slug-text'); // Store old slug value + var findElmSlug = $(element).find('.directorist_listing-slug-text'); + // Store old slug value var slugWrapper = $(element).children('.directorist_listing-slug-text'); - var oldSlugVal = slugWrapper.attr('data-value'); // Slug Edit + var oldSlugVal = slugWrapper.attr('data-value'); + // Slug Edit slugWrapper.on('input keypress', function (e) { var slugText = $(this).text(); $(this).attr('data-value', slugText); var setSlugBtn = $(this).siblings('.directorist-listing-slug-edit-wrap').children('.directorist_listing-slug-formText-add'); $(this).attr('data-value') === '' ? setSlugBtn.addClass('disabled') : setSlugBtn.removeClass('disabled'); - if (e.key === 'Enter' && $(this).attr('data-value') !== '') { e.preventDefault(); setSlugBtn.click(); } - if ($(this).attr('data-value') === '' && e.key === 'Enter') { e.preventDefault(); } - }); // Edit Form Open + }); + // Edit Form Open $('body').on('click', '.directorist-listing-slug__edit', function (e) { e.preventDefault(); $('.directorist_listing-slug-formText-remove').click(); @@ -1563,18 +1559,15 @@ window.addEventListener('DOMContentLoaded', function () { $(this).siblings('.directorist_listing-slug-formText-add').addClass('active'); $(this).siblings('.directorist_listing-slug-formText-remove').removeClass('directorist_listing-slug-formText-remove--hidden'); editableSlug.focus(); - }); // edit directory type slug + }); + // edit directory type slug $(element).find('.directorist_listing-slug-formText-add').on('click', function (e) { e.preventDefault(); - var _this = $(this); - var type_id = $(this).data('type-id'); var update_slug = $('.directorist-slug-text-' + type_id).attr('data-value'); - oldSlugVal = slugWrapper.attr('data-value'); - /* Update the slug values */ - + oldSlugVal = slugWrapper.attr('data-value'); /* Update the slug values */ var addSlug = $(this); var slugId = $('.directorist-slug-notice-' + type_id); var thisSiblings = $(_this).closest('.directorist-listing-slug-edit-wrap').siblings('.directorist_listing-slug-text'); @@ -1590,19 +1583,15 @@ window.addEventListener('DOMContentLoaded', function () { }, success: function success(response) { addSlug.closest('.directorist-listing-slug-edit-wrap').children('.directorist_loader').remove(); - if (response) { if (response.error) { slugId.removeClass('directorist-slug-notice-success'); slugId.addClass('directorist-slug-notice-error'); slugId.empty().html(response.error); - if (response.old_slug) { $('.directorist-slug-text-' + type_id).text(response.old_slug); } - _this.siblings('.directorist-listing-slug__edit').show(); - setTimeout(function () { slugId.empty().html(""); }, 3000); @@ -1610,9 +1599,7 @@ window.addEventListener('DOMContentLoaded', function () { slugId.empty().html(response.success); slugId.removeClass('directorist-slug-notice-error'); slugId.addClass('directorist-slug-notice-success'); - _this.siblings('.directorist-listing-slug__edit').show(); - setTimeout(function () { addSlug.closest('.directorist-listing-slug__form').css({ "display": "none" @@ -1621,15 +1608,15 @@ window.addEventListener('DOMContentLoaded', function () { }, 1500); } } - $(_this).removeClass('active'); $(_this).siblings('.directorist_listing-slug-formText-remove').addClass('directorist_listing-slug-formText-remove--hidden'); thisSiblings.removeClass('directorist_listing-slug-text--editable'); thisSiblings.attr('contenteditable', 'false'); } }); - }); // Edit Form Remove + }); + // Edit Form Remove $(element).find('.directorist_listing-slug-formText-remove').on('click', function (e) { e.preventDefault(); var thisClosestSibling = $(this).closest('.directorist-listing-slug-edit-wrap').siblings('.directorist_listing-slug-text'); @@ -1640,8 +1627,9 @@ window.addEventListener('DOMContentLoaded', function () { $(this).addClass('directorist_listing-slug-formText-remove--hidden'); thisClosestSibling.attr('data-value', oldSlugVal); thisClosestSibling.text(oldSlugVal); - }); // Hide Slug Form outside click + }); + // Hide Slug Form outside click $(document).on('click', function (e) { if (!e.target.closest('.directorist-type-slug')) { findElmSlug.attr('data-value', oldSlugVal); @@ -1653,44 +1641,47 @@ window.addEventListener('DOMContentLoaded', function () { findElmSlug.siblings('.directorist-listing-slug-edit-wrap').children('.directorist_listing-slug-formText-remove').addClass('directorist_listing-slug-formText-remove--hidden'); } }); - }); // Tab Content - // Modular, classes has no styling, so reusable + }); + // Tab Content + // Modular, classes has no styling, so reusable $('.atbdp-tab__nav-link').on('click', function (e) { e.preventDefault(); var data_target = $(this).data('target'); - var current_item = $(this).parent(); // Active Nav Item - + var current_item = $(this).parent(); + // Active Nav Item $('.atbdp-tab__nav-item').removeClass('active'); - current_item.addClass('active'); // Active Tab Content - + current_item.addClass('active'); + // Active Tab Content $('.atbdp-tab__content').removeClass('active'); $(data_target).addClass('active'); - }); // Custom + }); + // Custom $('.atbdp-tab-nav-menu__link').on('click', function (e) { e.preventDefault(); var data_target = $(this).data('target'); - var current_item = $(this).parent(); // Active Nav Item - + var current_item = $(this).parent(); + // Active Nav Item $('.atbdp-tab-nav-menu__item').removeClass('active'); - current_item.addClass('active'); // Active Tab Content - + current_item.addClass('active'); + // Active Tab Content $('.atbdp-tab-content').removeClass('active'); $(data_target).addClass('active'); - }); // Section Toggle + }); + // Section Toggle $('.atbdp-section-toggle').on('click', function (e) { e.preventDefault(); var data_target = $(this).data('target'); $(data_target).slideToggle(); - }); // Accordion Toggle + }); + // Accordion Toggle $('.atbdp-accordion-toggle').on('click', function (e) { e.preventDefault(); var data_parent = $(this).data('parent'); var data_target = $(this).data('target'); - if ($(data_target).hasClass('active')) { $(data_target).removeClass('active'); $(data_target).slideUp(); @@ -1713,24 +1704,20 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (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; } - +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; } window.addEventListener('DOMContentLoaded', function () { - var $ = jQuery; // License Authentication + var $ = jQuery; + + // License Authentication // ---------------------------------------------------------- // atbdp_get_license_authentication - var is_sending = false; $('#atbdp-directorist-license-login-form').on('submit', function (e) { e.preventDefault(); - if (is_sending) { return; } - var form = $(this); var submit_button = form.find('button[type="submit"]'); var form_data = { @@ -1751,17 +1738,15 @@ window.addEventListener('DOMContentLoaded', function () { }, success: function success(response) { var _response$status, _response$status2; - // console.log({response}); + if (response.has_previous_subscriptions) { location.reload(); return; } - is_sending = false; submit_button.attr('disabled', false); submit_button.find('.atbdp-loading').remove(); - if (response !== null && response !== void 0 && (_response$status = response.status) !== null && _response$status !== void 0 && _response$status.log) { for (var feedback in response.status.log) { var alert_type = response.status.log[feedback].type; @@ -1771,20 +1756,22 @@ window.addEventListener('DOMContentLoaded', function () { $('.atbdp-form-feedback').append(_alert); } } - if (response !== null && response !== void 0 && (_response$status2 = response.status) !== null && _response$status2 !== void 0 && _response$status2.success) { location.reload(); return; form.attr('id', 'atbdp-product-download-form'); form.find('.atbdp-form-page').remove(); var form_response_page = form.find('.atbdp-form-response-page'); - form_response_page.removeClass('atbdp-d-none'); // Append Response + form_response_page.removeClass('atbdp-d-none'); + // Append Response form_response_page.append('
    '); var themes = response.license_data && response.license_data.themes ? response.license_data.themes : []; var plugins = response.license_data && response.license_data.plugins ? response.license_data.plugins : []; var total_theme = themes.length; - var total_plugin = plugins.length; // console.log( { plugins, themes } ); + var total_plugin = plugins.length; + + // console.log( { plugins, themes } ); if (!plugins.length && !themes.length) { var title = '

    There is no product in your purchase, redirecting...

    '; @@ -1792,10 +1779,10 @@ window.addEventListener('DOMContentLoaded', function () { location.reload(); return; } - var title = '

    Activate your products

    '; - form_response_page.find('.atbdp-form-feedback').append(title); // Show Log - Themes + form_response_page.find('.atbdp-form-feedback').append(title); + // Show Log - Themes if (total_theme) { var theme_section = '
    '; form_response_page.find('.atbdp-form-feedback').append(theme_section); @@ -1804,10 +1791,8 @@ window.addEventListener('DOMContentLoaded', function () { form_response_page.find('.atbdp-themes-list-section').append(theme_title); form_response_page.find('.atbdp-themes-list-section').append(theme_check_lists); var counter = 0; - var _iterator = _createForOfIteratorHelper(themes), - _step; - + _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var theme = _step.value; @@ -1824,9 +1809,9 @@ window.addEventListener('DOMContentLoaded', function () { } finally { _iterator.f(); } - } // Show Log - Extensions - + } + // Show Log - Extensions if (total_plugin) { var plugin_section = '
    '; form_response_page.find('.atbdp-form-feedback').append(plugin_section); @@ -1835,10 +1820,8 @@ window.addEventListener('DOMContentLoaded', function () { form_response_page.find('.atbdp-extensions-list-section').append(plugin_title); form_response_page.find('.atbdp-extensions-list-section').append(plugin_check_lists); var counter = 0; - var _iterator2 = _createForOfIteratorHelper(plugins), - _step2; - + _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var extension = _step2.value; @@ -1856,7 +1839,6 @@ window.addEventListener('DOMContentLoaded', function () { _iterator2.f(); } } - var continue_button = '
    '; var skip_button = 'Skip'; form_response_page.append(continue_button); @@ -1866,7 +1848,6 @@ window.addEventListener('DOMContentLoaded', function () { var skiped_themes = 0; $('.atbdp-theme-checklist-item .atbdp-list-action .atbdp-checkbox').each(function (i, e) { var is_checked = $(e).is(':checked'); - if (!is_checked) { var id = $(e).attr('id'); var list_item = $(".check-list-item-".concat(id)); @@ -1877,7 +1858,6 @@ window.addEventListener('DOMContentLoaded', function () { var skiped_plugins = 0; $('.atbdp-plugin-checklist-item .atbdp-list-action .atbdp-checkbox').each(function (i, e) { var is_checked = $(e).is(':checked'); - if (!is_checked) { var id = $(e).attr('id'); var list_item = $(".check-list-item-".concat(id)); @@ -1896,17 +1876,16 @@ window.addEventListener('DOMContentLoaded', function () { failed_plugin_downloads: [], succeeded_theme_downloads: [], failed_theme_downloads: [] - }; // Download Files + }; + // Download Files var download_files = function download_files(file_list, counter, callback) { if (counter > file_list.length - 1) { if (callback) { callback(); } - return; } - var next_index = counter + 1; var file_item = file_list[counter]; var file = file_item.file; @@ -1915,12 +1894,10 @@ window.addEventListener('DOMContentLoaded', function () { var icon_elm = list_item.find('.atbdp-list-action .atbdp-icon'); var list_checkbox = $(".atbdp-".concat(file_type, "-checkbox-item-").concat(file.item_id)); var is_checked = list_checkbox.is(':checked'); - if (!is_checked) { download_files(file_list, next_index, callback); return; } - var form_data = { action: 'atbdp_download_file', download_item: file, @@ -1937,14 +1914,13 @@ window.addEventListener('DOMContentLoaded', function () { }, success: function success(response) { // console.log('success', counter, response); + if (response.status.success) { icon_elm.addClass('atbdp-text-success'); icon_elm.html(''); - if (file_type == 'plugin') { files_download_states.succeeded_plugin_downloads.push(file); } - if (file_type == 'theme') { files_download_states.succeeded_theme_downloads.push(file); } @@ -1953,16 +1929,13 @@ window.addEventListener('DOMContentLoaded', function () { list_item.append(msg); icon_elm.addClass('atbdp-text-danger'); icon_elm.html(''); - if (file_type == 'plugin') { files_download_states.failed_plugin_downloads.push(file); } - if (file_type == 'theme') { files_download_states.failed_theme_downloads.push(file); } } - download_files(file_list, next_index, callback); }, error: function error(_error) { @@ -1971,28 +1944,25 @@ window.addEventListener('DOMContentLoaded', function () { icon_elm.html(''); } }); - }; // Remove Unnecessary Sections - + }; + // Remove Unnecessary Sections if (!new_theme_count) { $('.atbdp-themes-list-section').remove(); } - if (!new_plugin_count) { $('.atbdp-extensions-list-section').remove(); } - if (new_theme_count || new_plugin_count) { var form_header_title = 'Activating your products'; form_response_page.find('.atbdp-form-feedback .form-header-title').html(form_header_title); } + var downloading_files = []; - var downloading_files = []; // Download Themes - + // Download Themes if (new_theme_count) { var _iterator3 = _createForOfIteratorHelper(themes), - _step3; - + _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var _theme = _step3.value; @@ -2006,13 +1976,12 @@ window.addEventListener('DOMContentLoaded', function () { } finally { _iterator3.f(); } - } // Download Plugins - + } + // Download Plugins if (new_plugin_count) { var _iterator4 = _createForOfIteratorHelper(plugins), - _step4; - + _step4; try { for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { var plugin = _step4.value; @@ -2027,38 +1996,30 @@ window.addEventListener('DOMContentLoaded', function () { _iterator4.f(); } } - var self = this; - var after_download_callback = function after_download_callback() { // Check invalid themes var all_thmes_are_invalid = false; var failed_download_themes_count = files_download_states.failed_theme_downloads.length; - if (new_theme_count && failed_download_themes_count === new_theme_count) { all_thmes_are_invalid = true; - } // Check invalid plugin - + } + // Check invalid plugin var all_plugins_are_invalid = false; var failed_download_plugins_count = files_download_states.failed_plugin_downloads.length; - if (new_plugin_count && failed_download_plugins_count === new_plugin_count) { all_plugins_are_invalid = true; } - var all_products_are_invalid = false; - if (all_thmes_are_invalid && all_plugins_are_invalid) { all_products_are_invalid = true; } - $(form_response_page).find('.account-connect__form-btn .account-connect__btn').remove(); var finish_btn_label = all_products_are_invalid ? 'Close' : 'Finish'; var finish_btn = ""); $(form_response_page).find('.account-connect__form-btn').append(finish_btn); }; - if (downloading_files.length) { download_files(downloading_files, 0, after_download_callback); } @@ -2072,14 +2033,16 @@ window.addEventListener('DOMContentLoaded', function () { submit_button.find('.atbdp-loading').remove(); } }); - }); // Reload Button + }); + // Reload Button $('body').on('click', '.reload', function (e) { - e.preventDefault(); // console.log('reloading...'); - + e.preventDefault(); + // console.log('reloading...'); location.reload(); - }); // Extension Update Button + }); + // Extension Update Button $('.ext-update-btn').on('click', function (e) { e.preventDefault(); $(this).prop('disabled', true); @@ -2089,11 +2052,11 @@ window.addEventListener('DOMContentLoaded', function () { action: 'atbdp_update_plugins', nonce: directorist_admin.nonce }; - if (plugin_key) { form_data.plugin_key = plugin_key; - } // console.log( { plugin_key } ); + } + // console.log( { plugin_key } ); var self = this; jQuery.ajax({ @@ -2106,6 +2069,7 @@ window.addEventListener('DOMContentLoaded', function () { }, success: function success(response) { // console.log( { response } ); + if (response.status.success) { $(self).html('Updated'); location.reload(); @@ -2120,16 +2084,15 @@ window.addEventListener('DOMContentLoaded', function () { $(this).prop('disabled', false); } }); - }); // Install Button + }); + // Install Button $('.file-install-btn').on('click', function (e) { e.preventDefault(); - if ($(this).hasClass('in-progress')) { // console.log('Wait...'); return; } - var data_key = $(this).data('key'); var data_type = $(this).data('type'); var form_data = { @@ -2154,10 +2117,10 @@ window.addEventListener('DOMContentLoaded', function () { }, success: function success(response) { // console.log(response); + if (response.status && !response.status.success && response.status.message) { alert(response.status.message); } - if (response.status && response.status.success) { $(self).html('Installed'); location.reload(); @@ -2172,16 +2135,15 @@ window.addEventListener('DOMContentLoaded', function () { $(self).html(btn_default_html); } }); - }); // Plugin Active Button + }); + // Plugin Active Button $('.plugin-active-btn').on('click', function (e) { e.preventDefault(); - if ($(this).hasClass('in-progress')) { // console.log('Wait...'); return; } - var data_key = $(this).data('key'); var form_data = { action: 'atbdp_activate_plugin', @@ -2203,17 +2165,17 @@ window.addEventListener('DOMContentLoaded', function () { }, success: function success(response) { // console.log(response); + // return; + if (response.status && !response.status.success && response.status.message) { alert(response.status.message); } - if (response.status && response.status.success) { $(self).html('Activated'); } else { $(self).html('Failed'); } - location.reload(); }, error: function error(_error5) { @@ -2223,8 +2185,9 @@ window.addEventListener('DOMContentLoaded', function () { $(self).html(btn_default_html); } }); - }); // Purchase refresh btn + }); + // Purchase refresh btn $('.purchase-refresh-btn').on('click', function (e) { e.preventDefault(); var purchase_refresh_btn_wrapper = $(this).parent(); @@ -2235,8 +2198,9 @@ window.addEventListener('DOMContentLoaded', function () { $(auth_section).animate({ width: 330 }, 500); - }); // et-close-auth-btn + }); + // et-close-auth-btn $('.et-close-auth-btn').on('click', function (e) { e.preventDefault(); var auth_section = $('.et-auth-section'); @@ -2247,10 +2211,12 @@ window.addEventListener('DOMContentLoaded', function () { $(auth_section).animate({ width: 0 }, 500); - }); // purchase-refresh-form + }); + // purchase-refresh-form $('#purchase-refresh-form').on('submit', function (e) { - e.preventDefault(); // console.log( 'purchase-refresh-form' ); + e.preventDefault(); + // console.log( 'purchase-refresh-form' ); var submit_btn = $(this).find('button[type="submit"]'); var btn_default_html = submit_btn.html(); @@ -2274,17 +2240,16 @@ window.addEventListener('DOMContentLoaded', function () { }, success: function success(response) { // console.log(response); + if (response.status.message) { var feedback_type = response.status.success ? 'success' : 'danger'; var message = "").concat(response.status.message, ""); form_feedback.html(message); } - if (!response.status.success) { $(submit_btn).html(btn_default_html); $(submit_btn).prop('disabled', false); $(close_btn).removeClass('atbdp-d-none'); - if (response.status.reload) { location.reload(); } @@ -2299,8 +2264,9 @@ window.addEventListener('DOMContentLoaded', function () { $(close_btn).removeClass('atbdp-d-none'); } }); - }); // Logout + }); + // Logout $('.subscriptions-logout-btn').on('click', function (e) { e.preventDefault(); var hard_logout = $(this).data('hard-logout'); @@ -2327,13 +2293,16 @@ window.addEventListener('DOMContentLoaded', function () { $(this).removeClass('in-progress'); $(self).html(btn_default_html); } - }); // atbdp_close_subscriptions_sassion - }); // Form Actions - // Apply button active status - My extension form + }); - var extFormCheckboxes = document.querySelectorAll('#atbdp-extensions-tab input[type="checkbox"]'); - var extFormActionSelect = document.querySelectorAll('#atbdp-extensions-tab select[name="bulk-actions"]'); //console.log(extFormActionSelect); + // atbdp_close_subscriptions_sassion + }); + // Form Actions + // Apply button active status - My extension form + var extFormCheckboxes = document.querySelectorAll('#atbdp-extensions-tab input[type="checkbox"]'); + var extFormActionSelect = document.querySelectorAll('#atbdp-extensions-tab select[name="bulk-actions"]'); + //console.log(extFormActionSelect); extFormCheckboxes.forEach(function (elm) { var thisClosest = elm.closest('form'); var bulkAction = thisClosest.querySelector('.ei-action-dropdown select'); @@ -2352,36 +2321,31 @@ window.addEventListener('DOMContentLoaded', function () { actionBtn.classList.add('ei-action-active'); } }); - if (this.value === '') { actionBtn.classList.remove('ei-action-active'); } }); - }); // Bulk Actions - My extensions form + }); + // Bulk Actions - My extensions form var is_bulk_processing = false; $('#atbdp-my-extensions-form').on('submit', function (e) { e.preventDefault(); - if (is_bulk_processing) { return; } - var task = $(this).find('select[name="bulk-actions"]').val(); var plugins_items = []; $(this).find('.extension-name-checkbox').each(function (i, e) { var is_checked = $(e).is(':checked'); var id = $(e).attr('id'); - if (is_checked) { plugins_items.push(id); } }); - if (!task.length || !plugins_items.length) { return; } - var self = this; is_bulk_processing = true; form_data = { @@ -2404,17 +2368,18 @@ window.addEventListener('DOMContentLoaded', function () { error: function error(_error8) { uninstalling = false; } - }); // console.log( task, plugins_items ); - }); // Bulk Actions - My extensions form + }); + + // console.log( task, plugins_items ); + }); + // Bulk Actions - My extensions form var is_bulk_processing = false; $('#atbdp-my-subscribed-extensions-form').on('submit', function (e) { e.preventDefault(); - if (is_bulk_processing) { return; } - var self = this; var task = $(this).find('select[name="bulk-actions"]').val(); var plugins_items = []; @@ -2422,40 +2387,35 @@ window.addEventListener('DOMContentLoaded', function () { $(self).find(tergeted_items_elm).each(function (i, e) { var is_checked = $(e).is(':checked'); var key = $(e).attr('name'); - if (is_checked) { plugins_items.push(key); } }); - if (!task.length || !plugins_items.length) { return; - } // Before Install - + } + // Before Install $(this).find('.file-install-btn').prop('disabled', true).addClass('in-progress'); var loading_icon = ' '; $(this).find('button[type="submit"]').prop('disabled', true).prepend(loading_icon); is_bulk_processing = true; - var after_bulk_process = function after_bulk_process() { is_bulk_processing = false; $(self).find('button[type="submit"]').find('.atbdp-icon').remove(); $(self).find('button[type="submit"]').prop('disabled', false); location.reload(); }; - plugins_bulk_actions('install', plugins_items, after_bulk_process); - }); // Bulk Actions - Required extensions form + }); + // Bulk Actions - Required extensions form var is_bulk_processing = false; $('#atbdp-required-extensions-form').on('submit', function (e) { e.preventDefault(); - if (is_bulk_processing) { return; } - var self = this; var task = $(this).find('select[name="bulk-actions"]').val(); var plugins_items = []; @@ -2463,37 +2423,33 @@ window.addEventListener('DOMContentLoaded', function () { $(self).find(tergeted_items_elm).each(function (i, e) { var is_checked = $(e).is(':checked'); var key = $(e).attr('value'); - if (is_checked) { plugins_items.push(key); } }); - if (!task.length || !plugins_items.length) { return; - } // Before Install - + } + // Before Install $(this).find('.file-install-btn').prop('disabled', true).addClass('in-progress'); $(this).find('.plugin-active-btn').prop('disabled', true).addClass('in-progress'); var loading_icon = ' '; $(this).find('button[type="submit"]').prop('disabled', true).prepend(loading_icon); is_bulk_processing = true; - var after_bulk_process = function after_bulk_process() { is_bulk_processing = false; $(self).find('button[type="submit"]').find('.atbdp-icon').remove(); $(self).find('button[type="submit"]').prop('disabled', false); location.reload(); }; - var available_task_list = ['install', 'activate']; - if (available_task_list.includes(task)) { plugins_bulk_actions(task, plugins_items, after_bulk_process); } - }); // plugins_bulk__actions + }); + // plugins_bulk__actions function plugins_bulk_actions(task, plugins_items, after_plugins_install) { var action = { install: 'atbdp_install_file_from_subscriptions', @@ -2511,16 +2467,13 @@ window.addEventListener('DOMContentLoaded', function () { install: '.file-install-btn', activate: '.plugin-active-btn' }; - var bulk_task = function bulk_task(plugins, counter, callback) { if (counter > plugins.length - 1) { if (callback) { callback(); } - return; } - var current_item = plugins[counter]; var action_wrapper_key = 'install' === task ? plugins[counter] : plugins[counter].replace(/\/.+$/g, ''); var action_wrapper = $(".ext-action-".concat(action_wrapper_key)); @@ -2547,26 +2500,23 @@ window.addEventListener('DOMContentLoaded', function () { } else { action_btn.html('Failed'); } - bulk_task(plugins, next_index, callback); }, - error: function error(_error9) {// console.log(error); + error: function error(_error9) { + // console.log(error); } }); }; - bulk_task(plugins_items, 0, after_plugins_install); - } // Ext Actions | Uninstall - + } + // Ext Actions | Uninstall var uninstalling = false; $('.ext-action-uninstall').on('click', function (e) { e.preventDefault(); - if (uninstalling) { return; } - var data_target = $(this).data('target'); var form_data = { action: 'atbdp_plugins_bulk_action', @@ -2593,11 +2543,11 @@ window.addEventListener('DOMContentLoaded', function () { uninstalling = false; } }); - }); // Bulk checkbox toggle + }); + // Bulk checkbox toggle $('#select-all-installed').on('change', function (e) { var is_checked = $(this).is(':checked'); - if (is_checked) { $('#atbdp-my-extensions-form').find('.extension-name-checkbox').prop('checked', true); } else { @@ -2606,7 +2556,6 @@ window.addEventListener('DOMContentLoaded', function () { }); $('#select-all-subscription').on('change', function (e) { var is_checked = $(this).is(':checked'); - if (is_checked) { $('#atbdp-my-subscribed-extensions-form').find('.extension-name-checkbox').prop('checked', true); } else { @@ -2615,18 +2564,17 @@ window.addEventListener('DOMContentLoaded', function () { }); $('#select-all-required-extensions').on('change', function (e) { var is_checked = $(this).is(':checked'); - if (is_checked) { $('#atbdp-required-extensions-form').find('.extension-name-checkbox').prop('checked', true); } else { $('#atbdp-required-extensions-form').find('.extension-name-checkbox').prop('checked', false); } - }); // + }); + // $('.ext-action-drop').each(function (i, e) { $(e).on('click', function (elm) { elm.preventDefault(); - if ($(this).hasClass('active')) { $(this).removeClass('active'); } else { @@ -2634,26 +2582,22 @@ window.addEventListener('DOMContentLoaded', function () { $(this).addClass('active'); } }); - }); // Theme Activation + }); + // Theme Activation var theme_is_activating = false; $('.theme-activate-btn').on('click', function (e) { e.preventDefault(); - if (theme_is_activating) { return; } - var data_target = $(this).data('target'); - if (!data_target) { return; } - if (!data_target.length) { return; } - var form_data = { action: 'atbdp_activate_theme', theme_stylesheet: data_target, @@ -2671,7 +2615,6 @@ window.addEventListener('DOMContentLoaded', function () { success: function success(response) { // console.log({ response }); $(self).find('.atbdp-icon').remove(); - if (response.status && response.status.success) { location.reload(); } @@ -2682,27 +2625,24 @@ window.addEventListener('DOMContentLoaded', function () { $(self).find('.atbdp-icon').remove(); } }); - }); // Theme Update + }); + // Theme Update $('.theme-update-btn').on('click', function (e) { e.preventDefault(); $(this).prop('disabled', true); - if ($(this).hasClass('in-progress')) { return; } - var theme_stylesheet = $(this).data('target'); var button_default_html = $(this).html(); var form_data = { action: 'atbdp_update_theme', nonce: directorist_admin.nonce }; - if (theme_stylesheet) { form_data.theme_stylesheet = theme_stylesheet; } - var self = this; $(this).addClass('in-progress'); $.ajax({ @@ -2714,6 +2654,7 @@ window.addEventListener('DOMContentLoaded', function () { }, success: function success(response) { // console.log({ response }); + if (response.status && response.status.success) { $(self).html('Updated'); location.reload(); @@ -2744,7 +2685,6 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // Recovery Password Modal @@ -2752,14 +2692,16 @@ window.addEventListener('DOMContentLoaded', function () { $(".atbdp_recovery_pass").on("click", function (e) { e.preventDefault(); $("#recover-pass-modal").slideToggle().show(); - }); // Contact form [on modal closed] + }); + // Contact form [on modal closed] $('#atbdp-contact-modal').on('hidden.bs.modal', function (e) { $('#atbdp-contact-message').val(''); $('#atbdp-contact-message-display').html(''); - }); // Template Restructured - // Modal + }); + // Template Restructured + // Modal var directoristModal = document.querySelector('.directorist-modal-js'); $('body').on('click', '.directorist-btn-modal-js', function (e) { e.preventDefault(); @@ -2788,52 +2730,44 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (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; } - +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 - +} +// Initialize function init() { // Add custom dropdown toggle button - selec2_add_custom_dropdown_toggle_button(); // Add custom close button where needed + selec2_add_custom_dropdown_toggle_button(); - selec2_add_custom_close_button_if_needed(); // Add custom close button if field contains value on change + // 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'; @@ -2841,9 +2775,9 @@ function selec2_add_custom_dropdown_toggle_button() { var dropdownHTML = "".concat(iconHTML, ""); addon_container.append(dropdownHTML); } + var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); - var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); // Toggle --is-open class - + // 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'); @@ -2851,41 +2785,36 @@ function selec2_add_custom_dropdown_toggle_button() { $('.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 + }); + // 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 + }); + // 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; - + _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) { @@ -2894,21 +2823,20 @@ function selec2_add_custom_close_button_if_needed() { _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 + // 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("".concat(iconHTML, "")); @@ -2918,56 +2846,46 @@ function selec2_add_custom_close_button(field) { field.val(null).trigger('change'); addon_container.find('.directorist-select2-dropdown-close').remove(); selec2_adjust_space_for_addons(); - }); // 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 + // 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(''); 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(''); 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' @@ -2994,18 +2912,16 @@ __webpack_require__.r(__webpack_exports__); /* 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; } - +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } 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 +document.body.addEventListener('directorist-reload-select2-fields', initSelect2); +// Init Static Select 2 Fields function initSelect2() { var select_fields = [{ elm: $('.directorist-select').find('select') @@ -3031,7 +2947,8 @@ function initSelect2() { elm: $('#directorist-select-fr-s-js') }, { elm: $('#directorist-select-fr-e-js') - }, // { elm: $('#directorist-location-select') }, + }, + // { elm: $('#directorist-location-select') }, // { elm: $('#directorist-category-select') }, { elm: $('.select-basic') @@ -3039,30 +2956,33 @@ function initSelect2() { elm: $('#loc-type') }, { elm: $('.bdas-location-search') - }, // { elm: $('.directorist-location-select') }, + }, + // { elm: $('.directorist-location-select') }, { elm: $('#at_biz_dir-category') }, { elm: $('#cat-type') }, { elm: $('.bdas-category-search') - } // { elm: $('.directorist-category-select') }, + } + // { 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 - +} +// Init Select2 Ajax Fields function initSelect2AjaxFields() { - var rest_base_url = "".concat(directorist.rest_url, "directorist/v1"); // Init Select2 Ajax Category Field + 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") @@ -3070,8 +2990,9 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-categories-field').find('select'), url: "".concat(rest_base_url, "/listings/categories") - }); // Init Select2 Ajax Location Field + }); + // Init Select2 Ajax Location Field initSelect2AjaxTaxonomy({ selector: $('.directorist-search-location').find('select'), url: "".concat(rest_base_url, "/listings/locations") @@ -3079,17 +3000,18 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-location-field').find('select'), url: "".concat(rest_base_url, "/listings/locations") - }); // Init Select2 Ajax Tag Field + }); + // Init Select2 Ajax Tag Field initSelect2AjaxTaxonomy({ selector: $('.directorist-form-tag-field').find('select'), url: "".concat(rest_base_url, "/listings/tags") }, { has_directory_type: false }); -} // initSelect2AjaxTaxonomy - +} +// initSelect2AjaxTaxonomy function initSelect2AjaxTaxonomy(args, terms_options) { var defaultArgs = { selector: '', @@ -3101,46 +3023,42 @@ function initSelect2AjaxTaxonomy(args, terms_options) { has_directory_type: true }; terms_options = terms_options ? _objectSpread(_objectSpread({}, default_terms_options), terms_options) : default_terms_options; - 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 createNew = item.getAttribute("data-allow_new"); var maxLength = item.getAttribute("data-max"); - if (terms_options.has_directory_type) { var search_form_parent = $(item).closest('.directorist-search-form'); var archive_page_parent = $(item).closest('.directorist-archive-contents'); var add_listing_form_hidden_input = $(item).closest('.directorist-add-listing-form').find('input[name="directory_type"]'); - var nav_list_item = []; // If search page + 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 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 has nav item if (nav_list_item.length) { directory_type_id = nav_list_item ? nav_list_item.data('listing_type_id') : 0; - } // If has nav item - + } + // If has nav item if (add_listing_form_hidden_input.length) { directory_type_id = add_listing_form_hidden_input.val(); } - if (directory_type_id) { directory_type_id = parseInt(directory_type_id); } } - var currentPage = 1; $(item).select2({ allowClear: true, @@ -3162,11 +3080,9 @@ function initSelect2AjaxTaxonomy(args, terms_options) { page: currentPage, per_page: args.perPage }; - if (directory_type_id) { query.directory = directory_type_id; } - return query; }, processResults: function processResults(data) { @@ -3197,16 +3113,15 @@ function initSelect2AjaxTaxonomy(args, terms_options) { return $request; } } - }); // Setup Preselected Option + }); + // Setup Preselected Option var selected_item_id = $(item).data('selected-id'); var selected_item_label = $(item).data('selected-label'); - var setup_selected_items = function setup_selected_items(element, selected_id, selected_label) { if (!element || !selected_id) { return; } - var selected_ids = "".concat(selected_id).split(','); var selected_labels = selected_label ? "".concat(selected_label).split(',') : []; selected_ids.forEach(function (id, index) { @@ -3224,7 +3139,6 @@ function initSelect2AjaxTaxonomy(args, terms_options) { }); }); }; - setup_selected_items(item, selected_item_id, selected_item_label); }); } @@ -3244,7 +3158,6 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__); document.addEventListener('DOMContentLoaded', init, false); - function Tasks() { return { init: function init() { @@ -3252,13 +3165,10 @@ function Tasks() { }, initToggleTabLinks: function initToggleTabLinks() { var links = document.querySelectorAll('.directorist-toggle-tab'); - if (!links) { return; } - var self = this; - _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(links).forEach(function (item) { item.addEventListener('click', function (event) { self.handleToggleTabLinksEvent(item, event); @@ -3270,53 +3180,44 @@ function Tasks() { var navContainerClass = item.getAttribute('data-nav-container'); var tabContainerClass = item.getAttribute('data-tab-container'); var tabClass = item.getAttribute('data-tab'); - if (!navContainerClass || !tabContainerClass || !tabClass) { return; } - var navContainer = item.closest('.' + navContainerClass); var tabContainer = document.querySelector('.' + tabContainerClass); - if (!navContainer || !tabContainer) { return; } - var tab = tabContainer.querySelector('.' + tabClass); - if (!tab) { return; - } // Remove Active Class - + } + // Remove Active Class var removeActiveClass = function removeActiveClass(item) { item.classList.remove('--is-active'); - }; // Toggle Nav - + }; + // Toggle Nav var activeNavItems = navContainer.querySelectorAll('.--is-active'); - if (activeNavItems) { _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(activeNavItems).forEach(removeActiveClass); } + item.classList.add('--is-active'); - item.classList.add('--is-active'); // Toggle Tab - + // Toggle Tab var activeTabItems = tabContainer.querySelectorAll('.--is-active'); - if (activeTabItems) { _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(activeTabItems).forEach(removeActiveClass); } + tab.classList.add('--is-active'); - tab.classList.add('--is-active'); // Update Query Var - + // Update Query Var var queryVarKey = item.getAttribute('data-query-var-key'); var queryVarValue = item.getAttribute('data-query-var-value'); - if (!queryVarKey || !queryVarValue) { return; } - this.addQueryParam(queryVarKey, queryVarValue); }, addQueryParam: function addQueryParam(key, value) { @@ -3326,7 +3227,6 @@ function Tasks() { } }; } - function init() { var tasks = new Tasks(); tasks.init(); @@ -3345,18 +3245,21 @@ window.addEventListener('DOMContentLoaded', function () { var $ = jQuery; document.querySelectorAll('.la-icon i').forEach(function (item) { className.push(item.getAttribute('class')); - }); // Handle Disabled Link Action + }); + // Handle Disabled Link Action $('.atbdp-disabled').on('click', function (e) { e.preventDefault(); - }); // Toggle Modal + }); + // Toggle Modal $('.cptm-modal-toggle').on('click', function (e) { e.preventDefault(); var target_class = $(this).data('target'); $('.' + target_class).toggleClass('active'); - }); // Change label on file select/change + }); + // Change label on file select/change $('.cptm-file-field').on('change', function (e) { var target_id = $(this).attr('id'); $('label[for=' + target_id + ']').text('Change'); @@ -3408,18 +3311,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -3432,24 +3331,19 @@ function get_dom_data(key, parent) { 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, @@ -3459,7 +3353,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -3470,17 +3363,14 @@ function convertToSelect2(field) { 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/scss/layout/admin/admin-style.scss": @@ -3503,14 +3393,9 @@ function convertToSelect2(field) { 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]; - } - + 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; /***/ }), @@ -3523,11 +3408,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -3537,9 +3420,11 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! \***************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperty(obj, key, value) { + key = toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, @@ -3550,10 +3435,8 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } - module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -3568,7 +3451,6 @@ module.exports = _defineProperty, module.exports.__esModule = true, module.expor 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; /***/ }), @@ -3583,7 +3465,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -3596,21 +3477,55 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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/toPrimitive.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPropertyKey.js": +/*!**************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js"); +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} +module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + /***/ "./node_modules/@babel/runtime/helpers/typeof.js": /*!*******************************************************!*\ !*** ./node_modules/@babel/runtime/helpers/typeof.js ***! @@ -3618,16 +3533,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -3640,7 +3554,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -3649,7 +3562,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }) diff --git a/assets/js/admin-plugins.js b/assets/js/admin-plugins.js index fc92205639..2c232f90b9 100644 --- a/assets/js/admin-plugins.js +++ b/assets/js/admin-plugins.js @@ -109,18 +109,14 @@ jQuery(document).ready(function ($) { var table = $(e.target).closest('table'); $('td input:checkbox', table).prop('checked', this.checked); }); - if ($(extWrapper).innerHeight() > 250) { $(extWrapper).addClass('ext-height-fix'); $(moreLink).show(); $(extWrapper).css('padding-bottom', '60px'); } - $(moreLink).on('click', function (e) { var _this = this; - e.preventDefault(); - if ($(extWrapper).hasClass('ext-height-fix')) { $(extWrapper).animate({ height: '100%' @@ -135,7 +131,6 @@ jQuery(document).ready(function ($) { }, 1000); } }); - if ($(tbody).html() === '') { $('.directorist-extensions').hide(); } diff --git a/assets/js/admin-setup-wizard.js b/assets/js/admin-setup-wizard.js index 36590f3148..b11d02d850 100644 --- a/assets/js/admin-setup-wizard.js +++ b/assets/js/admin-setup-wizard.js @@ -109,10 +109,9 @@ jQuery(document).ready(function ($) { $('.atbdp-mapping-step').removeClass('active').addClass('done'); $('.atbdp-progress-step').addClass('active'); var counter = 0; - var run_import = function run_import() { - var form_data = new FormData(); // ajax action - + var form_data = new FormData(); + // ajax action form_data.append('action', 'atbdp_dummy_data_import'); form_data.append('file', $('#dummy_csv_file').val()); form_data.append('limit', $('#atbdp-listings-to-import').val()); @@ -136,13 +135,11 @@ jQuery(document).ready(function ($) { }); return; } - imported += response.imported; failed += response.failed; redirect_url = response.url; $('.importer-details').html("Imported ".concat(response.next_position, " out of ").concat(response.total)); $('.directorist-importer-progress').val(response.percentage); - if (response.percentage != '100' && counter < 150) { position = response.next_position; run_import(); @@ -150,7 +147,6 @@ jQuery(document).ready(function ($) { } else { window.location = response.url; } - $('input[name="save_step"]').addClass("btn-hide"); $('.directorist-importer-length').css('width', response.percentage + '%'); }, @@ -159,10 +155,10 @@ jQuery(document).ready(function ($) { } }); }; - run_import(); - }); //options + }); + //options $('.atbdp-sw-gmap-key').hide(); $('#select_map').on('change', function (e) { if ($(this).val() === 'google') { @@ -171,13 +167,11 @@ jQuery(document).ready(function ($) { $('.atbdp-sw-gmap-key').hide(); } }); - if ($('#select_map').val() === 'google') { $('.atbdp-sw-gmap-key').show(); } else { $('.atbdp-sw-gmap-key').hide(); } - $('.atbdp-sw-featured-listing').hide(); $('#enable_monetization').on('change', function () { if ($(this).prop("checked") === true) { @@ -186,13 +180,11 @@ jQuery(document).ready(function ($) { $('.atbdp-sw-featured-listing').hide(); } }); - if ($('#enable_monetization').prop("checked") === true) { $('.atbdp-sw-featured-listing').show(); } else { $('.atbdp-sw-featured-listing').hide(); } - $('.atbdp-sw-listing-price').hide(); $('#enable_featured_listing').on('change', function () { if ($(this).prop("checked") === true) { @@ -201,15 +193,13 @@ jQuery(document).ready(function ($) { $('.atbdp-sw-listing-price').hide(); } }); - if ($('#enable_monetization').prop("checked") === true) { $('.atbdp-sw-listing-price').show(); } else { $('.atbdp-sw-listing-price').hide(); } - /* custom select */ - + /* custom select */ $('#select_map').select2({ minimumResultsForSearch: -1 }); diff --git a/assets/js/all-authors.js b/assets/js/all-authors.js index 7e44b69172..ce5cca3c1e 100644 --- a/assets/js/all-authors.js +++ b/assets/js/all-authors.js @@ -109,24 +109,19 @@ }); }); } - authorsMasonry(); - /* alphabet data value */ + /* alphabet data value */ var alphabetValue; - /* authors nav default active item */ + /* authors nav default active item */ if ($('.directorist-authors__nav').length) { $('.directorist-authors__nav ul li:first-child').addClass('active'); } /* authors nav item */ - - $('body').on('click', '.directorist-alphabet', function (e) { e.preventDefault(); - var _this = $(this); - var alphabet = $(this).attr("data-alphabet"); $('body').addClass('atbdp-form-fade'); $.ajax({ @@ -149,8 +144,8 @@ } }); }); - /* authors pagination */ + /* authors pagination */ $('body').on('click', '.directorist-authors-pagination a', function (e) { e.preventDefault(); var paged = $(this).attr('href'); @@ -170,13 +165,11 @@ $('body').removeClass('atbdp-form-fade'); $('#directorist-all-authors').empty().append(response); authorsMasonry(); - if (document.querySelector('.' + getAlphabetValue) !== null) { document.querySelector('.' + getAlphabetValue).closest('li').classList.add('active'); } else if ($('.directorist-authors__nav').length) { $('.directorist-authors__nav ul li:first-child').addClass('active'); } - ; }, error: function error(_error2) { diff --git a/assets/js/all-listings.js b/assets/js/all-listings.js index d417391793..31777098f2 100644 --- a/assets/js/all-listings.js +++ b/assets/js/all-listings.js @@ -94,52 +94,44 @@ /***/ (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; } - +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 - +} +// Initialize function init() { // Add custom dropdown toggle button - selec2_add_custom_dropdown_toggle_button(); // Add custom close button where needed + selec2_add_custom_dropdown_toggle_button(); - selec2_add_custom_close_button_if_needed(); // Add custom close button if field contains value on change + // 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'; @@ -147,9 +139,9 @@ function selec2_add_custom_dropdown_toggle_button() { var dropdownHTML = "".concat(iconHTML, ""); addon_container.append(dropdownHTML); } + var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); - var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); // Toggle --is-open class - + // 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'); @@ -157,41 +149,36 @@ function selec2_add_custom_dropdown_toggle_button() { $('.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 + }); + // 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 + }); + // 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; - + _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) { @@ -200,21 +187,20 @@ function selec2_add_custom_close_button_if_needed() { _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 + // 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("".concat(iconHTML, "")); @@ -224,56 +210,46 @@ function selec2_add_custom_close_button(field) { field.val(null).trigger('change'); addon_container.find('.directorist-select2-dropdown-close').remove(); selec2_adjust_space_for_addons(); - }); // 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 + // 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(''); 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(''); 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' @@ -300,18 +276,16 @@ __webpack_require__.r(__webpack_exports__); /* 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; } - +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } 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 +document.body.addEventListener('directorist-reload-select2-fields', initSelect2); +// Init Static Select 2 Fields function initSelect2() { var select_fields = [{ elm: $('.directorist-select').find('select') @@ -337,7 +311,8 @@ function initSelect2() { elm: $('#directorist-select-fr-s-js') }, { elm: $('#directorist-select-fr-e-js') - }, // { elm: $('#directorist-location-select') }, + }, + // { elm: $('#directorist-location-select') }, // { elm: $('#directorist-category-select') }, { elm: $('.select-basic') @@ -345,30 +320,33 @@ function initSelect2() { elm: $('#loc-type') }, { elm: $('.bdas-location-search') - }, // { elm: $('.directorist-location-select') }, + }, + // { elm: $('.directorist-location-select') }, { elm: $('#at_biz_dir-category') }, { elm: $('#cat-type') }, { elm: $('.bdas-category-search') - } // { elm: $('.directorist-category-select') }, + } + // { 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 - +} +// Init Select2 Ajax Fields function initSelect2AjaxFields() { - var rest_base_url = "".concat(directorist.rest_url, "directorist/v1"); // Init Select2 Ajax Category Field + 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") @@ -376,8 +354,9 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-categories-field').find('select'), url: "".concat(rest_base_url, "/listings/categories") - }); // Init Select2 Ajax Location Field + }); + // Init Select2 Ajax Location Field initSelect2AjaxTaxonomy({ selector: $('.directorist-search-location').find('select'), url: "".concat(rest_base_url, "/listings/locations") @@ -385,17 +364,18 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-location-field').find('select'), url: "".concat(rest_base_url, "/listings/locations") - }); // Init Select2 Ajax Tag Field + }); + // Init Select2 Ajax Tag Field initSelect2AjaxTaxonomy({ selector: $('.directorist-form-tag-field').find('select'), url: "".concat(rest_base_url, "/listings/tags") }, { has_directory_type: false }); -} // initSelect2AjaxTaxonomy - +} +// initSelect2AjaxTaxonomy function initSelect2AjaxTaxonomy(args, terms_options) { var defaultArgs = { selector: '', @@ -407,46 +387,42 @@ function initSelect2AjaxTaxonomy(args, terms_options) { has_directory_type: true }; terms_options = terms_options ? _objectSpread(_objectSpread({}, default_terms_options), terms_options) : default_terms_options; - 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 createNew = item.getAttribute("data-allow_new"); var maxLength = item.getAttribute("data-max"); - if (terms_options.has_directory_type) { var search_form_parent = $(item).closest('.directorist-search-form'); var archive_page_parent = $(item).closest('.directorist-archive-contents'); var add_listing_form_hidden_input = $(item).closest('.directorist-add-listing-form').find('input[name="directory_type"]'); - var nav_list_item = []; // If search page + 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 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 has nav item if (nav_list_item.length) { directory_type_id = nav_list_item ? nav_list_item.data('listing_type_id') : 0; - } // If has nav item - + } + // If has nav item if (add_listing_form_hidden_input.length) { directory_type_id = add_listing_form_hidden_input.val(); } - if (directory_type_id) { directory_type_id = parseInt(directory_type_id); } } - var currentPage = 1; $(item).select2({ allowClear: true, @@ -468,11 +444,9 @@ function initSelect2AjaxTaxonomy(args, terms_options) { page: currentPage, per_page: args.perPage }; - if (directory_type_id) { query.directory = directory_type_id; } - return query; }, processResults: function processResults(data) { @@ -503,16 +477,15 @@ function initSelect2AjaxTaxonomy(args, terms_options) { return $request; } } - }); // Setup Preselected Option + }); + // Setup Preselected Option var selected_item_id = $(item).data('selected-id'); var selected_item_label = $(item).data('selected-label'); - var setup_selected_items = function setup_selected_items(element, selected_id, selected_label) { if (!element || !selected_id) { return; } - var selected_ids = "".concat(selected_id).split(','); var selected_labels = selected_label ? "".concat(selected_label).split(',') : []; selected_ids.forEach(function (id, index) { @@ -530,7 +503,6 @@ function initSelect2AjaxTaxonomy(args, terms_options) { }); }); }; - setup_selected_items(item, selected_item_id, selected_item_label); }); } @@ -555,18 +527,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -579,24 +547,19 @@ function get_dom_data(key, parent) { 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, @@ -606,7 +569,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -617,17 +579,14 @@ function convertToSelect2(field) { 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/categoryLocation.js": @@ -644,10 +603,8 @@ window.addEventListener('DOMContentLoaded', function () { } else { return; } - (function ($) { /* Multi level hierarchy content */ - /* Category */ $('.atbdp_child_category').hide(); $('.atbd_category_wrapper > .expander').on('click', function () { @@ -657,8 +614,8 @@ window.addEventListener('DOMContentLoaded', function () { $(this).siblings('.atbdp_child_category').slideToggle(); $(this).parent('li').siblings('li').children('.atbdp_child_category').slideUp(); }); - /* Location */ + /* Location */ $('.atbdp_child_location').hide(); $('.atbd_location_wrapper > .expander').on('click', function () { $(this).siblings('.atbdp_child_location').slideToggle(); @@ -687,7 +644,6 @@ window.addEventListener('DOMContentLoaded', function () { } else { return; } - $(document).ready(function () { /* Initialize wp color picker */ function colorPickerInit() { @@ -699,10 +655,8 @@ window.addEventListener('DOMContentLoaded', function () { } }); } - colorPickerInit(); /* Initialize on Directory type change */ - document.body.addEventListener('directorist-search-form-nav-tab-reloaded', colorPickerInit); }); })(jQuery); @@ -717,7 +671,6 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_alert_executed === 'undefined') { @@ -725,12 +678,10 @@ window.addEventListener('DOMContentLoaded', function () { } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* Directorist alert dismiss */ var getUrl = window.location.href; var newUrl = getUrl.replace('notice=1', ''); - if ($('.directorist-alert__close') !== null) { $('.directorist-alert__close').each(function (i, e) { $(e).on('click', function (e) { @@ -753,7 +704,6 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_dropdown_executed === 'undefined') { @@ -761,19 +711,17 @@ window.addEventListener('DOMContentLoaded', function () { } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* custom dropdown */ - var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); // toggle dropdown + var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); + // toggle dropdown var clickCount = 0; - if (atbdDropdown !== null) { atbdDropdown.forEach(function (el) { el.querySelector('.directorist-dropdown-select-toggle').addEventListener('click', function (e) { e.preventDefault(); clickCount++; - if (clickCount % 2 === 1) { document.querySelectorAll('.directorist-dropdown-select-items').forEach(function (elem) { elem.classList.remove('directorist-dropdown-select-show'); @@ -786,9 +734,9 @@ window.addEventListener('DOMContentLoaded', function () { } }); }); - } // remvoe toggle when click outside - + } + // remvoe toggle when click outside document.body.addEventListener('click', function (e) { if (e.target.getAttribute('data-drop-toggle') !== 'directorist-dropdown-select-toggle') { clickCount = 0; @@ -796,10 +744,10 @@ window.addEventListener('DOMContentLoaded', function () { el.classList.remove('directorist-dropdown-select-show'); }); } - }); //custom select + }); + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.directorist-dropdown-select-items').forEach(function (item) { @@ -813,27 +761,30 @@ window.addEventListener('DOMContentLoaded', function () { }); }); }); - } // Dropdown - + } + // Dropdown $('body').on('click', '.directorist-dropdown .directorist-dropdown-toggle', function (e) { e.preventDefault(); $(this).siblings('.directorist-dropdown-option').toggle(); - }); // Select Option after click + }); + // Select Option after click $('body').on('click', '.directorist-dropdown .directorist-dropdown-option ul li a', function (e) { e.preventDefault(); var optionText = $(this).html(); $(this).children('.directorist-dropdown-toggle__text').html(optionText); $(this).closest('.directorist-dropdown-option').siblings('.directorist-dropdown-toggle').children('.directorist-dropdown-toggle__text').html(optionText); $('.directorist-dropdown-option').hide(); - }); // Hide Clicked Anywhere + }); + // Hide Clicked Anywhere $(document).bind('click', function (e) { var clickedDom = $(e.target); if (!clickedDom.parents().hasClass('directorist-dropdown')) $('.directorist-dropdown-option').hide(); - }); //atbd_dropdown + }); + //atbd_dropdown $(document).on("click", '.atbd_dropdown', function (e) { if ($(this).attr("class") === "atbd_dropdown") { e.preventDefault(); @@ -849,15 +800,14 @@ window.addEventListener('DOMContentLoaded', function () { }); $('body').on('click', '.atbd_dropdown-toggle', function (e) { e.preventDefault(); - }); // Directorist Dropdown + }); + // Directorist Dropdown $('body').on('click', '.directorist-dropdown-js .directorist-dropdown__toggle-js', function (e) { e.preventDefault(); - if (!$(this).siblings('.directorist-dropdown__links-js').is(':visible')) { $('.directorist-dropdown__links').hide(); } - $(this).siblings('.directorist-dropdown__links-js').toggle(); }); $('body').on('click', function (e) { @@ -878,7 +828,6 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_favorite_executed === 'undefined') { @@ -886,7 +835,6 @@ window.addEventListener('DOMContentLoaded', function () { } else { return; } - window.addEventListener('DOMContentLoaded', function () { // Add or Remove from favourites $('#atbdp-favourites').on('click', function (e) { @@ -900,7 +848,6 @@ window.addEventListener('DOMContentLoaded', function () { console.log('added'); console.log(response); console.log(directorist.ajaxurl); - if (response) { $('#atbdp-favourites').html(response); } @@ -918,7 +865,6 @@ window.addEventListener('DOMContentLoaded', function () { $.post(directorist.ajaxurl, data, function (response) { var post_id = data['post_id'].toString(); var staElement = $('.directorist_favourite_' + post_id); - if ('false' === response) { staElement.remove(); } @@ -939,7 +885,6 @@ window.addEventListener('DOMContentLoaded', function () { var post_id = data['post_id'].toString(); var staElement = $('.directorist-fav_' + post_id); var data_id = staElement.attr('data-listing_id'); - if (response === "login_required") { staElement.children(".directorist-favorite-tooltip").append(fav_tooltip_warning); staElement.children(".directorist-favorite-tooltip").fadeIn(); @@ -979,11 +924,9 @@ window.addEventListener('DOMContentLoaded', function () { window.directorist_select_executed = true; } else { return; - } //custom select - - + } + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -997,9 +940,9 @@ window.addEventListener('DOMContentLoaded', function () { }); }); }); - } // select data-status - + } + // select data-status var atbdSelectData = document.querySelectorAll('.atbd-drop-select.with-sort'); atbdSelectData.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -1022,7 +965,6 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_sorting_executed === 'undefined') { @@ -1030,7 +972,6 @@ window.addEventListener('DOMContentLoaded', function () { } else { return; } - window.addEventListener('DOMContentLoaded', function () { // Sorting Js if (!$('.directorist-instant-search').length) { @@ -1040,9 +981,9 @@ window.addEventListener('DOMContentLoaded', function () { $('#directorsit-listing-sort').attr('action', href); $('#directorsit-listing-sort').submit(); }); - } //sorting toggle - + } + //sorting toggle $('.sorting span').on('click', function () { $(this).toggleClass('fa-sort-amount-asc fa-sort-amount-desc'); }); @@ -1063,14 +1004,12 @@ window.addEventListener('DOMContentLoaded', function () { window.addEventListener('DOMContentLoaded', function () { if ($('.directorist-listing-no-thumb').innerWidth() <= 220) { $('.directorist-listing-no-thumb').addClass('directorist-listing-no-thumb--fix'); - } // Auhtor Profile Listing responsive fix - - + } + // Auhtor Profile Listing responsive fix if ($('.directorist-author-listing-content').innerWidth() <= 750) { $('.directorist-author-listing-content').addClass('directorist-author-listing-grid--fix'); - } // Directorist Archive responsive fix - - + } + // Directorist Archive responsive fix if ($('.directorist-archive-grid-view').innerWidth() <= 500) { $('.directorist-archive-grid-view').addClass('directorist-archive-grid--fix'); } @@ -1087,7 +1026,6 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { /* Responsive grid control */ $(document).ready(function () { @@ -1096,19 +1034,15 @@ window.addEventListener('DOMContentLoaded', function () { var columnRight = $(".directorist.col-lg-4"); var tabColumn = $(".atbd_dashboard_wrapper .tab-content .tab-pane .col-lg-4"); var w_size = d_wrapper.width(); - if (w_size >= 500 && w_size <= 735) { columnLeft.toggleClass("col-lg-8"); columnRight.toggleClass("col-lg-4"); } - if (w_size <= 600) { d_wrapper.addClass("size-xs"); tabColumn.toggleClass("col-lg-4"); } - var listing_size = $(".atbd_dashboard_wrapper .atbd_single_listing").width(); - if (listing_size < 200) { $(".atbd_single_listing .db_btn_area").addClass("db_btn_area--sm"); } @@ -1153,19 +1087,17 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { // Helper function to convert the mysql date Date.createFromMysql = function (mysql_string) { var t, - result = null; - + result = null; if (typeof mysql_string === 'string') { - t = mysql_string.split(/[- :]/); //when t[3], t[4] and t[5] are missing they defaults to zero + t = mysql_string.split(/[- :]/); + //when t[3], t[4] and t[5] are missing they defaults to zero result = new Date(t[0], t[1] - 1, t[2], t[3] || 0, t[4] || 0, t[5] || 0); } - return result; }; })(jQuery); @@ -1180,21 +1112,19 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { /*This function handles all ajax request*/ function atbdp_do_ajax(ElementToShowLoadingIconAfter, ActionName, arg, CallBackHandler) { var data; if (ActionName) data = "action=" + ActionName; if (arg) data = arg + "&action=" + ActionName; - if (arg && !ActionName) data = arg; //data = data ; + if (arg && !ActionName) data = arg; + //data = data ; var n = data.search(directorist.nonceName); - if (n < 0) { data = data + "&" + directorist.nonceName + "=" + directorist.nonce; } - jQuery.ajax({ type: "post", url: directorist.ajaxurl, @@ -1208,7 +1138,6 @@ __webpack_require__.r(__webpack_exports__); } }); } - window.atbdp_do_ajax = atbdp_do_ajax; })(jQuery); @@ -1222,7 +1151,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { /* Listing No Image Controller */ $('.atbd_listing_no_image .atbd_lower_badge').each(function (i, elm) { @@ -1242,7 +1170,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { //adding temporary css class to post draft page if ($(".edit_btn_wrap .atbdp_float_active").length) { @@ -1260,22 +1187,17 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { /* Helper Function for priting static rating */ function print_static_rating($star_number) { var v; - if ($star_number) { v = ''; } - return v; } })(jQuery); @@ -1295,121 +1217,91 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _lib_helper__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./../../lib/helper */ "./assets/src/js/lib/helper.js"); - -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_0___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; } - +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } ; - (function ($) { var full_url = window.location.href; - function update_instant_search_url(form_data) { if (history.pushState) { var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname; - if (form_data.paged && form_data.paged.length) { var query = '?paged=' + form_data.paged + ''; } - if (form_data.q && form_data.q.length) { var query = '?q=' + form_data.q; } - if (form_data.in_cat && form_data.in_cat.length) { var query = query && query.length ? query + '&in_cat=' + form_data.in_cat : '?in_cat=' + form_data.in_cat; } - if (form_data.in_loc && form_data.in_loc.length) { var query = query && query.length ? query + '&in_loc=' + form_data.in_loc : '?in_loc=' + form_data.in_loc; } - if (form_data.in_tag && form_data.in_tag.length) { var query = query && query.length ? query + '&in_tag=' + form_data.in_tag : '?in_tag=' + form_data.in_tag; } - if (form_data.price && form_data.price[0] && form_data.price[0] > 0) { var query = query && query.length ? query + '&price%5B0%5D=' + form_data.price[0] : '?price%5B0%5D=' + form_data.price[0]; } - if (form_data.price && form_data.price[1] && form_data.price[1] > 0) { var query = query && query.length ? query + '&price%5B1%5D=' + form_data.price[1] : '?price%5B1%5D=' + form_data.price[1]; } - if (form_data.price_range && form_data.price_range.length) { var query = query && query.length ? query + '&price_range=' + form_data.price_range : '?price_range=' + form_data.price_range; } - if (form_data.search_by_rating && form_data.search_by_rating.length) { var query = query && query.length ? query + '&search_by_rating=' + form_data.search_by_rating : '?search_by_rating=' + form_data.search_by_rating; } - if (form_data.cityLat && form_data.cityLat.length && form_data.address && form_data.address.length) { var query = query && query.length ? query + '&cityLat=' + form_data.cityLat : '?cityLat=' + form_data.cityLat; } - if (form_data.cityLng && form_data.cityLng.length && form_data.address && form_data.address.length) { var query = query && query.length ? query + '&cityLng=' + form_data.cityLng : '?cityLng=' + form_data.cityLng; } - if (form_data.miles && form_data.miles > 0) { var query = query && query.length ? query + '&miles=' + form_data.miles : '?miles=' + form_data.miles; } - if (form_data.address && form_data.address.length) { var query = query && query.length ? query + '&address=' + form_data.address : '?address=' + form_data.address; } - if (form_data.zip && form_data.zip.length) { var query = query && query.length ? query + '&zip=' + form_data.zip : '?zip=' + form_data.zip; } - if (form_data.fax && form_data.fax.length) { var query = query && query.length ? query + '&fax=' + form_data.fax : '?fax=' + form_data.fax; } - if (form_data.email && form_data.email.length) { var query = query && query.length ? query + '&email=' + form_data.email : '?email=' + form_data.email; } - if (form_data.website && form_data.website.length) { var query = query && query.length ? query + '&website=' + form_data.website : '?website=' + form_data.website; } - if (form_data.phone && form_data.phone.length) { var query = query && query.length ? query + '&phone=' + form_data.phone : '?phone=' + form_data.phone; } - if (form_data.custom_field && form_data.custom_field.length) { var query = query && query.length ? query + '&custom_field=' + form_data.custom_field : '?custom_field=' + form_data.custom_field; } - if (form_data.open_now && form_data.open_now.length) { var query = query && query.length ? query + '&open_now=' + form_data.open_now : '?open_now=' + form_data.open_now; } - var newurl = query ? newurl + query : newurl; window.history.pushState({ path: newurl }, '', newurl); } } - function getURLParameter(url, name) { var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'); var results = regex.exec(url); - if (!results || !results[2]) { return ''; } - return decodeURIComponent(results[2]); } - /* Directorist instant search */ - + /* Directorist instant search */ $('body').on("submit", ".directorist-instant-search .directorist-advanced-filter__form", function (e) { e.preventDefault(); var instant_search_element = $(this).closest('.directorist-instant-search'); @@ -1426,7 +1318,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va var test = $(el).attr('name'); var type = $(el).attr('type'); var post_id = test.replace(/(custom_field\[)/, '').replace(/\]/, ''); - if ('radio' === type) { $.each($("input[name='custom_field[" + post_id + "]']:checked"), function () { value = $(this).val(); @@ -1473,26 +1364,23 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va email: $(this).find('input[name="email"]').val(), website: $(this).find('input[name="website"]').val(), phone: $(this).find('input[name="phone"]').val() - }; //business hours + }; + //business hours if ($('input[name="open_now"]').is(':checked')) { fields.open_now = $(this).find('input[name="open_now"]').val(); } - if (fields.address && fields.address.length) { fields.cityLat = $(this).find('#cityLat').val(); fields.cityLng = $(this).find('#cityLng').val(); fields.miles = $(this).find('.directorist-range-slider-value').val(); } - if (fields.zip && fields.zip.length) { fields.zip_cityLat = $(this).find('.zip-cityLat').val(); fields.zip_cityLng = $(this).find('.zip-cityLng').val(); fields.miles = $(this).find('.directorist-range-slider-value').val(); } - var form_data = _objectSpread(_objectSpread({}, data), fields); - var allFieldsAreEmpty = Object.values(fields).every(function (item) { return !item; }); @@ -1505,16 +1393,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va var customFieldsAreEmpty = Object.values(data.custom_field).every(function (item) { return !item; }); - if (!allFieldsAreEmpty || !tagFieldEmpty || !priceFieldEmpty || !customFieldsAreEmpty) { if (view && view.length) { form_data.view = view; } - if (directory_type && directory_type.length) { form_data.directory_type = directory_type; } - update_instant_search_url(form_data); $.ajax({ url: directorist.ajaxurl, @@ -1543,9 +1428,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va $('body').on("submit", ".widget .default-ad-search:not(.directorist_single) .directorist-advanced-filter__form", function (e) { if ($('.directorist-instant-search').length) { e.preventDefault(); - var _this = $(this); - var tag = []; var price = []; var custom_field = {}; @@ -1559,7 +1442,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va var test = $(el).attr('name'); var type = $(el).attr('type'); var post_id = test.replace(/(custom_field\[)/, '').replace(/\]/, ''); - if ('radio' === type) { $.each($("input[name='custom_field[" + post_id + "]']:checked"), function () { value = $(this).val(); @@ -1607,25 +1489,20 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va website: $(this).find('input[name="website"]').val(), phone: $(this).find('input[name="phone"]').val() }; - if ($('input[name="open_now"]').is(':checked')) { fields.open_now = $(this).find('input[name="open_now"]').val(); } - if (fields.address && fields.address.length) { fields.cityLat = $(this).find('#cityLat').val(); fields.cityLng = $(this).find('#cityLng').val(); fields.miles = $(this).find('input[name="miles"]').val(); } - if (fields.zip && fields.zip.length) { fields.zip_cityLat = $(this).find('.zip-cityLat').val(); fields.zip_cityLng = $(this).find('.zip-cityLng').val(); fields.miles = $(this).find('.directorist-range-slider-value').val(); } - var form_data = _objectSpread(_objectSpread({}, data), fields); - var allFieldsAreEmpty = Object.values(fields).every(function (item) { return !item; }); @@ -1638,16 +1515,13 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va var customFieldsAreEmpty = Object.values(data.custom_field).every(function (item) { return !item; }); - if (!allFieldsAreEmpty || !tagFieldEmpty || !priceFieldEmpty || !customFieldsAreEmpty) { if (view && view.length) { form_data.view = view; } - if (directory_type && directory_type.length) { form_data.directory_type = directory_type; } - update_instant_search_url(form_data); $.ajax({ url: directorist.ajaxurl, @@ -1673,16 +1547,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va }); } } - }); // Directorist type changes + }); + // Directorist type changes $('body').on("click", ".directorist-instant-search .directorist-type-nav__link", function (e) { e.preventDefault(); - var _this = $(this); - var type_href = $(this).attr('href'); - var type = type_href.match(/directory_type=.+/); //let directory_type = ( type && type.length ) ? type[0].replace( /directory_type=/, '' ) : ''; - + var type = type_href.match(/directory_type=.+/); + //let directory_type = ( type && type.length ) ? type[0].replace( /directory_type=/, '' ) : ''; var directory_type = getURLParameter(type_href, 'directory_type'); var data_atts = $(this).closest('.directorist-instant-search').attr('data-atts'); var form_data = { @@ -1707,7 +1580,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va window.dispatchEvent(new CustomEvent('directorist-instant-search-reloaded')); window.dispatchEvent(new CustomEvent('directorist-reload-listings-map-archive')); } - var events = [new CustomEvent('directorist-instant-search-reloaded'), new CustomEvent('directorist-search-form-nav-tab-reloaded'), new CustomEvent('directorist-reload-select2-fields'), new CustomEvent('directorist-reload-map-api-field')]; events.forEach(function (event) { document.body.dispatchEvent(event); @@ -1718,8 +1590,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va }); $('body').on("click", ".disabled-link", function (e) { e.preventDefault(); - }); // Directorist view as changes + }); + // Directorist view as changes $('body').on("click", ".directorist-instant-search .directorist-viewas-dropdown .directorist-dropdown__links--single", function (e) { e.preventDefault(); var instant_search_element = $(this).closest('.directorist-instant-search'); @@ -1736,7 +1609,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va var test = $(el).attr('name'); var type = $(el).attr('type'); var post_id = test.replace(/(custom_field\[)/, '').replace(/\]/, ''); - if ('radio' === type) { $.each($("input[name='custom_field[" + post_id + "]']:checked"), function () { value = $(this).val(); @@ -1804,24 +1676,21 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va phone: phone || getURLParameter(full_url, 'phone'), custom_field: custom_field || getURLParameter(full_url, 'custom_field'), data_atts: JSON.parse(data_atts) - }; //business hours + }; + //business hours if ($('input[name="open_now"]').is(':checked')) { form_data.open_now = instant_search_element.find('input[name="open_now"]').val(); } - if (page_no && page_no.length) { form_data.paged = page_no; } - if (directory_type && directory_type.length) { form_data.directory_type = directory_type; } - if (sort && sort.length) { form_data.sort = sort; } - $.ajax({ url: directorist.ajaxurl, type: "POST", @@ -1833,8 +1702,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va instant_search_element.find('.directorist-archive-items').addClass('atbdp-form-fade'); instant_search_element.find('.directorist-dropdown__links').hide(); instant_search_element.find('.directorist-header-bar .directorist-advanced-filter').removeClass('directorist-advanced-filter--show'); - instant_search_element.find('.directorist-header-bar .directorist-advanced-filter').css('visibility', 'hidden'); //$(document).scrollTop( $(this).closest(".directorist-instant-search").offset().top ); + instant_search_element.find('.directorist-header-bar .directorist-advanced-filter').css('visibility', 'hidden'); + //$(document).scrollTop( $(this).closest(".directorist-instant-search").offset().top ); }, + success: function success(html) { if (html.view_as) { instant_search_element.find('.directorist-header-found-title span').text(html.count); @@ -1849,8 +1720,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va } }); }); - $('.directorist-instant-search .directorist-dropdown__links--single-js').off('click'); // Directorist sort by changes + $('.directorist-instant-search .directorist-dropdown__links--single-js').off('click'); + // Directorist sort by changes $('body').on("click", ".directorist-instant-search .directorist-sortby-dropdown .directorist-dropdown__links--single-js", function (e) { e.preventDefault(); var instant_search_element = $(this).closest('.directorist-instant-search'); @@ -1867,7 +1739,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va var test = $(el).attr('name'); var type = $(el).attr('type'); var post_id = test.replace(/(custom_field\[)/, '').replace(/\]/, ''); - if ('radio' === type) { $.each($("input[name='custom_field[" + post_id + "]']:checked"), function () { value = $(this).val(); @@ -1935,16 +1806,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va custom_field: custom_field || getURLParameter(full_url, 'custom_field'), view: view, data_atts: JSON.parse(data_atts) - }; //business hours + }; + //business hours if ($('input[name="open_now"]').is(':checked')) { form_data.open_now = instant_search_element.find('input[name="open_now"]').val(); } - if (directory_type && directory_type.length) { form_data.directory_type = directory_type; } - $.ajax({ url: directorist.ajaxurl, type: "POST", @@ -1967,16 +1837,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va instant_search_element.find('.directorist-sortby-dropdown .directorist-dropdown__links--single-js').removeClass("disabled-link"); instant_search_element.find('.directorist-dropdown__links-js a').addClass('directorist-dropdown__links--single-js'); } - window.dispatchEvent(new CustomEvent('directorist-instant-search-reloaded')); window.dispatchEvent(new CustomEvent('directorist-reload-listings-map-archive')); } }); - }); // Directorist pagination + }); + // Directorist pagination $('body').on("click", ".directorist-instant-search .directorist-pagination .page-numbers", function (e) { var _form_data; - e.preventDefault(); var tag = []; var price = []; @@ -1992,7 +1861,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va var test = $(el).attr('name'); var type = $(el).attr('type'); var post_id = test.replace(/(custom_field\[)/, '').replace(/\]/, ''); - if ('radio' === type) { $.each($("input[name='custom_field[" + post_id + "]']:checked"), function () { value = $(this).val(); @@ -2041,12 +1909,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va var page = paginate_link && paginate_link.length ? paginate_link.match(/page\/.+/) : ''; var page_value = page && page.length ? page[0].replace(/page\//, '') : ''; var page_no = page_value && page_value.length ? page_value.replace(/\//, '') : ''; - if (!page_no) { var page = paginate_link && paginate_link.length ? paginate_link.match(/paged=.+/) : ''; var page_no = page && page.length ? page[0].replace(/paged=/, '') : ''; } - var form_data = (_form_data = { action: 'directorist_instant_search', _nonce: directorist.ajax_nonce, @@ -2069,22 +1935,19 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va website: website || getURLParameter(full_url, 'website'), phone: phone || getURLParameter(full_url, 'phone'), custom_field: custom_field || getURLParameter(full_url, 'custom_field') - }, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_form_data, "view", view), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_form_data, "paged", page_no), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_form_data, "data_atts", JSON.parse(data_atts)), _form_data); //business hours + }, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_form_data, "view", view), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_form_data, "paged", page_no), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_form_data, "data_atts", JSON.parse(data_atts)), _form_data); + //business hours if ($('input[name="open_now"]').is(':checked')) { form_data.open_now = instant_search_element.find('input[name="open_now"]').val(); } - update_instant_search_url(form_data); - if (directory_type && directory_type.length) { form_data.directory_type = directory_type; } - if (sort && sort.length) { form_data.sort = sort; } - $.ajax({ url: directorist.ajaxurl, type: "POST", @@ -2099,7 +1962,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va instant_search_element.find('.directorist-archive-items').removeClass('atbdp-form-fade'); $(document).scrollTop(instant_search_element.offset().top); } - window.dispatchEvent(new CustomEvent('directorist-instant-search-reloaded')); window.dispatchEvent(new CustomEvent('directorist-reload-listings-map-archive')); } @@ -2118,16 +1980,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va window.addEventListener('DOMContentLoaded', function () { /* custom dropdown */ - var atbdDropdown = document.querySelectorAll('.atbd-dropdown'); // toggle dropdown + var atbdDropdown = document.querySelectorAll('.atbd-dropdown'); + // toggle dropdown var clickCount = 0; - if (atbdDropdown !== null) { atbdDropdown.forEach(function (el) { el.querySelector('.atbd-dropdown-toggle').addEventListener('click', function (e) { e.preventDefault(); clickCount++; - if (clickCount % 2 === 1) { document.querySelectorAll('.atbd-dropdown-items').forEach(function (elem) { elem.classList.remove('atbd-show'); @@ -2140,9 +2001,9 @@ window.addEventListener('DOMContentLoaded', function () { } }); }); - } // remvoe toggle when click outside - + } + // remvoe toggle when click outside document.body.addEventListener('click', function (e) { if (e.target.getAttribute('data-drop-toggle') !== 'atbd-toggle') { clickCount = 0; @@ -2166,18 +2027,16 @@ window.addEventListener('DOMContentLoaded', function () { function initObserver() { var targetNode = document.querySelector('.directorist-archive-contents'); var observer = new MutationObserver(initMasonry); - if (targetNode) { observer.observe(targetNode, { childList: true }); } -} // All listings Masonry layout - +} +// All listings Masonry layout function initMasonry() { var $ = jQuery; - function authorsMasonry(selector) { var authorsCard = $(selector); $(authorsCard).each(function (id, elm) { @@ -2190,10 +2049,8 @@ function initMasonry() { }); }); } - authorsMasonry('.directorist-archive-grid-view'); } - window.addEventListener('DOMContentLoaded', initObserver); window.addEventListener('DOMContentLoaded', initMasonry); @@ -2212,13 +2069,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _review_starRating__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_review_starRating__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _review_advanced_review__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./review/advanced-review */ "./assets/src/js/public/components/review/advanced-review.js"); // Helper Components - // import './review/addReview' + +// import './review/addReview' // import './review/reviewAttatchment' // import './review/deleteReview' // import './review/reviewPagination' - /***/ }), /***/ "./assets/src/js/public/components/review/advanced-review.js": @@ -2236,36 +2093,27 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__); - 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; } - +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; } window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { 'use strict'; var ReplyFormObserver = /*#__PURE__*/function () { function ReplyFormObserver() { var _this = this; - _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, ReplyFormObserver); - this.init(); $(document).on('directorist_review_updated', function () { return _this.init(); }); } - _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(ReplyFormObserver, [{ key: "init", value: function init() { var node = document.querySelector('.commentlist'); - if (node) { this.observe(node); } @@ -2284,38 +2132,28 @@ window.addEventListener('DOMContentLoaded', function () { key: "callback", value: function callback(mutationsList, observer) { var _iterator = _createForOfIteratorHelper(mutationsList), - _step; - + _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var mutation = _step.value; var target = mutation.target; - if (mutation.removedNodes) { target.classList.remove('directorist-form-added'); - var _iterator2 = _createForOfIteratorHelper(mutation.removedNodes), - _step2; - + _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var node = _step2.value; - if (!node.id || node.id !== 'respond') { continue; } - var criteria = node.querySelector('.directorist-review-criteria'); - if (criteria) { criteria.style.display = ''; } - var ratings = node.querySelectorAll('.directorist-review-criteria-select'); - var _iterator3 = _createForOfIteratorHelper(ratings), - _step3; - + _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var rating = _step3.value; @@ -2326,9 +2164,9 @@ window.addEventListener('DOMContentLoaded', function () { } finally { _iterator3.f(); } - node.querySelector('#submit').innerHTML = 'Submit Review'; - node.querySelector('#comment').setAttribute('placeholder', 'Leave a review'); //console.log(node.querySelector('#comment')) + node.querySelector('#comment').setAttribute('placeholder', 'Leave a review'); + //console.log(node.querySelector('#comment')) } } catch (err) { _iterator2.e(err); @@ -2336,30 +2174,22 @@ window.addEventListener('DOMContentLoaded', function () { _iterator2.f(); } } - var form = target.querySelector('#commentform'); - if (form) { target.classList.add('directorist-form-added'); var isReview = target.classList.contains('review'); var isEditing = target.classList.contains('directorist-form-editing'); - if (!isReview || isReview && !isEditing) { var _criteria = form.querySelector('.directorist-review-criteria'); - if (_criteria) { _criteria.style.display = 'none'; } - var _ratings = form.querySelectorAll('.directorist-review-criteria-select'); - var _iterator4 = _createForOfIteratorHelper(_ratings), - _step4; - + _step4; try { for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { var _rating = _step4.value; - _rating.setAttribute('disabled', 'disabled'); } } catch (err) { @@ -2368,13 +2198,10 @@ window.addEventListener('DOMContentLoaded', function () { _iterator4.f(); } } - var alert = form.querySelector('.directorist-alert'); - if (alert) { alert.style.display = 'none'; } - form.querySelector('#submit').innerHTML = 'Submit Reply'; form.querySelector('#comment').setAttribute('placeholder', 'Leave your reply'); } @@ -2386,17 +2213,13 @@ window.addEventListener('DOMContentLoaded', function () { } } }]); - return ReplyFormObserver; }(); - var CommentEditHandler = /*#__PURE__*/function () { function CommentEditHandler() { _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, CommentEditHandler); - this.init(); } - _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(CommentEditHandler, [{ key: "init", value: function init() { @@ -2428,7 +2251,6 @@ window.addEventListener('DOMContentLoaded', function () { CommentEditHandler.showError($form, data.data.html); return; } - var body = $('
    '); body.append(data); var comment_section = '.directorist-review-container'; @@ -2436,12 +2258,11 @@ window.addEventListener('DOMContentLoaded', function () { $(comment_section).replaceWith(comments); $(document).trigger('directorist_review_updated', data); var commentTop = $("#comment-" + commentID).offset().top; - if ($('body').hasClass('admin-bar')) { commentTop = commentTop - $('#wpadminbar').height(); - } // scroll to comment - + } + // scroll to comment if (commentID) { $("body, html").animate({ scrollTop: commentTop @@ -2464,17 +2285,13 @@ window.addEventListener('DOMContentLoaded', function () { $form.prepend(msg); } }]); - return CommentEditHandler; }(); - var CommentAddReplyHandler = /*#__PURE__*/function () { function CommentAddReplyHandler() { _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, CommentAddReplyHandler); - this.init(); } - _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(CommentAddReplyHandler, [{ key: "init", value: function init() { @@ -2482,7 +2299,6 @@ window.addEventListener('DOMContentLoaded', function () { if ($('.directorist-review-container').length) { $(document).off('submit', '#commentform'); } - clearTimeout(t); }, 2000); $(document).off('submit', '.directorist-review-container #commentform'); @@ -2492,7 +2308,6 @@ window.addEventListener('DOMContentLoaded', function () { key: "onSubmit", value: function onSubmit(event) { var _this2 = this; - event.preventDefault(); var form = $('.directorist-review-container #commentform'); var originalButtonLabel = form.find('[type="submit"]').val(); @@ -2513,17 +2328,17 @@ window.addEventListener('DOMContentLoaded', function () { var comment_section = '.directorist-review-container'; var comments = body.find(comment_section); var errorMsg = body.find('.wp-die-message'); - if (errorMsg.length > 0) { CommentAddReplyHandler.showError(form, errorMsg); $(document).trigger('directorist_review_update_failed'); return; } - $(comment_section).replaceWith(comments); $(document).trigger('directorist_review_updated', data); var newComment = comments.find('.commentlist li:first-child'); - var newCommentId = newComment.attr('id'); // // catch the new comment id by comparing to old dom. + var newCommentId = newComment.attr('id'); + + // // catch the new comment id by comparing to old dom. // commentsLists.each( // function ( index ) { // var _this = $( commentsLists[ index ] ); @@ -2532,15 +2347,15 @@ window.addEventListener('DOMContentLoaded', function () { // } // } // ); + // console.log(newComment, newCommentId) var commentTop = $("#" + newCommentId).offset().top; - if ($('body').hasClass('admin-bar')) { commentTop = commentTop - $('#wpadminbar').height(); - } // scroll to comment - + } + // scroll to comment if (newCommentId) { $('body, html').animate({ scrollTop: commentTop @@ -2553,7 +2368,6 @@ window.addEventListener('DOMContentLoaded', function () { console.log(data); CommentAddReplyHandler.showError(form, body.find('.wp-die-message')); $(document).trigger('directorist_review_update_failed'); - if (data.status === 403 || data.status === 401) { $(document).off('submit', '.directorist-review-container #commentform', _this2.onSubmit); $('#comment').prop('disabled', false); @@ -2572,13 +2386,10 @@ window.addEventListener('DOMContentLoaded', function () { if ($dom.find('p').length) { $dom = $dom.find('p'); } - var words = $dom.text().split(':'); - if (words.length > 1) { words.shift(); } - return words.join(' ').trim(); } }, { @@ -2587,26 +2398,21 @@ window.addEventListener('DOMContentLoaded', function () { if (form.find('.directorist-alert').length) { form.find('.directorist-alert').remove(); } - var $error = $('
    ', { class: 'directorist-alert directorist-alert-danger' }).html(CommentAddReplyHandler.getErrorMsg($dom)); form.prepend($error); } }]); - return CommentAddReplyHandler; }(); - var CommentsManager = /*#__PURE__*/function () { function CommentsManager() { _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, CommentsManager); - this.$doc = $(document); this.setupComponents(); this.addEventListeners(); } - _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(CommentsManager, [{ key: "initStarRating", value: function initStarRating() { @@ -2619,7 +2425,6 @@ window.addEventListener('DOMContentLoaded', function () { value: function cancelOthersEditMode(currentCommentId) { $('.directorist-comment-editing').each(function (index, comment) { var $cancelButton = $(comment).find('.directorist-js-cancel-comment-edit'); - if ($cancelButton.data('commentid') != currentCommentId) { $cancelButton.click(); } @@ -2635,7 +2440,6 @@ window.addEventListener('DOMContentLoaded', function () { key: "addEventListeners", value: function addEventListeners() { var _this3 = this; - var self = this; this.$doc.on('directorist_review_updated', function (event) { _this3.initStarRating(); @@ -2646,7 +2450,6 @@ window.addEventListener('DOMContentLoaded', function () { this.$doc.on('click', 'a[href="#respond"]', function (event) { // First cancle the reply form then scroll to review form. Order matters. _this3.cancelReplyMode(); - _this3.onWriteReivewClick(event); }); this.$doc.on('click', '.directorist-js-edit-comment', function (event) { @@ -2686,11 +2489,9 @@ window.addEventListener('DOMContentLoaded', function () { value: function onWriteReivewClick(event) { event.preventDefault(); var scrollTop = $('#respond').offset().top; - if ($('body').hasClass('admin-bar')) { scrollTop = scrollTop - $('#wpadminbar').height(); } - $('body, html').animate({ scrollTop: scrollTop }, 600); @@ -2703,10 +2504,8 @@ window.addEventListener('DOMContentLoaded', function () { new CommentEditHandler(); } }]); - return CommentsManager; }(); - var commentsManager = new CommentsManager(); })(jQuery); }); @@ -2722,7 +2521,6 @@ window.addEventListener('DOMContentLoaded', function () { window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { //Star rating if ($('.directorist-review-criteria-select').length) { @@ -2780,10 +2578,12 @@ __webpack_require__.r(__webpack_exports__); Author: wpWax Author URI: www.wpwax.com */ - // General Components +// General Components + + @@ -2821,14 +2621,9 @@ __webpack_require__.r(__webpack_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]; - } - + 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; /***/ }), @@ -2841,11 +2636,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -2862,7 +2655,6 @@ function _classCallCheck(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } - module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -2872,18 +2664,18 @@ module.exports = _classCallCheck, module.exports.__esModule = true, module.expor !*** ./node_modules/@babel/runtime/helpers/createClass.js ***! \************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); + Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); @@ -2892,7 +2684,6 @@ function _createClass(Constructor, protoProps, staticProps) { }); return Constructor; } - module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -2902,9 +2693,11 @@ module.exports = _createClass, module.exports.__esModule = true, module.exports[ !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! \***************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperty(obj, key, value) { + key = toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, @@ -2915,10 +2708,8 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } - module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -2933,7 +2724,6 @@ module.exports = _defineProperty, module.exports.__esModule = true, module.expor 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; /***/ }), @@ -2948,7 +2738,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -2961,21 +2750,55 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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/toPrimitive.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPropertyKey.js": +/*!**************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js"); +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} +module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + /***/ "./node_modules/@babel/runtime/helpers/typeof.js": /*!*******************************************************!*\ !*** ./node_modules/@babel/runtime/helpers/typeof.js ***! @@ -2983,16 +2806,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -3005,7 +2827,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -3014,7 +2835,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/all-location-category.js b/assets/js/all-location-category.js index d112bd7129..4985f47c2c 100644 --- a/assets/js/all-location-category.js +++ b/assets/js/all-location-category.js @@ -100,10 +100,8 @@ window.addEventListener('DOMContentLoaded', function () { } else { return; } - (function ($) { /* Multi level hierarchy content */ - /* Category */ $('.atbdp_child_category').hide(); $('.atbd_category_wrapper > .expander').on('click', function () { @@ -113,8 +111,8 @@ window.addEventListener('DOMContentLoaded', function () { $(this).siblings('.atbdp_child_category').slideToggle(); $(this).parent('li').siblings('li').children('.atbdp_child_category').slideUp(); }); - /* Location */ + /* Location */ $('.atbdp_child_location').hide(); $('.atbd_location_wrapper > .expander').on('click', function () { $(this).siblings('.atbdp_child_location').slideToggle(); diff --git a/assets/js/author-profile.js b/assets/js/author-profile.js index 977db50d7a..1706c69f37 100644 --- a/assets/js/author-profile.js +++ b/assets/js/author-profile.js @@ -94,7 +94,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_alert_executed === 'undefined') { @@ -102,12 +101,10 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* Directorist alert dismiss */ var getUrl = window.location.href; var newUrl = getUrl.replace('notice=1', ''); - if ($('.directorist-alert__close') !== null) { $('.directorist-alert__close').each(function (i, e) { $(e).on('click', function (e) { @@ -130,7 +127,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_dropdown_executed === 'undefined') { @@ -138,19 +134,17 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* custom dropdown */ - var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); // toggle dropdown + var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); + // toggle dropdown var clickCount = 0; - if (atbdDropdown !== null) { atbdDropdown.forEach(function (el) { el.querySelector('.directorist-dropdown-select-toggle').addEventListener('click', function (e) { e.preventDefault(); clickCount++; - if (clickCount % 2 === 1) { document.querySelectorAll('.directorist-dropdown-select-items').forEach(function (elem) { elem.classList.remove('directorist-dropdown-select-show'); @@ -163,9 +157,9 @@ } }); }); - } // remvoe toggle when click outside - + } + // remvoe toggle when click outside document.body.addEventListener('click', function (e) { if (e.target.getAttribute('data-drop-toggle') !== 'directorist-dropdown-select-toggle') { clickCount = 0; @@ -173,10 +167,10 @@ el.classList.remove('directorist-dropdown-select-show'); }); } - }); //custom select + }); + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.directorist-dropdown-select-items').forEach(function (item) { @@ -190,27 +184,30 @@ }); }); }); - } // Dropdown - + } + // Dropdown $('body').on('click', '.directorist-dropdown .directorist-dropdown-toggle', function (e) { e.preventDefault(); $(this).siblings('.directorist-dropdown-option').toggle(); - }); // Select Option after click + }); + // Select Option after click $('body').on('click', '.directorist-dropdown .directorist-dropdown-option ul li a', function (e) { e.preventDefault(); var optionText = $(this).html(); $(this).children('.directorist-dropdown-toggle__text').html(optionText); $(this).closest('.directorist-dropdown-option').siblings('.directorist-dropdown-toggle').children('.directorist-dropdown-toggle__text').html(optionText); $('.directorist-dropdown-option').hide(); - }); // Hide Clicked Anywhere + }); + // Hide Clicked Anywhere $(document).bind('click', function (e) { var clickedDom = $(e.target); if (!clickedDom.parents().hasClass('directorist-dropdown')) $('.directorist-dropdown-option').hide(); - }); //atbd_dropdown + }); + //atbd_dropdown $(document).on("click", '.atbd_dropdown', function (e) { if ($(this).attr("class") === "atbd_dropdown") { e.preventDefault(); @@ -226,15 +223,14 @@ }); $('body').on('click', '.atbd_dropdown-toggle', function (e) { e.preventDefault(); - }); // Directorist Dropdown + }); + // Directorist Dropdown $('body').on('click', '.directorist-dropdown-js .directorist-dropdown__toggle-js', function (e) { e.preventDefault(); - if (!$(this).siblings('.directorist-dropdown__links-js').is(':visible')) { $('.directorist-dropdown__links').hide(); } - $(this).siblings('.directorist-dropdown__links-js').toggle(); }); $('body').on('click', function (e) { @@ -255,7 +251,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_favorite_executed === 'undefined') { @@ -263,7 +258,6 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { // Add or Remove from favourites $('#atbdp-favourites').on('click', function (e) { @@ -277,7 +271,6 @@ console.log('added'); console.log(response); console.log(directorist.ajaxurl); - if (response) { $('#atbdp-favourites').html(response); } @@ -295,7 +288,6 @@ $.post(directorist.ajaxurl, data, function (response) { var post_id = data['post_id'].toString(); var staElement = $('.directorist_favourite_' + post_id); - if ('false' === response) { staElement.remove(); } @@ -316,7 +308,6 @@ var post_id = data['post_id'].toString(); var staElement = $('.directorist-fav_' + post_id); var data_id = staElement.attr('data-listing_id'); - if (response === "login_required") { staElement.children(".directorist-favorite-tooltip").append(fav_tooltip_warning); staElement.children(".directorist-favorite-tooltip").fadeIn(); @@ -351,7 +342,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_sorting_executed === 'undefined') { @@ -359,7 +349,6 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { // Sorting Js if (!$('.directorist-instant-search').length) { @@ -369,9 +358,9 @@ $('#directorsit-listing-sort').attr('action', href); $('#directorsit-listing-sort').submit(); }); - } //sorting toggle - + } + //sorting toggle $('.sorting span').on('click', function () { $(this).toggleClass('fa-sort-amount-asc fa-sort-amount-desc'); }); @@ -392,14 +381,12 @@ window.addEventListener('DOMContentLoaded', function () { if ($('.directorist-listing-no-thumb').innerWidth() <= 220) { $('.directorist-listing-no-thumb').addClass('directorist-listing-no-thumb--fix'); - } // Auhtor Profile Listing responsive fix - - + } + // Auhtor Profile Listing responsive fix if ($('.directorist-author-listing-content').innerWidth() <= 750) { $('.directorist-author-listing-content').addClass('directorist-author-listing-grid--fix'); - } // Directorist Archive responsive fix - - + } + // Directorist Archive responsive fix if ($('.directorist-archive-grid-view').innerWidth() <= 500) { $('.directorist-archive-grid-view').addClass('directorist-archive-grid--fix'); } @@ -417,7 +404,6 @@ window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { //Star rating if ($('.directorist-review-criteria-select').length) { diff --git a/assets/js/checkout.js b/assets/js/checkout.js index ad2f328cbe..e8fd2e3875 100644 --- a/assets/js/checkout.js +++ b/assets/js/checkout.js @@ -104,8 +104,9 @@ checkout_net_price_area.html(get_currency_format(pricing_statement.total_price)); checkout_net_hidden_price_area.val(pricing_statement.total_price); update_payment_methods(pricing_statement); - }); // get_pricing_statement + }); + // get_pricing_statement function get_pricing_statement(price_item_elm) { var total_price = 0; var total_product = 0; @@ -113,7 +114,6 @@ var price_item = price_item_elm[index]; var price = price_item.value; price = isNaN(price_item.value) ? 0 : Number(price); - if ($(price_item).is(':checked')) { total_price = total_price + price; total_product++; @@ -123,15 +123,14 @@ total_product: total_product, total_price: total_price }; - } // update_payment_methods - + } + // update_payment_methods function update_payment_methods(pricing_statement) { if (!pricing_statement.total_product) { $('#directorist_payment_gateways, #atbdp_checkout_submit_btn').hide(); return; } - if (pricing_statement.total_price > 0) { $('#directorist_payment_gateways').show(); $('#atbdp_checkout_submit_btn').val(directorist.payNow).show(); @@ -141,18 +140,18 @@ $('#atbdp_checkout_submit_btn').val(directorist.completeSubmission).show(); $('#atbdp_checkout_submit_btn_label').val(directorist.completeSubmission); } - } // Helpers + } + + // Helpers // -------------------- // get_currency_format - - function get_currency_format(number) { number = number.toFixed(2); number = number_with_commas(number); return number; - } // number_with_commas - + } + // number_with_commas function number_with_commas(number) { return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } diff --git a/assets/js/directorist-dashboard.js b/assets/js/directorist-dashboard.js index cd5012f211..9c3a62cd37 100644 --- a/assets/js/directorist-dashboard.js +++ b/assets/js/directorist-dashboard.js @@ -99,7 +99,6 @@ Author: Sovware Author URI: https://sovware.com/ */ - /* disable-eslint */ var aazztechModal1 = function aazztechModal1(selector) { var element = document.querySelectorAll(selector); @@ -109,7 +108,6 @@ var aazztechModal1 = function aazztechModal1(selector) { var current_elm = event.target; var target_id = current_elm.getAttribute('data-target'); var el_id = el.getAttribute('id'); - if (target_id === el_id) { event.preventDefault(); el.style.display = 'block'; @@ -140,11 +138,9 @@ var aazztechModal1 = function aazztechModal1(selector) { }); }); }; - function initModal() { aazztechModal1('#dcl-claim-modal, #atbdp-report-abuse-modal, #atpp-plan-change-modal, #pyn-plan-change-modal'); } - window.addEventListener('load', function () { setTimeout(function () { initModal(); @@ -166,7 +162,6 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _atmodal__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_atmodal__WEBPACK_IMPORTED_MODULE_0__); ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // User Dashboard Table More Button @@ -196,7 +191,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // Clear seen Announcements @@ -205,11 +199,10 @@ __webpack_require__.r(__webpack_exports__); if (cleared_seen_announcements) { return; } - var target = $(this).attr('target'); - if ('dashboard_announcement' === target) { // console.log( target, 'clear seen announcements' ); + $.ajax({ type: "post", url: directorist.ajaxurl, @@ -218,6 +211,7 @@ __webpack_require__.r(__webpack_exports__); }, success: function success(response) { // console.log( response ); + if (response.success) { cleared_seen_announcements = true; $('.directorist-announcement-count').removeClass('show'); @@ -231,17 +225,16 @@ __webpack_require__.r(__webpack_exports__); } }); } - }); // Closing the Announcement + }); + // Closing the Announcement var closing_announcement = false; $('.close-announcement').on('click', function (e) { e.preventDefault(); - if (closing_announcement) { // console.log('Please wait...'); return; } - var post_id = $(this).closest('.directorist-announcement').data('post-id'); var form_data = { action: 'atbdp_close_announcement', @@ -265,10 +258,8 @@ __webpack_require__.r(__webpack_exports__); closing_announcement = false; $(self).removeClass('disable'); $(self).attr('disable', false); - if (response.success) { $('.announcement-id-' + post_id).remove(); - if (!$('.announcement-item').length) { location.reload(); } @@ -300,7 +291,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // Dashboard become an author @@ -320,8 +310,9 @@ __webpack_require__.r(__webpack_exports__); userId: userId, nonce: nonce, action: "atbdp_become_author" - }; // Send the data + }; + // Send the data $.post(directorist.ajaxurl, data, function (response) { $('.directorist-become-author__loader').addClass('active'); $('#directorist-become-author-success').html(response); @@ -342,7 +333,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // Dashboard Listing Ajax @@ -379,29 +369,27 @@ __webpack_require__.r(__webpack_exports__); $('#directorist-dashboard-preloader').hide(); } }); - } // Dashboard Listing Tabs - + } + // Dashboard Listing Tabs $('.directorist-dashboard-listing-nav-js a').on('click', function (event) { var $item = $(this); - if ($item.hasClass('directorist-tab__nav__active')) { return false; } - directorist_dashboard_listing_ajax($item); $('#directorist-dashboard-listing-searchform input[name=searchtext').val(''); $('#directorist-dashboard-mylistings-js').data('search', ''); return false; - }); // Dashboard Tasks eg. delete + }); + // Dashboard Tasks eg. delete $('.directorist-dashboard-listings-tbody').on('click', '.directorist-dashboard-listing-actions a[data-task]', function (event) { var task = $(this).data('task'); var postid = $(this).closest('tr').data('id'); var $activeTab = $('.directorist-dashboard-listing-nav-js a.directorist-tab__nav__active'); var paged = $('#directorist-dashboard-mylistings-js').data('paged'); var search = $('#directorist-dashboard-mylistings-js').data('search'); - if (task == 'delete') { swal({ title: directorist.listing_remove_title, @@ -425,10 +413,10 @@ __webpack_require__.r(__webpack_exports__); } }); } - return false; - }); // Remove Listing + }); + // Remove Listing $(document).on('click', '#remove_listing', function (e) { e.preventDefault(); var $this = $(this); @@ -449,7 +437,6 @@ __webpack_require__.r(__webpack_exports__); // user has confirmed, now remove the listing atbdp_do_ajax($this, 'remove_listing', data, function (response) { $('body').append(response); - if ('success' === response) { // show success message swal({ @@ -472,9 +459,12 @@ __webpack_require__.r(__webpack_exports__); } }); } - }); // send an ajax request to the ajax-handler.php and then delete the review of the given id - }); // Dashboard pagination + }); + + // send an ajax request to the ajax-handler.php and then delete the review of the given id + }); + // Dashboard pagination $('.directorist-dashboard-pagination').on('click', 'a', function (event) { var $link = $(this); var paged = $link.attr('href'); @@ -484,8 +474,9 @@ __webpack_require__.r(__webpack_exports__); $activeTab = $('.directorist-dashboard-listing-nav-js a.directorist-tab__nav__active'); directorist_dashboard_listing_ajax($activeTab, paged, search); return false; - }); // Dashboard Search + }); + // Dashboard Search $('#directorist-dashboard-listing-searchform input[name=searchtext').val(''); //onready $('#directorist-dashboard-listing-searchform').on('submit', function (event) { @@ -508,16 +499,13 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { //dashboard content responsive fix var tabContentWidth = $(".directorist-user-dashboard .directorist-user-dashboard__contents").innerWidth(); - if (tabContentWidth < 1399) { $(".directorist-user-dashboard .directorist-user-dashboard__contents").addClass("directorist-tab-content-grid-fix"); } - $(window).bind("resize", function () { if ($(this).width() <= 1199) { $(".directorist-user-dashboard__nav").addClass("directorist-dashboard-nav-collapsed"); @@ -527,8 +515,9 @@ __webpack_require__.r(__webpack_exports__); $('.directorist-dashboard__nav--close, .directorist-shade').on('click', function () { $(".directorist-user-dashboard__nav").addClass('directorist-dashboard-nav-collapsed'); $(".directorist-shade").removeClass("directorist-active"); - }); // Profile Responsive + }); + // Profile Responsive $('.directorist-tab__nav__link').on('click', function () { if ($('#user_profile_form').width() < 800 && $('#user_profile_form').width() !== 0) { $('#user_profile_form').addClass('directorist-profile-responsive'); @@ -547,24 +536,23 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { //dashboard sidebar nav toggler $(".directorist-user-dashboard__toggle__link").on("click", function (e) { e.preventDefault(); - $(".directorist-user-dashboard__nav").toggleClass("directorist-dashboard-nav-collapsed"); // $(".directorist-shade").toggleClass("directorist-active"); + $(".directorist-user-dashboard__nav").toggleClass("directorist-dashboard-nav-collapsed"); + // $(".directorist-shade").toggleClass("directorist-active"); }); if ($(window).innerWidth() < 767) { $(".directorist-user-dashboard__nav").addClass("directorist-dashboard-nav-collapsed"); $(".directorist-user-dashboard__nav").addClass("directorist-dashboard-nav-collapsed--fixed"); - } //dashboard nav dropdown - + } + //dashboard nav dropdown $(".directorist-tab__nav__link").on("click", function (e) { e.preventDefault(); - if ($(this).hasClass("atbd-dash-nav-dropdown")) { // Slide toggle the sibling ul element $(this).siblings("ul").slideToggle(); @@ -573,7 +561,6 @@ __webpack_require__.r(__webpack_exports__); $(".atbd-dash-nav-dropdown").siblings("ul").slideUp(); } }); - if ($(window).innerWidth() < 1199) { $(".directorist-tab__nav__link").on("click", function () { $(".directorist-user-dashboard__nav").addClass('directorist-dashboard-nav-collapsed'); @@ -597,7 +584,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function () { new DashTab('.directorist-tab'); })(); @@ -612,7 +598,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_alert_executed === 'undefined') { @@ -620,12 +605,10 @@ __webpack_require__.r(__webpack_exports__); } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* Directorist alert dismiss */ var getUrl = window.location.href; var newUrl = getUrl.replace('notice=1', ''); - if ($('.directorist-alert__close') !== null) { $('.directorist-alert__close').each(function (i, e) { $(e).on('click', function (e) { @@ -648,7 +631,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_dropdown_executed === 'undefined') { @@ -656,19 +638,17 @@ __webpack_require__.r(__webpack_exports__); } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* custom dropdown */ - var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); // toggle dropdown + var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); + // toggle dropdown var clickCount = 0; - if (atbdDropdown !== null) { atbdDropdown.forEach(function (el) { el.querySelector('.directorist-dropdown-select-toggle').addEventListener('click', function (e) { e.preventDefault(); clickCount++; - if (clickCount % 2 === 1) { document.querySelectorAll('.directorist-dropdown-select-items').forEach(function (elem) { elem.classList.remove('directorist-dropdown-select-show'); @@ -681,9 +661,9 @@ __webpack_require__.r(__webpack_exports__); } }); }); - } // remvoe toggle when click outside - + } + // remvoe toggle when click outside document.body.addEventListener('click', function (e) { if (e.target.getAttribute('data-drop-toggle') !== 'directorist-dropdown-select-toggle') { clickCount = 0; @@ -691,10 +671,10 @@ __webpack_require__.r(__webpack_exports__); el.classList.remove('directorist-dropdown-select-show'); }); } - }); //custom select + }); + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.directorist-dropdown-select-items').forEach(function (item) { @@ -708,27 +688,30 @@ __webpack_require__.r(__webpack_exports__); }); }); }); - } // Dropdown - + } + // Dropdown $('body').on('click', '.directorist-dropdown .directorist-dropdown-toggle', function (e) { e.preventDefault(); $(this).siblings('.directorist-dropdown-option').toggle(); - }); // Select Option after click + }); + // Select Option after click $('body').on('click', '.directorist-dropdown .directorist-dropdown-option ul li a', function (e) { e.preventDefault(); var optionText = $(this).html(); $(this).children('.directorist-dropdown-toggle__text').html(optionText); $(this).closest('.directorist-dropdown-option').siblings('.directorist-dropdown-toggle').children('.directorist-dropdown-toggle__text').html(optionText); $('.directorist-dropdown-option').hide(); - }); // Hide Clicked Anywhere + }); + // Hide Clicked Anywhere $(document).bind('click', function (e) { var clickedDom = $(e.target); if (!clickedDom.parents().hasClass('directorist-dropdown')) $('.directorist-dropdown-option').hide(); - }); //atbd_dropdown + }); + //atbd_dropdown $(document).on("click", '.atbd_dropdown', function (e) { if ($(this).attr("class") === "atbd_dropdown") { e.preventDefault(); @@ -744,15 +727,14 @@ __webpack_require__.r(__webpack_exports__); }); $('body').on('click', '.atbd_dropdown-toggle', function (e) { e.preventDefault(); - }); // Directorist Dropdown + }); + // Directorist Dropdown $('body').on('click', '.directorist-dropdown-js .directorist-dropdown__toggle-js', function (e) { e.preventDefault(); - if (!$(this).siblings('.directorist-dropdown__links-js').is(':visible')) { $('.directorist-dropdown__links').hide(); } - $(this).siblings('.directorist-dropdown__links-js').toggle(); }); $('body').on('click', function (e) { @@ -773,7 +755,6 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_favorite_executed === 'undefined') { @@ -781,7 +762,6 @@ __webpack_require__.r(__webpack_exports__); } else { return; } - window.addEventListener('DOMContentLoaded', function () { // Add or Remove from favourites $('#atbdp-favourites').on('click', function (e) { @@ -795,7 +775,6 @@ __webpack_require__.r(__webpack_exports__); console.log('added'); console.log(response); console.log(directorist.ajaxurl); - if (response) { $('#atbdp-favourites').html(response); } @@ -813,7 +792,6 @@ __webpack_require__.r(__webpack_exports__); $.post(directorist.ajaxurl, data, function (response) { var post_id = data['post_id'].toString(); var staElement = $('.directorist_favourite_' + post_id); - if ('false' === response) { staElement.remove(); } @@ -834,7 +812,6 @@ __webpack_require__.r(__webpack_exports__); var post_id = data['post_id'].toString(); var staElement = $('.directorist-fav_' + post_id); var data_id = staElement.attr('data-listing_id'); - if (response === "login_required") { staElement.children(".directorist-favorite-tooltip").append(fav_tooltip_warning); staElement.children(".directorist-favorite-tooltip").fadeIn(); @@ -874,11 +851,9 @@ window.addEventListener('DOMContentLoaded', function () { window.directorist_select_executed = true; } else { return; - } //custom select - - + } + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -892,9 +867,9 @@ window.addEventListener('DOMContentLoaded', function () { }); }); }); - } // select data-status - + } + // select data-status var atbdSelectData = document.querySelectorAll('.atbd-drop-select.with-sort'); atbdSelectData.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -918,16 +893,15 @@ window.addEventListener('DOMContentLoaded', function () { window.addEventListener('DOMContentLoaded', function () { /* custom dropdown */ - var atbdDropdown = document.querySelectorAll('.atbd-dropdown'); // toggle dropdown + var atbdDropdown = document.querySelectorAll('.atbd-dropdown'); + // toggle dropdown var clickCount = 0; - if (atbdDropdown !== null) { atbdDropdown.forEach(function (el) { el.querySelector('.atbd-dropdown-toggle').addEventListener('click', function (e) { e.preventDefault(); clickCount++; - if (clickCount % 2 === 1) { document.querySelectorAll('.atbd-dropdown-items').forEach(function (elem) { elem.classList.remove('atbd-show'); @@ -940,9 +914,9 @@ window.addEventListener('DOMContentLoaded', function () { } }); }); - } // remvoe toggle when click outside - + } + // remvoe toggle when click outside document.body.addEventListener('click', function (e) { if (e.target.getAttribute('data-drop-toggle') !== 'atbd-toggle') { clickCount = 0; @@ -963,18 +937,15 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { var profileMediaUploader = null; - if ($(".directorist-profile-uploader").length) { profileMediaUploader = new EzMediaUploader({ containerClass: "directorist-profile-uploader" }); profileMediaUploader.init(); } - var is_processing = false; $('#user_profile_form').on('submit', function (e) { // submit the form to the ajax handler and then send a response from the database and then work accordingly and then after finishing the update profile then work on remove listing and also remove the review and rating form the custom table once the listing is deleted successfully. @@ -982,37 +953,31 @@ window.addEventListener('DOMContentLoaded', function () { var submit_button = $('#update_user_profile'); submit_button.attr('disabled', true); submit_button.addClass("directorist-loader"); - if (is_processing) { submit_button.removeAttr('disabled'); return; } - var form_data = new FormData(); var err_log = {}; - var error_count; // ajax action + var error_count; + // ajax action form_data.append('action', 'update_user_profile'); form_data.append('directorist_nonce', directorist.directorist_nonce); - if (profileMediaUploader) { var hasValidFiles = profileMediaUploader.hasValidFiles(); - if (hasValidFiles) { //files var files = profileMediaUploader.getTheFiles(); var filesMeta = profileMediaUploader.getFilesMeta(); - if (files.length) { for (var i = 0; i < files.length; i++) { form_data.append('profile_picture', files[i]); } } - if (filesMeta.length) { for (var i = 0; i < filesMeta.length; i++) { var elm = filesMeta[i]; - for (var key in elm) { form_data.append('profile_picture_meta[' + i + '][' + key + ']', elm[key]); } @@ -1026,7 +991,6 @@ window.addEventListener('DOMContentLoaded', function () { error_count++; } } - var $form = $(this); var arrData = $form.serializeArray(); $.each(arrData, function (index, elem) { @@ -1042,13 +1006,15 @@ window.addEventListener('DOMContentLoaded', function () { data: form_data, success: function success(response) { submit_button.removeAttr('disabled'); - submit_button.removeClass("directorist-loader"); // console.log(response); + submit_button.removeClass("directorist-loader"); + + // console.log(response); if (response.success) { - $('#directorist-prifile-notice').html('' + response.data + ''); // Reload if password updated + $('#directorist-prifile-notice').html('' + response.data + ''); + // Reload if password updated var newPass = form_data.get('user[new_pass]'); - if (typeof newPass == 'string' && newPass.length > 0) { location.reload(); return false; @@ -1061,12 +1027,13 @@ window.addEventListener('DOMContentLoaded', function () { submit_button.removeAttr('disabled'); console.log(response); } - }); // remove notice after five second - + }); + // remove notice after five second setTimeout(function () { $("#directorist-prifile-notice .directorist-alert").remove(); - }, 5000); // prevent the from submitting + }, 5000); + // prevent the from submitting return false; }); }); @@ -1082,11 +1049,8 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (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; } - +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; } /* Plugin: Dash Tab Version: 1.0.0 @@ -1098,21 +1062,20 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len if (window.isInitializedDashTab) { return; } - window.isInitializedDashTab = true; this.activateNavLinkByURL(); }; - this.activateNavLinkByURL = function () { var hash = window.location.hash; - var queryStrings = null; // Split the URL into its components + var queryStrings = null; + // Split the URL into its components var urlParts = hash.split(/[?|&]/); - if (urlParts.length > 1) { // Get Hash Link - var hashLink = urlParts[0]; // Get the search parameters + var hashLink = urlParts[0]; + // Get the search parameters queryStrings = JSON.parse(JSON.stringify(urlParts)); queryStrings.splice(0, 1); queryStrings = queryStrings.filter(function (item) { @@ -1121,49 +1084,42 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len queryStrings = queryStrings.join('&'); window.location.hash = hashLink; hash = window.location.hash; - } // Activate Current Navigation Item - + } + // Activate Current Navigation Item var navLinks = document.querySelectorAll('.directorist-tab__nav__link'); - var _iterator = _createForOfIteratorHelper(navLinks), - _step; - + _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var link = _step.value; var href = link.getAttribute('href'); var target = link.getAttribute('target'); - if (href === hash || "#".concat(target) === hash || window.location.hash.match(new RegExp("^".concat(href, "$")))) { var parent = link.closest('.atbdp_tab_nav--has-child'); - if (parent) { var dropdownMenu = parent.querySelector('.atbd-dashboard-nav'); - if (dropdownMenu) { dropdownMenu.style.display = 'block'; } } - link.click(); break; } - } // Update Window History + } + // Update Window History } catch (err) { _iterator.e(err); } finally { _iterator.f(); } - if (queryStrings) { // Reconstruct the URL with the updated search parameters var newUrl = window.location.pathname + window.location.hash + "?" + queryStrings; window.history.replaceState(null, null, newUrl); } }; - this.navLinksSetup = function (selector) { var selector = document.querySelectorAll(selector); selector.forEach(function (el) { @@ -1174,47 +1130,43 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len event.preventDefault(); event.stopPropagation(); var ul = event.target.closest('.directorist-tab__nav'), - main = ul.nextElementSibling, - item_link = ul.querySelectorAll('.directorist-tab__nav__link'), - section = main.querySelectorAll('.directorist-tab__pane'); // Activate Navigation Panel + main = ul.nextElementSibling, + item_link = ul.querySelectorAll('.directorist-tab__nav__link'), + section = main.querySelectorAll('.directorist-tab__pane'); + // Activate Navigation Panel item_link.forEach(function (link) { link.classList.remove('directorist-tab__nav__active'); }); var parentNavRef = event.target.getAttribute('data-parent-nav'); - if (parentNavRef) { var parentNav = document.querySelector(parentNavRef); - if (parentNav) { parentNav.classList.add('directorist-tab__nav__active'); } } else { var _event$target$closest; - event.target.classList.add('directorist-tab__nav__active'); var dropDownToggler = (_event$target$closest = event.target.closest('.atbdp_tab_nav--has-child')) === null || _event$target$closest === void 0 ? void 0 : _event$target$closest.querySelector('.atbd-dash-nav-dropdown'); - if (dropDownToggler && !dropDownToggler.classList.contains('directorist-tab__nav__active')) { dropDownToggler.classList.add('directorist-tab__nav__active'); } - } // Activate Content Panel - + } + // Activate Content Panel section.forEach(function (sectionItem) { sectionItem.classList.remove('directorist-tab__pane--active'); }); var content_id = event.target.getAttribute('target'); - document.getElementById(content_id).classList.add('directorist-tab__pane--active'); // Add Hash To Window Location + document.getElementById(content_id).classList.add('directorist-tab__pane--active'); + // Add Hash To Window Location var hashID = content_id; var link = event.target.getAttribute('href'); - if (link) { var matchLink = link.match(/#(.+)/); hashID = matchLink ? matchLink[1] : hashID; } - var hasMatch = window.location.hash.match(new RegExp("^".concat(link, "$"))); window.location.hash = hasMatch ? hasMatch[0] : "#" + hashID; var newHash = window.location.hash; @@ -1224,7 +1176,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len }); }); }; - if (document.querySelector(selector)) { this.navLinksSetup(selector); this.globalSetup(); @@ -1271,19 +1222,21 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _components_directoristAlert__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../components/directoristAlert */ "./assets/src/js/public/components/directoristAlert.js"); /* harmony import */ var _components_directoristAlert__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_components_directoristAlert__WEBPACK_IMPORTED_MODULE_13__); // Lib - // Dashboard Js +// Dashboard Js - // General Components -// import '../components/tab'; +// General Components +// import '../components/tab'; + + diff --git a/assets/js/directorist-plupload.js b/assets/js/directorist-plupload.js index c58fe51cea..65cdceee73 100644 --- a/assets/js/directorist-plupload.js +++ b/assets/js/directorist-plupload.js @@ -97,27 +97,25 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _lib_helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../lib/helper */ "./assets/src/js/lib/helper.js"); - jQuery.fn.exists = function () { return jQuery(this).length > 0; }; - var atbdp_plupload_params = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('atbdp_plupload_params'); var atbdp_params = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('atbdp_params'); -var $ = jQuery; // Init +var $ = jQuery; +// Init if (atbdp_plupload_params) { jQuery(document).ready(init); window.addEventListener('directorist-reload-plupload', init); } - function init() { atbdp_plupload_params = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('atbdp_plupload_params'); atbdp_params = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('atbdp_params'); - if ($(".plupload-upload-uic").exists()) { - var pluploadConfig, msgErr, post_id; // set the post id + var pluploadConfig, msgErr, post_id; + // set the post id if (jQuery("#atbdpectory-add-post input[name='ID']").length) { post_id = jQuery("#atbdpectory-add-post input[name='ID']").val(); // frontend } else { @@ -132,28 +130,22 @@ function init() { pluploadConfig = JSON.parse(atbdp_plupload_params.base_plupload_config); pluploadConfig["browse_button"] = imgId + pluploadConfig["browse_button"]; pluploadConfig["container"] = imgId + pluploadConfig["container"]; - if (jQuery('#' + imgId + 'dropbox').length) { pluploadConfig["drop_element"] = imgId + 'dropbox'; } // only add drop area if there is one - pluploadConfig["file_data_name"] = imgId + pluploadConfig["file_data_name"]; pluploadConfig["multipart_params"]["imgid"] = imgId; pluploadConfig["multipart_params"]["post_id"] = post_id; pluploadConfig["max_file_size"] = $('#' + imgId + '_file_size').val(); - if ($this.hasClass("plupload-upload-uic-multiple")) { pluploadConfig["multi_selection"] = true; } - var allowed_exts = jQuery('#' + imgId + '_allowed_types').val(); allowed_exts = allowed_exts && allowed_exts != '' ? allowed_exts : ''; - if (imgId == 'post_images' && typeof atbdp_params.atbdp_allowed_img_types != 'undefined' && atbdp_params.atbdp_allowed_img_types != '') { allowed_exts = atbdp_params.atbdp_allowed_img_types; } - if (allowed_exts && allowed_exts != '') { var txt_all_files = typeof atbdp_params.txt_all_files != 'undefined' && atbdp_params.txt_all_files != '' ? atbdp_params.txt_all_files : 'Allowed files'; pluploadConfig['filters'] = [{ @@ -161,7 +153,6 @@ function init() { 'extensions': allowed_exts }]; } - var uploader = new plupload.Uploader(pluploadConfig); uploader.bind('Init', function (up, params) { if (uploader.features.dragdrop) { @@ -182,14 +173,12 @@ function init() { uploader.bind('Error', function (up, files) { var errorMessage; $errorHolder.addClass('upload-error'); - if (files.code == -600) { if (typeof atbdp_params.err_max_file_size != 'undefined' && atbdp_params.err_max_file_size != '') { errorMessage = atbdp_params.err_max_file_size; } else { errorMessage = 'File size error : You tried to upload a file over %s'; } - errorMessage = errorMessage.replace("%s", $('#' + imgId + '_file_size').val()); } else if (files.code == -601) { if (typeof atbdp_params.err_file_type != 'undefined' && atbdp_params.err_file_type != '') { @@ -197,7 +186,6 @@ function init() { } else { errorMessage = 'File type error. Allowed file types: %s'; } - if (imgId == 'post_images') { var txtReplace = allowed_exts != '' ? "." + allowed_exts.replace(/,/g, ", .") : '*'; errorMessage = errorMessage.replace("%s", txtReplace); @@ -207,53 +195,46 @@ function init() { } else { errorMessage = files.message; } - $errorHolder.html(errorMessage); - }); //a file was added in the queue + }); + + //a file was added in the queue //totalImg = atbdp_plupload_params.totalImg; //limitImg = atbdp_plupload_params.image_limit; - uploader.bind('FilesAdded', function (up, files) { var totalImg = parseInt(jQuery("#" + imgId + "totImg").val()); var limitImg = parseInt(jQuery("#" + imgId + "image_limit").val()); $errorHolder.html('').removeClass('upload-error'); - if (limitImg && $this.hasClass("plupload-upload-uic-multiple") && limitImg > 0) { if (totalImg >= limitImg && limitImg > 0) { while (up.files.length > 0) { up.removeFile(up.files[0]); } // remove images - if (typeof atbdp_params.err_file_upload_limit != 'undefined' && atbdp_params.err_file_upload_limit != '') { msgErr = atbdp_params.err_file_upload_limit; } else { msgErr = 'You have reached your upload limit of %s files.'; } - msgErr = msgErr.replace("%s", limitImg); $errorHolder.addClass('upload-error').html(msgErr); return false; } - if (up.files.length > limitImg && limitImg > 0) { while (up.files.length > 0) { up.removeFile(up.files[0]); } // remove images - if (typeof atbdp_params.err_pkg_upload_limit != 'undefined' && atbdp_params.err_pkg_upload_limit != '') { msgErr = atbdp_params.err_pkg_upload_limit; } else { msgErr = 'You may only upload %s files with this package, please try again.'; } - msgErr = msgErr.replace("%s", limitImg); $errorHolder.addClass('upload-error').html(msgErr); return false; } } - $.each(files, function (i, file) { $this.find('.filelist').append('
    ' + file.name + ' (' + plupload.formatSize(0) + '/' + plupload.formatSize(file.size) + ') ' + '
    '); }); @@ -269,44 +250,42 @@ function init() { var indexes = new Array(); uploader.bind('FileUploaded', function (up, file, response) { response = JSON.parse(response["response"]); - if (!response.success) { $errorHolder.addClass('upload-error').html(response.data); return; - } //up.removeFile(up.files[0]); // remove images - + } + //up.removeFile(up.files[0]); // remove images var totalImg = parseInt(jQuery("#" + imgId + "totImg").val()); indexes[i] = up; i++; - $('#' + file.id).fadeOut(); // add url to the hidden field + $('#' + file.id).fadeOut(); + // add url to the hidden field if ($this.hasClass("plupload-upload-uic-multiple")) { totalImg++; - jQuery("#" + imgId + "totImg").val(totalImg); // multiple - + jQuery("#" + imgId + "totImg").val(totalImg); + // multiple var v1 = $.trim($("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val()); - if (v1) { v1 = v1 + "::" + response.data; } else { v1 = response.data; } - - $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(v1); //console.log(v1); + $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(v1); + //console.log(v1); } else { // single - $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(response.data + ""); //console.log(response); - } // show thumbs - - + $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(response.data + ""); + //console.log(response); + } + // show thumbs plu_show_thumbs(imgId); }); Error; }); } } - function atbdp_esc_entities(str) { var entityMap = { '&': '&', @@ -322,7 +301,6 @@ function atbdp_esc_entities(str) { return entityMap[s]; }); } - function atbdp_remove_file_index(indexes) { for (var i = 0; i < indexes.length; i++) { if (indexes[i].files.length > 0) { @@ -330,28 +308,23 @@ function atbdp_remove_file_index(indexes) { } } } - function plu_show_thumbs(imgId) { //console.log("plu_show_thumbs"); var totalImg = parseInt(jQuery("#" + imgId + "totImg").val()); var limitImg = parseInt(jQuery("#" + imgId + "image_limit").val()); var $ = jQuery; var thumbsC = $("#" + imgId + "plupload-thumbs"); - thumbsC.html(""); // get urls - + thumbsC.html(""); + // get urls var imagesS = $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(); var txtRemove = 'Remove'; - if (typeof atbdp_params.action_remove != 'undefined' && atbdp_params.action_remove != '') { txtRemove = atbdp_params.action_remove; } - if (!imagesS) { return; } - var images = imagesS.split("::"); - for (var i = 0; i < images.length; i++) { if (images[i] && images[i] != 'null') { var img_arr = images[i].split("|"); @@ -360,56 +333,47 @@ function plu_show_thumbs(imgId) { var image_title = img_arr[2]; var image_caption = img_arr[3]; var image_title_html = ''; - var image_caption_html = ''; // fix undefined id + var image_caption_html = ''; + // fix undefined id if (typeof image_id === "undefined") { image_id = ''; - } // fix undefined title - - + } + // fix undefined title if (typeof image_title === "undefined") { image_title = ''; - } // fix undefined title - - + } + // fix undefined title if (typeof image_caption === "undefined") { image_caption = ''; - } //Esc title and caption - + } + //Esc title and caption image_title = atbdp_esc_entities(image_title); image_caption = atbdp_esc_entities(image_caption); var file_ext = image_url.substring(image_url.lastIndexOf('.') + 1); file_ext = file_ext.split('?').shift(); // in case the image url has params - if (file_ext) { file_ext = file_ext.toLowerCase(); } - var fileNameIndex = image_url.lastIndexOf("/") + 1; var dotIndex = image_url.lastIndexOf('.'); - if (dotIndex < fileNameIndex) { continue; } - var file_name = image_url.substr(fileNameIndex, dotIndex < fileNameIndex ? loc.length : dotIndex); var file_display = ''; var file_display_class = ''; - if (file_ext == 'jpg' || file_ext == 'jpe' || file_ext == 'jpeg' || file_ext == 'png' || file_ext == 'gif' || file_ext == 'bmp' || file_ext == 'ico') { file_display = ''; - if (!!image_title.trim()) { image_title_html = '' + image_title + ''; } - if (!!image_caption.trim()) { image_caption_html = '' + image_caption + ''; } } else { var file_type_class = 'la-file'; - if (file_ext == 'pdf') { file_type_class = 'la-file-pdf-o'; } else if (file_ext == 'zip' || file_ext == 'tar') { @@ -423,11 +387,9 @@ function plu_show_thumbs(imgId) { } else if (file_ext == 'avi' || file_ext == 'mp4' || file_ext == 'mov') { file_type_class = 'la-file-video-0'; } - file_display_class = 'file-thumb'; file_display = ''; } - var iconURL = directorist.assets_url + 'icons/font-awesome/svgs/solid/trash.svg'; var iconHTML = directorist.icon_markup.replace('##URL##', iconURL).replace('##CLASS##', ''); var thumb = $('
    ' + image_title_html + file_display + image_caption_html + '
    ' + '' + iconHTML + '' + '
    ' + '
    '); @@ -436,10 +398,8 @@ function plu_show_thumbs(imgId) { //console.log("plu_show_thumbs-thumbremovelink"); if (jQuery('#' + imgId + 'plupload-upload-ui').hasClass("plupload-upload-uic-multiple")) { totalImg--; // remove image from total - jQuery("#" + imgId + "totImg").val(totalImg); } - jQuery('#' + imgId + 'upload-error').html(''); jQuery('#' + imgId + 'upload-error').removeClass('upload-error'); var ki = $(this).attr("id").replace("thumbremovelink" + imgId, ""); @@ -447,21 +407,18 @@ function plu_show_thumbs(imgId) { var kimages = []; imagesS = $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(); images = imagesS.split("::"); - for (var j = 0; j < images.length; j++) { if (j != ki) { kimages[kimages.length] = images[j]; } } - - $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(kimages.join("::")); //console.log("plu_show_thumbs-thumbremovelink-run"); - + $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(kimages.join("::")); + //console.log("plu_show_thumbs-thumbremovelink-run"); plu_show_thumbs(imgId); return false; }); } } - if (images.length > 1) { //console.log("plu_show_thumbs-sortable"); thumbsC.sortable({ @@ -470,14 +427,17 @@ function plu_show_thumbs(imgId) { thumbsC.find(".atbdp-file-info").each(function () { kimages[kimages.length] = $(this).data("src") + "|" + $(this).data("id") + "|" + $(this).data("title") + "|" + $(this).data("caption"); $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(kimages.join("::")); - plu_show_thumbs(imgId); //console.log("plu_show_thumbs-sortable-run"); + plu_show_thumbs(imgId); + //console.log("plu_show_thumbs-sortable-run"); }); } }); + thumbsC.disableSelection(); - } // we need to run the basics here. - //console.log("run basics"); + } + // we need to run the basics here. + //console.log("run basics"); var kimages = []; thumbsC.find(".atbdp-file-info").each(function () { @@ -485,7 +445,6 @@ function plu_show_thumbs(imgId) { $("#" + imgId, $('#' + imgId + 'plupload-upload-ui').parent()).val(kimages.join("::")); }); } - function gd_edit_image_meta(input, order_id) { var imagesS = jQuery("#" + input.id, jQuery('#' + input.id + 'plupload-upload-ui').parent()).val(); var images = imagesS.split("::"); @@ -494,15 +453,11 @@ function gd_edit_image_meta(input, order_id) { var image_caption = img_arr[3]; var html = ''; html = html + "
    "; // title value - html = html + "
    "; // caption value - html = html + "
    "; // caption value - jQuery('#atbdp-image-meta-input').html(html); lity('#atbdp-image-meta-input'); } - function gd_set_image_meta(input_id, order_id) { //alert(order_id); var imagesS = jQuery("#" + input_id, jQuery('#' + input_id + 'plupload-upload-ui').parent()).val(); @@ -539,18 +494,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -563,24 +514,19 @@ function get_dom_data(key, parent) { 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, @@ -590,7 +536,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -601,17 +546,14 @@ function convertToSelect2(field) { 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); }); } - /***/ }), /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": @@ -623,14 +565,9 @@ function convertToSelect2(field) { 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]; - } - + 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; /***/ }), @@ -643,11 +580,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -662,7 +597,6 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex 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; /***/ }), @@ -677,7 +611,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -690,17 +623,12 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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; /***/ }), @@ -712,16 +640,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -734,7 +661,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -743,7 +669,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }) diff --git a/assets/js/global-geolocation.js b/assets/js/global-geolocation.js index c3cc9651ed..b42f45100c 100644 --- a/assets/js/global-geolocation.js +++ b/assets/js/global-geolocation.js @@ -108,13 +108,11 @@ window.addEventListener('DOMContentLoaded', function () { }); }); } - (function () { eventDelegation('click', '.directorist-filter-location-icon > i, .directorist-filter-location-icon > span', function (e) { var locationInput = e.target.closest('.directorist-search-field').querySelector('.location-name'); var get_lat = e.target.closest('.directorist-search-field').querySelector("#cityLat"); var get_lng = e.target.closest('.directorist-search-field').querySelector("#cityLng"); - function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, showError); @@ -122,9 +120,7 @@ window.addEventListener('DOMContentLoaded', function () { locationInput.value = 'Geolocation is not supported by this browser.'; } } - getLocation(); - function showPosition(position) { lat = position.coords.latitude; lon = position.coords.longitude; @@ -132,27 +128,22 @@ window.addEventListener('DOMContentLoaded', function () { get_lat.value = lat; get_lng.value = lon; } - function showError(error) { switch (error.code) { case error.PERMISSION_DENIED: locationInput.value = 'User denied the request for Geolocation.'; break; - case error.POSITION_UNAVAILABLE: locationInput.value = 'Location information is unavailable.'; break; - case error.TIMEOUT: locationInput.value = 'The request to get user location timed out.'; break; - case error.UNKNOWN_ERROR: locationInput.value = 'An unknown error occurred.'; break; } } - function displayLocation(latitude, longitude) { var geocoder; geocoder = new google.maps.Geocoder(); @@ -180,7 +171,6 @@ window.addEventListener('DOMContentLoaded', function () { } }); } - function displayCurrentLocation(latitude, longitude) { var geocoder; geocoder = new google.maps.Geocoder(); @@ -225,7 +215,6 @@ window.addEventListener('DOMContentLoaded', function () { } }); } - $('body').on("click", ".directorist-filter-location-icon", function (e) { navigator.geolocation.getCurrentPosition(function (position) { return displayLocation(position, e); diff --git a/assets/js/global-main.js b/assets/js/global-main.js index f794756663..1a629024c6 100644 --- a/assets/js/global-main.js +++ b/assets/js/global-main.js @@ -94,7 +94,6 @@ /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // Recovery Password Modal @@ -102,14 +101,16 @@ $(".atbdp_recovery_pass").on("click", function (e) { e.preventDefault(); $("#recover-pass-modal").slideToggle().show(); - }); // Contact form [on modal closed] + }); + // Contact form [on modal closed] $('#atbdp-contact-modal').on('hidden.bs.modal', function (e) { $('#atbdp-contact-message').val(''); $('#atbdp-contact-message-display').html(''); - }); // Template Restructured - // Modal + }); + // Template Restructured + // Modal var directoristModal = document.querySelector('.directorist-modal-js'); $('body').on('click', '.directorist-btn-modal-js', function (e) { e.preventDefault(); @@ -138,52 +139,44 @@ /***/ (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; } - +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 - +} +// Initialize function init() { // Add custom dropdown toggle button - selec2_add_custom_dropdown_toggle_button(); // Add custom close button where needed + selec2_add_custom_dropdown_toggle_button(); - selec2_add_custom_close_button_if_needed(); // Add custom close button if field contains value on change + // 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'; @@ -191,9 +184,9 @@ function selec2_add_custom_dropdown_toggle_button() { var dropdownHTML = "".concat(iconHTML, ""); addon_container.append(dropdownHTML); } + var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); - var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); // Toggle --is-open class - + // 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'); @@ -201,41 +194,36 @@ function selec2_add_custom_dropdown_toggle_button() { $('.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 + }); + // 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 + }); + // 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; - + _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) { @@ -244,21 +232,20 @@ function selec2_add_custom_close_button_if_needed() { _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 + // 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("".concat(iconHTML, "")); @@ -268,56 +255,46 @@ function selec2_add_custom_close_button(field) { field.val(null).trigger('change'); addon_container.find('.directorist-select2-dropdown-close').remove(); selec2_adjust_space_for_addons(); - }); // 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 + // 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(''); 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(''); 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' @@ -344,18 +321,16 @@ __webpack_require__.r(__webpack_exports__); /* 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; } - +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } 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 +document.body.addEventListener('directorist-reload-select2-fields', initSelect2); +// Init Static Select 2 Fields function initSelect2() { var select_fields = [{ elm: $('.directorist-select').find('select') @@ -381,7 +356,8 @@ function initSelect2() { elm: $('#directorist-select-fr-s-js') }, { elm: $('#directorist-select-fr-e-js') - }, // { elm: $('#directorist-location-select') }, + }, + // { elm: $('#directorist-location-select') }, // { elm: $('#directorist-category-select') }, { elm: $('.select-basic') @@ -389,30 +365,33 @@ function initSelect2() { elm: $('#loc-type') }, { elm: $('.bdas-location-search') - }, // { elm: $('.directorist-location-select') }, + }, + // { elm: $('.directorist-location-select') }, { elm: $('#at_biz_dir-category') }, { elm: $('#cat-type') }, { elm: $('.bdas-category-search') - } // { elm: $('.directorist-category-select') }, + } + // { 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 - +} +// Init Select2 Ajax Fields function initSelect2AjaxFields() { - var rest_base_url = "".concat(directorist.rest_url, "directorist/v1"); // Init Select2 Ajax Category Field + 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") @@ -420,8 +399,9 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-categories-field').find('select'), url: "".concat(rest_base_url, "/listings/categories") - }); // Init Select2 Ajax Location Field + }); + // Init Select2 Ajax Location Field initSelect2AjaxTaxonomy({ selector: $('.directorist-search-location').find('select'), url: "".concat(rest_base_url, "/listings/locations") @@ -429,17 +409,18 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-location-field').find('select'), url: "".concat(rest_base_url, "/listings/locations") - }); // Init Select2 Ajax Tag Field + }); + // Init Select2 Ajax Tag Field initSelect2AjaxTaxonomy({ selector: $('.directorist-form-tag-field').find('select'), url: "".concat(rest_base_url, "/listings/tags") }, { has_directory_type: false }); -} // initSelect2AjaxTaxonomy - +} +// initSelect2AjaxTaxonomy function initSelect2AjaxTaxonomy(args, terms_options) { var defaultArgs = { selector: '', @@ -451,46 +432,42 @@ function initSelect2AjaxTaxonomy(args, terms_options) { has_directory_type: true }; terms_options = terms_options ? _objectSpread(_objectSpread({}, default_terms_options), terms_options) : default_terms_options; - 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 createNew = item.getAttribute("data-allow_new"); var maxLength = item.getAttribute("data-max"); - if (terms_options.has_directory_type) { var search_form_parent = $(item).closest('.directorist-search-form'); var archive_page_parent = $(item).closest('.directorist-archive-contents'); var add_listing_form_hidden_input = $(item).closest('.directorist-add-listing-form').find('input[name="directory_type"]'); - var nav_list_item = []; // If search page + 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 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 has nav item if (nav_list_item.length) { directory_type_id = nav_list_item ? nav_list_item.data('listing_type_id') : 0; - } // If has nav item - + } + // If has nav item if (add_listing_form_hidden_input.length) { directory_type_id = add_listing_form_hidden_input.val(); } - if (directory_type_id) { directory_type_id = parseInt(directory_type_id); } } - var currentPage = 1; $(item).select2({ allowClear: true, @@ -512,11 +489,9 @@ function initSelect2AjaxTaxonomy(args, terms_options) { page: currentPage, per_page: args.perPage }; - if (directory_type_id) { query.directory = directory_type_id; } - return query; }, processResults: function processResults(data) { @@ -547,16 +522,15 @@ function initSelect2AjaxTaxonomy(args, terms_options) { return $request; } } - }); // Setup Preselected Option + }); + // Setup Preselected Option var selected_item_id = $(item).data('selected-id'); var selected_item_label = $(item).data('selected-label'); - var setup_selected_items = function setup_selected_items(element, selected_id, selected_label) { if (!element || !selected_id) { return; } - var selected_ids = "".concat(selected_id).split(','); var selected_labels = selected_label ? "".concat(selected_label).split(',') : []; selected_ids.forEach(function (id, index) { @@ -574,7 +548,6 @@ function initSelect2AjaxTaxonomy(args, terms_options) { }); }); }; - setup_selected_items(item, selected_item_id, selected_item_label); }); } @@ -594,7 +567,6 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__); document.addEventListener('DOMContentLoaded', init, false); - function Tasks() { return { init: function init() { @@ -602,13 +574,10 @@ function Tasks() { }, initToggleTabLinks: function initToggleTabLinks() { var links = document.querySelectorAll('.directorist-toggle-tab'); - if (!links) { return; } - var self = this; - _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(links).forEach(function (item) { item.addEventListener('click', function (event) { self.handleToggleTabLinksEvent(item, event); @@ -620,53 +589,44 @@ function Tasks() { var navContainerClass = item.getAttribute('data-nav-container'); var tabContainerClass = item.getAttribute('data-tab-container'); var tabClass = item.getAttribute('data-tab'); - if (!navContainerClass || !tabContainerClass || !tabClass) { return; } - var navContainer = item.closest('.' + navContainerClass); var tabContainer = document.querySelector('.' + tabContainerClass); - if (!navContainer || !tabContainer) { return; } - var tab = tabContainer.querySelector('.' + tabClass); - if (!tab) { return; - } // Remove Active Class - + } + // Remove Active Class var removeActiveClass = function removeActiveClass(item) { item.classList.remove('--is-active'); - }; // Toggle Nav - + }; + // Toggle Nav var activeNavItems = navContainer.querySelectorAll('.--is-active'); - if (activeNavItems) { _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(activeNavItems).forEach(removeActiveClass); } + item.classList.add('--is-active'); - item.classList.add('--is-active'); // Toggle Tab - + // Toggle Tab var activeTabItems = tabContainer.querySelectorAll('.--is-active'); - if (activeTabItems) { _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(activeTabItems).forEach(removeActiveClass); } + tab.classList.add('--is-active'); - tab.classList.add('--is-active'); // Update Query Var - + // Update Query Var var queryVarKey = item.getAttribute('data-query-var-key'); var queryVarValue = item.getAttribute('data-query-var-value'); - if (!queryVarKey || !queryVarValue) { return; } - this.addQueryParam(queryVarKey, queryVarValue); }, addQueryParam: function addQueryParam(key, value) { @@ -676,7 +636,6 @@ function Tasks() { } }; } - function init() { var tasks = new Tasks(); tasks.init(); @@ -695,18 +654,21 @@ window.addEventListener('DOMContentLoaded', function () { var $ = jQuery; document.querySelectorAll('.la-icon i').forEach(function (item) { className.push(item.getAttribute('class')); - }); // Handle Disabled Link Action + }); + // Handle Disabled Link Action $('.atbdp-disabled').on('click', function (e) { e.preventDefault(); - }); // Toggle Modal + }); + // Toggle Modal $('.cptm-modal-toggle').on('click', function (e) { e.preventDefault(); var target_class = $(this).data('target'); $('.' + target_class).toggleClass('active'); - }); // Change label on file select/change + }); + // Change label on file select/change $('.cptm-file-field').on('change', function (e) { var target_id = $(this).attr('id'); $('label[for=' + target_id + ']').text('Change'); @@ -758,18 +720,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -782,24 +740,19 @@ function get_dom_data(key, parent) { 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, @@ -809,7 +762,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -820,17 +772,14 @@ function convertToSelect2(field) { 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); }); } - /***/ }), /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": @@ -842,14 +791,9 @@ function convertToSelect2(field) { 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]; - } - + 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; /***/ }), @@ -862,11 +806,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -876,9 +818,11 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! \***************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperty(obj, key, value) { + key = toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, @@ -889,10 +833,8 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } - module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -907,7 +849,6 @@ module.exports = _defineProperty, module.exports.__esModule = true, module.expor 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; /***/ }), @@ -922,7 +863,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -935,21 +875,55 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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/toPrimitive.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPropertyKey.js": +/*!**************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js"); +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} +module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + /***/ "./node_modules/@babel/runtime/helpers/typeof.js": /*!*******************************************************!*\ !*** ./node_modules/@babel/runtime/helpers/typeof.js ***! @@ -957,16 +931,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -979,7 +952,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -988,7 +960,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/global-markerclusterer.js b/assets/js/global-markerclusterer.js index 8136043a0b..ce34f2be1d 100644 --- a/assets/js/global-markerclusterer.js +++ b/assets/js/global-markerclusterer.js @@ -98,7 +98,6 @@ __webpack_require__.r(__webpack_exports__); /* 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__); - // ==ClosureCompiler== // @compilation_level ADVANCED_OPTIMIZATIONS // @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/maps/google_maps_api_v3_3.js @@ -168,101 +167,97 @@ function MarkerClusterer(map, opt_markers, opt_options) { // there is no point going ahead :) this.extend(MarkerClusterer, google.maps.OverlayView); this.map_ = map; + /** * @type {Array.} * @private */ - this.markers_ = []; + /** * @type {Array.} */ - this.clusters_ = []; this.sizes = [53, 56, 66, 78, 90]; + /** * @private */ - this.styles_ = []; + /** * @private */ - this.cssClass_ = ''; + /** * @type {boolean} * @private */ - this.ready_ = false; var options = opt_options || {}; + /** * @type {number} * @private */ - this.gridSize_ = options['gridSize'] || 60; + /** * @private */ - this.minClusterSize_ = options['minimumClusterSize'] || 2; + /** * @type {?number} * @private */ - this.maxZoom_ = options['maxZoom'] || null; this.styles_ = options['styles'] || []; this.cssClass_ = options['cssClass'] || null; + /** * @type {string} * @private */ - this.imagePath_ = options['imagePath'] || this.MARKER_CLUSTER_IMAGE_PATH_; + /** * @type {string} * @private */ - this.imageExtension_ = options['imageExtension'] || this.MARKER_CLUSTER_IMAGE_EXTENSION_; + /** * @type {boolean} * @private */ - this.zoomOnClick_ = true; - if (options['zoomOnClick'] != undefined) { this.zoomOnClick_ = options['zoomOnClick']; } + /** * @type {boolean} * @private */ - - this.averageCenter_ = false; - if (options['averageCenter'] != undefined) { this.averageCenter_ = options['averageCenter']; } - this.setupStyles_(); this.setMap(map); + /** * @type {number} * @private */ + this.prevZoom_ = this.map_.getZoom(); - this.prevZoom_ = this.map_.getZoom(); // Add the map event listeners - + // Add the map event listeners var that = this; google.maps.event.addListener(this.map_, 'zoom_changed', function () { var zoom = that.map_.getZoom(); - if (that.prevZoom_ != zoom) { that.prevZoom_ = zoom; that.resetViewport(); @@ -270,29 +265,30 @@ function MarkerClusterer(map, opt_markers, opt_options) { }); google.maps.event.addListener(this.map_, 'idle', function () { that.redraw(); - }); // Finally, add the markers + }); + // Finally, add the markers if (opt_markers && opt_markers.length) { this.addMarkers(opt_markers, false); } } + /** * The marker cluster image path. * * @type {string} * @private */ - - MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_ = 'http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/' + 'images/m'; + /** * The marker cluster image path. * * @type {string} * @private */ - MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_ = 'png'; + /** * Extends a objects prototype by anothers. * @@ -301,44 +297,38 @@ MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_EXTENSION_ = 'png'; * @return {Object} The new extended object. * @ignore */ - MarkerClusterer.prototype.extend = function (obj1, obj2) { return function (object) { for (var property in object.prototype) { this.prototype[property] = object.prototype[property]; } - return this; }.apply(obj1, [obj2]); }; + /** * Implementaion of the interface method. * @ignore */ - - MarkerClusterer.prototype.onAdd = function () { this.setReady_(true); }; + /** * Implementaion of the interface method. * @ignore */ - - MarkerClusterer.prototype.draw = function () {}; + /** * Sets up the styles object. * * @private */ - - MarkerClusterer.prototype.setupStyles_ = function () { if (this.styles_.length) { return; } - for (var i = 0, size; size = this.sizes[i]; i++) { this.styles_.push({ url: this.imagePath_ + (i + 1) + '.' + this.imageExtension_, @@ -347,101 +337,91 @@ MarkerClusterer.prototype.setupStyles_ = function () { }); } }; + /** * Fit the map to the bounds of the markers in the clusterer. */ - - MarkerClusterer.prototype.fitMapToMarkers = function () { var markers = this.getMarkers(); var bounds = new google.maps.LatLngBounds(); - for (var i = 0, marker; marker = markers[i]; i++) { bounds.extend(marker.getPosition()); } - this.map_.fitBounds(bounds); }; + /** * Sets the styles. * * @param {Object} styles The style to set. */ - - MarkerClusterer.prototype.setStyles = function (styles) { this.styles_ = styles; }; + /** * Gets the styles. * * @return {Object} The styles object. */ - - MarkerClusterer.prototype.getStyles = function () { return this.styles_; }; + /** * Whether zoom on click is set. * * @return {boolean} True if zoomOnClick_ is set. */ - - MarkerClusterer.prototype.isZoomOnClick = function () { return this.zoomOnClick_; }; + /** * Whether average center is set. * * @return {boolean} True if averageCenter_ is set. */ - - MarkerClusterer.prototype.isAverageCenter = function () { return this.averageCenter_; }; + /** * Returns the array of markers in the clusterer. * * @return {Array.} The markers. */ - - MarkerClusterer.prototype.getMarkers = function () { return this.markers_; }; + /** * Returns the number of markers in the clusterer * * @return {Number} The number of markers. */ - - MarkerClusterer.prototype.getTotalMarkers = function () { return this.markers_.length; }; + /** * Sets the max zoom for the clusterer. * * @param {number} maxZoom The max zoom level. */ - - MarkerClusterer.prototype.setMaxZoom = function (maxZoom) { this.maxZoom_ = maxZoom; }; + /** * Gets the max zoom for the clusterer. * * @return {number} The max zoom level. */ - - MarkerClusterer.prototype.getMaxZoom = function () { return this.maxZoom_; }; + /** * The function for calculating the cluster icon image. * @@ -450,24 +430,21 @@ MarkerClusterer.prototype.getMaxZoom = function () { * @return {Object} A object properties: 'text' (string) and 'index' (number). * @private */ - - MarkerClusterer.prototype.calculator_ = function (markers, numStyles) { var index = 0; var count = markers.length; var dv = count; - while (dv !== 0) { dv = parseInt(dv / 10, 10); index++; } - index = Math.min(index, numStyles); return { text: count, index: index }; }; + /** * Set the calculator function. * @@ -476,49 +453,42 @@ MarkerClusterer.prototype.calculator_ = function (markers, numStyles) { * 'text' (string) and 'index' (number). * */ - - MarkerClusterer.prototype.setCalculator = function (calculator) { this.calculator_ = calculator; }; + /** * Get the calculator function. * * @return {function(Array, number)} the calculator function. */ - - MarkerClusterer.prototype.getCalculator = function () { return this.calculator_; }; + /** * Add an array of markers to the clusterer. * * @param {Array.} markers The markers to add. * @param {boolean=} opt_nodraw Whether to redraw the clusters. */ - - MarkerClusterer.prototype.addMarkers = function (markers, opt_nodraw) { for (var i = 0, marker; marker = markers[i]; i++) { this.pushMarkerTo_(marker); } - if (!opt_nodraw) { this.redraw(); } }; + /** * Pushes a marker to the clusterer. * * @param {google.maps.Marker} marker The marker to add. * @private */ - - MarkerClusterer.prototype.pushMarkerTo_ = function (marker) { marker.isAdded = false; - if (marker['draggable']) { // If the marker is draggable add a listener so we update the clusters on // the drag end. @@ -528,24 +498,22 @@ MarkerClusterer.prototype.pushMarkerTo_ = function (marker) { that.repaint(); }); } - this.markers_.push(marker); }; + /** * Adds a marker to the clusterer and redraws if needed. * * @param {google.maps.Marker} marker The marker to add. * @param {boolean=} opt_nodraw Whether to redraw the clusters. */ - - MarkerClusterer.prototype.addMarker = function (marker, opt_nodraw) { this.pushMarkerTo_(marker); - if (!opt_nodraw) { this.redraw(); } }; + /** * Removes a marker and returns true if removed, false if not * @@ -553,11 +521,8 @@ MarkerClusterer.prototype.addMarker = function (marker, opt_nodraw) { * @return {boolean} Whether the marker was removed or not * @private */ - - MarkerClusterer.prototype.removeMarker_ = function (marker) { var index = -1; - if (this.markers_.indexOf) { index = this.markers_.indexOf(marker); } else { @@ -568,16 +533,15 @@ MarkerClusterer.prototype.removeMarker_ = function (marker) { } } } - if (index == -1) { // Marker is not in our list of markers. return false; } - marker.setMap(null); this.markers_.splice(index, 1); return true; }; + /** * Remove a marker from the cluster. * @@ -585,11 +549,8 @@ MarkerClusterer.prototype.removeMarker_ = function (marker) { * @param {boolean=} opt_nodraw Optional boolean to force no redraw. * @return {boolean} True if the marker was removed. */ - - MarkerClusterer.prototype.removeMarker = function (marker, opt_nodraw) { var removed = this.removeMarker_(marker); - if (!opt_nodraw && removed) { this.resetViewport(); this.redraw(); @@ -598,140 +559,133 @@ MarkerClusterer.prototype.removeMarker = function (marker, opt_nodraw) { return false; } }; + /** * Removes an array of markers from the cluster. * * @param {Array.} markers The markers to remove. * @param {boolean=} opt_nodraw Optional boolean to force no redraw. */ - - MarkerClusterer.prototype.removeMarkers = function (markers, opt_nodraw) { var removed = false; - for (var i = 0, marker; marker = markers[i]; i++) { var r = this.removeMarker_(marker); removed = removed || r; } - if (!opt_nodraw && removed) { this.resetViewport(); this.redraw(); return true; } }; + /** * Sets the clusterer's ready state. * * @param {boolean} ready The state. * @private */ - - MarkerClusterer.prototype.setReady_ = function (ready) { if (!this.ready_) { this.ready_ = ready; this.createClusters_(); } }; + /** * Returns the number of clusters in the clusterer. * * @return {number} The number of clusters. */ - - MarkerClusterer.prototype.getTotalClusters = function () { return this.clusters_.length; }; + /** * Returns the google map that the clusterer is associated with. * * @return {google.maps.Map} The map. */ - - MarkerClusterer.prototype.getMap = function () { return this.map_; }; + /** * Sets the google map that the clusterer is associated with. * * @param {google.maps.Map} map The map. */ - - MarkerClusterer.prototype.setMap = function (map) { this.map_ = map; }; + /** * Returns the size of the grid. * * @return {number} The grid size. */ - - MarkerClusterer.prototype.getGridSize = function () { return this.gridSize_; }; + /** * Sets the size of the grid. * * @param {number} size The grid size. */ - - MarkerClusterer.prototype.setGridSize = function (size) { this.gridSize_ = size; }; + /** * Returns the min cluster size. * * @return {number} The grid size. */ - - MarkerClusterer.prototype.getMinClusterSize = function () { return this.minClusterSize_; }; + /** * Sets the min cluster size. * * @param {number} size The grid size. */ - - MarkerClusterer.prototype.setMinClusterSize = function (size) { this.minClusterSize_ = size; }; + /** * Extends a bounds object by the grid size. * * @param {google.maps.LatLngBounds} bounds The bounds to extend. * @return {google.maps.LatLngBounds} The extended bounds. */ - - MarkerClusterer.prototype.getExtendedBounds = function (bounds) { - var projection = this.getProjection(); // Turn the bounds into latlng. + var projection = this.getProjection(); + // Turn the bounds into latlng. var tr = new google.maps.LatLng(bounds.getNorthEast().lat(), bounds.getNorthEast().lng()); - var bl = new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()); // Convert the points to pixels and the extend out by the grid size. + var bl = new google.maps.LatLng(bounds.getSouthWest().lat(), bounds.getSouthWest().lng()); + // Convert the points to pixels and the extend out by the grid size. var trPix = projection.fromLatLngToDivPixel(tr); trPix.x += this.gridSize_; trPix.y -= this.gridSize_; var blPix = projection.fromLatLngToDivPixel(bl); blPix.x -= this.gridSize_; - blPix.y += this.gridSize_; // Convert the pixel points back to LatLng + blPix.y += this.gridSize_; + // Convert the pixel points back to LatLng var ne = projection.fromDivPixelToLatLng(trPix); - var sw = projection.fromDivPixelToLatLng(blPix); // Extend the bounds to contain the new bounds. + var sw = projection.fromDivPixelToLatLng(blPix); + // Extend the bounds to contain the new bounds. bounds.extend(ne); bounds.extend(sw); return bounds; }; + /** * Determins if a marker is contained in a bounds. * @@ -740,70 +694,65 @@ MarkerClusterer.prototype.getExtendedBounds = function (bounds) { * @return {boolean} True if the marker is in the bounds. * @private */ - - MarkerClusterer.prototype.isMarkerInBounds_ = function (marker, bounds) { return bounds.contains(marker.getPosition()); }; + /** * Clears all clusters and markers from the clusterer. */ - - MarkerClusterer.prototype.clearMarkers = function () { - this.resetViewport(true); // Set the markers a empty array. + this.resetViewport(true); + // Set the markers a empty array. this.markers_ = []; }; + /** * Clears all existing clusters and recreates them. * @param {boolean} opt_hide To also hide the marker. */ - - MarkerClusterer.prototype.resetViewport = function (opt_hide) { // Remove all the clusters for (var i = 0, cluster; cluster = this.clusters_[i]; i++) { cluster.remove(); - } // Reset the markers to not be added and to be invisible. - + } + // Reset the markers to not be added and to be invisible. for (var i = 0, marker; marker = this.markers_[i]; i++) { marker.isAdded = false; - if (opt_hide) { marker.setMap(null); } } - this.clusters_ = []; }; + /** * */ - - MarkerClusterer.prototype.repaint = function () { var oldClusters = this.clusters_.slice(); this.clusters_.length = 0; this.resetViewport(); - this.redraw(); // Remove the old clusters. - // Do it in a timeout so the other clusters have been drawn first. + this.redraw(); + // Remove the old clusters. + // Do it in a timeout so the other clusters have been drawn first. window.setTimeout(function () { for (var i = 0, cluster; cluster = oldClusters[i]; i++) { cluster.remove(); } }, 0); }; + /** * Redraws the clusters. */ - - MarkerClusterer.prototype.redraw = function () { this.createClusters_(); }; + /** * Calculates the distance between two latlng locations in km. * @see http://www.movable-type.co.uk/scripts/latlong.html @@ -813,15 +762,11 @@ MarkerClusterer.prototype.redraw = function () { * @return {number} The distance between the two points in km. * @private */ - - MarkerClusterer.prototype.distanceBetweenPoints_ = function (p1, p2) { if (!p1 || !p2) { return 0; } - var R = 6371; // Radius of the Earth in km - var dLat = (p2.lat() - p1.lat()) * Math.PI / 180; var dLon = (p2.lng() - p1.lng()) * Math.PI / 180; var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(p1.lat() * Math.PI / 180) * Math.cos(p2.lat() * Math.PI / 180) * Math.sin(dLon / 2) * Math.sin(dLon / 2); @@ -829,33 +774,27 @@ MarkerClusterer.prototype.distanceBetweenPoints_ = function (p1, p2) { var d = R * c; return d; }; + /** * Add a marker to a cluster, or creates a new cluster. * * @param {google.maps.Marker} marker The marker to add. * @private */ - - MarkerClusterer.prototype.addToClosestCluster_ = function (marker) { var distance = 40000; // Some large number - var clusterToAddTo = null; var pos = marker.getPosition(); - for (var i = 0, cluster; cluster = this.clusters_[i]; i++) { var center = cluster.getCenter(); - if (center) { var d = this.distanceBetweenPoints_(center, marker.getPosition()); - if (d < distance) { distance = d; clusterToAddTo = cluster; } } } - if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) { clusterToAddTo.addMarker(marker); } else { @@ -864,29 +803,28 @@ MarkerClusterer.prototype.addToClosestCluster_ = function (marker) { this.clusters_.push(cluster); } }; + /** * Creates the clusters. * * @private */ - - MarkerClusterer.prototype.createClusters_ = function () { if (!this.ready_) { return; - } // Get our current map view bounds. - // Create a new bounds object so we don't affect the map. - + } + // Get our current map view bounds. + // Create a new bounds object so we don't affect the map. var mapBounds = new google.maps.LatLngBounds(this.map_.getBounds().getSouthWest(), this.map_.getBounds().getNorthEast()); var bounds = this.getExtendedBounds(mapBounds); - for (var i = 0, marker; marker = this.markers_[i]; i++) { if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds)) { this.addToClosestCluster_(marker); } } }; + /** * A cluster that contains markers. * @@ -895,8 +833,6 @@ MarkerClusterer.prototype.createClusters_ = function () { * @constructor * @ignore */ - - function Cluster(markerClusterer) { this.markerClusterer_ = markerClusterer; this.map_ = markerClusterer.getMap(); @@ -908,14 +844,13 @@ function Cluster(markerClusterer) { this.bounds_ = null; this.clusterIcon_ = new ClusterIcon(this, markerClusterer.getStyles(), markerClusterer.getGridSize()); } + /** * Determins if a marker is already added to the cluster. * * @param {google.maps.Marker} marker The marker to check. * @return {boolean} True if the marker is already added. */ - - Cluster.prototype.isMarkerAlreadyAdded = function (marker) { if (this.markers_.indexOf) { return this.markers_.indexOf(marker) != -1; @@ -926,22 +861,19 @@ Cluster.prototype.isMarkerAlreadyAdded = function (marker) { } } } - return false; }; + /** * Add a marker the cluster. * * @param {google.maps.Marker} marker The marker to add. * @return {boolean} True if the marker was added. */ - - Cluster.prototype.addMarker = function (marker) { if (this.isMarkerAlreadyAdded(marker)) { return false; } - if (!this.center_) { this.center_ = marker.getPosition(); this.calculateBounds_(); @@ -954,159 +886,139 @@ Cluster.prototype.addMarker = function (marker) { this.calculateBounds_(); } } - marker.isAdded = true; this.markers_.push(marker); var len = this.markers_.length; - if (len < this.minClusterSize_ && marker.getMap() != this.map_) { // Min cluster size not reached so show the marker. marker.setMap(this.map_); } - if (len == this.minClusterSize_) { // Hide the markers that were showing. for (var i = 0; i < len; i++) { this.markers_[i].setMap(null); } } - if (len >= this.minClusterSize_) { marker.setMap(null); } - this.updateIcon(); return true; }; + /** * Returns the marker clusterer that the cluster is associated with. * * @return {MarkerClusterer} The associated marker clusterer. */ - - Cluster.prototype.getMarkerClusterer = function () { return this.markerClusterer_; }; + /** * Returns the bounds of the cluster. * * @return {google.maps.LatLngBounds} the cluster bounds. */ - - Cluster.prototype.getBounds = function () { var bounds = new google.maps.LatLngBounds(this.center_, this.center_); var markers = this.getMarkers(); - for (var i = 0, marker; marker = markers[i]; i++) { bounds.extend(marker.getPosition()); } - return bounds; }; + /** * Removes the cluster */ - - Cluster.prototype.remove = function () { this.clusterIcon_.remove(); this.markers_.length = 0; delete this.markers_; }; + /** * Returns the center of the cluster. * * @return {number} The cluster center. */ - - Cluster.prototype.getSize = function () { return this.markers_.length; }; + /** * Returns the center of the cluster. * * @return {Array.} The cluster center. */ - - Cluster.prototype.getMarkers = function () { return this.markers_; }; + /** * Returns the center of the cluster. * * @return {google.maps.LatLng} The cluster center. */ - - Cluster.prototype.getCenter = function () { return this.center_; }; + /** * Calculated the extended bounds of the cluster with the grid. * * @private */ - - Cluster.prototype.calculateBounds_ = function () { var bounds = new google.maps.LatLngBounds(this.center_, this.center_); this.bounds_ = this.markerClusterer_.getExtendedBounds(bounds); }; + /** * Determines if a marker lies in the clusters bounds. * * @param {google.maps.Marker} marker The marker to check. * @return {boolean} True if the marker lies in the bounds. */ - - Cluster.prototype.isMarkerInClusterBounds = function (marker) { return this.bounds_.contains(marker.getPosition()); }; + /** * Returns the map that the cluster is associated with. * * @return {google.maps.Map} The map. */ - - Cluster.prototype.getMap = function () { return this.map_; }; + /** * Updates the cluster icon */ - - Cluster.prototype.updateIcon = function () { var zoom = this.map_.getZoom(); var mz = this.markerClusterer_.getMaxZoom(); - if (mz && zoom > mz) { // The zoom is greater than our max zoom so show all the markers in cluster. for (var i = 0, marker; marker = this.markers_[i]; i++) { marker.setMap(this.map_); } - return; } - if (this.markers_.length < this.minClusterSize_) { // Min cluster size not yet reached. this.clusterIcon_.hide(); return; } - var numStyles = this.markerClusterer_.getStyles().length; var sums = this.markerClusterer_.getCalculator()(this.markers_, numStyles); this.clusterIcon_.setCenter(this.center_); this.clusterIcon_.setSums(sums); this.clusterIcon_.show(); }; + /** * A cluster icon * @@ -1124,8 +1036,6 @@ Cluster.prototype.updateIcon = function () { * @extends google.maps.OverlayView * @ignore */ - - function ClusterIcon(cluster, styles, opt_padding) { cluster.getMarkerClusterer().extend(ClusterIcon, google.maps.OverlayView); this.styles_ = styles; @@ -1138,41 +1048,36 @@ function ClusterIcon(cluster, styles, opt_padding) { this.visible_ = false; this.setMap(this.map_); } + /** * Triggers the clusterclick event and zoom's if the option is set. */ - - ClusterIcon.prototype.triggerClusterClick = function () { - var markerClusterer = this.cluster_.getMarkerClusterer(); // Trigger the clusterclick event. + var markerClusterer = this.cluster_.getMarkerClusterer(); + // Trigger the clusterclick event. google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_); - if (markerClusterer.isZoomOnClick()) { // Zoom into the cluster. this.map_.fitBounds(this.cluster_.getBounds()); } }; + /** * Adding the cluster icon to the dom. * @ignore */ - - ClusterIcon.prototype.onAdd = function () { this.div_ = document.createElement('DIV'); - if (this.visible_) { var pos = this.getPosFromLatLng_(this.center_); this.div_.style.cssText = this.createCss(pos); this.div_.innerHTML = this.sums_.text; var markerClusterer = this.cluster_.getMarkerClusterer(); - if (markerClusterer.cssClass_) { this.div_.className = markerClusterer.cssClass_; } } - var panes = this.getPanes(); panes.overlayMouseTarget.appendChild(this.div_); var that = this; @@ -1180,6 +1085,7 @@ ClusterIcon.prototype.onAdd = function () { that.triggerClusterClick(); }); }; + /** * Returns the position to place the div dending on the latlng. * @@ -1187,20 +1093,17 @@ ClusterIcon.prototype.onAdd = function () { * @return {google.maps.Point} The position in pixels. * @private */ - - ClusterIcon.prototype.getPosFromLatLng_ = function (latlng) { var pos = this.getProjection().fromLatLngToDivPixel(latlng); pos.x -= parseInt(this.width_ / 2, 10); pos.y -= parseInt(this.height_ / 2, 10); return pos; }; + /** * Draw the icon. * @ignore */ - - ClusterIcon.prototype.draw = function () { if (this.visible_) { var pos = this.getPosFromLatLng_(this.center_); @@ -1208,46 +1111,40 @@ ClusterIcon.prototype.draw = function () { this.div_.style.left = pos.x + 'px'; } }; + /** * Hide the icon. */ - - ClusterIcon.prototype.hide = function () { if (this.div_) { this.div_.style.display = 'none'; } - this.visible_ = false; }; + /** * Position and show the icon. */ - - ClusterIcon.prototype.show = function () { if (this.div_) { var pos = this.getPosFromLatLng_(this.center_); this.div_.style.cssText = this.createCss(pos); this.div_.style.display = ''; } - this.visible_ = true; }; + /** * Remove the icon from the map */ - - ClusterIcon.prototype.remove = function () { this.setMap(null); }; + /** * Implementation of the onRemove interface. * @ignore */ - - ClusterIcon.prototype.onRemove = function () { if (this.div_ && this.div_.parentNode) { this.hide(); @@ -1255,6 +1152,7 @@ ClusterIcon.prototype.onRemove = function () { this.div_ = null; } }; + /** * Set the sums of the icon. * @@ -1262,24 +1160,19 @@ ClusterIcon.prototype.onRemove = function () { * 'text': (string) The text to display in the icon. * 'index': (number) The style index of the icon. */ - - ClusterIcon.prototype.setSums = function (sums) { this.sums_ = sums; this.text_ = sums.text; this.index_ = sums.index; - if (this.div_) { this.div_.innerHTML = sums.text; } - this.useStyle(); }; + /** * Sets the icon to the the styles. */ - - ClusterIcon.prototype.useStyle = function () { var index = Math.max(0, this.sums_.index - 1); index = Math.min(this.styles_.length - 1, index); @@ -1292,40 +1185,35 @@ ClusterIcon.prototype.useStyle = function () { this.textSize_ = style['textSize']; this.backgroundPosition_ = style['backgroundPosition']; }; + /** * Sets the center of the icon. * * @param {google.maps.LatLng} center The latlng to set as the center. */ - - ClusterIcon.prototype.setCenter = function (center) { this.center_ = center; }; + /** * Create the css text based on the position of the icon. * * @param {google.maps.Point} pos The position. * @return {string} The css style text. */ - - ClusterIcon.prototype.createCss = function (pos) { var style = []; var markerClusterer = this.cluster_.getMarkerClusterer(); - if (!markerClusterer.cssClass_) { style.push('background-image:url(' + this.url_ + ');'); var backgroundPosition = this.backgroundPosition_ ? this.backgroundPosition_ : '0 0'; style.push('background-position:' + backgroundPosition + ';'); - if (_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(this.anchor_) === 'object') { if (typeof this.anchor_[0] === 'number' && this.anchor_[0] > 0 && this.anchor_[0] < this.height_) { style.push('height:' + (this.height_ - this.anchor_[0]) + 'px; padding-top:' + this.anchor_[0] + 'px;'); } else { style.push('height:' + this.height_ + 'px; line-height:' + this.height_ + 'px;'); } - if (typeof this.anchor_[1] === 'number' && this.anchor_[1] > 0 && this.anchor_[1] < this.width_) { style.push('width:' + (this.width_ - this.anchor_[1]) + 'px; padding-left:' + this.anchor_[1] + 'px;'); } else { @@ -1334,20 +1222,18 @@ ClusterIcon.prototype.createCss = function (pos) { } else { style.push('height:' + this.height_ + 'px; line-height:' + this.height_ + 'px; width:' + this.width_ + 'px; text-align:center;'); } - var txtColor = this.textColor_ ? this.textColor_ : 'black'; var txtSize = this.textSize_ ? this.textSize_ : 11; style.push('cursor:pointer; color:' + txtColor + '; position:absolute; font-size:' + txtSize + 'px; font-family:Arial,sans-serif; font-weight:bold'); } else { style.push('top:' + pos.y + 'px; left:' + pos.x + 'px;'); } - return style.join(''); -}; // Export Symbols for Closure +}; + +// Export Symbols for Closure // If you are not going to compile with closure then you can remove the // code below. - - window['MarkerClusterer'] = MarkerClusterer; MarkerClusterer.prototype['addMarker'] = MarkerClusterer.prototype.addMarker; MarkerClusterer.prototype['addMarkers'] = MarkerClusterer.prototype.addMarkers; @@ -1388,16 +1274,15 @@ ClusterIcon.prototype['onRemove'] = ClusterIcon.prototype.onRemove; /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), diff --git a/assets/js/google-map.js b/assets/js/google-map.js index 83a4a02665..88f78b6284 100644 --- a/assets/js/google-map.js +++ b/assets/js/google-map.js @@ -102,8 +102,9 @@ __webpack_require__.r(__webpack_exports__); (function ($) { $(document).ready(function () { if ($('#gmap').length) { - var localized_data = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('map_data'); // initialize all vars here to avoid hoisting related misunderstanding. + var localized_data = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('map_data'); + // initialize all vars here to avoid hoisting related misunderstanding. var placeSearch; var map; var autocomplete; @@ -113,8 +114,9 @@ __webpack_require__.r(__webpack_exports__); var $manual_lat; var $manual_lng; var saved_lat_lng; - var info_content; // Localized Data + var info_content; + // Localized Data var loc_default_latitude = parseFloat(localized_data.default_latitude); var loc_default_longitude = parseFloat(localized_data.default_longitude); var loc_manual_lat = parseFloat(localized_data.manual_lat); @@ -127,24 +129,27 @@ __webpack_require__.r(__webpack_exports__); saved_lat_lng = { lat: loc_manual_lat, lng: loc_manual_lng - }; // default is London city + }; - info_content = localized_data.info_content, markers = [], // initialize the array to keep track all the marker + // default is London city + info_content = localized_data.info_content, markers = [], + // initialize the array to keep track all the marker info_window = new google.maps.InfoWindow({ content: info_content, maxWidth: 400 - }); // if(address_input){ + }); + + // if(address_input){ // address_input = document.getElementById('address'); // address_input.addEventListener('focus', geolocate); // } address_input = document.getElementById('address'); - if (address_input !== null) { address_input.addEventListener('focus', geolocate); - } // this function will work on sites that uses SSL, it applies to Chrome especially, other browsers may allow location sharing without securing. - + } + // this function will work on sites that uses SSL, it applies to Chrome especially, other browsers may allow location sharing without securing. function geolocate() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function (position) { @@ -160,7 +165,6 @@ __webpack_require__.r(__webpack_exports__); }); } } - function initAutocomplete() { // Create the autocomplete object, restricting the search to geographical var opt = { @@ -171,31 +175,34 @@ __webpack_require__.r(__webpack_exports__); }; var options = directorist.countryRestriction ? opt : { types: [] - }; // location types. + }; - autocomplete = new google.maps.places.Autocomplete(address_input, options); // When the user selects an address from the dropdown, populate the necessary input fields and draw a marker + // location types. + autocomplete = new google.maps.places.Autocomplete(address_input, options); + // When the user selects an address from the dropdown, populate the necessary input fields and draw a marker autocomplete.addListener('place_changed', fillInAddress); } - function fillInAddress() { // Get the place details from the autocomplete object. - var place = autocomplete.getPlace(); // set the value of input field to save them to the database + var place = autocomplete.getPlace(); + // set the value of input field to save them to the database $manual_lat.val(place.geometry.location.lat()); $manual_lng.val(place.geometry.location.lng()); map.setCenter(place.geometry.location); var marker = new google.maps.Marker({ map: map, position: place.geometry.location - }); // marker.addListener('click', function () { + }); + + // marker.addListener('click', function () { // info_window.open(map, marker); // }); - // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. + // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. markers.push(marker); } - initAutocomplete(); // start google map place auto complete API call function initMap() { @@ -209,40 +216,41 @@ __webpack_require__.r(__webpack_exports__); position: saved_lat_lng, draggable: true, title: localized_data.marker_title - }); // marker.addListener('click', function () { + }); + // marker.addListener('click', function () { // info_window.open(map, marker); // }); // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. + markers.push(marker); - markers.push(marker); // create a Geocode instance - + // create a Geocode instance var geocoder = new google.maps.Geocoder(); document.getElementById('generate_admin_map').addEventListener('click', function (e) { e.preventDefault(); geocodeAddress(geocoder, map); - }); // This event listener calls addMarker() when the map is clicked. + }); + // This event listener calls addMarker() when the map is clicked. google.maps.event.addListener(map, 'click', function (event) { deleteMarker(); // at first remove previous marker and then set new marker; // set the value of input field to save them to the database - $manual_lat.val(event.latLng.lat()); - $manual_lng.val(event.latLng.lng()); // add the marker to the given map. - + $manual_lng.val(event.latLng.lng()); + // add the marker to the given map. addMarker(event.latLng, map); - }); // This event listener update the lat long field of the form so that we can add the lat long to the database when the MARKER is drag. - + }); + // This event listener update the lat long field of the form so that we can add the lat long to the database when the MARKER is drag. google.maps.event.addListener(marker, 'dragend', function (event) { // set the value of input field to save them to the database $manual_lat.val(event.latLng.lat()); $manual_lng.val(event.latLng.lng()); }); } + /* * Geocode and address using google map javascript api and then populate the input fields for storing lat and long * */ - function geocodeAddress(geocoder, resultsMap) { var address = address_input.value; var lat = parseFloat(document.getElementById('manual_lat').value); @@ -261,54 +269,53 @@ __webpack_require__.r(__webpack_exports__); var marker = new google.maps.Marker({ map: resultsMap, position: results[0].geometry.location - }); // marker.addListener('click', function () { + }); + + // marker.addListener('click', function () { // info_window.open(map, marker); // }); - deleteMarker(); // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. - + deleteMarker(); + // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. markers.push(marker); } else { alert(localized_data.geocode_error_msg + status); } }); } + initMap(); - initMap(); // adding features of creating marker manually on the map on add listing page. - + // adding features of creating marker manually on the map on add listing page. /* var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; var labelIndex = 0; */ - // Adds a marker to the map. + // Adds a marker to the map. function addMarker(location, map) { // Add the marker at the clicked location, and add the next-available label // from the array of alphabetical characters. var marker = new google.maps.Marker({ position: location, - /* label: labels[labelIndex++ % labels.length], */ draggable: true, title: localized_data.marker_title, map: map - }); // marker.addListener('click', function () { + }); + // marker.addListener('click', function () { // info_window.open(map, marker); // }); // add the marker to the markers array to keep track of it, so that we can show/hide/delete them all later. - markers.push(marker); - } // Delete Marker - + } + // Delete Marker $('#delete_marker').on('click', function (e) { e.preventDefault(); deleteMarker(); }); - function deleteMarker() { for (var i = 0; i < markers.length; i++) { markers[i].setMap(null); } - markers = []; } } @@ -334,29 +341,24 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _single_listing_google_map_widget__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_single_listing_google_map_widget__WEBPACK_IMPORTED_MODULE_3__); ; - (function () { window.addEventListener('DOMContentLoaded', initMap); window.addEventListener('directorist-reload-listings-map-archive', initMap); - function initMap() { - var mapData = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('atbdp_map'); // Define Marker Shapes + var mapData = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('atbdp_map'); + // Define Marker Shapes var MAP_PIN = 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z'; - var inherits = function inherits(childCtor, parentCtor) { /** @constructor */ function tempCtor() {} - tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; childCtor.prototype = new tempCtor(); childCtor.prototype.constructor = childCtor; }; - function Marker(options) { google.maps.Marker.apply(this, arguments); - if (options.map_icon_label) { this.MarkerLabel = new MarkerLabel({ map: this.map, @@ -365,33 +367,37 @@ __webpack_require__.r(__webpack_exports__); }); this.MarkerLabel.bindTo('position', this, 'position'); } - } // Apply the inheritance - + } - inherits(Marker, google.maps.Marker); // Custom Marker SetMap + // Apply the inheritance + inherits(Marker, google.maps.Marker); + // Custom Marker SetMap Marker.prototype.setMap = function () { google.maps.Marker.prototype.setMap.apply(this, arguments); this.MarkerLabel && this.MarkerLabel.setMap.apply(this.MarkerLabel, arguments); - }; // Marker Label Overlay - + }; + // Marker Label Overlay var MarkerLabel = function MarkerLabel(options) { var self = this; - this.setValues(options); // Create the label container + this.setValues(options); + // Create the label container this.div = document.createElement('div'); - this.div.className = 'map-icon-label'; // Trigger the marker click handler if clicking on the label + this.div.className = 'map-icon-label'; + // Trigger the marker click handler if clicking on the label google.maps.event.addDomListener(this.div, 'click', function (e) { e.stopPropagation && e.stopPropagation(); google.maps.event.trigger(self.marker, 'click'); }); - }; // Create MarkerLabel Object - + }; - MarkerLabel.prototype = new google.maps.OverlayView(); // Marker Label onAdd + // Create MarkerLabel Object + MarkerLabel.prototype = new google.maps.OverlayView(); + // Marker Label onAdd MarkerLabel.prototype.onAdd = function () { var pane = this.getPanes().overlayImage.appendChild(this.div); var self = this; @@ -402,49 +408,46 @@ __webpack_require__.r(__webpack_exports__); }), google.maps.event.addListener(this, 'zindex_changed', function () { self.draw(); })]; - }; // Marker Label onRemove - + }; + // Marker Label onRemove MarkerLabel.prototype.onRemove = function () { this.div.parentNode.removeChild(this.div); - for (var i = 0, I = this.listeners.length; i < I; ++i) { google.maps.event.removeListener(this.listeners[i]); } - }; // Implement draw - + }; + // Implement draw MarkerLabel.prototype.draw = function () { var projection = this.getProjection(); var position = projection.fromLatLngToDivPixel(this.get('position')); var div = this.div; this.div.innerHTML = this.get('text').toString(); div.style.zIndex = this.get('zIndex'); // Allow label to overlay marker - div.style.position = 'absolute'; div.style.display = 'block'; div.style.left = "".concat(position.x - div.offsetWidth / 2, "px"); div.style.top = "".concat(position.y - div.offsetHeight, "px"); }; - (function ($) { // map view - /** * Render a Google Map onto the selected jQuery element. * * @since 5.0.0 */ var at_icon = []; - /* Use Default lat/lng in listings map view */ + /* Use Default lat/lng in listings map view */ var defCordEnabled = mapData.use_def_lat_long; - function atbdp_rander_map($el) { - $el.addClass('atbdp-map-loaded'); // var + $el.addClass('atbdp-map-loaded'); - var $markers = $el.find('.marker'); // vars + // var + var $markers = $el.find('.marker'); + // vars var args = { zoom: parseInt(mapData.zoom), center: new google.maps.LatLng(0, 0), @@ -454,17 +457,20 @@ __webpack_require__.r(__webpack_exports__); gestureHandling: 'cooperative', averageCenter: true, scrollWheelZoom: 'center' - }; // create map + }; - var map = new google.maps.Map($el[0], args); // add a markers reference + // create map + var map = new google.maps.Map($el[0], args); - map.markers = []; // set map type + // add a markers reference + map.markers = []; + // set map type map.type = $el.data('type'); var infowindow = new google.maps.InfoWindow({ content: '' - }); // add markers - + }); + // add markers $markers.each(function () { atbdp_add_marker($(this), map, infowindow); }); @@ -472,13 +478,12 @@ __webpack_require__.r(__webpack_exports__); lat: Number(mapData.default_latitude) ? Number(mapData.default_latitude) : 40.7127753 ? defCordEnabled : undefined, lng: Number(mapData.default_longitude) ? Number(mapData.default_longitude) : -74.0059728 ? defCordEnabled : Number(mapData.default_longitude) }; - if ($markers.length) { cord.lat = defCordEnabled ? Number(mapData.default_latitude) : Number($markers[0].getAttribute('data-latitude')); cord.lng = defCordEnabled ? Number(mapData.default_longitude) : Number($markers[0].getAttribute('data-longitude')); - } // center map - + } + // center map atbdp_center_map(map, cord); var mcOptions = new MarkerClusterer(map, [], { imagePath: mapData.plugin_url + 'assets/images/m' @@ -487,39 +492,35 @@ __webpack_require__.r(__webpack_exports__); style.textColor = '#fff'; return style; })); - if (map.type === 'markerclusterer') { //const markerCluster = new MarkerClusterer(map, map.markers, mcOptions); mcOptions.addMarkers(map.markers); } } + /** * Add a marker to the selected Google Map. * * @since 1.0.0 */ - - function atbdp_add_marker($marker, map, infowindow) { // var - var latlng = new google.maps.LatLng($marker.data('latitude'), $marker.data('longitude')); // check to see if any of the existing markers match the latlng of the new marker - + var latlng = new google.maps.LatLng($marker.data('latitude'), $marker.data('longitude')); + // check to see if any of the existing markers match the latlng of the new marker if (map.markers.length) { for (var i = 0; i < map.markers.length; i++) { var existing_marker = map.markers[i]; - var pos = existing_marker.getPosition(); // if a marker already exists in the same position as this marker + var pos = existing_marker.getPosition(); + // if a marker already exists in the same position as this marker if (latlng.equals(pos)) { // update the position of the coincident marker by applying a small multipler to its coordinates var latitude = latlng.lat() + (Math.random() - 0.5) / 1500; // * (Math.random() * (max - min) + min); - var longitude = latlng.lng() + (Math.random() - 0.5) / 1500; // * (Math.random() * (max - min) + min); - latlng = new google.maps.LatLng(latitude, longitude); } } } - var icon = JSON.parse($marker.data('icon')); var marker = new Marker({ position: latlng, @@ -532,10 +533,11 @@ __webpack_require__.r(__webpack_exports__); strokeWeight: 0 }, map_icon_label: icon !== undefined && "
    ".concat(icon, "
    ") - }); // add to array - - map.markers.push(marker); // if marker contains HTML, add it to an infoWindow + }); + // add to array + map.markers.push(marker); + // if marker contains HTML, add it to an infoWindow if ($marker.html()) { // map info window close button google.maps.event.addListener(infowindow, 'domready', function () { @@ -543,44 +545,43 @@ __webpack_require__.r(__webpack_exports__); google.maps.event.addDomListener(closeBtn[0], 'click', function () { infowindow.close(); }); - }); // show info window when marker is clicked + }); + // show info window when marker is clicked google.maps.event.addListener(marker, 'click', function () { if (mapData.disable_info_window === 'no') { var marker_childrens = $($marker).children(); - if (marker_childrens.length) { var marker_content = marker_childrens[0]; $(marker_content).addClass('map-info-wrapper--show'); } - infowindow.setContent($marker.html()); infowindow.open(map, marker); } }); } } + /** * Center the map, showing all markers attached to this map. * * @since 1.0.0 */ - function atbdp_center_map(map, cord) { map.setCenter(cord); map.setZoom(parseInt(mapData.zoom)); } - function setup_info_window() { var abc = document.querySelectorAll('div'); abc.forEach(function (el, index) { if (el.innerText === 'atgm_marker') { el.innerText = ' '; el.innerHTML = "".concat(at_icon, ""); - } // ${$marker.data('icon')} - + } + // ${$marker.data('icon')} }); + document.querySelectorAll('div').forEach(function (el1, index) { if (el1.style.backgroundImage.split('/').pop() === 'm1.png")') { el1.addEventListener('click', function () { @@ -597,14 +598,12 @@ __webpack_require__.r(__webpack_exports__); } }); } - function setup_map() { // render map in the custom post $('.atbdp-map').each(function () { atbdp_rander_map($(this)); }); } - setup_map(); setup_info_window(); $(document).ready(function () { @@ -613,8 +612,8 @@ __webpack_require__.r(__webpack_exports__); })(jQuery); } })(); -/* Add listing google map */ +/* Add listing google map */ /* Single listing google map */ @@ -623,7 +622,6 @@ __webpack_require__.r(__webpack_exports__); /* Widget google map */ - /***/ }), /***/ "./assets/src/js/global/map-scripts/single-listing/google-map-widget.js": @@ -634,26 +632,22 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { /* Widget google map */ + window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { if ($('#gmap-widget').length) { var MAP_PIN = 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z'; - var inherits = function inherits(childCtor, parentCtor) { /** @constructor */ function tempCtor() {} - tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; childCtor.prototype = new tempCtor(); childCtor.prototype.constructor = childCtor; }; - function Marker(options) { google.maps.Marker.apply(this, arguments); - if (options.map_icon_label) { this.MarkerLabel = new MarkerLabel({ map: this.map, @@ -662,33 +656,37 @@ window.addEventListener('DOMContentLoaded', function () { }); this.MarkerLabel.bindTo('position', this, 'position'); } - } // Apply the inheritance - + } - inherits(Marker, google.maps.Marker); // Custom Marker SetMap + // Apply the inheritance + inherits(Marker, google.maps.Marker); + // Custom Marker SetMap Marker.prototype.setMap = function () { google.maps.Marker.prototype.setMap.apply(this, arguments); this.MarkerLabel && this.MarkerLabel.setMap.apply(this.MarkerLabel, arguments); - }; // Marker Label Overlay - + }; + // Marker Label Overlay var MarkerLabel = function MarkerLabel(options) { var self = this; - this.setValues(options); // Create the label container + this.setValues(options); + // Create the label container this.div = document.createElement('div'); - this.div.className = 'map-icon-label'; // Trigger the marker click handler if clicking on the label + this.div.className = 'map-icon-label'; + // Trigger the marker click handler if clicking on the label google.maps.event.addDomListener(this.div, 'click', function (e) { e.stopPropagation && e.stopPropagation(); google.maps.event.trigger(self.marker, 'click'); }); - }; // Create MarkerLabel Object - + }; - MarkerLabel.prototype = new google.maps.OverlayView(); // Marker Label onAdd + // Create MarkerLabel Object + MarkerLabel.prototype = new google.maps.OverlayView(); + // Marker Label onAdd MarkerLabel.prototype.onAdd = function () { var pane = this.getPanes().overlayImage.appendChild(this.div); var self = this; @@ -699,35 +697,33 @@ window.addEventListener('DOMContentLoaded', function () { }), google.maps.event.addListener(this, 'zindex_changed', function () { self.draw(); })]; - }; // Marker Label onRemove - + }; + // Marker Label onRemove MarkerLabel.prototype.onRemove = function () { this.div.parentNode.removeChild(this.div); - for (var i = 0, I = this.listeners.length; i < I; ++i) { google.maps.event.removeListener(this.listeners[i]); } - }; // Implement draw - + }; + // Implement draw MarkerLabel.prototype.draw = function () { var projection = this.getProjection(); var position = projection.fromLatLngToDivPixel(this.get('position')); var div = this.div; this.div.innerHTML = this.get('text').toString(); div.style.zIndex = this.get('zIndex'); // Allow label to overlay marker - div.style.position = 'absolute'; div.style.display = 'block'; div.style.left = position.x - div.offsetWidth / 2 + 'px'; div.style.top = position.y - div.offsetHeight + 'px'; }; - $(document).ready(function () { // initialize all vars here to avoid hoisting related misunderstanding. - var map, info_window, saved_lat_lng, info_content; // Localized Data + var map, info_window, saved_lat_lng, info_content; + // Localized Data var map_container = localized_data_widget.map_container_id ? localized_data_widget.map_container_id : 'gmap'; var loc_default_latitude = parseFloat(localized_data_widget.default_latitude); var loc_default_longitude = parseFloat(localized_data_widget.default_longitude); @@ -744,14 +740,13 @@ window.addEventListener('DOMContentLoaded', function () { saved_lat_lng = { lat: loc_manual_lat, lng: loc_manual_lng - }; // create an info window for map + }; + // create an info window for map if (display_map_info) { info_window = new google.maps.InfoWindow({ content: info_content, - maxWidth: 400 - /*Add configuration for max width*/ - + maxWidth: 400 /*Add configuration for max width*/ }); } @@ -765,7 +760,6 @@ window.addEventListener('DOMContentLoaded', function () { map: map, position: saved_lat_lng });*/ - var marker = new Marker({ position: saved_lat_lng, map: map, @@ -778,7 +772,6 @@ window.addEventListener('DOMContentLoaded', function () { }, map_icon_label: '
    ' + cat_icon + '
    ' }); - if (display_map_info) { marker.addListener('click', function () { info_window.open(map, marker); @@ -791,9 +784,8 @@ window.addEventListener('DOMContentLoaded', function () { }); } } - - initMap(); //Convert address tags to google map links - - + initMap(); + //Convert address tags to google map links - $('address').each(function () { var link = "" + $(this).text() + ""; $(this).html(link); @@ -813,27 +805,23 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { /* Single listing google map */ + window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { if ($('.directorist-single-map').length) { document.querySelectorAll('.directorist-single-map').forEach(function (mapElm) { var MAP_PIN = 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z'; - var inherits = function inherits(childCtor, parentCtor) { /** @constructor */ function tempCtor() {} - tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; childCtor.prototype = new tempCtor(); childCtor.prototype.constructor = childCtor; }; - function Marker(options) { google.maps.Marker.apply(this, arguments); - if (options.map_icon_label) { this.MarkerLabel = new MarkerLabel({ map: this.map, @@ -842,33 +830,37 @@ window.addEventListener('DOMContentLoaded', function () { }); this.MarkerLabel.bindTo('position', this, 'position'); } - } // Apply the inheritance - + } - inherits(Marker, google.maps.Marker); // Custom Marker SetMap + // Apply the inheritance + inherits(Marker, google.maps.Marker); + // Custom Marker SetMap Marker.prototype.setMap = function () { google.maps.Marker.prototype.setMap.apply(this, arguments); this.MarkerLabel && this.MarkerLabel.setMap.apply(this.MarkerLabel, arguments); - }; // Marker Label Overlay - + }; + // Marker Label Overlay var MarkerLabel = function MarkerLabel(options) { var self = this; - this.setValues(options); // Create the label container + this.setValues(options); + // Create the label container this.div = document.createElement('div'); - this.div.className = 'map-icon-label'; // Trigger the marker click handler if clicking on the label + this.div.className = 'map-icon-label'; + // Trigger the marker click handler if clicking on the label google.maps.event.addDomListener(this.div, 'click', function (e) { e.stopPropagation && e.stopPropagation(); google.maps.event.trigger(self.marker, 'click'); }); - }; // Create MarkerLabel Object - + }; - MarkerLabel.prototype = new google.maps.OverlayView(); // Marker Label onAdd + // Create MarkerLabel Object + MarkerLabel.prototype = new google.maps.OverlayView(); + // Marker Label onAdd MarkerLabel.prototype.onAdd = function () { var pane = this.getPanes().overlayImage.appendChild(this.div); var self = this; @@ -879,35 +871,33 @@ window.addEventListener('DOMContentLoaded', function () { }), google.maps.event.addListener(this, 'zindex_changed', function () { self.draw(); })]; - }; // Marker Label onRemove - + }; + // Marker Label onRemove MarkerLabel.prototype.onRemove = function () { this.div.parentNode.removeChild(this.div); - for (var i = 0, I = this.listeners.length; i < I; ++i) { google.maps.event.removeListener(this.listeners[i]); } - }; // Implement draw - + }; + // Implement draw MarkerLabel.prototype.draw = function () { var projection = this.getProjection(); var position = projection.fromLatLngToDivPixel(this.get('position')); var div = this.div; this.div.innerHTML = this.get('text').toString(); div.style.zIndex = this.get('zIndex'); // Allow label to overlay marker - div.style.position = 'absolute'; div.style.display = 'block'; div.style.left = position.x - div.offsetWidth / 2 + 'px'; div.style.top = position.y - div.offsetHeight + 'px'; }; - $(document).ready(function () { // initialize all vars here to avoid hoisting related misunderstanding. - var map, info_window, saved_lat_lng, info_content; // Localized Data + var map, info_window, saved_lat_lng, info_content; + // Localized Data var mapData = JSON.parse(mapElm.getAttribute('data-map')); var loc_default_latitude = parseFloat(mapData.default_latitude); var loc_default_longitude = parseFloat(mapData.default_longitude); @@ -924,14 +914,13 @@ window.addEventListener('DOMContentLoaded', function () { saved_lat_lng = { lat: loc_manual_lat, lng: loc_manual_lng - }; // create an info window for map + }; + // create an info window for map if (display_map_info) { info_window = new google.maps.InfoWindow({ content: info_content, - maxWidth: 400 - /*Add configuration for max width*/ - + maxWidth: 400 /*Add configuration for max width*/ }); } @@ -945,7 +934,6 @@ window.addEventListener('DOMContentLoaded', function () { map: map, position: saved_lat_lng });*/ - var marker = new Marker({ position: saved_lat_lng, map: map, @@ -958,7 +946,6 @@ window.addEventListener('DOMContentLoaded', function () { }, map_icon_label: "
    ".concat(cat_icon, "
    ") }); - if (display_map_info) { marker.addListener('click', function () { info_window.open(map, marker); @@ -971,9 +958,8 @@ window.addEventListener('DOMContentLoaded', function () { }); } } - - initMap(); //Convert address tags to google map links - - + initMap(); + //Convert address tags to google map links - $('address').each(function () { var link = "" + $(this).text() + ""; $(this).html(link); @@ -1004,18 +990,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -1028,24 +1010,19 @@ function get_dom_data(key, parent) { 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, @@ -1055,7 +1032,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -1066,17 +1042,14 @@ function convertToSelect2(field) { 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); }); } - /***/ }), /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": @@ -1088,14 +1061,9 @@ function convertToSelect2(field) { 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]; - } - + 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; /***/ }), @@ -1108,11 +1076,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -1127,7 +1093,6 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex 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; /***/ }), @@ -1142,7 +1107,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -1155,17 +1119,12 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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; /***/ }), @@ -1177,16 +1136,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -1199,7 +1157,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -1208,7 +1165,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/openstreet-map.js b/assets/js/openstreet-map.js index 43973f7704..7f7e98dc7d 100644 --- a/assets/js/openstreet-map.js +++ b/assets/js/openstreet-map.js @@ -98,12 +98,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _lib_helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./../../../lib/helper */ "./assets/src/js/lib/helper.js"); /* Add listing OSMap */ -; +; (function ($) { $(document).ready(function () { - var mapData = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('map_data'); // Localized Data + var mapData = Object(_lib_helper__WEBPACK_IMPORTED_MODULE_0__["get_dom_data"])('map_data'); + // Localized Data var loc_default_latitude = parseFloat(mapData.default_latitude); var loc_default_longitude = parseFloat(mapData.default_longitude); var loc_manual_lat = parseFloat(mapData.manual_lat); @@ -112,13 +113,11 @@ __webpack_require__.r(__webpack_exports__); var loc_map_icon = mapData.map_icon; loc_manual_lat = isNaN(loc_manual_lat) ? loc_default_latitude : loc_manual_lat; loc_manual_lng = isNaN(loc_manual_lng) ? loc_default_longitude : loc_manual_lng; - function mapLeaflet(lat, lon) { // @todo @kowsar / remove later. fix js error if ($("#gmap").length == 0) { return; } - var fontAwesomeIcon = L.icon({ iconUrl: loc_map_icon, iconSize: [20, 25] @@ -145,39 +144,34 @@ __webpack_require__.r(__webpack_exports__); attribution: '© OpenStreetMap contributors' }).addTo(mymap); } - function directorist_debounce(func, wait, immediate) { var timeout; return function () { var context = this, - args = arguments; - + 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); }; } - ; $('.directorist-location-js').each(function (id, elm) { var result_container = $(elm).siblings('.address_result'); $(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. + 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-form-address-field'); var search = $(elm).val(); - if (search.length < 3) { result_container.css({ 'display': 'none' @@ -193,19 +187,15 @@ __webpack_require__.r(__webpack_exports__); data: {}, success: function success(data) { var res = ''; - for (var i = 0; i < data.length; i++) { res += "
  • ").concat(data[i].display_name, "
  • "); } - result_container.find('ul').html(res); - if (res.length) { result_container.show(); } else { result_container.hide(); } - locationAddressField.removeClass('atbdp-form-fade'); } }); @@ -213,17 +203,16 @@ __webpack_require__.r(__webpack_exports__); }, 750)); }); var lat = loc_manual_lat, - lon = loc_manual_lng; + lon = loc_manual_lng; mapLeaflet(lat, lon); $('body').on('click', '.directorist-form-address-field .address_result ul li a', function (event) { if (document.getElementById('osm')) { document.getElementById('osm').innerHTML = "
    "; } - event.preventDefault(); var text = $(this).text(), - lat = $(this).data('lat'), - lon = $(this).data('lon'); + lat = $(this).data('lat'), + lon = $(this).data('lon'); $('#manual_lat').val(lat); $('#manual_lng').val(lon); $(this).closest('.address_result').siblings('.directorist-location-js').val(text); @@ -244,33 +233,28 @@ __webpack_require__.r(__webpack_exports__); event.preventDefault(); document.getElementById('osm').innerHTML = "
    "; mapLeaflet($('#manual_lat').val(), $('#manual_lng').val()); - }); // Popup controller by keyboard + }); + // Popup controller by keyboard var index = 0; $('.directorist-location-js').on('keyup', function (event) { event.preventDefault(); var length = $('#directorist.atbd_wrapper .address_result ul li a').length; - if (event.keyCode === 40) { index++; - if (index > length) { index = 0; } } else if (event.keyCode === 38) { index--; - if (index < 0) { index = length; } - ; } - if ($('#directorist.atbd_wrapper .address_result ul li a').length > 0) { $('#directorist.atbd_wrapper .address_result ul li a').removeClass('active'); $($('#directorist.atbd_wrapper .address_result ul li a')[index]).addClass('active'); - if (event.keyCode === 13) { $($('#directorist.atbd_wrapper .address_result ul li a')[index]).click(); event.preventDefault(); @@ -278,9 +262,10 @@ __webpack_require__.r(__webpack_exports__); return false; } } - ; - }); // $('#post').on('submit', function (event) { + }); + + // $('#post').on('submit', function (event) { // event.preventDefault(); // return false; // }); @@ -304,11 +289,9 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _single_listing_openstreet_map_widget__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./single-listing/openstreet-map-widget */ "./assets/src/js/global/map-scripts/single-listing/openstreet-map-widget.js"); /* harmony import */ var _single_listing_openstreet_map_widget__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_single_listing_openstreet_map_widget__WEBPACK_IMPORTED_MODULE_2__); ; - (function () { // DOM Mutation observer var targetNode = document.querySelector('.directorist-archive-contents'); - if (targetNode) { function initObserver() { var observer = new MutationObserver(initMap); @@ -316,39 +299,31 @@ __webpack_require__.r(__webpack_exports__); childList: true }); } - window.addEventListener('DOMContentLoaded', initObserver); } - window.addEventListener('DOMContentLoaded', initMap); window.addEventListener('directorist-reload-listings-map-archive', initMap); - function initMap() { var $ = jQuery; var mapData; $('#map').length ? mapData = JSON.parse($('#map').attr('data-options')) : ''; - function setup_map() { bundle1.fillPlaceholders(); var localVersion = bundle1.getLibVersion('leaflet.featuregroup.subgroup', 'local'); - if (localVersion) { localVersion.checkAssetsAvailability(true).then(function () { mapData !== undefined ? load() : ''; }).catch(function () { var version102 = bundle1.getLibVersion('leaflet.featuregroup.subgroup', '1.0.2'); - if (version102) { version102.defaultVersion = true; } - mapData !== undefined ? load() : ''; }); } else { mapData !== undefined ? load() : ''; } } - function load() { var url = window.location.href; var urlParts = URI.parse(url); @@ -360,15 +335,14 @@ __webpack_require__.r(__webpack_exports__); }); loadJsCss.list(list, { delayScripts: 500 // Load scripts after stylesheets, delayed by this duration (in ms). - }); } setup_map(); } })(); -/* Add listing OSMap */ +/* Add listing OSMap */ /* Single listing OSMap */ @@ -377,7 +351,6 @@ __webpack_require__.r(__webpack_exports__); /* Widget OSMap */ - /***/ }), /***/ "./assets/src/js/global/map-scripts/single-listing/openstreet-map-widget.js": @@ -388,8 +361,8 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { /* Widget OSMap */ -; +; (function ($) { jQuery(document).ready(function () { // Localized Data @@ -401,11 +374,11 @@ __webpack_require__.r(__webpack_exports__); var loc_manual_lng = parseFloat(localized_data_widget.manual_lng); var loc_map_zoom_level = parseInt(localized_data_widget.map_zoom_level); var _localized_data_widge = localized_data_widget, - display_map_info = _localized_data_widge.display_map_info; + display_map_info = _localized_data_widge.display_map_info; var _localized_data_widge2 = localized_data_widget, - cat_icon = _localized_data_widge2.cat_icon; + cat_icon = _localized_data_widge2.cat_icon; var _localized_data_widge3 = localized_data_widget, - info_content = _localized_data_widge3.info_content; + info_content = _localized_data_widge3.info_content; loc_manual_lat = isNaN(loc_manual_lat) ? loc_default_latitude : loc_manual_lat; loc_manual_lng = isNaN(loc_manual_lng) ? loc_default_longitude : loc_manual_lng; $manual_lat = $('#manual_lat'); @@ -414,7 +387,6 @@ __webpack_require__.r(__webpack_exports__); lat: loc_manual_lat, lng: loc_manual_lng }; - function mapLeaflet(lat, lon) { var fontAwesomeIcon = L.divIcon({ html: "
    ".concat(cat_icon, "
    "), @@ -422,7 +394,6 @@ __webpack_require__.r(__webpack_exports__); className: 'myDivIcon' }); var mymap = L.map(map_container).setView([lat, lon], loc_map_zoom_level); - if (display_map_info) { L.marker([lat, lon], { icon: fontAwesomeIcon @@ -432,12 +403,10 @@ __webpack_require__.r(__webpack_exports__); icon: fontAwesomeIcon }).addTo(mymap); } - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(mymap); } - mapLeaflet(loc_manual_lat, loc_manual_lng); } }); @@ -453,6 +422,7 @@ __webpack_require__.r(__webpack_exports__); /***/ (function(module, exports) { /* Single listing OSMap */ + (function ($) { jQuery(document).ready(function () { // Localized Data @@ -475,7 +445,6 @@ __webpack_require__.r(__webpack_exports__); lat: loc_manual_lat, lng: loc_manual_lng }; - function mapLeaflet(lat, lon) { var fontAwesomeIcon = L.divIcon({ html: "
    ".concat(cat_icon, "
    "), @@ -485,7 +454,6 @@ __webpack_require__.r(__webpack_exports__); var mymap = L.map(mapElm, { scrollWheelZoom: false }).setView([lat, lon], loc_map_zoom_level); - if (display_map_info) { L.marker([lat, lon], { icon: fontAwesomeIcon @@ -495,12 +463,10 @@ __webpack_require__.r(__webpack_exports__); icon: fontAwesomeIcon }).addTo(mymap); } - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(mymap); } - mapLeaflet(loc_manual_lat, loc_manual_lng); }); } @@ -527,18 +493,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -551,24 +513,19 @@ function get_dom_data(key, parent) { 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, @@ -578,7 +535,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -589,17 +545,14 @@ function convertToSelect2(field) { 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); }); } - /***/ }), /***/ "./node_modules/@babel/runtime/helpers/arrayLikeToArray.js": @@ -611,14 +564,9 @@ function convertToSelect2(field) { 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]; - } - + 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; /***/ }), @@ -631,11 +579,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -650,7 +596,6 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex 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; /***/ }), @@ -665,7 +610,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -678,17 +622,12 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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; /***/ }), @@ -700,16 +639,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -722,7 +660,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -731,7 +668,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/public-add-listing.js b/assets/js/public-add-listing.js index 6ddad78fb1..292c8ef84b 100644 --- a/assets/js/public-add-listing.js +++ b/assets/js/public-add-listing.js @@ -94,7 +94,6 @@ /***/ (function(module, exports) { // General Components - /* import '../components/directoristDropdown'; import '../components/directoristSelect'; import '../components/colorPicker'; */ diff --git a/assets/js/public-atmodal.js b/assets/js/public-atmodal.js index ec10559aa1..329f8fbf75 100644 --- a/assets/js/public-atmodal.js +++ b/assets/js/public-atmodal.js @@ -99,7 +99,6 @@ Author: Sovware Author URI: https://sovware.com/ */ - /* disable-eslint */ var aazztechModal1 = function aazztechModal1(selector) { var element = document.querySelectorAll(selector); @@ -109,7 +108,6 @@ var aazztechModal1 = function aazztechModal1(selector) { var current_elm = event.target; var target_id = current_elm.getAttribute('data-target'); var el_id = el.getAttribute('id'); - if (target_id === el_id) { event.preventDefault(); el.style.display = 'block'; @@ -140,11 +138,9 @@ var aazztechModal1 = function aazztechModal1(selector) { }); }); }; - function initModal() { aazztechModal1('#dcl-claim-modal, #atbdp-report-abuse-modal, #atpp-plan-change-modal, #pyn-plan-change-modal'); } - window.addEventListener('load', function () { setTimeout(function () { initModal(); diff --git a/assets/js/public-geolocation-widget.js b/assets/js/public-geolocation-widget.js index 62079ed6b2..feb50afb8f 100644 --- a/assets/js/public-geolocation-widget.js +++ b/assets/js/public-geolocation-widget.js @@ -122,7 +122,6 @@ var x = document.querySelector(".widget-location-name"); var get_lat = document.querySelector("#cityLat"); var get_lng = document.querySelector("#cityLng"); - function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, showError); @@ -130,7 +129,6 @@ x.value = "Geolocation is not supported by this browser."; } } - function showPosition(position) { lat = position.coords.latitude; lon = position.coords.longitude; @@ -138,27 +136,22 @@ get_lat.value = lat; get_lng.value = lon; } - function showError(error) { switch (error.code) { case error.PERMISSION_DENIED: x.value = "User denied the request for Geolocation."; break; - case error.POSITION_UNAVAILABLE: x.value = "Location information is unavailable."; break; - case error.TIMEOUT: x.value = "The request to get user location timed out."; break; - case error.UNKNOWN_ERROR: x.value = "An unknown error occurred."; break; } } - function displayLocation(latitude, longitude) { var geocoder; geocoder = new google.maps.Geocoder(); @@ -183,12 +176,10 @@ } }); } - var get_loc_btn = document.querySelector(".atbd_get_loc_wid"); get_loc_btn.addEventListener("click", function () { getLocation(); }); - if (directorist.i18n_text.select_listing_map === 'google') { function initialize() { var input = document.getElementById('address_widget'); @@ -205,7 +196,6 @@ document.getElementById('cityLng').value = place.geometry.location.lng(); }); } - google.maps.event.addDomListener(window, 'load', initialize); } })(); @@ -216,13 +206,11 @@ $('#address_widget_result').css({ 'display': 'block' }); - if (search === "") { $('#address_widget_result').css({ 'display': 'none' }); } - var res = ""; $.ajax({ url: "https://nominatim.openstreetmap.org/?q=%27+".concat(search, "+%27&format=json"), @@ -233,7 +221,6 @@ for (var i = 0; i < data.length; i++) { res += '
  • ' + data[i].display_name + '
  • '; } - $('#address_widget_result').html('
      ' + res + '
    '); } }); @@ -241,14 +228,13 @@ $('body').on('click', '#address_widget_result ul li a', function (event) { event.preventDefault(); var text = $(this).text(), - lat = $(this).data('lat'), - lon = $(this).data('lon'); + lat = $(this).data('lat'), + lon = $(this).data('lon'); $('#cityLat').val(lat); $('#cityLng').val(lon); $('#address_widget').val(text); $('#address_widget_result').hide(); }); - function displayLocation(position) { var lat = position.coords.latitude; var lng = position.coords.longitude; @@ -263,12 +249,10 @@ } }); } - $(".atbd_get_loc_wid").on('click', function () { navigator.geolocation.getCurrentPosition(displayLocation); }); } - if ($('#address_widget').val() === "") { $('#address_widget_result').css({ 'display': 'none' diff --git a/assets/js/public-main.js b/assets/js/public-main.js index 0af6dd7031..9ee140f32a 100644 --- a/assets/js/public-main.js +++ b/assets/js/public-main.js @@ -94,7 +94,6 @@ /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // Recovery Password Modal @@ -102,14 +101,16 @@ $(".atbdp_recovery_pass").on("click", function (e) { e.preventDefault(); $("#recover-pass-modal").slideToggle().show(); - }); // Contact form [on modal closed] + }); + // Contact form [on modal closed] $('#atbdp-contact-modal').on('hidden.bs.modal', function (e) { $('#atbdp-contact-message').val(''); $('#atbdp-contact-message-display').html(''); - }); // Template Restructured - // Modal + }); + // Template Restructured + // Modal var directoristModal = document.querySelector('.directorist-modal-js'); $('body').on('click', '.directorist-btn-modal-js', function (e) { e.preventDefault(); @@ -138,52 +139,44 @@ /***/ (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; } - +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 - +} +// Initialize function init() { // Add custom dropdown toggle button - selec2_add_custom_dropdown_toggle_button(); // Add custom close button where needed + selec2_add_custom_dropdown_toggle_button(); - selec2_add_custom_close_button_if_needed(); // Add custom close button if field contains value on change + // 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'; @@ -191,9 +184,9 @@ function selec2_add_custom_dropdown_toggle_button() { var dropdownHTML = "".concat(iconHTML, ""); addon_container.append(dropdownHTML); } + var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); - var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); // Toggle --is-open class - + // 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'); @@ -201,41 +194,36 @@ function selec2_add_custom_dropdown_toggle_button() { $('.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 + }); + // 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 + }); + // 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; - + _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) { @@ -244,21 +232,20 @@ function selec2_add_custom_close_button_if_needed() { _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 + // 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("".concat(iconHTML, "")); @@ -268,56 +255,46 @@ function selec2_add_custom_close_button(field) { field.val(null).trigger('change'); addon_container.find('.directorist-select2-dropdown-close').remove(); selec2_adjust_space_for_addons(); - }); // 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 + // 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(''); 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(''); 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' @@ -344,18 +321,16 @@ __webpack_require__.r(__webpack_exports__); /* 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; } - +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } 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 +document.body.addEventListener('directorist-reload-select2-fields', initSelect2); +// Init Static Select 2 Fields function initSelect2() { var select_fields = [{ elm: $('.directorist-select').find('select') @@ -381,7 +356,8 @@ function initSelect2() { elm: $('#directorist-select-fr-s-js') }, { elm: $('#directorist-select-fr-e-js') - }, // { elm: $('#directorist-location-select') }, + }, + // { elm: $('#directorist-location-select') }, // { elm: $('#directorist-category-select') }, { elm: $('.select-basic') @@ -389,30 +365,33 @@ function initSelect2() { elm: $('#loc-type') }, { elm: $('.bdas-location-search') - }, // { elm: $('.directorist-location-select') }, + }, + // { elm: $('.directorist-location-select') }, { elm: $('#at_biz_dir-category') }, { elm: $('#cat-type') }, { elm: $('.bdas-category-search') - } // { elm: $('.directorist-category-select') }, + } + // { 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 - +} +// Init Select2 Ajax Fields function initSelect2AjaxFields() { - var rest_base_url = "".concat(directorist.rest_url, "directorist/v1"); // Init Select2 Ajax Category Field + 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") @@ -420,8 +399,9 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-categories-field').find('select'), url: "".concat(rest_base_url, "/listings/categories") - }); // Init Select2 Ajax Location Field + }); + // Init Select2 Ajax Location Field initSelect2AjaxTaxonomy({ selector: $('.directorist-search-location').find('select'), url: "".concat(rest_base_url, "/listings/locations") @@ -429,17 +409,18 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-location-field').find('select'), url: "".concat(rest_base_url, "/listings/locations") - }); // Init Select2 Ajax Tag Field + }); + // Init Select2 Ajax Tag Field initSelect2AjaxTaxonomy({ selector: $('.directorist-form-tag-field').find('select'), url: "".concat(rest_base_url, "/listings/tags") }, { has_directory_type: false }); -} // initSelect2AjaxTaxonomy - +} +// initSelect2AjaxTaxonomy function initSelect2AjaxTaxonomy(args, terms_options) { var defaultArgs = { selector: '', @@ -451,46 +432,42 @@ function initSelect2AjaxTaxonomy(args, terms_options) { has_directory_type: true }; terms_options = terms_options ? _objectSpread(_objectSpread({}, default_terms_options), terms_options) : default_terms_options; - 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 createNew = item.getAttribute("data-allow_new"); var maxLength = item.getAttribute("data-max"); - if (terms_options.has_directory_type) { var search_form_parent = $(item).closest('.directorist-search-form'); var archive_page_parent = $(item).closest('.directorist-archive-contents'); var add_listing_form_hidden_input = $(item).closest('.directorist-add-listing-form').find('input[name="directory_type"]'); - var nav_list_item = []; // If search page + 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 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 has nav item if (nav_list_item.length) { directory_type_id = nav_list_item ? nav_list_item.data('listing_type_id') : 0; - } // If has nav item - + } + // If has nav item if (add_listing_form_hidden_input.length) { directory_type_id = add_listing_form_hidden_input.val(); } - if (directory_type_id) { directory_type_id = parseInt(directory_type_id); } } - var currentPage = 1; $(item).select2({ allowClear: true, @@ -512,11 +489,9 @@ function initSelect2AjaxTaxonomy(args, terms_options) { page: currentPage, per_page: args.perPage }; - if (directory_type_id) { query.directory = directory_type_id; } - return query; }, processResults: function processResults(data) { @@ -547,16 +522,15 @@ function initSelect2AjaxTaxonomy(args, terms_options) { return $request; } } - }); // Setup Preselected Option + }); + // Setup Preselected Option var selected_item_id = $(item).data('selected-id'); var selected_item_label = $(item).data('selected-label'); - var setup_selected_items = function setup_selected_items(element, selected_id, selected_label) { if (!element || !selected_id) { return; } - var selected_ids = "".concat(selected_id).split(','); var selected_labels = selected_label ? "".concat(selected_label).split(',') : []; selected_ids.forEach(function (id, index) { @@ -574,7 +548,6 @@ function initSelect2AjaxTaxonomy(args, terms_options) { }); }); }; - setup_selected_items(item, selected_item_id, selected_item_label); }); } @@ -594,7 +567,6 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__); document.addEventListener('DOMContentLoaded', init, false); - function Tasks() { return { init: function init() { @@ -602,13 +574,10 @@ function Tasks() { }, initToggleTabLinks: function initToggleTabLinks() { var links = document.querySelectorAll('.directorist-toggle-tab'); - if (!links) { return; } - var self = this; - _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(links).forEach(function (item) { item.addEventListener('click', function (event) { self.handleToggleTabLinksEvent(item, event); @@ -620,53 +589,44 @@ function Tasks() { var navContainerClass = item.getAttribute('data-nav-container'); var tabContainerClass = item.getAttribute('data-tab-container'); var tabClass = item.getAttribute('data-tab'); - if (!navContainerClass || !tabContainerClass || !tabClass) { return; } - var navContainer = item.closest('.' + navContainerClass); var tabContainer = document.querySelector('.' + tabContainerClass); - if (!navContainer || !tabContainer) { return; } - var tab = tabContainer.querySelector('.' + tabClass); - if (!tab) { return; - } // Remove Active Class - + } + // Remove Active Class var removeActiveClass = function removeActiveClass(item) { item.classList.remove('--is-active'); - }; // Toggle Nav - + }; + // Toggle Nav var activeNavItems = navContainer.querySelectorAll('.--is-active'); - if (activeNavItems) { _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(activeNavItems).forEach(removeActiveClass); } + item.classList.add('--is-active'); - item.classList.add('--is-active'); // Toggle Tab - + // Toggle Tab var activeTabItems = tabContainer.querySelectorAll('.--is-active'); - if (activeTabItems) { _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(activeTabItems).forEach(removeActiveClass); } + tab.classList.add('--is-active'); - tab.classList.add('--is-active'); // Update Query Var - + // Update Query Var var queryVarKey = item.getAttribute('data-query-var-key'); var queryVarValue = item.getAttribute('data-query-var-value'); - if (!queryVarKey || !queryVarValue) { return; } - this.addQueryParam(queryVarKey, queryVarValue); }, addQueryParam: function addQueryParam(key, value) { @@ -676,7 +636,6 @@ function Tasks() { } }; } - function init() { var tasks = new Tasks(); tasks.init(); @@ -695,18 +654,21 @@ window.addEventListener('DOMContentLoaded', function () { var $ = jQuery; document.querySelectorAll('.la-icon i').forEach(function (item) { className.push(item.getAttribute('class')); - }); // Handle Disabled Link Action + }); + // Handle Disabled Link Action $('.atbdp-disabled').on('click', function (e) { e.preventDefault(); - }); // Toggle Modal + }); + // Toggle Modal $('.cptm-modal-toggle').on('click', function (e) { e.preventDefault(); var target_class = $(this).data('target'); $('.' + target_class).toggleClass('active'); - }); // Change label on file select/change + }); + // Change label on file select/change $('.cptm-file-field').on('change', function (e) { var target_id = $(this).attr('id'); $('label[for=' + target_id + ']').text('Change'); @@ -758,18 +720,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -782,24 +740,19 @@ function get_dom_data(key, parent) { 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, @@ -809,7 +762,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -820,17 +772,14 @@ function convertToSelect2(field) { 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/main.js": @@ -854,8 +803,11 @@ __webpack_require__.r(__webpack_exports__); // console.log( directorist_options ) // Styles - // Single Listing Page + + +// Single Listing Page // import './components/single-listing-page/slider'; + // General Components // import './components/general'; // import './components/helpers'; @@ -874,6 +826,7 @@ __webpack_require__.r(__webpack_exports__); // import './components/categoryLocation'; // import './components/legacy-support'; // import './components/author'; + // Booking // import './components/booking'; @@ -899,14 +852,9 @@ __webpack_require__.r(__webpack_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]; - } - + 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; /***/ }), @@ -919,11 +867,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -933,9 +879,11 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! \***************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperty(obj, key, value) { + key = toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, @@ -946,10 +894,8 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } - module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -964,7 +910,6 @@ module.exports = _defineProperty, module.exports.__esModule = true, module.expor 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; /***/ }), @@ -979,7 +924,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -992,21 +936,55 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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/toPrimitive.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPropertyKey.js": +/*!**************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js"); +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} +module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + /***/ "./node_modules/@babel/runtime/helpers/typeof.js": /*!*******************************************************!*\ !*** ./node_modules/@babel/runtime/helpers/typeof.js ***! @@ -1014,16 +992,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -1036,7 +1013,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -1045,7 +1021,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/range-slider.js b/assets/js/range-slider.js index 22d1bc8199..d7f0a13fc9 100644 --- a/assets/js/range-slider.js +++ b/assets/js/range-slider.js @@ -100,34 +100,30 @@ __webpack_require__.r(__webpack_exports__); /* 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
    \n \n
    \n\t\t"); + max = obj.maxValue, + min = obj.minValue, + down = 'mousedown', + up = 'mouseup', + move = 'mousemove', + div = "\n
    \n \n
    \n\t\t"); var touch = ("ontouchstart" in document.documentElement); - if (touch) { down = 'touchstart'; up = 'touchend'; move = 'touchmove'; - } //RTL - + } + //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; @@ -135,33 +131,28 @@ var directorist_range_slider = function directorist_range_slider(selector, obj) 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; + 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 = "".concat(min, " ").concat(sliderDataUnit); var x = null, - count = 0, - slid1_val = 0, - slid1_val2 = sliderDataMin, - count2 = width; - + 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'); }); @@ -170,14 +161,12 @@ var directorist_range_slider = function directorist_range_slider(selector, obj) 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; @@ -185,22 +174,18 @@ var directorist_range_slider = function directorist_range_slider(selector, obj) 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 = "".concat(slid1_val, " ").concat(sliderDataUnit); @@ -239,16 +224,15 @@ window.addEventListener("load", function () { /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), diff --git a/assets/js/search-form.js b/assets/js/search-form.js index 819225f1cc..f435d74831 100644 --- a/assets/js/search-form.js +++ b/assets/js/search-form.js @@ -94,52 +94,44 @@ /***/ (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; } - +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 - +} +// Initialize function init() { // Add custom dropdown toggle button - selec2_add_custom_dropdown_toggle_button(); // Add custom close button where needed + selec2_add_custom_dropdown_toggle_button(); - selec2_add_custom_close_button_if_needed(); // Add custom close button if field contains value on change + // 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'; @@ -147,9 +139,9 @@ function selec2_add_custom_dropdown_toggle_button() { var dropdownHTML = "".concat(iconHTML, ""); addon_container.append(dropdownHTML); } + var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); - var selec2_custom_dropdown = addon_container.find('.directorist-select2-dropdown-toggle'); // Toggle --is-open class - + // 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'); @@ -157,41 +149,36 @@ function selec2_add_custom_dropdown_toggle_button() { $('.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 + }); + // 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 + }); + // 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; - + _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) { @@ -200,21 +187,20 @@ function selec2_add_custom_close_button_if_needed() { _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 + // 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("".concat(iconHTML, "")); @@ -224,56 +210,46 @@ function selec2_add_custom_close_button(field) { field.val(null).trigger('change'); addon_container.find('.directorist-select2-dropdown-close').remove(); selec2_adjust_space_for_addons(); - }); // 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 + // 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(''); 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(''); 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' @@ -300,18 +276,16 @@ __webpack_require__.r(__webpack_exports__); /* 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; } - +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } 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 +document.body.addEventListener('directorist-reload-select2-fields', initSelect2); +// Init Static Select 2 Fields function initSelect2() { var select_fields = [{ elm: $('.directorist-select').find('select') @@ -337,7 +311,8 @@ function initSelect2() { elm: $('#directorist-select-fr-s-js') }, { elm: $('#directorist-select-fr-e-js') - }, // { elm: $('#directorist-location-select') }, + }, + // { elm: $('#directorist-location-select') }, // { elm: $('#directorist-category-select') }, { elm: $('.select-basic') @@ -345,30 +320,33 @@ function initSelect2() { elm: $('#loc-type') }, { elm: $('.bdas-location-search') - }, // { elm: $('.directorist-location-select') }, + }, + // { elm: $('.directorist-location-select') }, { elm: $('#at_biz_dir-category') }, { elm: $('#cat-type') }, { elm: $('.bdas-category-search') - } // { elm: $('.directorist-category-select') }, + } + // { 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 - +} +// Init Select2 Ajax Fields function initSelect2AjaxFields() { - var rest_base_url = "".concat(directorist.rest_url, "directorist/v1"); // Init Select2 Ajax Category Field + 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") @@ -376,8 +354,9 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-categories-field').find('select'), url: "".concat(rest_base_url, "/listings/categories") - }); // Init Select2 Ajax Location Field + }); + // Init Select2 Ajax Location Field initSelect2AjaxTaxonomy({ selector: $('.directorist-search-location').find('select'), url: "".concat(rest_base_url, "/listings/locations") @@ -385,17 +364,18 @@ function initSelect2AjaxFields() { initSelect2AjaxTaxonomy({ selector: $('.directorist-form-location-field').find('select'), url: "".concat(rest_base_url, "/listings/locations") - }); // Init Select2 Ajax Tag Field + }); + // Init Select2 Ajax Tag Field initSelect2AjaxTaxonomy({ selector: $('.directorist-form-tag-field').find('select'), url: "".concat(rest_base_url, "/listings/tags") }, { has_directory_type: false }); -} // initSelect2AjaxTaxonomy - +} +// initSelect2AjaxTaxonomy function initSelect2AjaxTaxonomy(args, terms_options) { var defaultArgs = { selector: '', @@ -407,46 +387,42 @@ function initSelect2AjaxTaxonomy(args, terms_options) { has_directory_type: true }; terms_options = terms_options ? _objectSpread(_objectSpread({}, default_terms_options), terms_options) : default_terms_options; - 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 createNew = item.getAttribute("data-allow_new"); var maxLength = item.getAttribute("data-max"); - if (terms_options.has_directory_type) { var search_form_parent = $(item).closest('.directorist-search-form'); var archive_page_parent = $(item).closest('.directorist-archive-contents'); var add_listing_form_hidden_input = $(item).closest('.directorist-add-listing-form').find('input[name="directory_type"]'); - var nav_list_item = []; // If search page + 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 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 has nav item if (nav_list_item.length) { directory_type_id = nav_list_item ? nav_list_item.data('listing_type_id') : 0; - } // If has nav item - + } + // If has nav item if (add_listing_form_hidden_input.length) { directory_type_id = add_listing_form_hidden_input.val(); } - if (directory_type_id) { directory_type_id = parseInt(directory_type_id); } } - var currentPage = 1; $(item).select2({ allowClear: true, @@ -468,11 +444,9 @@ function initSelect2AjaxTaxonomy(args, terms_options) { page: currentPage, per_page: args.perPage }; - if (directory_type_id) { query.directory = directory_type_id; } - return query; }, processResults: function processResults(data) { @@ -503,16 +477,15 @@ function initSelect2AjaxTaxonomy(args, terms_options) { return $request; } } - }); // Setup Preselected Option + }); + // Setup Preselected Option var selected_item_id = $(item).data('selected-id'); var selected_item_label = $(item).data('selected-label'); - var setup_selected_items = function setup_selected_items(element, selected_id, selected_label) { if (!element || !selected_id) { return; } - var selected_ids = "".concat(selected_id).split(','); var selected_labels = selected_label ? "".concat(selected_label).split(',') : []; selected_ids.forEach(function (id, index) { @@ -530,7 +503,6 @@ function initSelect2AjaxTaxonomy(args, terms_options) { }); }); }; - setup_selected_items(item, selected_item_id, selected_item_label); }); } @@ -555,18 +527,14 @@ __webpack_require__.r(__webpack_exports__); 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); @@ -579,24 +547,19 @@ function get_dom_data(key, parent) { 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, @@ -606,7 +569,6 @@ function convertToSelect2(field) { if (!data.field) { return data.text; } - var $field = $(data.field); var $wrapper = $(''); $wrapper.addClass($field[0].className); @@ -617,17 +579,14 @@ function convertToSelect2(field) { 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": @@ -645,7 +604,6 @@ function convertToSelect2(field) { } else { return; } - $(document).ready(function () { /* Initialize wp color picker */ function colorPickerInit() { @@ -657,10 +615,8 @@ function convertToSelect2(field) { } }); } - colorPickerInit(); /* Initialize on Directory type change */ - document.body.addEventListener('directorist-search-form-nav-tab-reloaded', colorPickerInit); }); })(jQuery); @@ -680,11 +636,9 @@ window.addEventListener('DOMContentLoaded', function () { window.directorist_select_executed = true; } else { return; - } //custom select - - + } + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -698,9 +652,9 @@ window.addEventListener('DOMContentLoaded', function () { }); }); }); - } // select data-status - + } + // select data-status var atbdSelectData = document.querySelectorAll('.atbd-drop-select.with-sort'); atbdSelectData.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -729,34 +683,30 @@ __webpack_require__.r(__webpack_exports__); /* 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
    \n \n
    \n\t\t"); + max = obj.maxValue, + min = obj.minValue, + down = 'mousedown', + up = 'mouseup', + move = 'mousemove', + div = "\n
    \n \n
    \n\t\t"); var touch = ("ontouchstart" in document.documentElement); - if (touch) { down = 'touchstart'; up = 'touchend'; move = 'touchmove'; - } //RTL - + } + //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; @@ -764,33 +714,28 @@ var directorist_range_slider = function directorist_range_slider(selector, obj) 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; + 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 = "".concat(min, " ").concat(sliderDataUnit); var x = null, - count = 0, - slid1_val = 0, - slid1_val2 = sliderDataMin, - count2 = width; - + 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'); }); @@ -799,14 +744,12 @@ var directorist_range_slider = function directorist_range_slider(selector, obj) 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; @@ -814,22 +757,18 @@ var directorist_range_slider = function directorist_range_slider(selector, obj) 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 = "".concat(slid1_val, " ").concat(sliderDataUnit); @@ -885,27 +824,24 @@ __webpack_require__.r(__webpack_exports__); - (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) { @@ -914,7 +850,6 @@ __webpack_require__.r(__webpack_exports__); 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(); @@ -923,69 +858,55 @@ __webpack_require__.r(__webpack_exports__); $(abc2).slice(4, abc2.length).fadeOut(); } }); - /* Advanced search */ + /* 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 */ + /* 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; + 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', @@ -1003,12 +924,11 @@ __webpack_require__.r(__webpack_exports__); }); } }); - /* Hide overlapped advanced filter */ + /* 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) { @@ -1047,19 +967,20 @@ __webpack_require__.r(__webpack_exports__); 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 + $(".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 + }); + //reset fields function resetFields() { var inputArray = document.querySelectorAll('.search-area input'); inputArray.forEach(function (input) { @@ -1074,19 +995,15 @@ __webpack_require__.r(__webpack_exports__); 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; @@ -1098,13 +1015,12 @@ __webpack_require__.r(__webpack_exports__); $('.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 */ + /* advanced search form reset */ function adsFormReset(searchForm) { searchForm.querySelectorAll("input[type='text']").forEach(function (el) { el.value = ""; @@ -1123,13 +1039,11 @@ __webpack_require__.r(__webpack_exports__); }); 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) { @@ -1144,141 +1058,112 @@ __webpack_require__.r(__webpack_exports__); $(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 */ - + /* 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 */ - + /* 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 */ - + /* 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 */ - + /* 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'); @@ -1298,16 +1183,20 @@ __webpack_require__.r(__webpack_exports__); if (response) { // Add Temp Element var new_inserted_elm = '
    '; - parent.before(new_inserted_elm); // Remove Old Parent + parent.before(new_inserted_elm); - parent.remove(); // Insert New Parent + // Remove Old Parent + parent.remove(); + // Insert New Parent $('.directorist_search_temp').after(response['search_form']); - var newParent = $('.directorist_search_temp').next(); // Toggle Active Class + 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 + 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) { @@ -1316,10 +1205,8 @@ __webpack_require__.r(__webpack_exports__); }); 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"])(); @@ -1329,9 +1216,10 @@ __webpack_require__.r(__webpack_exports__); console.log(_error2); } }); - }); // Advance search - // Populate atbdp child terms dropdown + }); + // Advance search + // Populate atbdp child terms dropdown $('.bdas-terms').on('change', 'select', function (e) { e.preventDefault(); var $this = $(this); @@ -1341,7 +1229,6 @@ __webpack_require__.r(__webpack_exports__); 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('
    '); var data = { @@ -1357,7 +1244,6 @@ __webpack_require__.r(__webpack_exports__); }); } }); - if ($('.directorist-search-contents').length) { $('body').on('change', '.directorist-category-select', function (event) { var $this = $(this); @@ -1388,19 +1274,18 @@ __webpack_require__.r(__webpack_exports__); window.dispatchEvent(event); }); } - $search_form_box.removeClass('atbdp-form-fade'); }, - error: function error(_error) {//console.log(_error); + error: function error(_error) { + //console.log(_error); } }); }); - } // load custom fields of the selected category in the search form - + } + // 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('
    '); var data = { @@ -1415,49 +1300,43 @@ __webpack_require__.r(__webpack_exports__); 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 + }); + + // 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; - + 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'); var zipcode_search = $(this).closest('.directorist-zipcode-search'); - if (zipcode) { zipcode_search.addClass('dir_loading'); } - if (directorist.i18n_text.select_listing_map === 'google') { var url = directorist.ajax_url; } else { @@ -1465,14 +1344,12 @@ __webpack_require__.r(__webpack_exports__); $('.directorist-country').css({ display: 'block' }); - if (zipcode === '') { $('.directorist-country').css({ display: 'none' }); } } - var res = ''; var google_data = { 'nonce': directorist.directorist_nonce, @@ -1490,9 +1367,7 @@ __webpack_require__.r(__webpack_exports__); zipcode_search.find('.zip-cityLng').val(''); zipcode_search.append(data.data.error_message); } - zipcode_search.removeClass('dir_loading'); - if (directorist.i18n_text.select_listing_map === 'google' && typeof data.lat !== 'undefined' && typeof data.lng !== 'undefined') { zipcode_search.find('.error_message').remove(); zipcode_search.find('.zip-cityLat').val(data.lat); @@ -1508,9 +1383,7 @@ __webpack_require__.r(__webpack_exports__); res += "
  • ").concat(data[i].address.country, "
  • "); } } - $(country_suggest).html("
      ".concat(res, "
    ")); - if (res.length) { $('.directorist-country').show(); } else { @@ -1519,8 +1392,9 @@ __webpack_require__.r(__webpack_exports__); } } }); - }, 250)); // hide country result when click outside the zipcode field + }, 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(); @@ -1538,7 +1412,6 @@ __webpack_require__.r(__webpack_exports__); $('.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() { @@ -1560,14 +1433,12 @@ __webpack_require__.r(__webpack_exports__); 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(); @@ -1576,22 +1447,18 @@ __webpack_require__.r(__webpack_exports__); }); }); }; - 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', @@ -1613,19 +1480,17 @@ __webpack_require__.r(__webpack_exports__); 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. + 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' @@ -1641,19 +1506,15 @@ __webpack_require__.r(__webpack_exports__); data: {}, success: function success(data) { var res = ''; - for (var i = 0, len = data.length; i < len; i++) { res += "
  • ").concat(data[i].display_name, "
  • "); } - result_container.html("
      ".concat(res, "
    ")); - if (res.length) { result_container.show(); } else { result_container.hide(); } - locationAddressField.removeClass('atbdp-form-fade'); }, error: function error(_error3) { @@ -1664,14 +1525,14 @@ __webpack_require__.r(__webpack_exports__); }); } }, 750)); - }); // hide address result when click outside the input field + }); + // 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(); @@ -1684,7 +1545,6 @@ __webpack_require__.r(__webpack_exports__); 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' @@ -1696,22 +1556,20 @@ __webpack_require__.r(__webpack_exports__); }); }); } - 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 */ + /* 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, .zip-radius-search').each(function (index, locationDom) { @@ -1727,14 +1585,12 @@ __webpack_require__.r(__webpack_exports__); } }); } - $('body').on('keyup keydown input change focus', '.directorist-location-js, .zip-radius-search', function (e) { handleRadiusVisibility(); - }); // DOM Mutation observer - + }); + // DOM Mutation observer function initObserver() { var targetNode = document.querySelector('.directorist-location-js'); - if (targetNode) { var observer = new MutationObserver(handleRadiusVisibility); observer.observe(targetNode, { @@ -1742,7 +1598,6 @@ __webpack_require__.r(__webpack_exports__); }); } } - initObserver(); handleRadiusVisibility(); }); @@ -1759,14 +1614,9 @@ __webpack_require__.r(__webpack_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]; - } - + 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; /***/ }), @@ -1779,11 +1629,9 @@ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exp /***/ (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; /***/ }), @@ -1793,9 +1641,11 @@ module.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.ex !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! \***************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperty(obj, key, value) { + key = toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, @@ -1806,10 +1656,8 @@ function _defineProperty(obj, key, value) { } else { obj[key] = value; } - return obj; } - module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -1824,7 +1672,6 @@ module.exports = _defineProperty, module.exports.__esModule = true, module.expor 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; /***/ }), @@ -1839,7 +1686,6 @@ module.exports = _iterableToArray, module.exports.__esModule = true, module.expo 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; /***/ }), @@ -1852,21 +1698,55 @@ module.exports = _nonIterableSpread, module.exports.__esModule = true, module.ex /***/ (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/toPrimitive.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPropertyKey.js": +/*!**************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js"); +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} +module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + /***/ "./node_modules/@babel/runtime/helpers/typeof.js": /*!*******************************************************!*\ !*** ./node_modules/@babel/runtime/helpers/typeof.js ***! @@ -1874,16 +1754,15 @@ module.exports = _toConsumableArray, module.exports.__esModule = true, module.ex /*! no static exports found */ /***/ (function(module, exports) { -function _typeof(obj) { +function _typeof(o) { "@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); + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); } - module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -1896,7 +1775,6 @@ module.exports = _typeof, module.exports.__esModule = true, module.exports["defa /***/ (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); @@ -1905,7 +1783,6 @@ function _unsupportedIterableToArray(o, minLen) { 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; /***/ }), diff --git a/assets/js/single-listing-google-map-widget.js b/assets/js/single-listing-google-map-widget.js index 35c3fbca44..41a3148c2c 100644 --- a/assets/js/single-listing-google-map-widget.js +++ b/assets/js/single-listing-google-map-widget.js @@ -94,26 +94,22 @@ /***/ (function(module, exports) { /* Widget google map */ + window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { if ($('#gmap-widget').length) { var MAP_PIN = 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z'; - var inherits = function inherits(childCtor, parentCtor) { /** @constructor */ function tempCtor() {} - tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; childCtor.prototype = new tempCtor(); childCtor.prototype.constructor = childCtor; }; - function Marker(options) { google.maps.Marker.apply(this, arguments); - if (options.map_icon_label) { this.MarkerLabel = new MarkerLabel({ map: this.map, @@ -122,33 +118,37 @@ window.addEventListener('DOMContentLoaded', function () { }); this.MarkerLabel.bindTo('position', this, 'position'); } - } // Apply the inheritance + } + // Apply the inheritance + inherits(Marker, google.maps.Marker); - inherits(Marker, google.maps.Marker); // Custom Marker SetMap - + // Custom Marker SetMap Marker.prototype.setMap = function () { google.maps.Marker.prototype.setMap.apply(this, arguments); this.MarkerLabel && this.MarkerLabel.setMap.apply(this.MarkerLabel, arguments); - }; // Marker Label Overlay - + }; + // Marker Label Overlay var MarkerLabel = function MarkerLabel(options) { var self = this; - this.setValues(options); // Create the label container + this.setValues(options); + // Create the label container this.div = document.createElement('div'); - this.div.className = 'map-icon-label'; // Trigger the marker click handler if clicking on the label + this.div.className = 'map-icon-label'; + // Trigger the marker click handler if clicking on the label google.maps.event.addDomListener(this.div, 'click', function (e) { e.stopPropagation && e.stopPropagation(); google.maps.event.trigger(self.marker, 'click'); }); - }; // Create MarkerLabel Object - + }; - MarkerLabel.prototype = new google.maps.OverlayView(); // Marker Label onAdd + // Create MarkerLabel Object + MarkerLabel.prototype = new google.maps.OverlayView(); + // Marker Label onAdd MarkerLabel.prototype.onAdd = function () { var pane = this.getPanes().overlayImage.appendChild(this.div); var self = this; @@ -159,35 +159,33 @@ window.addEventListener('DOMContentLoaded', function () { }), google.maps.event.addListener(this, 'zindex_changed', function () { self.draw(); })]; - }; // Marker Label onRemove - + }; + // Marker Label onRemove MarkerLabel.prototype.onRemove = function () { this.div.parentNode.removeChild(this.div); - for (var i = 0, I = this.listeners.length; i < I; ++i) { google.maps.event.removeListener(this.listeners[i]); } - }; // Implement draw - + }; + // Implement draw MarkerLabel.prototype.draw = function () { var projection = this.getProjection(); var position = projection.fromLatLngToDivPixel(this.get('position')); var div = this.div; this.div.innerHTML = this.get('text').toString(); div.style.zIndex = this.get('zIndex'); // Allow label to overlay marker - div.style.position = 'absolute'; div.style.display = 'block'; div.style.left = position.x - div.offsetWidth / 2 + 'px'; div.style.top = position.y - div.offsetHeight + 'px'; }; - $(document).ready(function () { // initialize all vars here to avoid hoisting related misunderstanding. - var map, info_window, saved_lat_lng, info_content; // Localized Data + var map, info_window, saved_lat_lng, info_content; + // Localized Data var map_container = localized_data_widget.map_container_id ? localized_data_widget.map_container_id : 'gmap'; var loc_default_latitude = parseFloat(localized_data_widget.default_latitude); var loc_default_longitude = parseFloat(localized_data_widget.default_longitude); @@ -204,14 +202,13 @@ window.addEventListener('DOMContentLoaded', function () { saved_lat_lng = { lat: loc_manual_lat, lng: loc_manual_lng - }; // create an info window for map + }; + // create an info window for map if (display_map_info) { info_window = new google.maps.InfoWindow({ content: info_content, - maxWidth: 400 - /*Add configuration for max width*/ - + maxWidth: 400 /*Add configuration for max width*/ }); } @@ -225,7 +222,6 @@ window.addEventListener('DOMContentLoaded', function () { map: map, position: saved_lat_lng });*/ - var marker = new Marker({ position: saved_lat_lng, map: map, @@ -238,7 +234,6 @@ window.addEventListener('DOMContentLoaded', function () { }, map_icon_label: '
    ' + cat_icon + '
    ' }); - if (display_map_info) { marker.addListener('click', function () { info_window.open(map, marker); @@ -251,9 +246,8 @@ window.addEventListener('DOMContentLoaded', function () { }); } } - - initMap(); //Convert address tags to google map links - - + initMap(); + //Convert address tags to google map links - $('address').each(function () { var link = "" + $(this).text() + ""; $(this).html(link); diff --git a/assets/js/single-listing-google-map.js b/assets/js/single-listing-google-map.js index bc4d5bf8f4..16230150ee 100644 --- a/assets/js/single-listing-google-map.js +++ b/assets/js/single-listing-google-map.js @@ -94,27 +94,23 @@ /***/ (function(module, exports) { /* Single listing google map */ + window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { if ($('.directorist-single-map').length) { document.querySelectorAll('.directorist-single-map').forEach(function (mapElm) { var MAP_PIN = 'M0-48c-9.8 0-17.7 7.8-17.7 17.4 0 15.5 17.7 30.6 17.7 30.6s17.7-15.4 17.7-30.6c0-9.6-7.9-17.4-17.7-17.4z'; - var inherits = function inherits(childCtor, parentCtor) { /** @constructor */ function tempCtor() {} - tempCtor.prototype = parentCtor.prototype; childCtor.superClass_ = parentCtor.prototype; childCtor.prototype = new tempCtor(); childCtor.prototype.constructor = childCtor; }; - function Marker(options) { google.maps.Marker.apply(this, arguments); - if (options.map_icon_label) { this.MarkerLabel = new MarkerLabel({ map: this.map, @@ -123,33 +119,37 @@ window.addEventListener('DOMContentLoaded', function () { }); this.MarkerLabel.bindTo('position', this, 'position'); } - } // Apply the inheritance + } + // Apply the inheritance + inherits(Marker, google.maps.Marker); - inherits(Marker, google.maps.Marker); // Custom Marker SetMap - + // Custom Marker SetMap Marker.prototype.setMap = function () { google.maps.Marker.prototype.setMap.apply(this, arguments); this.MarkerLabel && this.MarkerLabel.setMap.apply(this.MarkerLabel, arguments); - }; // Marker Label Overlay - + }; + // Marker Label Overlay var MarkerLabel = function MarkerLabel(options) { var self = this; - this.setValues(options); // Create the label container + this.setValues(options); + // Create the label container this.div = document.createElement('div'); - this.div.className = 'map-icon-label'; // Trigger the marker click handler if clicking on the label + this.div.className = 'map-icon-label'; + // Trigger the marker click handler if clicking on the label google.maps.event.addDomListener(this.div, 'click', function (e) { e.stopPropagation && e.stopPropagation(); google.maps.event.trigger(self.marker, 'click'); }); - }; // Create MarkerLabel Object - + }; - MarkerLabel.prototype = new google.maps.OverlayView(); // Marker Label onAdd + // Create MarkerLabel Object + MarkerLabel.prototype = new google.maps.OverlayView(); + // Marker Label onAdd MarkerLabel.prototype.onAdd = function () { var pane = this.getPanes().overlayImage.appendChild(this.div); var self = this; @@ -160,35 +160,33 @@ window.addEventListener('DOMContentLoaded', function () { }), google.maps.event.addListener(this, 'zindex_changed', function () { self.draw(); })]; - }; // Marker Label onRemove - + }; + // Marker Label onRemove MarkerLabel.prototype.onRemove = function () { this.div.parentNode.removeChild(this.div); - for (var i = 0, I = this.listeners.length; i < I; ++i) { google.maps.event.removeListener(this.listeners[i]); } - }; // Implement draw - + }; + // Implement draw MarkerLabel.prototype.draw = function () { var projection = this.getProjection(); var position = projection.fromLatLngToDivPixel(this.get('position')); var div = this.div; this.div.innerHTML = this.get('text').toString(); div.style.zIndex = this.get('zIndex'); // Allow label to overlay marker - div.style.position = 'absolute'; div.style.display = 'block'; div.style.left = position.x - div.offsetWidth / 2 + 'px'; div.style.top = position.y - div.offsetHeight + 'px'; }; - $(document).ready(function () { // initialize all vars here to avoid hoisting related misunderstanding. - var map, info_window, saved_lat_lng, info_content; // Localized Data + var map, info_window, saved_lat_lng, info_content; + // Localized Data var mapData = JSON.parse(mapElm.getAttribute('data-map')); var loc_default_latitude = parseFloat(mapData.default_latitude); var loc_default_longitude = parseFloat(mapData.default_longitude); @@ -205,14 +203,13 @@ window.addEventListener('DOMContentLoaded', function () { saved_lat_lng = { lat: loc_manual_lat, lng: loc_manual_lng - }; // create an info window for map + }; + // create an info window for map if (display_map_info) { info_window = new google.maps.InfoWindow({ content: info_content, - maxWidth: 400 - /*Add configuration for max width*/ - + maxWidth: 400 /*Add configuration for max width*/ }); } @@ -226,7 +223,6 @@ window.addEventListener('DOMContentLoaded', function () { map: map, position: saved_lat_lng });*/ - var marker = new Marker({ position: saved_lat_lng, map: map, @@ -239,7 +235,6 @@ window.addEventListener('DOMContentLoaded', function () { }, map_icon_label: "
    ".concat(cat_icon, "
    ") }); - if (display_map_info) { marker.addListener('click', function () { info_window.open(map, marker); @@ -252,9 +247,8 @@ window.addEventListener('DOMContentLoaded', function () { }); } } - - initMap(); //Convert address tags to google map links - - + initMap(); + //Convert address tags to google map links - $('address').each(function () { var link = "" + $(this).text() + ""; $(this).html(link); diff --git a/assets/js/single-listing-openstreet-map-widget.js b/assets/js/single-listing-openstreet-map-widget.js index 97405531ff..51b38b8198 100644 --- a/assets/js/single-listing-openstreet-map-widget.js +++ b/assets/js/single-listing-openstreet-map-widget.js @@ -94,8 +94,8 @@ /***/ (function(module, exports) { /* Widget OSMap */ -; +; (function ($) { jQuery(document).ready(function () { // Localized Data @@ -107,11 +107,11 @@ var loc_manual_lng = parseFloat(localized_data_widget.manual_lng); var loc_map_zoom_level = parseInt(localized_data_widget.map_zoom_level); var _localized_data_widge = localized_data_widget, - display_map_info = _localized_data_widge.display_map_info; + display_map_info = _localized_data_widge.display_map_info; var _localized_data_widge2 = localized_data_widget, - cat_icon = _localized_data_widge2.cat_icon; + cat_icon = _localized_data_widge2.cat_icon; var _localized_data_widge3 = localized_data_widget, - info_content = _localized_data_widge3.info_content; + info_content = _localized_data_widge3.info_content; loc_manual_lat = isNaN(loc_manual_lat) ? loc_default_latitude : loc_manual_lat; loc_manual_lng = isNaN(loc_manual_lng) ? loc_default_longitude : loc_manual_lng; $manual_lat = $('#manual_lat'); @@ -120,7 +120,6 @@ lat: loc_manual_lat, lng: loc_manual_lng }; - function mapLeaflet(lat, lon) { var fontAwesomeIcon = L.divIcon({ html: "
    ".concat(cat_icon, "
    "), @@ -128,7 +127,6 @@ className: 'myDivIcon' }); var mymap = L.map(map_container).setView([lat, lon], loc_map_zoom_level); - if (display_map_info) { L.marker([lat, lon], { icon: fontAwesomeIcon @@ -138,12 +136,10 @@ icon: fontAwesomeIcon }).addTo(mymap); } - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(mymap); } - mapLeaflet(loc_manual_lat, loc_manual_lng); } }); diff --git a/assets/js/single-listing-openstreet-map.js b/assets/js/single-listing-openstreet-map.js index c285c4ff7d..6aec20e1d4 100644 --- a/assets/js/single-listing-openstreet-map.js +++ b/assets/js/single-listing-openstreet-map.js @@ -94,6 +94,7 @@ /***/ (function(module, exports) { /* Single listing OSMap */ + (function ($) { jQuery(document).ready(function () { // Localized Data @@ -116,7 +117,6 @@ lat: loc_manual_lat, lng: loc_manual_lng }; - function mapLeaflet(lat, lon) { var fontAwesomeIcon = L.divIcon({ html: "
    ".concat(cat_icon, "
    "), @@ -126,7 +126,6 @@ var mymap = L.map(mapElm, { scrollWheelZoom: false }).setView([lat, lon], loc_map_zoom_level); - if (display_map_info) { L.marker([lat, lon], { icon: fontAwesomeIcon @@ -136,12 +135,10 @@ icon: fontAwesomeIcon }).addTo(mymap); } - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(mymap); } - mapLeaflet(loc_manual_lat, loc_manual_lng); }); } diff --git a/assets/js/single-listing.js b/assets/js/single-listing.js index 0436e0f972..0aefc2f191 100644 --- a/assets/js/single-listing.js +++ b/assets/js/single-listing.js @@ -94,7 +94,6 @@ /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { // Recovery Password Modal @@ -102,14 +101,16 @@ $(".atbdp_recovery_pass").on("click", function (e) { e.preventDefault(); $("#recover-pass-modal").slideToggle().show(); - }); // Contact form [on modal closed] + }); + // Contact form [on modal closed] $('#atbdp-contact-modal').on('hidden.bs.modal', function (e) { $('#atbdp-contact-message').val(''); $('#atbdp-contact-message-display').html(''); - }); // Template Restructured - // Modal + }); + // Template Restructured + // Modal var directoristModal = document.querySelector('.directorist-modal-js'); $('body').on('click', '.directorist-btn-modal-js', function (e) { e.preventDefault(); @@ -138,7 +139,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_alert_executed === 'undefined') { @@ -146,12 +146,10 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* Directorist alert dismiss */ var getUrl = window.location.href; var newUrl = getUrl.replace('notice=1', ''); - if ($('.directorist-alert__close') !== null) { $('.directorist-alert__close').each(function (i, e) { $(e).on('click', function (e) { @@ -174,7 +172,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_dropdown_executed === 'undefined') { @@ -182,19 +179,17 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { /* custom dropdown */ - var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); // toggle dropdown + var atbdDropdown = document.querySelectorAll('.directorist-dropdown-select'); + // toggle dropdown var clickCount = 0; - if (atbdDropdown !== null) { atbdDropdown.forEach(function (el) { el.querySelector('.directorist-dropdown-select-toggle').addEventListener('click', function (e) { e.preventDefault(); clickCount++; - if (clickCount % 2 === 1) { document.querySelectorAll('.directorist-dropdown-select-items').forEach(function (elem) { elem.classList.remove('directorist-dropdown-select-show'); @@ -207,9 +202,9 @@ } }); }); - } // remvoe toggle when click outside - + } + // remvoe toggle when click outside document.body.addEventListener('click', function (e) { if (e.target.getAttribute('data-drop-toggle') !== 'directorist-dropdown-select-toggle') { clickCount = 0; @@ -217,10 +212,10 @@ el.classList.remove('directorist-dropdown-select-show'); }); } - }); //custom select + }); + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.directorist-dropdown-select-items').forEach(function (item) { @@ -234,27 +229,30 @@ }); }); }); - } // Dropdown - + } + // Dropdown $('body').on('click', '.directorist-dropdown .directorist-dropdown-toggle', function (e) { e.preventDefault(); $(this).siblings('.directorist-dropdown-option').toggle(); - }); // Select Option after click + }); + // Select Option after click $('body').on('click', '.directorist-dropdown .directorist-dropdown-option ul li a', function (e) { e.preventDefault(); var optionText = $(this).html(); $(this).children('.directorist-dropdown-toggle__text').html(optionText); $(this).closest('.directorist-dropdown-option').siblings('.directorist-dropdown-toggle').children('.directorist-dropdown-toggle__text').html(optionText); $('.directorist-dropdown-option').hide(); - }); // Hide Clicked Anywhere + }); + // Hide Clicked Anywhere $(document).bind('click', function (e) { var clickedDom = $(e.target); if (!clickedDom.parents().hasClass('directorist-dropdown')) $('.directorist-dropdown-option').hide(); - }); //atbd_dropdown + }); + //atbd_dropdown $(document).on("click", '.atbd_dropdown', function (e) { if ($(this).attr("class") === "atbd_dropdown") { e.preventDefault(); @@ -270,15 +268,14 @@ }); $('body').on('click', '.atbd_dropdown-toggle', function (e) { e.preventDefault(); - }); // Directorist Dropdown + }); + // Directorist Dropdown $('body').on('click', '.directorist-dropdown-js .directorist-dropdown__toggle-js', function (e) { e.preventDefault(); - if (!$(this).siblings('.directorist-dropdown__links-js').is(':visible')) { $('.directorist-dropdown__links').hide(); } - $(this).siblings('.directorist-dropdown__links-js').toggle(); }); $('body').on('click', function (e) { @@ -299,7 +296,6 @@ /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_favorite_executed === 'undefined') { @@ -307,7 +303,6 @@ } else { return; } - window.addEventListener('DOMContentLoaded', function () { // Add or Remove from favourites $('#atbdp-favourites').on('click', function (e) { @@ -321,7 +316,6 @@ console.log('added'); console.log(response); console.log(directorist.ajaxurl); - if (response) { $('#atbdp-favourites').html(response); } @@ -339,7 +333,6 @@ $.post(directorist.ajaxurl, data, function (response) { var post_id = data['post_id'].toString(); var staElement = $('.directorist_favourite_' + post_id); - if ('false' === response) { staElement.remove(); } @@ -360,7 +353,6 @@ var post_id = data['post_id'].toString(); var staElement = $('.directorist-fav_' + post_id); var data_id = staElement.attr('data-listing_id'); - if (response === "login_required") { staElement.children(".directorist-favorite-tooltip").append(fav_tooltip_warning); staElement.children(".directorist-favorite-tooltip").fadeIn(); @@ -400,11 +392,9 @@ window.addEventListener('DOMContentLoaded', function () { window.directorist_select_executed = true; } else { return; - } //custom select - - + } + //custom select var atbdSelect = document.querySelectorAll('.atbd-drop-select'); - if (atbdSelect !== null) { atbdSelect.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -418,9 +408,9 @@ window.addEventListener('DOMContentLoaded', function () { }); }); }); - } // select data-status - + } + // select data-status var atbdSelectData = document.querySelectorAll('.atbd-drop-select.with-sort'); atbdSelectData.forEach(function (el) { el.querySelectorAll('.atbd-dropdown-item').forEach(function (item) { @@ -443,15 +433,14 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { window.addEventListener('DOMContentLoaded', function () { $('#directorist-report-abuse-form').on('submit', function (e) { - $('.directorist-report-abuse-modal button[type=submit]').addClass('directorist-btn-loading'); // Check for errors - + $('.directorist-report-abuse-modal button[type=submit]').addClass('directorist-btn-loading'); + // Check for errors if (!e.isDefaultPrevented()) { - e.preventDefault(); // Post via AJAX - + e.preventDefault(); + // Post via AJAX var data = { 'action': 'atbdp_public_report_abuse', 'directorist_nonce': directorist.directorist_nonce, @@ -465,26 +454,28 @@ window.addEventListener('DOMContentLoaded', function () { $('#directorist-report-message').val(''); $('#directorist-report-abuse-message-display').addClass('text-success').html(response.message); } - $('.directorist-report-abuse-modal button[type=submit]').removeClass('directorist-btn-loading'); }, 'json'); } }); - $('#atbdp-report-abuse-form').removeAttr('novalidate'); // Validate contact form + $('#atbdp-report-abuse-form').removeAttr('novalidate'); + // Validate contact form $('.directorist-contact-owner-form').on('submit', function (e) { e.preventDefault(); var submit_button = $(this).find('button[type="submit"]'); - var status_area = $(this).find('.directorist-contact-message-display'); // Show loading message + var status_area = $(this).find('.directorist-contact-message-display'); + // Show loading message var msg = '
    ' + directorist.waiting_msg + '
    '; status_area.html(msg); var name = $(this).find('input[name="atbdp-contact-name"]'); var contact_email = $(this).find('input[name="atbdp-contact-email"]'); var message = $(this).find('textarea[name="atbdp-contact-message"]'); var post_id = $(this).find('input[name="atbdp-post-id"]'); - var listing_email = $(this).find('input[name="atbdp-listing-email"]'); // Post via AJAX + var listing_email = $(this).find('input[name="atbdp-listing-email"]'); + // Post via AJAX var data = { 'action': 'atbdp_public_send_contact_email', 'post_id': post_id.val(), @@ -497,21 +488,21 @@ window.addEventListener('DOMContentLoaded', function () { submit_button.prop('disabled', true); $.post(directorist.ajaxurl, data, function (response) { submit_button.prop('disabled', false); - if (1 == response.error) { - atbdp_contact_submitted = false; // Show error message + atbdp_contact_submitted = false; + // Show error message var msg = '
    ' + response.message + '
    '; status_area.html(msg); } else { name.val(''); message.val(''); - contact_email.val(''); // Show success message + contact_email.val(''); + // Show success message var msg = '
    ' + response.message + '
    '; status_area.html(msg); } - setTimeout(function () { status_area.html(''); }, 5000); @@ -531,7 +522,6 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { ; - (function ($) { // Make sure the codes in this file runs only once, even if enqueued twice if (typeof window.directorist_loginjs_executed === 'undefined') { @@ -539,7 +529,6 @@ window.addEventListener('DOMContentLoaded', function () { } else { return; } - window.addEventListener('DOMContentLoaded', function () { // Perform AJAX login on form submit $('form#login').on('submit', function (e) { @@ -562,7 +551,6 @@ window.addEventListener('DOMContentLoaded', function () { if ('nonce_faild' in data && data.nonce_faild) { $('p.status').html('
    ' + data.message + '
    '); } - if (data.loggedin == true) { $('p.status').html('
    ' + data.message + '
    '); document.location.href = directorist.redirect_url; @@ -574,7 +562,6 @@ window.addEventListener('DOMContentLoaded', function () { if ('nonce_faild' in data && data.nonce_faild) { $('p.status').html('
    ' + data.message + '
    '); } - $('p.status').show().html('
    ' + directorist.login_error_message + '
    '); } }); @@ -582,7 +569,6 @@ window.addEventListener('DOMContentLoaded', function () { }); $('form#login .status').on('click', 'a', function (e) { e.preventDefault(); - if ($(this).attr('href') === '#atbdp_recovery_pass') { $("#recover-pass-modal").slideDown().show(); window.scrollTo({ @@ -592,22 +578,24 @@ window.addEventListener('DOMContentLoaded', function () { } else { location.href = href; } - }); // Alert users to login (only if applicable) + }); + // Alert users to login (only if applicable) $('.atbdp-require-login, .directorist-action-report-not-loggedin').on('click', function (e) { e.preventDefault(); alert(directorist.login_alert_message); return false; - }); // Remove URL params to avoid show message again and again + }); + // Remove URL params to avoid show message again and again var current_url = location.href; var url = new URL(current_url); url.searchParams.delete('registration_status'); - url.searchParams.delete('errors'); // url.searchParams.delete('key'); - + url.searchParams.delete('errors'); + // url.searchParams.delete('key'); url.searchParams.delete('password_reset'); - url.searchParams.delete('confirm_mail'); // url.searchParams.delete('user'); - + url.searchParams.delete('confirm_mail'); + // url.searchParams.delete('user'); url.searchParams.delete('verification'); url.searchParams.delete('send_verification_email'); window.history.pushState(null, null, url.toString()); @@ -629,13 +617,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _review_starRating__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_review_starRating__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _review_advanced_review__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./review/advanced-review */ "./assets/src/js/public/components/review/advanced-review.js"); // Helper Components - // import './review/addReview' + +// import './review/addReview' // import './review/reviewAttatchment' // import './review/deleteReview' // import './review/reviewPagination' - /***/ }), /***/ "./assets/src/js/public/components/review/advanced-review.js": @@ -653,36 +641,27 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__); - 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; } - +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; } window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { 'use strict'; var ReplyFormObserver = /*#__PURE__*/function () { function ReplyFormObserver() { var _this = this; - _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, ReplyFormObserver); - this.init(); $(document).on('directorist_review_updated', function () { return _this.init(); }); } - _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(ReplyFormObserver, [{ key: "init", value: function init() { var node = document.querySelector('.commentlist'); - if (node) { this.observe(node); } @@ -701,38 +680,28 @@ window.addEventListener('DOMContentLoaded', function () { key: "callback", value: function callback(mutationsList, observer) { var _iterator = _createForOfIteratorHelper(mutationsList), - _step; - + _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var mutation = _step.value; var target = mutation.target; - if (mutation.removedNodes) { target.classList.remove('directorist-form-added'); - var _iterator2 = _createForOfIteratorHelper(mutation.removedNodes), - _step2; - + _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var node = _step2.value; - if (!node.id || node.id !== 'respond') { continue; } - var criteria = node.querySelector('.directorist-review-criteria'); - if (criteria) { criteria.style.display = ''; } - var ratings = node.querySelectorAll('.directorist-review-criteria-select'); - var _iterator3 = _createForOfIteratorHelper(ratings), - _step3; - + _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var rating = _step3.value; @@ -743,9 +712,9 @@ window.addEventListener('DOMContentLoaded', function () { } finally { _iterator3.f(); } - node.querySelector('#submit').innerHTML = 'Submit Review'; - node.querySelector('#comment').setAttribute('placeholder', 'Leave a review'); //console.log(node.querySelector('#comment')) + node.querySelector('#comment').setAttribute('placeholder', 'Leave a review'); + //console.log(node.querySelector('#comment')) } } catch (err) { _iterator2.e(err); @@ -753,30 +722,22 @@ window.addEventListener('DOMContentLoaded', function () { _iterator2.f(); } } - var form = target.querySelector('#commentform'); - if (form) { target.classList.add('directorist-form-added'); var isReview = target.classList.contains('review'); var isEditing = target.classList.contains('directorist-form-editing'); - if (!isReview || isReview && !isEditing) { var _criteria = form.querySelector('.directorist-review-criteria'); - if (_criteria) { _criteria.style.display = 'none'; } - var _ratings = form.querySelectorAll('.directorist-review-criteria-select'); - var _iterator4 = _createForOfIteratorHelper(_ratings), - _step4; - + _step4; try { for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { var _rating = _step4.value; - _rating.setAttribute('disabled', 'disabled'); } } catch (err) { @@ -785,13 +746,10 @@ window.addEventListener('DOMContentLoaded', function () { _iterator4.f(); } } - var alert = form.querySelector('.directorist-alert'); - if (alert) { alert.style.display = 'none'; } - form.querySelector('#submit').innerHTML = 'Submit Reply'; form.querySelector('#comment').setAttribute('placeholder', 'Leave your reply'); } @@ -803,17 +761,13 @@ window.addEventListener('DOMContentLoaded', function () { } } }]); - return ReplyFormObserver; }(); - var CommentEditHandler = /*#__PURE__*/function () { function CommentEditHandler() { _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, CommentEditHandler); - this.init(); } - _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(CommentEditHandler, [{ key: "init", value: function init() { @@ -845,7 +799,6 @@ window.addEventListener('DOMContentLoaded', function () { CommentEditHandler.showError($form, data.data.html); return; } - var body = $('
    '); body.append(data); var comment_section = '.directorist-review-container'; @@ -853,12 +806,11 @@ window.addEventListener('DOMContentLoaded', function () { $(comment_section).replaceWith(comments); $(document).trigger('directorist_review_updated', data); var commentTop = $("#comment-" + commentID).offset().top; - if ($('body').hasClass('admin-bar')) { commentTop = commentTop - $('#wpadminbar').height(); - } // scroll to comment - + } + // scroll to comment if (commentID) { $("body, html").animate({ scrollTop: commentTop @@ -881,17 +833,13 @@ window.addEventListener('DOMContentLoaded', function () { $form.prepend(msg); } }]); - return CommentEditHandler; }(); - var CommentAddReplyHandler = /*#__PURE__*/function () { function CommentAddReplyHandler() { _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, CommentAddReplyHandler); - this.init(); } - _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(CommentAddReplyHandler, [{ key: "init", value: function init() { @@ -899,7 +847,6 @@ window.addEventListener('DOMContentLoaded', function () { if ($('.directorist-review-container').length) { $(document).off('submit', '#commentform'); } - clearTimeout(t); }, 2000); $(document).off('submit', '.directorist-review-container #commentform'); @@ -909,7 +856,6 @@ window.addEventListener('DOMContentLoaded', function () { key: "onSubmit", value: function onSubmit(event) { var _this2 = this; - event.preventDefault(); var form = $('.directorist-review-container #commentform'); var originalButtonLabel = form.find('[type="submit"]').val(); @@ -930,17 +876,17 @@ window.addEventListener('DOMContentLoaded', function () { var comment_section = '.directorist-review-container'; var comments = body.find(comment_section); var errorMsg = body.find('.wp-die-message'); - if (errorMsg.length > 0) { CommentAddReplyHandler.showError(form, errorMsg); $(document).trigger('directorist_review_update_failed'); return; } - $(comment_section).replaceWith(comments); $(document).trigger('directorist_review_updated', data); var newComment = comments.find('.commentlist li:first-child'); - var newCommentId = newComment.attr('id'); // // catch the new comment id by comparing to old dom. + var newCommentId = newComment.attr('id'); + + // // catch the new comment id by comparing to old dom. // commentsLists.each( // function ( index ) { // var _this = $( commentsLists[ index ] ); @@ -949,15 +895,15 @@ window.addEventListener('DOMContentLoaded', function () { // } // } // ); + // console.log(newComment, newCommentId) var commentTop = $("#" + newCommentId).offset().top; - if ($('body').hasClass('admin-bar')) { commentTop = commentTop - $('#wpadminbar').height(); - } // scroll to comment - + } + // scroll to comment if (newCommentId) { $('body, html').animate({ scrollTop: commentTop @@ -970,7 +916,6 @@ window.addEventListener('DOMContentLoaded', function () { console.log(data); CommentAddReplyHandler.showError(form, body.find('.wp-die-message')); $(document).trigger('directorist_review_update_failed'); - if (data.status === 403 || data.status === 401) { $(document).off('submit', '.directorist-review-container #commentform', _this2.onSubmit); $('#comment').prop('disabled', false); @@ -989,13 +934,10 @@ window.addEventListener('DOMContentLoaded', function () { if ($dom.find('p').length) { $dom = $dom.find('p'); } - var words = $dom.text().split(':'); - if (words.length > 1) { words.shift(); } - return words.join(' ').trim(); } }, { @@ -1004,26 +946,21 @@ window.addEventListener('DOMContentLoaded', function () { if (form.find('.directorist-alert').length) { form.find('.directorist-alert').remove(); } - var $error = $('
    ', { class: 'directorist-alert directorist-alert-danger' }).html(CommentAddReplyHandler.getErrorMsg($dom)); form.prepend($error); } }]); - return CommentAddReplyHandler; }(); - var CommentsManager = /*#__PURE__*/function () { function CommentsManager() { _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, CommentsManager); - this.$doc = $(document); this.setupComponents(); this.addEventListeners(); } - _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(CommentsManager, [{ key: "initStarRating", value: function initStarRating() { @@ -1036,7 +973,6 @@ window.addEventListener('DOMContentLoaded', function () { value: function cancelOthersEditMode(currentCommentId) { $('.directorist-comment-editing').each(function (index, comment) { var $cancelButton = $(comment).find('.directorist-js-cancel-comment-edit'); - if ($cancelButton.data('commentid') != currentCommentId) { $cancelButton.click(); } @@ -1052,7 +988,6 @@ window.addEventListener('DOMContentLoaded', function () { key: "addEventListeners", value: function addEventListeners() { var _this3 = this; - var self = this; this.$doc.on('directorist_review_updated', function (event) { _this3.initStarRating(); @@ -1063,7 +998,6 @@ window.addEventListener('DOMContentLoaded', function () { this.$doc.on('click', 'a[href="#respond"]', function (event) { // First cancle the reply form then scroll to review form. Order matters. _this3.cancelReplyMode(); - _this3.onWriteReivewClick(event); }); this.$doc.on('click', '.directorist-js-edit-comment', function (event) { @@ -1103,11 +1037,9 @@ window.addEventListener('DOMContentLoaded', function () { value: function onWriteReivewClick(event) { event.preventDefault(); var scrollTop = $('#respond').offset().top; - if ($('body').hasClass('admin-bar')) { scrollTop = scrollTop - $('#wpadminbar').height(); } - $('body, html').animate({ scrollTop: scrollTop }, 600); @@ -1120,10 +1052,8 @@ window.addEventListener('DOMContentLoaded', function () { new CommentEditHandler(); } }]); - return CommentsManager; }(); - var commentsManager = new CommentsManager(); })(jQuery); }); @@ -1139,7 +1069,6 @@ window.addEventListener('DOMContentLoaded', function () { window.addEventListener('DOMContentLoaded', function () { ; - (function ($) { //Star rating if ($('.directorist-review-criteria-select').length) { @@ -1160,8 +1089,8 @@ window.addEventListener('DOMContentLoaded', function () { /***/ (function(module, exports) { document.addEventListener('DOMContentLoaded', function () { - var $ = jQuery; // Plasma Slider Initialization - + var $ = jQuery; + // Plasma Slider Initialization if ($('.plasmaSlider').length !== 0) { var single_listing_slider = new PlasmaSlider({ containerID: "directorist-single-listing-slider" @@ -1170,21 +1099,17 @@ document.addEventListener('DOMContentLoaded', function () { var singleListingSlider = document.getElementById("directorist-single-listing-slider"); var width = singleListingSlider.getAttribute("data-width"); var height = singleListingSlider.getAttribute("data-height"); - if (width) { singleListingSlider.style.setProperty('width', width + "px"); } - if (height) { singleListingSlider.style.setProperty('height', height + "px"); } } - /* Related listings slider */ - + /* Related listings slider */ var rtl = directorist.rtl === 'true'; var relLis = $('.directorist-related-carousel'); - if (relLis.length !== 0) { var relLisData = relLis.data('attr'); var prevArrow = typeof relLisData !== 'undefined' ? relLisData.prevArrow : ''; @@ -1262,9 +1187,10 @@ __webpack_require__.r(__webpack_exports__); - // Single Listing Page +// Single Listing Page + /***/ }), @@ -1280,7 +1206,6 @@ function _classCallCheck(instance, Constructor) { throw new TypeError("Cannot call a class as a function"); } } - module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), @@ -1290,18 +1215,18 @@ module.exports = _classCallCheck, module.exports.__esModule = true, module.expor !*** ./node_modules/@babel/runtime/helpers/createClass.js ***! \************************************************************/ /*! no static exports found */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { +var toPropertyKey = __webpack_require__(/*! ./toPropertyKey.js */ "./node_modules/@babel/runtime/helpers/toPropertyKey.js"); function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); + Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor); } } - function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); @@ -1310,11 +1235,69 @@ function _createClass(Constructor, protoProps, staticProps) { }); return Constructor; } - module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports; /***/ }), +/***/ "./node_modules/@babel/runtime/helpers/toPrimitive.js": +/*!************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPrimitive.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +function _toPrimitive(input, hint) { + if (_typeof(input) !== "object" || input === null) return input; + var prim = input[Symbol.toPrimitive]; + if (prim !== undefined) { + var res = prim.call(input, hint || "default"); + if (_typeof(res) !== "object") return res; + throw new TypeError("@@toPrimitive must return a primitive value."); + } + return (hint === "string" ? String : Number)(input); +} +module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + +/***/ "./node_modules/@babel/runtime/helpers/toPropertyKey.js": +/*!**************************************************************!*\ + !*** ./node_modules/@babel/runtime/helpers/toPropertyKey.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +var _typeof = __webpack_require__(/*! ./typeof.js */ "./node_modules/@babel/runtime/helpers/typeof.js")["default"]; +var toPrimitive = __webpack_require__(/*! ./toPrimitive.js */ "./node_modules/@babel/runtime/helpers/toPrimitive.js"); +function _toPropertyKey(arg) { + var key = toPrimitive(arg, "string"); + return _typeof(key) === "symbol" ? key : String(key); +} +module.exports = _toPropertyKey, 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(o) { + "@babel/helpers - typeof"; + + return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { + return typeof o; + } : function (o) { + return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; + }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o); +} +module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports; + +/***/ }), + /***/ 11: /*!**************************************************************!*\ !*** multi ./assets/src/js/public/modules/single-listing.js ***! diff --git a/assets/src/js/admin/components/block-3.js b/assets/src/js/admin/components/block-3.js index e837f13829..b2a03b6def 100644 --- a/assets/src/js/admin/components/block-3.js +++ b/assets/src/js/admin/components/block-3.js @@ -147,32 +147,36 @@ window.addEventListener('DOMContentLoaded', () => { } else { $('.atbd_tagline_moto_field').fadeOut(); } - if ($('.directorist-form-pricing-field').hasClass('price-type-both')) { - $('#price').show(); - $('#price_range').hide(); - } - $('.directorist_pricing_options label').on( 'click', function () { - const $this = $(this); - $this.children('input[type=checkbox]').prop('checked') == true - ? $(`#${$this.data('option')}`).show() - : $(`#${$this.data('option')}`).hide(); - const $sibling = $this.siblings('label'); - $sibling.children('input[type=checkbox]').prop('checked', false); - $(`#${$sibling.data('option')}`).hide(); - }); - $('.directorist_pricing_options label').on( 'click', function () { - const self = $( this ); + /** + * Price field. + */ + // if ( $( '.directorist-form-pricing-field' ).hasClass( 'price-type-both' ) ) { + // $('#price, #price_range').hide(); + // } + + // $( '.directorist_pricing_options label' ).on( 'click', function() { + // const $this = $(this); + // $this.children('input[type=checkbox]').prop('checked') == true + // ? $(`#${$this.data('option')}`).show() + // : $(`#${$this.data('option')}`).hide(); + // const $sibling = $this.siblings('label'); + // $sibling.children('input[type=checkbox]').prop('checked', false); + // $(`#${$sibling.data('option')}`).hide(); + // } ); - const current_input = self.attr( 'for' ); - const current_field = `#${self.data('option')}`; + // $('.directorist_pricing_options label').on( 'click', function () { + // const self = $( this ); - $( '.directorist_pricing_options input[type=checkbox]' ).prop( 'checked', false ); - $( '.directorist_pricing_options input[id='+ current_input +']' ).attr( 'checked', true ); + // const current_input = self.attr( 'for' ); + // const current_field = `#${self.data('option')}`; - $('.directory_pricing_field').hide(); - $( current_field ).show(); - }); + // $( '.directorist_pricing_options input[type=checkbox]' ).prop( 'checked', false ); + // $( '.directorist_pricing_options input[id='+ current_input +']' ).attr( 'checked', true ); + + // $('.directory_pricing_field').hide(); + // $( current_field ).show(); + // }); $('#atbd_optional_field_check').on('change', function () { $(this).is(':checked') ? @@ -734,36 +738,60 @@ $( fields_elm[ field ].elm ).val( fields_elm[ field ].default ); }); function assetsNeedToWorkInVirtualDom() { - // price range - /* $('#price_range').hide(); - const pricing = $('#atbd_listing_pricing').val(); - if (pricing === 'range') { - $('#price').hide(); - $('#price_range').show(); - } */ - - $('.atbd_pricing_options label').on('click', function () { - const $this = $(this); - $this.children('input[type=checkbox]').prop('checked') == true ? - $(`#${$this.data('option')}`).show() : - $(`#${$this.data('option')}`).hide(); - const $sibling = $this.siblings('label'); - $sibling.children('input[type=checkbox]').prop('checked', false); - $(`#${$sibling.data('option')}`).hide(); - }); + function getPriceTypeInput(typeId) { + return $(`#${$(`[for="${typeId}"]`).data('option')}`); + } - $('.directorist_pricing_options label').on('click', function () { - const self = $(this); + $( '.directorist-form-pricing-field__options' ).on( 'change', 'input', function() { + const $otherOptions = $(this).parent().siblings('.directorist-checkbox').find( 'input' ); - const current_input = self.attr('for'); - const current_field = `#${self.data('option')}`; + $otherOptions.prop( 'checked', false ); + getPriceTypeInput( $otherOptions.attr('id') ).hide(); - $('.directorist_pricing_options input[type=checkbox]').prop('checked', false); - $('.directorist_pricing_options input[id=' + current_input + ']').attr('checked', true); + if ( this.checked ) { + getPriceTypeInput( this.id ).show(); + } else { + getPriceTypeInput( this.id ).hide(); + } + } ); - $('.directory_pricing_field').hide(); - $(current_field).show(); - }); + // Must be placed after the event listener. + if ( $( '.directorist-form-pricing-field' ).hasClass( 'price-type-both' ) ) { + $( '#price_range, #price' ).hide(); + + const $selectedPriceType = $( '.directorist-form-pricing-field__options input:checked' ); + + if ( $selectedPriceType.length ) { + getPriceTypeInput( $selectedPriceType.attr( 'id' ) ).show(); + } else { + $( $( '.directorist-form-pricing-field__options input' ).get(0) ) + .prop( 'checked', true ) + .trigger( 'change' ); + } + } + + // $('.atbd_pricing_options label').on('click', function () { + // const $this = $(this); + // $this.children('input[type=checkbox]').prop('checked') == true ? + // $(`#${$this.data('option')}`).show() : + // $(`#${$this.data('option')}`).hide(); + // const $sibling = $this.siblings('label'); + // $sibling.children('input[type=checkbox]').prop('checked', false); + // $(`#${$sibling.data('option')}`).hide(); + // }); + + // $('.directorist_pricing_options label').on('click', function () { + // const self = $(this); + + // const current_input = self.attr('for'); + // const current_field = `#${self.data('option')}`; + + // $('.directorist_pricing_options input[type=checkbox]').prop('checked', false); + // $('.directorist_pricing_options input[id=' + current_input + ']').attr('checked', true); + + // $('.directory_pricing_field').hide(); + // $(current_field).show(); + // }); let imageUpload; if (imageUpload) { diff --git a/assets/src/js/global/add-listing.js b/assets/src/js/global/add-listing.js index 63392207f9..eb9bb881ab 100644 --- a/assets/src/js/global/add-listing.js +++ b/assets/src/js/global/add-listing.js @@ -220,22 +220,39 @@ $(document).ready(function () { } - // price range - if ($('.directorist-form-pricing-field').hasClass('price-type-both')) { - $('#price').show(); - $('#price_range').hide(); + /** + * Price field. + */ + function getPriceTypeInput(typeId) { + return $(`#${$(`[for="${typeId}"]`).data('option')}`); } - $('.directorist-form-pricing-field__options .directorist-checkbox__label').on('click', function () { - const $this = $(this); - if ($this.parent('.directorist-checkbox').children('input[type=checkbox]').prop('checked') === true) { - $(`#${$this.data('option')}`).hide(); + + $( '.directorist-form-pricing-field__options' ).on( 'change', 'input', function() { + const $otherOptions = $(this).parent().siblings('.directorist-checkbox').find( 'input' ); + + $otherOptions.prop( 'checked', false ); + getPriceTypeInput( $otherOptions.attr('id') ).hide(); + + if ( this.checked ) { + getPriceTypeInput( this.id ).show(); } else { - $(`#${$this.data('option')}`).show(); + getPriceTypeInput( this.id ).hide(); } - const $sibling = $this.parent().siblings('.directorist-checkbox'); - $sibling.children('input[type=checkbox]').prop('checked', false); - $(`#${$sibling.children('.directorist-checkbox__label').data('option')}`).hide(); - }); + } ); + + if ( $( '.directorist-form-pricing-field' ).hasClass( 'price-type-both' ) ) { + $( '#price_range, #price' ).hide(); + + const $selectedPriceType = $( '.directorist-form-pricing-field__options input:checked' ); + + if ( $selectedPriceType.length ) { + getPriceTypeInput( $selectedPriceType.attr( 'id' ) ).show(); + } else { + $( $( '.directorist-form-pricing-field__options input' ).get(0) ) + .prop( 'checked', true ) + .trigger( 'change' ); + } + } const has_tagline = $('#has_tagline').val(); const has_excerpt = $('#has_excerpt').val(); @@ -507,7 +524,7 @@ $(document).ready(function () { success( response ) { if ( ! response.success ) { enableSubmitButton() - + $notification.show().html(`${response.data}`); return; @@ -516,7 +533,7 @@ $(document).ready(function () { uploadedImages.push( response.data ); counter++; - + if ( counter < selectedImages.length ) { uploadImage(); } else { @@ -544,27 +561,27 @@ $(document).ready(function () { var error_count = 0; var err_log = {}; let form_data = new FormData(); - + form_data.append('action', 'add_listing_action'); form_data.append('directorist_nonce', directorist.directorist_nonce); form_data.append('listing_img', uploadedImages ); - + disableSubmitButton(); - + const fieldValuePairs = $form.serializeArray(); - + // Append Form Fields Values for ( const field of fieldValuePairs ) { form_data.append( field.name, field.value ); } - + //images if (mediaUploaders.length) { for (var uploader of mediaUploaders) { if (!uploader.media_uploader || $(uploader.media_uploader.container).parents('form').get(0) !== $form.get(0)) { continue; } - + if (uploader.media_uploader.hasValidFiles()) { var files_meta = uploader.media_uploader.getFilesMeta(); if (files_meta) { @@ -576,16 +593,16 @@ $(document).ready(function () { err_log.listing_gallery = { msg: uploader.uploaders_data['error_msg'] }; - + error_count++; - + if ($('.' + uploader.uploaders_data.element_id).length) { scrollTo('.' + uploader.uploaders_data.element_id); } } } } - + // categories const categories = $form.find('#at_biz_dir-categories').val(); if ( Array.isArray( categories ) && categories.length ) { @@ -593,30 +610,30 @@ $(document).ready(function () { form_data.append('tax_input[at_biz_dir-category][]', categories[key]); } } - + if ( typeof categories === 'string' ) { form_data.append('tax_input[at_biz_dir-category][]', categories); } - + if( form_data.has( 'admin_category_select[]') ) { form_data.delete( 'admin_category_select[]' ); } - + if( form_data.has( 'directory_type') ) { form_data.delete( 'directory_type' ); } - + var form_directory_type = $form.find( "input[name='directory_type']" ); - + var form_directory_type_value = form_directory_type !== undefined ? form_directory_type.val() : ''; var directory_type = qs.directory_type ? qs.directory_type : form_directory_type_value; - + form_data.append('directory_type', directory_type); - + if (qs.plan) { form_data.append('plan_id', qs.plan); } - + if (error_count) { enableSubmitButton(); @@ -641,33 +658,33 @@ $(document).ready(function () { success(response) { var redirect_url = ( response && response.redirect_url ) ? response.redirect_url : ''; redirect_url = ( redirect_url && typeof redirect_url === 'string' ) ? response.redirect_url.replace( /:\/\//g, '%3A%2F%2F' ) : ''; - + if (response.error === true) { enableSubmitButton(); - + $notification.show().html(`${response.error_msg}`); - + if (response.quick_login_required) { var modal = $('#directorist-quick-login'); var email = response.email; - + // Prepare fields modal.find('input[name="email"]').val(email); modal.find('input[name="email"]').prop('disabled', true); - + // Show alert var alert = '
    ' + response.error_msg + '
    '; modal.find('.directorist-modal-alerts-area').html(alert); - + // Show the modal modal.addClass('show'); - + quick_login_modal__success_callback = function (args) { $('#guest_user_email').prop('disabled', true); $notification.hide().html(''); - + args.elements.submit_button.remove(); - + var form_actions = args.elements.form.find('.directorist-form-actions'); form_actions.find('.directorist-toggle-modal').removeClass('directorist-d-none'); } @@ -679,9 +696,9 @@ $(document).ready(function () { $notification .show() .html(`${response.success_msg}`); - + window.location.href = joinQueryString( response.preview_url, `preview=1&redirect=${redirect_url}` ); - + } else { $notification .show() @@ -697,7 +714,7 @@ $(document).ready(function () { window.location.href = joinQueryString( response.preview_url, `preview=1&payment=1&redirect=${redirect_url}` ); } else { const is_edited = response.edited_listing ? `listing_id=${response.id}&edited=1` : ''; - + if (response.need_payment === true) { $notification.show().html(`${response.success_msg}`); window.location.href = decodeURIComponent(redirect_url); diff --git a/includes/fields/class-directorist-pricing-field.php b/includes/fields/class-directorist-pricing-field.php index d8eb070bb1..762d7c0afc 100644 --- a/includes/fields/class-directorist-pricing-field.php +++ b/includes/fields/class-directorist-pricing-field.php @@ -14,6 +14,10 @@ class Pricing_Field extends Base_Field { public $type = 'pricing'; public function get_value( $posted_data ) { + if ( $this->get_price_type_prop() !== 'both' ) { + $posted_data['atbd_listing_pricing'] = $this->get_price_type_prop(); + } + if ( ! isset( $posted_data['atbd_listing_pricing'] ) && ( isset( $posted_data['price'] ) || isset( $posted_data['price_range'] ) ) ) { return array(); } @@ -50,6 +54,18 @@ protected function get_price_types() { protected function get_price_ranges() { return array( 'skimming', 'moderate', 'economy', 'bellow_economy' ); } + + protected function get_price_type_prop() { + $pricing_type = $this->__get( 'pricing_type' ); + + if ( $pricing_type === 'price_unit' ) { + return 'price'; + } elseif ( $pricing_type === 'price_range' ) { + return 'range'; + } else { + return 'both'; + } + } } Fields::register( new Pricing_Field() ); diff --git a/templates/listing-form/fields/pricing.php b/templates/listing-form/fields/pricing.php index 65c412d0c0..e2521be322 100644 --- a/templates/listing-form/fields/pricing.php +++ b/templates/listing-form/fields/pricing.php @@ -7,87 +7,46 @@ if ( ! defined( 'ABSPATH' ) ) exit; -$p_id = $listing_form->get_add_listing_id(); -$price = get_post_meta( $p_id, '_price', true ); -$price_range = get_post_meta( $p_id, '_price_range', true ); -$atbd_listing_pricing = get_post_meta( $p_id, '_atbd_listing_pricing', true ); -$price_placeholder = $data['price_unit_field_placeholder']; -$price_range_placeholder = $data['price_range_placeholder']; +$listing_id = $listing_form->get_add_listing_id(); +$price = get_post_meta( $listing_id, '_price', true ); +$price_range = get_post_meta( $listing_id, '_price_range', true ); +$price_type = get_post_meta( $listing_id, '_atbd_listing_pricing', true ); $allow_decimal = get_directorist_option( 'allow_decimal', 1 ); -$currency = directorist_get_currency(); -$c_symbol = atbdp_currency_symbol( $currency ); -$current_price_type = ''; -?> +$currency_symbol = atbdp_currency_symbol( directorist_get_currency() ); +?>
    - field_label_template( $data ); ?> - - - - - - -
    - + +
    - > + >
    - - + +
    - > - + > +
    - -
    +
    + - - - + + - if ( $data['pricing_type'] == 'both' || $data['pricing_type'] == 'price_range' ) { - ?> + - - -
    \ No newline at end of file + +