PageSourceSearch

https://www.takasho-studio.jp/tkss/wp-content/themes/realhomes/ass…/js/inspiry-search-form.js?ver=4.3.6

js takasho-studio.jp collected 2026-10-04 19:50:49 UTC 7,499 bytes, 222 lines download raw bytes

1/**
2 * JavaScript Related to Search Form
3 */
4(function ($) {
5	"use strict";
6
7	/**
8	 * Change Min and Max Price fields based on selected status for rent
9	 */
10	if ( localizedSearchParams.rent_slug !== undefined) {
11
12		var property_status_changed = function (new_status) {
13			var price_for_others = $('.advance-search-form .price-for-others');
14			var price_for_rent = $('.advance-search-form .price-for-rent');
15			if (price_for_others.length > 0 && price_for_rent.length > 0) {
16				if (new_status == localizedSearchParams.rent_slug) {
17					price_for_others.addClass('hide-fields').find('select').prop('disabled', true);
18					price_for_rent.removeClass('hide-fields').find('select').prop('disabled', false);
19				} else {
20					price_for_rent.addClass('hide-fields').find('select').prop('disabled', true);
21					price_for_others.removeClass('hide-fields').find('select').prop('disabled', false);
22				}
23			}
24		}
25		$('.advance-search-form #select-status').change(function (e) {
26			var selected_status = $(this).val();
27			property_status_changed(selected_status);
28		});
29
30		/* On page load ( as on search page ) */
31		var selected_status = $('.advance-search-form #select-status').val();
32		if (selected_status == localizedSearchParams.rent_slug) {
33			property_status_changed(selected_status);
34		}
35	}
36
37	/**
38	 * Max and Min Price
39	 * Shows red outline if min price is bigger than max price
40	 */
41
42	/* for normal prices */
43	$('#select-min-price,#select-max-price').change(function (obj, e) {
44		var min_text_val = $('#select-min-price').val();
45		var min_int_val = (isNaN(min_text_val)) ? 0 : parseInt(min_text_val);
46
47		var max_text_val = $('#select-max-price').val();
48		var max_int_val = (isNaN(max_text_val)) ? 0 : parseInt(max_text_val);
49
50		if ((min_int_val >= max_int_val) && (min_int_val != 0) && (max_int_val != 0)) {
51			$('#select-min-price,#select-max-price').siblings('button.dropdown-toggle').css('outline', '1px solid red');
52		} else {
53			$('#select-min-price,#select-max-price').siblings('button.dropdown-toggle').css('outline', 'none');
54		}
55	});
56
57	/* for rent prices */
58	$('#select-min-price-for-rent, #select-max-price-for-rent').change(function (obj, e) {
59		var min_text_val = $('#select-min-price-for-rent').val();
60		var min_int_val = (isNaN(min_text_val)) ? 0 : parseInt(min_text_val);
61
62		var max_text_val = $('#select-max-price-for-rent').val();
63		var max_int_val = (isNaN(max_text_val)) ? 0 : parseInt(max_text_val);
64
65		if ((min_int_val >= max_int_val) && (min_int_val != 0) && (max_int_val != 0)) {
66			$('#select-min-price-for-rent, #select-max-price-for-rent').siblings('button.dropdown-toggle').css('outline', '1px solid red');
67		} else {
68			$('#select-min-price-for-rent, #select-max-price-for-rent').siblings('button.dropdown-toggle').css('outline', 'none');
69		}
70	});
71
72	/**
73	 * Max and Min Area
74	 * To show red outline if min is bigger than max
75	 */
76	$('#min-area,#max-area').change(function (obj, e) {
77		var min_text_val = $('#min-area').val();
78		var min_int_val = (isNaN(min_text_val)) ? 0 : parseInt(min_text_val);
79
80		var max_text_val = $('#max-area').val();
81		var max_int_val = (isNaN(max_text_val)) ? 0 : parseInt(max_text_val);
82
83		if ((min_int_val >= max_int_val) && (min_int_val != 0) && (max_int_val != 0)) {
84			$('#min-area,#max-area').css('outline', '1px solid red');
85		} else {
86			$('#min-area,#max-area').css('outline', 'none');
87		}
88	});
89
90
91	/**
92	 * Disable empty values on submission to reduce query string size
93	 */
94	$('.advance-search-form').submit(function (event) {
95		var searchFormElements = $(this).find(':input');
96		$.each(searchFormElements, function (index, element) {
97			if (element.value == '' || element.value == 'any') {
98				if (!element.disabled) {
99					element.disabled = true;
100				}
101			}
102		});
103	});
104
105	/**
106	 * Add to compare -- Search Page
107	 */
108	function removeBorder () {
109		let screenWidth = $(window).width();
110		let isRtl = $('body').hasClass('rtl');
111
112		if ((979 < screenWidth && 1200 > screenWidth) || (767 >= screenWidth && 500 <= screenWidth)) {
113			if (!isRtl) {
114				let addToCompareSpan = $('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').length;
115				if (addToCompareSpan) {
116					$('.page-template-template-search .property-item .compare-meta span').css({
117						'border': 'none'
118					});
119
120					$('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').css({
121						'margin-right': '-20px',
122						'border-left': 'none'
123					});
124				}
125			} else {
126				let addToCompareSpan = $('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').length;
127				if (addToCompareSpan) {
128					$('.page-template-template-search .property-item .compare-meta span').css({
129						'border-left': 'none'
130					});
131
132					$('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').css({
133						'margin-left': '-20px',
134						'border-right': 'none',
135						'float': 'left'
136					});
137				}
138			}
139		} else if (500 <= screenWidth) {
140			if (!isRtl) {
141				let addToCompareSpan = $('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').length;
142				if (addToCompareSpan) {
143					$('.page-template-template-search .property-item .compare-meta span:nth-last-child(2)').css({
144						'border': 'none'
145					});
146
147					$('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').css({
148						'margin-right': '-20px',
149						'border-left': '1px solid #dedede'
150					});
151				}
152			} else {
153				let addToCompareSpan = $('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').length;
154				if (addToCompareSpan) {
155					$('.page-template-template-search .property-item .compare-meta span:nth-last-child(2)').css({
156						'border': 'none'
157					});
158
159					$('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').css({
160						'margin-left': '-20px',
161						'border-right': '1px solid #dedede',
162						'float': 'left'
163					});
164				}
165			}
166		} else {
167			if (!isRtl) {
168				let addToCompareSpan = $('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').length;
169				if (addToCompareSpan) {
170					$('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').css({
171						'margin-right': '0',
172						'border-left': 'none'
173					});
174				}
175			} else {
176				let addToCompareSpan = $('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').length;
177				if (addToCompareSpan) {
178					$('.page-template-template-search .property-item .compare-meta span.add-to-compare-span').css({
179						'margin-right': '0',
180						'border-left': 'none',
181						'float': 'right'
182					});
183				}
184			}
185		}
186	}
187	removeBorder();
188	/* Execute again on window resize. */
189	$(window).on('resize', function () {
190		removeBorder();
191	});
192
193
194	/**
195	 * Ajax Search for keyword in Search Form
196	 */
197	$(document).ready(function () {
198		$('#keyword-txt').keyup(function () {
199			var words = $(this).val().split(' ');
200			var wordcounts = words.length;
201			if (wordcounts > 1) {
202				$('.rh_sfoi_data_fetch_list').slideDown();
203				$('.rh_sfoi_ajax_loader').show();
204				$.ajax({
205					url: frontEndAjaxUrl.sfoiajaxurl,
206					type: 'POST',
207					data: {
208						action: 'rh_sfoi_data_fetch',
209						keyword: $(this).val()
210					},
211					success: function (data) {
212						$('.rh_sfoi_data_fetch_list').html(data);
213						$('.rh_sfoi_ajax_loader').hide();
214					}
215				});
216			} else {
217				$('.rh_sfoi_data_fetch_list').slideUp();
218			}
219		});
220	});
221
222})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.