';
- 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("
"));
-
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("
"));
-
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() );
+?>
\ No newline at end of file
+
+