PluginProbe
Property Hive / 1.4.62
Property Hive v1.4.62
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / assets / js / frontend / search.js

search.js in Property Hive 1.4.62, at assets/js/frontend/search.js

148 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 function 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
39 if (selected.length > 0)
40 {
41 selectedDepartment = selected.val();
42
43 // controls won't always be display:block so we should get the
44 // first visible component (that isnt sales/lettings-only) and
45 // use that display
46 var display = 'block';
47 var found = false;
48 jQuery(this).find('.control').each(function()
49 {
50 if (!jQuery(this).hasClass('.sales-only') && !jQuery(this).hasClass('.lettings-only') && !jQuery(this).hasClass('.residential-only') && !jQuery(this).hasClass('.commercial-only') && jQuery(this).css('display') != 'none')
51 {
52 display = jQuery(this).css('display');
53 found = true;
54 }
55 });
56
57 if (found == false)
58 {
59 if (jQuery(this).css('display') == 'table')
60 {
61 display = 'table-cell';
62 }
63 }
64
65 if (selectedDepartment == 'residential-sales')
66 {
67 jQuery(this).find('.sales-only').css('display', display);
68 jQuery(this).find('.residential-only').css('display', display);
69 }
70 else if (selectedDepartment == 'residential-lettings')
71 {
72 jQuery(this).find('.lettings-only').css('display', display);
73 jQuery(this).find('.residential-only').css('display', display);
74 }
75 else if (selectedDepartment == 'commercial')
76 {
77 jQuery(this).find('.commercial-only').css('display', display);
78 }
79
80 if ( jQuery(this).find('[name=\'availability\']').length > 0 && typeof availability_departments !== "undefined" )
81 {
82 if ( Object.keys(availability_departments).length > 0 )
83 {
84 jQuery(this).find('[name=\'availability\']').empty();
85
86 for ( var i in availabilities_order )
87 {
88 var availability_id = availabilities_order[i];
89 var availability_text = availabilities[availabilities_order[i]];
90
91 var this_availability_departments = [];
92 var availability_departments_exist = true;
93 if ( typeof availability_departments[availability_id] !== 'undefined' )
94 {
95 this_availability_departments = availability_departments[availability_id];
96 }
97 else
98 {
99 availability_departments_exist = false;
100 }
101
102 if ( jQuery.inArray( selectedDepartment, this_availability_departments ) > -1 || !availability_departments_exist )
103 {
104 jQuery(this).find('[name=\'availability\']').append( jQuery("<option />").val(availability_id).text(availability_text) );
105 }
106 jQuery(this).find('[name=\'availability\']').val(selected_availability);
107 }
108 if ( jQuery(this).find('[name=\'availability\']').val() == '' || jQuery(this).find('[name=\'availability\']').val() == null )
109 {
110 jQuery(this).find('[name=\'availability\']').val( jQuery(this).find('[name=\'availability\'] option:first').val() );
111 }
112 }
113 }
114 }
115 });
116 }
117 }
118
119 jQuery( function(jQuery){
120
121 // Orderby
122 jQuery( '.propertyhive-ordering' ).on( 'change', 'select.orderby', function() {
123 jQuery( this ).closest( 'form' ).submit();
124 });
125
126 toggleDepartmentFields();
127
128 jQuery('form.property-search-form [name=\'department\']').change(function()
129 {
130 toggleDepartmentFields();
131 });
132
133 if ( jQuery('form.property-search-form select.ph-form-multiselect').length > 0 )
134 {
135 jQuery('form.property-search-form select.ph-form-multiselect').each(function()
136 {
137 jQuery(this).multiselect({
138 texts: {
139 placeholder: jQuery(this).data('blank-option')
140 }
141 });
142 });
143 }
144 });
145
146 jQuery(window).resize(function() {
147 toggleDepartmentFields();
148 });