blob: 786a5995824f63a8b5d14391885132d4fbd4b4b4 [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 });
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020031 // Sender ACL
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010032 if ($("#editSelectSenderACL option[value='\*']:selected").length > 0){
33 $("#sender_acl_disabled").show();
34 }
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020035 $('#editSelectSenderACL').change(function() {
36 if ($("#editSelectSenderACL option[value='\*']:selected").length > 0){
37 $("#sender_acl_disabled").show();
38 }
39 else {
40 $("#sender_acl_disabled").hide();
41 }
42 });
43 // Resources
44 if ($("#editSelectMultipleBookings").val() == "custom") {
45 $("#multiple_bookings_custom_div").show();
46 $('input[name=multiple_bookings]').val($("#multiple_bookings_custom").val());
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010047 }
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020048 $("#editSelectMultipleBookings").change(function() {
49 $('input[name=multiple_bookings]').val($("#editSelectMultipleBookings").val());
50 if ($('input[name=multiple_bookings]').val() == "custom") {
51 $("#multiple_bookings_custom_div").show();
52 }
53 else {
54 $("#multiple_bookings_custom_div").hide();
55 }
56 });
57 $("#multiple_bookings_custom").bind("change keypress keyup blur", function() {
58 $('input[name=multiple_bookings]').val($("#multiple_bookings_custom").val());
59 });
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010060});
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020061
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +010062jQuery(function($){
63 // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
64 function validateEmail(email) {
65 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,}))$/;
66 return re.test(email);
67 }
68 function draw_wl_policy_domain_table() {
69 ft_wl_policy_mailbox_table = FooTable.init('#wl_policy_domain_table', {
70 "columns": [
71 {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
72 {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
73 {"sorted": true,"name":"value","title":lang_user.spamfilter_table_rule},
74 {"name":"object","title":"Scope"}
75 ],
76 "empty": lang_user.empty,
77 "rows": $.ajax({
78 dataType: 'json',
79 url: '/api/v1/get/policy_wl_domain/' + table_for_domain,
80 jsonp: false,
81 error: function () {
82 console.log('Cannot draw mailbox policy wl table');
83 },
84 success: function (data) {
85 $.each(data, function (i, item) {
86 if (!validateEmail(item.object)) {
87 item.chkbox = '<input type="checkbox" data-id="policy_wl_domain" name="multi_select" value="' + item.prefid + '" />';
88 }
89 else {
90 item.chkbox = '<input type="checkbox" disabled title="' + lang_user.spamfilter_table_domain_policy + '" />';
91 }
92 });
93 }
94 }),
95 "paging": {
96 "enabled": true,
97 "limit": 5,
98 "size": pagination_size
99 },
100 "sorting": {
101 "enabled": true
102 }
103 });
104 }
105 function draw_bl_policy_domain_table() {
106 ft_bl_policy_mailbox_table = FooTable.init('#bl_policy_domain_table', {
107 "columns": [
108 {"name":"chkbox","title":"","style":{"maxWidth":"40px","width":"40px"},"filterable": false,"sortable": false,"type":"html"},
109 {"name":"prefid","style":{"maxWidth":"40px","width":"40px"},"title":"ID","filterable": false,"sortable": false},
110 {"sorted": true,"name":"value","title":lang_user.spamfilter_table_rule},
111 {"name":"object","title":"Scope"}
112 ],
113 "empty": lang_user.empty,
114 "rows": $.ajax({
115 dataType: 'json',
116 url: '/api/v1/get/policy_bl_domain/' + table_for_domain,
117 jsonp: false,
118 error: function () {
119 console.log('Cannot draw mailbox policy bl table');
120 },
121 success: function (data) {
122 $.each(data, function (i, item) {
123 if (!validateEmail(item.object)) {
124 item.chkbox = '<input type="checkbox" data-id="policy_bl_domain" name="multi_select" value="' + item.prefid + '" />';
125 }
126 else {
127 item.chkbox = '<input type="checkbox" disabled tooltip="' + lang_user.spamfilter_table_domain_policy + '" />';
128 }
129 });
130 }
131 }),
132 "paging": {
133 "enabled": true,
134 "limit": 5,
135 "size": pagination_size
136 },
137 "sorting": {
138 "enabled": true
139 }
140 });
141 }
142 draw_wl_policy_domain_table();
143 draw_bl_policy_domain_table();
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +0200144});