PluginProbe
Property Hive / 1.4.56
Property Hive v1.4.56
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.56, at assets/js/frontend/search.js

113 lines 4.0 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 });
81 }
82 }
83
84 jQuery( function(jQuery){
85
86 // Orderby
87 jQuery( '.propertyhive-ordering' ).on( 'change', 'select.orderby', function() {
88 jQuery( this ).closest( 'form' ).submit();
89 });
90
91 toggleDepartmentFields();
92
93 jQuery('form.property-search-form [name=\'department\']').change(function()
94 {
95 toggleDepartmentFields();
96 });
97
98 if ( jQuery('form.property-search-form select.ph-form-multiselect').length > 0 )
99 {
100 jQuery('form.property-search-form select.ph-form-multiselect').each(function()
101 {
102 jQuery(this).multiselect({
103 texts: {
104 placeholder: jQuery(this).data('blank-option')
105 }
106 });
107 });
108 }
109 });
110
111 jQuery(window).resize(function() {
112 toggleDepartmentFields();
113 });