PluginProbe
Property Hive / 1.4.5
Property Hive v1.4.5
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.5, at assets/js/admin/settings.js

119 lines 4.4 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 });