This repository has been archived by the owner on Jun 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailforward.js
45 lines (38 loc) · 1.8 KB
/
mailforward.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* Mail Forward plugin script
* @version 1.0
*/
if (window.rcmail) {
rcmail.addEventListener('init', function(evt) {
// <span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span>
var tab = $('<span>').attr('id', 'settingstabpluginmailforward').addClass('tablink mailforward');
var button = $('<a>').attr('href', rcmail.env.comm_path+'&_action=plugin.mailforward').html(rcmail.gettext('mailforwarding', 'mailforward')).appendTo(tab);
// add button and register commands
rcmail.add_element(tab, 'tabs');
rcmail.add_element(tab, 'tabs');
rcmail.register_command('plugin.mailforward-save', function() {
var inputForwardAddressRef = rcube_find_object('inputMailForwardAddress');
if ( inputForwardAddressRef.value != '' && parent.rcmail.mailforwardValidateEMail(inputForwardAddressRef.value) != true) {
alert(rcmail.gettext('novalidemail', 'mailforward'));
input_forwardaddress.focus();
return false;
}
rcmail.gui_objects.mailforwardform.submit();
}, true);
},true);
}
rcube_webmail.prototype.checkboxOnChange = function() {
var inputMailForwardEnabledRef = rcube_find_object('inputMailForwardEnabled');
var inputForwardAddressRef = rcube_find_object('inputMailForwardAddress');
var checkKeepLocalCopyRef = rcube_find_object('checkKeepLocalCopy');
inputForwardAddressRef.disabled = !inputMailForwardEnabledRef.checked;
checkKeepLocalCopy.disabled = !inputMailForwardEnabledRef.checked;
}
rcube_webmail.prototype.mailforwardValidateEMail = function(email) {
var atpos=email.indexOf("@");
var dotpos=email.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length) {
return false;
}
return true;
}