From 26f1b0770c50aae4e778be49026c3f1a9f790f39 Mon Sep 17 00:00:00 2001 From: PhilW Date: Thu, 16 Nov 2017 20:52:57 +0000 Subject: [PATCH] use skinned alert boxes --- program/include/rcmail.php | 2 +- program/js/app.js | 56 ++++++++++++++++++------- program/localization/en_GB/labels.inc | 1 + program/localization/en_GB/messages.inc | 1 + program/localization/en_US/labels.inc | 1 + program/localization/en_US/messages.inc | 1 + 6 files changed, 45 insertions(+), 17 deletions(-) diff --git a/program/include/rcmail.php b/program/include/rcmail.php index 0349fb038..2a298c05c 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -455,7 +455,7 @@ class rcmail extends rcube // add some basic labels to client $this->output->add_label('loading', 'servererror', 'connerror', 'requesttimedout', - 'refreshing', 'windowopenerror', 'uploadingmany', 'close', 'save', 'cancel', 'confirmationtitle', 'delete', 'continue'); + 'refreshing', 'windowopenerror', 'uploadingmany', 'close', 'save', 'cancel', 'alerttitle', 'confirmationtitle', 'delete', 'continue', 'ok'); return $this->output; } diff --git a/program/js/app.js b/program/js/app.js index 009ef576d..57379af51 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -948,8 +948,10 @@ function rcube_webmail() if (form) { // user prefs if ((input = $("[name='_pagesize']", form)) && input.length && isNaN(parseInt(input.val()))) { - alert(this.get_label('nopagesizewarning')); - input.focus(); + this.show_alert(this.get_label('nopagesizewarning'), function() { + input.focus(); + return true; + }); break; } // contacts/identities @@ -961,8 +963,10 @@ function rcube_webmail() else if (this.task == 'settings' && (this.env.identities_level % 2) == 0 && (input = $("[name='_email']", form)) && input.length && !rcube_check_email(input.val()) ) { - alert(this.get_label('noemailwarning')); - input.focus(); + this.show_alert(this.get_label('noemailwarning'), function() { + input.focus(); + return true; + }); break; } } @@ -1203,7 +1207,7 @@ function rcube_webmail() if (!(flag = this.upload_file(props || this.gui_objects.uploadform, 'upload'))) { if (flag !== false) - alert(this.get_label('selectimportfile')); + this.show_alert(this.get_label('selectimportfile')); aborted = true; } break; @@ -1355,7 +1359,7 @@ function rcube_webmail() if (!(flag = this.upload_file(form, 'import', importlock))) { this.set_busy(false, null, importlock); if (flag !== false) - alert(this.get_label('selectimportfile')); + this.show_alert(this.get_label('selectimportfile')); aborted = true; } break; @@ -1370,7 +1374,7 @@ function rcube_webmail() if (form) { var lock, file = win.$('#rcmimportfile')[0]; if (file && !file.value) { - alert(win.rcmail.get_label('selectimportfile')); + win.rcmail.show_alert(win.rcmail.get_label('selectimportfile')); return; } @@ -3710,7 +3714,7 @@ function rcube_webmail() // notify user about loosing attachments if (ref.env.attachments && !$.isEmptyObject(ref.env.attachments)) { - alert(ref.get_label('encryptnoattachments')); + ref.show_alert(ref.get_label('encryptnoattachments')); $.each(ref.env.attachments, function(name, attach) { ref.remove_from_attachment_list(name); @@ -3767,8 +3771,10 @@ function rcube_webmail() if (!isvalid) { if (!recipients.length) { - alert(ref.get_label('norecipientwarning')); - $("[name='_to']").focus(); + ref.show_alert(ref.get_label('norecipientwarning'), function() { + $("[name='_to']").focus(); + return true; + }); } return false; } @@ -4002,7 +4008,7 @@ function rcube_webmail() // import to keyring ref.mailvelope_keyring.importPublicKey(armored).then(function(status) { if (status === 'REJECTED') { - // alert(ref.get_label('Key import was rejected')); + // ref.show_alert(ref.get_label('Key import was rejected')); } else { var $key = keyid.substr(-8).toUpperCase(); @@ -4523,7 +4529,7 @@ function rcube_webmail() // check if all files has been uploaded for (key in this.env.attachments) { if (typeof this.env.attachments[key] === 'object' && !this.env.attachments[key].complete) { - alert(this.get_label('notuploadedwarning')); + this.show_alert(this.get_label('notuploadedwarning')); return false; } } @@ -4605,15 +4611,19 @@ function rcube_webmail() // check sender (if have no identities) if (input_from.prop('type') == 'text' && !rcube_check_email(input_from.val(), true)) { - alert(this.get_label('nosenderwarning')); - input_from.focus(); + this.show_alert(this.get_label('nosenderwarning'), function() { + input_from.focus(); + return true; + }); return false; } // check for empty recipient if (!rcube_check_email(get_recipients([input_to, input_cc, input_bcc]), true)) { - alert(this.get_label('norecipientwarning')); - input_to.focus(); + this.show_alert(this.get_label('norecipientwarning'), function() { + input_to.focus(); + return true; + }); return false; } @@ -7907,6 +7917,20 @@ function rcube_webmail() return this.show_popup_dialog(content, title, buttons, options); }; + // show_popup_dialog() wrapper for alert() type dialogs + this.show_alert = function(content, action_func) + { + var close_func = function(e, ui, dialog) { (ref.is_framed() ? parent.$ : $)(dialog || this).dialog('close'); }, + buttons = [{ + text: ref.get_label('ok'), + 'class': 'mainaction ok', + click: function(e, ui) { if (!action_func || action_func(e, ref)) close_func(e, ui, this); } + }], + options = { close: buttons[0].click }; + + return this.show_popup_dialog(content, this.get_label('alerttitle'), buttons, options); + }; + // simple_dialog() wrapper for confirm() type dialogs this.show_confirm = function(content, button_label, action_func) { diff --git a/program/localization/en_GB/labels.inc b/program/localization/en_GB/labels.inc index 3abd2469a..c96fc43be 100644 --- a/program/localization/en_GB/labels.inc +++ b/program/localization/en_GB/labels.inc @@ -363,6 +363,7 @@ $labels['save'] = 'Save'; $labels['delete'] = 'Delete'; $labels['discard'] = 'Discard'; $labels['continue'] = 'Continue'; +$labels['ok'] = 'OK'; $labels['rename'] = 'Rename'; $labels['addphoto'] = 'Add'; $labels['replacephoto'] = 'Replace'; diff --git a/program/localization/en_GB/messages.inc b/program/localization/en_GB/messages.inc index e33de517b..444c76d17 100644 --- a/program/localization/en_GB/messages.inc +++ b/program/localization/en_GB/messages.inc @@ -76,6 +76,7 @@ $messages['errormoving'] = 'Could not move the message(s).'; $messages['errorcopying'] = 'Could not copy the message(s).'; $messages['errordeleting'] = 'Could not delete the message(s).'; $messages['errormarking'] = 'Could not mark the message(s).'; +$messages['alerttitle'] = 'Attention'; $messages['confirmationtitle'] = 'Are you sure...'; $messages['deletecontactconfirm'] = 'Do you really want to delete the selected contact(s)?'; $messages['deletegroupconfirm'] = 'Do you really want to delete the selected group?'; diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index a976fb8a1..f72a108f4 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -420,6 +420,7 @@ $labels['save'] = 'Save'; $labels['delete'] = 'Delete'; $labels['discard'] = 'Discard'; $labels['continue'] = 'Continue'; +$labels['ok'] = 'OK'; $labels['rename'] = 'Rename'; $labels['addphoto'] = 'Add'; $labels['replacephoto'] = 'Replace'; diff --git a/program/localization/en_US/messages.inc b/program/localization/en_US/messages.inc index 566d206a2..99369b6cc 100644 --- a/program/localization/en_US/messages.inc +++ b/program/localization/en_US/messages.inc @@ -78,6 +78,7 @@ $messages['errormoving'] = 'Could not move the message(s).'; $messages['errorcopying'] = 'Could not copy the message(s).'; $messages['errordeleting'] = 'Could not delete the message(s).'; $messages['errormarking'] = 'Could not mark the message(s).'; +$messages['alerttitle'] = 'Attention'; $messages['confirmationtitle'] = 'Are you sure...'; $messages['deletecontactconfirm'] = 'Do you really want to delete selected contact(s)?'; $messages['deletegroupconfirm'] = 'Do you really want to delete selected group?';