https://www.lurotbrand.co.uk/wp-content/plugins/propertyhive/assets/js/frontend/search.js?ver=2.0.18
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 departmentEl = jQuery(this).find('[name=\'department\']') 11 if (departmentEl.length > 0) 12 { 13 switch (departmentEl.prop('tagName').toLowerCase()) 14 { 15 case "select": 16 { 17 var selected = departmentEl; 18 break; 19 } 20 default: 21 { 22 if ( departmentEl.attr('type') == 'hidden' ) 23 { 24 var selected = departmentEl; 25 } 26 else 27 { 28 var selected = departmentEl.filter(':checked'); 29 } 30 } 31 } 32 } 33 34 jQuery(this).find('.sales-only').hide(); 35 jQuery(this).find('.lettings-only').hide(); 36 jQuery(this).find('.residential-only').hide(); 37 jQuery(this).find('.commercial-only').hide(); 38 jQuery(this).find('.commercial-sales-only').hide(); 39 jQuery(this).find('.commercial-lettings-only').hide(); 40 41 if (selected.length > 0) 42 { 43 selectedDepartment = selected.val(); 44 45 // controls won't always be display:block so we should get the 46 // first visible component (that isnt sales/lettings-only) and 47 // use that display 48 var display = 'block'; 49 var found = false; 50 jQuery(this).find('.control').each(function() 51 { 52 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') 53 { 54 display = jQuery(this).css('display'); 55 found = true; 56 } 57 }); 58 59 if (found == false) 60 { 61 if (jQuery(this).css('display') == 'table') 62 { 63 display = 'table-cell'; 64 } 65 } 66 67 if ( selectedDepartment == 'residential-sales' || ( propertyhive_search_params.custom_departments[selectedDepartment] && propertyhive_search_params.custom_departments[selectedDepartment].based_on == 'residential-sales' ) ) 68 { 69 jQuery(this).find('.sales-only').css('display', display); 70 jQuery(this).find('.residential-only').css('display', display); 71 } 72 else if ( selectedDepartment == 'residential-lettings' || ( propertyhive_search_params.custom_departments[selectedDepartment] && propertyhive_search_params.custom_departments[selectedDepartment].based_on == 'residential-lettings' )) 73 { 74 jQuery(this).find('.lettings-only').css('display', display); 75 jQuery(this).find('.residential-only').css('display', display); 76 } 77 else if ( selectedDepartment == 'commercial' || ( propertyhive_search_params.custom_departments[selectedDepartment] && propertyhive_search_params.custom_departments[selectedDepartment].based_on == 'commercial' ) ) 78 { 79 jQuery(this).find('.commercial-only').css('display', display); 80 jQuery(this).find('.commercial-sales-only').css('display', 'none'); 81 jQuery(this).find('.commercial-lettings-only').css('display', 'none'); 82 83 if ( jQuery(this).find('[name=\'commercial_for_sale_to_rent\']').length > 0 ) 84 { 85 var commercial_for_sale_to_rent = jQuery(this).find('[name=\'commercial_for_sale_to_rent\']').val(); 86 87 if ( commercial_for_sale_to_rent == 'for_sale' ) 88 { 89 jQuery(this).find('.commercial-sales-only').css('display', display); 90 jQuery(this).find('.commercial-lettings-only').css('display', 'none'); 91 } 92 if ( commercial_for_sale_to_rent == 'to_rent' ) 93 { 94 jQuery(this).find('.commercial-sales-only').css('display', 'none'); 95 jQuery(this).find('.commercial-lettings-only').css('display', display); 96 } 97 } 98 } 99 100 if ( jQuery(this).find('[name=\'availability\']').length > 0 && typeof availability_departments !== "undefined" ) 101 { 102 if ( Object.keys(availability_departments).length > 0 ) 103 { 104 jQuery(this).find('[name=\'availability\']').empty(); 105 106 for ( var i in availabilities_order ) 107 { 108 var availability_id = availabilities_order[i]; 109 var availability_text = availabilities[availabilities_order[i]].label; 110 111 var this_availability_departments = []; 112 var availability_departments_exist = true; 113 if ( typeof availability_departments[availability_id] !== 'undefined' ) 114 { 115 this_availability_departments = availability_departments[availability_id]; 116 } 117 else 118 { 119 availability_departments_exist = false;
120 } 121 122 if ( jQuery.inArray( selectedDepartment, this_availability_departments ) > -1 || !availability_departments_exist ) 123 { 124 jQuery(this).find('[name=\'availability\']').append( jQuery("<option />").val(availability_id).text(availability_text) ); 125 } 126 jQuery(this).find('[name=\'availability\']').val(selected_availability); 127 } 128 if ( jQuery(this).find('[name=\'availability\']').val() == '' || jQuery(this).find('[name=\'availability\']').val() == null ) 129 { 130 jQuery(this).find('[name=\'availability\']').val( jQuery(this).find('[name=\'availability\'] option:first').val() ); 131 } 132 } 133 } 134 135 jQuery(this).trigger('ph:toggleSearchDepartment', [selectedDepartment]); 136 } 137 }); 138 } 139} 140 141jQuery( function(jQuery){ 142 143 // Orderby 144 jQuery( '.propertyhive-ordering' ).on( 'change', 'select.orderby', function() { 145 jQuery( this ).closest( 'form' ).submit(); 146 }); 147 148 toggleDepartmentFields(); 149 150 jQuery('body').on('change', 'form.property-search-form [name=\'department\']', function() 151 { 152 toggleDepartmentFields(); 153 }); 154 155 jQuery('body').on('change', 'form.property-search-form [name=\'commercial_for_sale_to_rent\']', function() 156 { 157 toggleDepartmentFields(); 158 }); 159 160 if ( jQuery('form.property-search-form select.ph-form-multiselect').length > 0 ) 161 { 162 jQuery('form.property-search-form select.ph-form-multiselect').each(function() 163 { 164 jQuery(this).multiselect({ 165 texts: { 166 placeholder: jQuery(this).data('blank-option') 167 } 168 }); 169 }); 170 } 171}); 172 173jQuery(window).resize(function() { 174 toggleDepartmentFields(); 175});
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.