PluginProbe
Property Hive / 1.4.53
Property Hive v1.4.53
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 1.4.62 All 260 releases
propertyhive / assets / js / admin / settings.js

settings.js in Property Hive 1.4.53, at assets/js/admin/settings.js

197 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery( function($){
2
3 $('input.colorpick').wpColorPicker();
4
5 $('form').submit(function()
6 {
7 // Check for confirm removal checkbox
8 // and make sure it's ticked
9 if ( $('input[type=\'checkbox\'][name=\'confirm_removal\']').length > 0 )
10 {
11 if ( !$('input[type=\'checkbox\'][name=\'confirm_removal\']').is( ":checked" ) )
12 {
13 alert( propertyhive_admin_settings.confirm_not_selected_warning );
14 return false;
15 }
16 }
17
18 // Make sure a department has been ticked
19 if ( $('input[type=\'checkbox\'][name^=\'propertyhive_active_departments_\']').length > 0 )
20 {
21 var department_ticked = false;
22 $('input[type=\'checkbox\'][name^=\'propertyhive_active_departments_\']').each(function()
23 {
24 if ( $(this).is( ":checked" ) )
25 {
26 department_ticked = true;
27 }
28 });
29
30 if ( !department_ticked )
31 {
32 alert( propertyhive_admin_settings.no_departments_selected_warning );
33 return false;
34 }
35
36 // Make sure primary department is in the list of ticked departments
37 var selected_primary_department = $("input[type=\'radio\'][name=\'propertyhive_primary_department\']:checked").val();
38 selected_primary_department = selected_primary_department.replace("residential-", "");
39 if ( !$('input[type=\'checkbox\'][name=\'propertyhive_active_departments_' + selected_primary_department + '\']').is( ":checked" ) )
40 {
41 alert( propertyhive_admin_settings.primary_department_not_active_warning );
42 return false;
43 }
44 }
45
46 // Validate disabled modules
47 if ( $('input[type=\'checkbox\'][name^=\'propertyhive_module_disabled_\']').length > 0 )
48 {
49 if (
50 $('input[type=\'checkbox\'][name=\'propertyhive_module_disabled_contacts\']').is( ":checked" ) &&
51 (
52 !$('input[type=\'checkbox\'][name=\'propertyhive_module_disabled_viewings\']').is( ":checked" ) ||
53 !$('input[type=\'checkbox\'][name=\'propertyhive_module_disabled_offers_sales\']').is( ":checked" )
54 )
55 )
56 {
57 alert( 'The contacts module must be enabled in order to use the viewings, offers and sales modules' );
58 return false;
59 }
60 };
61
62 if ( $('select[name=\'propertyhive_default_country\']').length > 0 )
63 {
64 // Make sure default country is in list of selected countries
65 var selected_countries = $('select[name=\'propertyhive_countries[]\']').val();
66 if ( selected_countries == null )
67 {
68 alert( propertyhive_admin_settings.no_countries_selected );
69 return false;
70 }
71 var default_country = $('select[name=\'propertyhive_default_country\']').val();
72 var default_in_selected = false;
73 for ( var i in selected_countries )
74 {
75 if ( default_country == selected_countries[i] )
76 {
77 default_in_selected = true;
78 }
79 }
80 if ( !default_in_selected )
81 {
82 alert( propertyhive_admin_settings.default_country_not_in_selected );
83 return false;
84 }
85 }
86
87 // Disable submit button when form is being submitted to prevent double submissions
88 $('p.submit input[type=\'submit\']').attr('disabled', 'disabled');
89 });
90
91 $('a.batch-delete').click(function()
92 {
93 var term_ids = new Array;
94
95 $('input[name=\'term_id[]\']:checked').each(function()
96 {
97 term_ids.push( $(this).val() );
98 });
99
100 if ( term_ids.length > 0 )
101 {
102 window.location.href = propertyhive_admin_settings.admin_url + 'admin.php?page=ph-settings&tab=customfields&section=' + propertyhive_admin_settings.taxonomy_section + '-delete&id=' + term_ids.join("-");
103 }
104
105 return false;
106 });
107
108 $('input[name=\'term_id[]\']').change(function()
109 {
110 if ( $('input[name=\'term_id[]\']:checked').length > 0 )
111 {
112 $('a.batch-delete').attr('disabled', false);
113 }
114 else
115 {
116 $('a.batch-delete').attr('disabled', 'disabled');
117 }
118 });
119
120 jQuery('select[name=\'propertyhive_countries[]\']').change(function()
121 {
122 fill_search_form_currency_options();
123 });
124 fill_search_form_currency_options();
125
126 jQuery('input[name^=\'propertyhive_active_departments\']').change(function()
127 {
128 toggle_department_specific_options();
129 });
130 toggle_department_specific_options();
131 });
132
133 function fill_search_form_currency_options()
134 {
135 var selected_countries = jQuery('select[name=\'propertyhive_countries[]\']').val();
136 var selected_currency = jQuery('#propertyhive_search_form_currency').val();
137
138 var new_currency_options = new Array();
139
140 for ( var i in selected_countries)
141 {
142 var country = countries[selected_countries[i]];
143
144 new_currency_options.push( country.currency_code );
145 }
146
147 jQuery('#propertyhive_search_form_currency').find('option').remove();
148 if ( new_currency_options.length > 0 )
149 {
150 new_currency_options = jQuery.unique( new_currency_options );
151
152 /*new_currency_options.sort(function(a, b) {
153 var a1 = a.new_currency_options, b1 = b.new_currency_options;
154 if(a1 == b1) return 0;
155 return a1 > b1 ? 1 : -1;
156 });*/
157
158 for ( var i in new_currency_options)
159 {
160 jQuery('#propertyhive_search_form_currency').append('<option value="' + new_currency_options[i] + '">' + new_currency_options[i] + '</option>');
161 }
162 jQuery('#propertyhive_search_form_currency').val(selected_currency);
163
164 if ( new_currency_options.length > 1 )
165 {
166 jQuery('#propertyhive_search_form_currency').parent().parent().show();
167 }
168 else
169 {
170 jQuery('#propertyhive_search_form_currency').parent().parent().hide();
171 }
172
173 if ( jQuery("#propertyhive_search_form_currency :selected").length == 0 )
174 {
175 jQuery("#propertyhive_search_form_currency").val( jQuery("#propertyhive_search_form_currency option:first").val() );
176
177 }
178 }
179 }
180
181 function toggle_department_specific_options()
182 {
183 jQuery('#row_propertyhive_lettings_fees').hide();
184 jQuery('#row_propertyhive_lettings_fees_commercial').hide();
185 jQuery('#row_propertyhive_lettings_fees_display_search_results').hide();
186
187 if (jQuery('#propertyhive_active_departments_lettings').prop('checked') == true)
188 {
189 jQuery('#row_propertyhive_lettings_fees').show();
190 jQuery('#row_propertyhive_lettings_fees_display_search_results').show();
191 }
192 if (jQuery('#propertyhive_active_departments_commercial').prop('checked') == true)
193 {
194 jQuery('#row_propertyhive_lettings_fees_commercial').show();
195 jQuery('#row_propertyhive_lettings_fees_display_search_results').show();
196 }
197 }