summaryrefslogtreecommitdiff
path: root/program/js
diff options
context:
space:
mode:
Diffstat (limited to 'program/js')
-rw-r--r--program/js/app.js104
-rw-r--r--program/js/common.js15
2 files changed, 110 insertions, 9 deletions
diff --git a/program/js/app.js b/program/js/app.js
index 3f86e9f11..91825d3e6 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -6,7 +6,7 @@
| Copyright (C) 2005, RoundCube Dev, - Switzerland |
| Licensed under the GNU GPL |
| |
- | Modified: 2005/11/01 (roundcube) |
+ | Modified: 2005/11/06 (roundcube) |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
@@ -19,6 +19,7 @@ var rcube_webmail_client;
function rcube_webmail()
{
this.env = new Object();
+ this.labels = new Object();
this.buttons = new Object();
this.gui_objects = new Object();
this.commands = new Object();
@@ -49,6 +50,14 @@ function rcube_webmail()
this.env[name] = value;
};
+
+ // add a localized label to the client environment
+ this.add_label = function(key, value)
+ {
+ this.labels[key] = value;
+ };
+
+
// add a button to the button list
this.register_button = function(command, id, type, act, sel, over)
{
@@ -513,7 +522,37 @@ function rcube_webmail()
case 'save-identity':
case 'save':
if (this.gui_objects.editform)
+ {
+ var input_pagesize = rcube_find_object('_pagesize');
+ var input_name = rcube_find_object('_name');
+ var input_email = rcube_find_object('_email');
+
+ // user prefs
+ if (input_pagesize && input_pagesize.value == '')
+ {
+ alert(this.get_label('nopagesizewarning'));
+ input_pagesize.focus();
+ break;
+ }
+ // contacts/identities
+ else
+ {
+ if (input_name && input_name.value == '')
+ {
+ alert(this.get_label('nonamewarning'));
+ input_name.focus();
+ break;
+ }
+ else if (input_email && !rcube_check_email(input_email.value))
+ {
+ alert(this.get_label('noemailwarning'));
+ input_email.focus();
+ break;
+ }
+ }
+
this.gui_objects.editform.submit();
+ }
break;
case 'delete':
@@ -639,14 +678,46 @@ function rcube_webmail()
var input_to = rcube_find_object('_to');
var input_subject = rcube_find_object('_subject');
var input_message = rcube_find_object('_message');
-
- if (input_to.value!='' && input_message.value!='')
+
+ // check for empty recipient
+ if (input_to && !rcube_check_email(input_to.value, true))
{
- this.set_busy(true, 'sendingmessage');
- var form = this.gui_objects.messageform;
- form.submit();
+ alert(this.get_label('norecipientwarning'));
+ input_to.focus();
+ break;
}
-
+
+ // display localized warning for missing subject
+ if (input_subject && input_subject.value == '')
+ {
+ var subject = prompt(this.get_label('nosubjectwarning'), this.get_label('nosubject'));
+
+ // user hit cancel, so don't send
+ if (!subject && subject !== '')
+ {
+ input_subject.focus();
+ break;
+ }
+ else
+ {
+ input_subject.value = subject ? subject : this.get_label('nosubject');
+ }
+ }
+
+ // check for empty body
+ if (input_message.value=='')
+ {
+ if (!confirm(this.get_label('nobodywarning')))
+ {
+ input_message.focus();
+ break;
+ }
+ }
+
+ // all checks passed, send message
+ this.set_busy(true, 'sendingmessage');
+ var form = this.gui_objects.messageform;
+ form.submit();
break;
case 'add-attachment':
@@ -760,7 +831,13 @@ function rcube_webmail()
this.set_busy = function(a, message)
{
if (a && message)
- this.display_message('Loading...', 'loading', true);
+ {
+ var msg = this.get_label(message);
+ if (msg==message)
+ msg = 'Loading...';
+
+ this.display_message(msg, 'loading', true);
+ }
else if (!a && this.busy)
this.hide_message();
@@ -780,6 +857,17 @@ function rcube_webmail()
};
+ // return a localized string
+ this.get_label = function(name)
+ {
+ if (this.labels[name])
+ return this.labels[name];
+ else
+ return name;
+ };
+
+
+ // switch to another application task
this.switch_task = function(task)
{
if (this.task===task && task!='mail')
diff --git a/program/js/common.js b/program/js/common.js
index 78fecf8fe..0c9917ad9 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -6,7 +6,7 @@
| Copyright (C) 2005, RoundCube Dev, - Switzerland |
| Licensed under the GNU GPL |
| |
- | Modified:2005/10/21 (roundcube) |
+ | Modified:2005/11/06 (roundcube) |
| |
+-----------------------------------------------------------------------+
| Author: Thomas Bruederli <roundcube@gmail.com> |
@@ -264,6 +264,19 @@ function rcube_layer(id, attributes)
}
+// check if input is a valid email address
+function rcube_check_email(input, inline)
+ {
+ if (input && window.RegExp)
+ {
+ var reg_str = '([a-z0-9][-a-z0-9\.\+_]*)\@([a-z0-9]([-a-z0-9][\.]?)*[a-z0-9]\.[a-z]{2,9})';
+ var reg1 = inline ? new RegExp(reg_str, 'i') : new RegExp('^'+reg_str+'$', 'i');
+ var reg2 = /[\._\-\@]{2}/;
+ return reg1.test(input) && !reg2.test(input) ? true : false;
+ }
+ return false;
+ }
+
// find a value in a specific array and returns the index
function find_in_array()