1function toggleDepartmentFields() 2{ 3 if (jQuery('form.property-search-form').length > 0) 4 { 5 // There may be multiple forms on the page so treat each one individually 6 jQuery('form.property-search-form').each(function() 7 { 8 var selectedDepartment = "residential-sales"; // TODO: Use default from settings 9 10 var selected; 11 12 var departmentEl = jQuery(this).find('[name=\'department\']') 13 if (departmentEl.length > 0) 14 { 15 switch (departmentEl.prop('tagName').toLowerCase()) 16 { 17 case "select": 18 { 19 selected = departmentEl; 20 break; 21 } 22 default: 23 { 24 if ( departmentEl.attr('type') == 'hidden' ) 25 { 26 selected = departmentEl; 27 } 28 else 29 { 30 selected = departmentEl.filter(':checked'); 31 } 32 } 33 } 34 } 35 36 jQuery(this).find('.sales-only').hide(); 37 jQuery(this).find('.lettings-only').hide(); 38 jQuery(this).find('.residential-only').hide(); 39 jQuery(this).find('.commercial-only').hide(); 40 jQuery(this).find('.commercial-sales-only').hide(); 41 jQuery(this).find('.commercial-lettings-only').hide(); 42 43 if (selected && selected.length > 0) 44 { 45 selectedDepartment = selected.val(); 46 47 // controls won't always be display:block so we should get the 48 // first visible component (that isnt sales/lettings-only) and 49 // use that display 50 var display = 'block'; 51 var found = false; 52 jQuery(this).find('.control').each(function() 53 { 54 if (!jQuery(this).hasClass('.sales-only') && !jQuery(this).hasClass('.lettings-only') && !jQuery(this).hasClass('.residential-only') && !jQuery(this).hasClass('.commercial-only') && !jQuery(this).hasClass('.commercial-sales-only') && !jQuery(this).hasClass('.commercial-lettings-only') && jQuery(this).css('display') != 'none') 55 { 56 display = jQuery(this).css('display'); 57 found = true; 58 } 59 }); 60 61 if (found == false) 62 { 63 if (jQuery(this).css('display') == 'table') 64 { 65 display = 'table-cell'; 66 } 67 } 68 69 if ( selectedDepartment == 'residential-sales' || ( propertyhive_search_params.custom_departments[selectedDepartment] && propertyhive_search_params.custom_departments[selectedDepartment].based_on == 'residential-sales' ) ) 70 { 71 jQuery(this).find('.sales-only').css('display', display); 72 jQuery(this).find('.residential-only').css('display', display); 73 } 74 else if ( selectedDepartment == 'residential-lettings' || ( propertyhive_search_params.custom_departments[selectedDepartment] && propertyhive_search_params.custom_departments[selectedDepartment].based_on == 'residential-lettings' )) 75 { 76 jQuery(this).find('.lettings-only').css('display', display); 77 jQuery(this).find('.residential-only').css('display', display); 78 } 79 else if ( selectedDepartment == 'commercial' || ( propertyhive_search_params.custom_departments[selectedDepartment] && propertyhive_search_params.custom_departments[selectedDepartment].based_on == 'commercial' ) ) 80 { 81 jQuery(this).find('.commercial-only').css('display', display); 82 jQuery(this).find('.commercial-sales-only').css('display', 'none'); 83 jQuery(this).find('.commercial-lettings-only').css('display', 'none'); 84 85 if ( jQuery(this).find('[name=\'commercial_for_sale_to_rent\']').length > 0 ) 86 { 87 var commercial_for_sale_to_rent = jQuery(this).find('[name=\'commercial_for_sale_to_rent\']').val(); 88 89 if ( commercial_for_sale_to_rent == 'for_sale' ) 90 { 91 jQuery(this).find('.commercial-sales-only').css('display', display); 92 jQuery(this).find('.commercial-lettings-only').css('display', 'none'); 93 } 94 if ( commercial_for_sale_to_rent == 'to_rent' ) 95 { 96 jQuery(this).find('.commercial-sales-only').css('display', 'none'); 97 jQuery(this).find('.commercial-lettings-only').css('display', display); 98 } 99 } 100 } 101 102 if ( jQuery(this).find('[name=\'availability\']').length > 0 && typeof availability_departments !== "undefined" ) 103 { 104 if ( Object.keys(availability_departments).length > 0 ) 105 { 106 jQuery(this).find('[name=\'availability\']').empty(); 107 108 for ( var i in availabilities_order ) 109 { 110 var availability_id = availabilities_order[i]; 111 var availability_text = availabilities[availabilities_order[i]].label; 112 113 var this_availability_departments = []; 114 var availability_departments_exist = true; 115 116 if ( typeof availability_departments[availability_id] !== 'undefined' ) 117 { 118 this_availability_departments = availability_departments[availability_id]; 119 } 120 else 121 { 122 availability_departments_exist = false;
123 } 124 125 if ( availability_id == '' || jQuery.inArray( selectedDepartment, this_availability_departments ) > -1 || !availability_departments_exist ) 126 { 127 jQuery(this).find('[name=\'availability\']').append( jQuery("<option />").val(availability_id).text(availability_text) ); 128 } 129 jQuery(this).find('[name=\'availability\']').val(selected_availability); 130 } 131 if ( jQuery(this).find('[name=\'availability\']').val() == '' || jQuery(this).find('[name=\'availability\']').val() == null ) 132 { 133 jQuery(this).find('[name=\'availability\']').val( jQuery(this).find('[name=\'availability\'] option:first').val() ); 134 } 135 } 136 } 137 138 jQuery(this).trigger('ph:toggleSearchDepartment', [selectedDepartment]); 139 } 140 }); 141 } 142} 143 144jQuery( function(jQuery){ 145 146 // Orderby 147 jQuery( '.propertyhive-ordering' ).on( 'change', 'select.orderby', function() { 148 jQuery( this ).closest( 'form' ).submit(); 149 }); 150 151 toggleDepartmentFields(); 152 153 jQuery('body').on('change', 'form.property-search-form [name=\'department\']', function() 154 { 155 toggleDepartmentFields(); 156 }); 157 158 jQuery('body').on('change', 'form.property-search-form [name=\'commercial_for_sale_to_rent\']', function() 159 { 160 toggleDepartmentFields(); 161 }); 162 163 if ( jQuery('form.property-search-form select.ph-form-multiselect').length > 0 ) 164 { 165 jQuery('form.property-search-form select.ph-form-multiselect').each(function() 166 { 167 jQuery(this).multiselect({ 168 texts: { 169 placeholder: jQuery(this).data('blank-option') 170 } 171 }); 172 }); 173 } 174}); 175 176jQuery(window).resize(function() { 177 toggleDepartmentFields(); 178}); 179 180let ph_turnstile_widgets = {}; // store widget IDs so we can reset later 181function ph_init_turnstile() 182{ 183 const widgets = document.querySelectorAll('.turnstile'); 184 185 widgets.forEach(el => { 186 // If the widget has already been rendered once: 187 if ( ph_turnstile_widgets[el.dataset.tsId] ) 188 { 189 // Only reset if element is visible 190 if ( el.offsetParent !== null ) 191 { 192 turnstile.reset(ph_turnstile_widgets[el.dataset.tsId]); 193 } 194 return; 195 } 196 197 // Only render if the element is actually visible 198 if ( el.offsetParent === null ) 199 { 200 return; // skip hidden ones (e.g., in closed modal) 201 } 202 203 // Create a unique ID for this element 204 const id = Math.random().toString(36).substring(2); 205 el.dataset.tsId = id; 206 207 // Render Turnstile widget 208 ph_turnstile_widgets[id] = turnstile.render(el, { 209 sitekey: el.dataset.sitekey, 210 callback: (token) => { 211 console.log("Turnstile token:", token); 212 } 213 }); 214 }); 215} 216 217jQuery(document).on('afterShow.fb', function(e, instance, slide) { 218 ph_init_turnstile(); 219}); 220 221jQuery(window).resize(function() 222{ 223 ph_template_assistant_set_image_heights(); 224}); 225 226jQuery(document).ready(function() 227{ 228 ph_template_assistant_set_image_heights(); 229}); 230 231jQuery(window).on('load', function() 232{ 233 ph_template_assistant_set_image_heights(); 234}); 235 236function ph_template_assistant_set_image_heights() 237{ 238 if ( propertyhive_search_params.hasOwnProperty('do_image_resize') && propertyhive_search_params.do_image_resize === '1' ) 239 { 240 241 } 242 else 243 { 244 return; 245 } 246 247 jQuery('.propertyhive ul.properties > li').height('auto'); 248 jQuery('.propertyhive ul.properties > li .thumbnail img').height('auto'); 249 250 // Check the top pos of the first and second and check if they're the same. 251 // This will tell us if we're in a grid or not 252 if ( 253 jQuery('.propertyhive ul.properties > li' ).eq(0).length > 0 && 254 jQuery('.propertyhive ul.properties > li' ).eq(1).length > 0 && 255 Math.round(jQuery('.propertyhive ul.properties > li' ).eq(0).offset().top) == Math.round(jQuery('.propertyhive ul.properties > li' ).eq(1).offset().top) 256 ) 257 { 258 // Make the images the same height 259 jQuery('.propertyhive ul.properties > li .thumbnail img').each(function() 260 { 261 var ratio = 2 / 3; 262 if ( propertyhive_search_params.hasOwnProperty('image_ratio') ) 263 { 264 ratio = propertyhive_search_params.image_ratio; 265 } 266 jQuery(this).height( jQuery(this).width() * ratio ); 267 }); 268 269 // Make the properties on each row the same height 270 var row = 0; 271 var previousTop = 0; 272 var maxRowHeight = 0; 273 var elements_in_row = new Array; 274 jQuery('.propertyhive ul.properties > li').each(function() 275 { 276 var this_top = jQuery(this).offset().top; 277 var this_height = jQuery(this).height(); 278 if (maxRowHeight != 0 && Math.round(this_top) != Math.round(previousTop)) 279 { 280 // we're on a new row 281 jQuery(elements_in_row).each(function() 282 { 283 jQuery(this).height(maxRowHeight); 284 }); 285 286 row = row + 1; 287 maxRowHeight = 0; 288 previousTop = 0; 289 elements_in_row = new Array; 290 } 291 292 if (this_height > maxRowHeight) 293 { 294 maxRowHeight = this_height; 295 } 296 297 elements_in_row.push(jQuery(this)); 298 299 previousTop = Math.round(this_top); 300 }); 301 jQuery(elements_in_row).each(function() 302 { 303 jQuery(this).height(maxRowHeight); 304 }); 305 } 306}
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.