blob: 1626d4b05948ad9adceeb2c78566f79c5398a84f [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001$(document).ready(function() {
2 $(".arrow-toggle").on('click', function(e) { e.preventDefault(); $(this).find('.arrow').toggleClass("animation"); });
3 $("#pushover_delete").click(function() { return confirm(lang.delete_ays); });
4 $(".goto_checkbox").click(function( event ) {
5 $("form[data-id='editalias'] .goto_checkbox").not(this).prop('checked', false);
6 if ($("form[data-id='editalias'] .goto_checkbox:checked").length > 0) {
7 $('#textarea_alias_goto').prop('disabled', true);
8 }
9 else {
10 $("#textarea_alias_goto").removeAttr('disabled');
11 }
12 });
13 $("#disable_sender_check").click(function( event ) {
14 if ($("form[data-id='editmailbox'] #disable_sender_check:checked").length > 0) {
15 $('#editSelectSenderACL').prop('disabled', true);
16 $('#editSelectSenderACL').selectpicker('refresh');
17 }
18 else {
19 $('#editSelectSenderACL').prop('disabled', false);
20 $('#editSelectSenderACL').selectpicker('refresh');
21 }
22 });
23 if ($("form[data-id='editalias'] .goto_checkbox:checked").length > 0) {
24 $('#textarea_alias_goto').prop('disabled', true);
25 }
26
27 $("#mailbox-password-warning-close").click(function( event ) {
28 $('#mailbox-passwd-hidden-info').addClass('hidden');
29 $('#mailbox-passwd-form-groups').removeClass('hidden');
30 });
31});
32if ($("#editSelectMultipleBookings").val() == "custom") {
33 $("#multiple_bookings_custom_div").show();
34 $('input[name=multiple_bookings]').val($("#multiple_bookings_custom").val());
35}
36$("#editSelectMultipleBookings").change(function() {
37 $('input[name=multiple_bookings]').val($("#editSelectMultipleBookings").val());
38 if ($('input[name=multiple_bookings]').val() == "custom") {
39 $("#multiple_bookings_custom_div").show();
40 }
41 else {
42 $("#multiple_bookings_custom_div").hide();
43 }
44});
45if ($("#editSelectSenderACL option[value='\*']:selected").length > 0){
46 $("#sender_acl_disabled").show();
47}
48$('#editSelectSenderACL').change(function() {
49 if ($("#editSelectSenderACL option[value='\*']:selected").length > 0){
50 $("#sender_acl_disabled").show();
51 }
52 else {
53 $("#sender_acl_disabled").hide();
54 }
55});
56$("#multiple_bookings_custom").bind("change keypress keyup blur", function() {
57 $('input[name=multiple_bookings]').val($("#multiple_bookings_custom").val());
58});
59jQuery(function($){
60 // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
61 function validateEmail(email) {
62 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
63 return re.test(email);
64 }
65 function draw_wl_policy_domain_table() {
66 ft_wl_policy_mailbox_table = FooTable.init('#wl_policy_domain_table', {
67 "columns": [
68 {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
69 {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
70 {"sorted": true,"name":"value","title":lang_user.spamfilter_table_rule},
71 {"name":"object","title":"Scope"}
72 ],
73 "empty": lang_user.empty,
74 "rows": $.ajax({
75 dataType: 'json',
76 url: '/api/v1/get/policy_wl_domain/' + table_for_domain,
77 jsonp: false,
78 error: function () {
79 console.log('Cannot draw mailbox policy wl table');
80 },
81 success: function (data) {
82 $.each(data, function (i, item) {
83 if (!validateEmail(item.object)) {
84 item.chkbox = '<input type="checkbox" data-id="policy_wl_domain" name="multi_select" value="' + item.prefid + '" />';
85 }
86 else {
87 item.chkbox = '<input type="checkbox" disabled title="' + lang_user.spamfilter_table_domain_policy + '" />';
88 }
89 });
90 }
91 }),
92 "paging": {
93 "enabled": true,
94 "limit": 5,
95 "size": pagination_size
96 },
97 "sorting": {
98 "enabled": true
99 }
100 });
101 }
102 function draw_bl_policy_domain_table() {
103 ft_bl_policy_mailbox_table = FooTable.init('#bl_policy_domain_table', {
104 "columns": [
105 {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
106 {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
107 {"sorted": true,"name":"value","title":lang_user.spamfilter_table_rule},
108 {"name":"object","title":"Scope"}
109 ],
110 "empty": lang_user.empty,
111 "rows": $.ajax({
112 dataType: 'json',
113 url: '/api/v1/get/policy_bl_domain/' + table_for_domain,
114 jsonp: false,
115 error: function () {
116 console.log('Cannot draw mailbox policy bl table');
117 },
118 success: function (data) {
119 $.each(data, function (i, item) {
120 if (!validateEmail(item.object)) {
121 item.chkbox = '<input type="checkbox" data-id="policy_bl_domain" name="multi_select" value="' + item.prefid + '" />';
122 }
123 else {
124 item.chkbox = '<input type="checkbox" disabled tooltip="' + lang_user.spamfilter_table_domain_policy + '" />';
125 }
126 });
127 }
128 }),
129 "paging": {
130 "enabled": true,
131 "limit": 5,
132 "size": pagination_size
133 },
134 "sorting": {
135 "enabled": true
136 }
137 });
138 }
139 draw_wl_policy_domain_table();
140 draw_bl_policy_domain_table();
141});