PluginProbe
Property Hive / 1.4.60
Property Hive v1.4.60
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 / admin / settings.js

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

215 lines 7.6 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 $('[name=\'propertyhive_auto_incremental_reference_numbers\']').change(function()
133 {
134 ph_toggle_auto_incremental_reference_number_options();
135 });
136 ph_toggle_auto_incremental_reference_number_options();
137 });
138
139 function ph_toggle_auto_incremental_reference_number_options()
140 {
141 if ( jQuery('[name=\'propertyhive_auto_incremental_reference_numbers\']').is(":checked") )
142 {
143 jQuery('#row_propertyhive_auto_incremental_next').show();
144 }
145 else
146 {
147 jQuery('#row_propertyhive_auto_incremental_next').hide();
148 }
149 }
150
151 function fill_search_form_currency_options()
152 {
153 var selected_countries = jQuery('select[name=\'propertyhive_countries[]\']').val();
154 var selected_currency = jQuery('#propertyhive_search_form_currency').val();
155
156 var new_currency_options = new Array();
157
158 for ( var i in selected_countries)
159 {
160 var country = countries[selected_countries[i]];
161
162 new_currency_options.push( country.currency_code );
163 }
164
165 jQuery('#propertyhive_search_form_currency').find('option').remove();
166 if ( new_currency_options.length > 0 )
167 {
168 new_currency_options = jQuery.unique( new_currency_options );
169
170 /*new_currency_options.sort(function(a, b) {
171 var a1 = a.new_currency_options, b1 = b.new_currency_options;
172 if(a1 == b1) return 0;
173 return a1 > b1 ? 1 : -1;
174 });*/
175
176 for ( var i in new_currency_options)
177 {
178 jQuery('#propertyhive_search_form_currency').append('<option value="' + new_currency_options[i] + '">' + new_currency_options[i] + '</option>');
179 }
180 jQuery('#propertyhive_search_form_currency').val(selected_currency);
181
182 if ( new_currency_options.length > 1 )
183 {
184 jQuery('#propertyhive_search_form_currency').parent().parent().show();
185 }
186 else
187 {
188 jQuery('#propertyhive_search_form_currency').parent().parent().hide();
189 }
190
191 if ( jQuery("#propertyhive_search_form_currency :selected").length == 0 )
192 {
193 jQuery("#propertyhive_search_form_currency").val( jQuery("#propertyhive_search_form_currency option:first").val() );
194
195 }
196 }
197 }
198
199 function toggle_department_specific_options()
200 {
201 jQuery('#row_propertyhive_lettings_fees').hide();
202 jQuery('#row_propertyhive_lettings_fees_commercial').hide();
203 jQuery('#row_propertyhive_lettings_fees_display_search_results').hide();
204
205 if (jQuery('#propertyhive_active_departments_lettings').prop('checked') == true)
206 {
207 jQuery('#row_propertyhive_lettings_fees').show();
208 jQuery('#row_propertyhive_lettings_fees_display_search_results').show();
209 }
210 if (jQuery('#propertyhive_active_departments_commercial').prop('checked') == true)
211 {
212 jQuery('#row_propertyhive_lettings_fees_commercial').show();
213 jQuery('#row_propertyhive_lettings_fees_display_search_results').show();
214 }
215 }