Merge branch 'pretty_confirms' of https://github.com/JohnDoh/roundcubemail into JohnDoh-pretty_confirms

pull/5874/merge
Aleksander Machniak 7 years ago
commit 43c210f04d

@ -54,13 +54,17 @@ rcube_webmail.prototype.acl_delete = function()
{
var users = this.acl_get_usernames();
if (users && users.length && confirm(this.get_label('acl.deleteconfirm'))) {
this.http_post('settings/plugin.acl', {
_act: 'delete',
_user: users.join(','),
_mbox: this.env.mailbox
},
this.set_busy(true, 'acl.deleting'));
if (users && users.length) {
this.confirm_dialog(this.get_label('acl.deleteconfirm'), 'delete', function(e, ref) {
ref.http_post('settings/plugin.acl', {
_act: 'delete',
_user: users.join(','),
_mbox: rcmail.env.mailbox
},
ref.set_busy(true, 'acl.deleting'));
return true;
});
}
}
@ -80,11 +84,11 @@ rcube_webmail.prototype.acl_save = function()
}
if (!user) {
alert(this.get_label('acl.nouser'));
this.alert_dialog(this.get_label('acl.nouser'));
return;
}
if (!rights) {
alert(this.get_label('acl.norights'));
this.alert_dialog(this.get_label('acl.norights'));
return;
}

@ -134,14 +134,20 @@ rcube_webmail.prototype.enigma_key_create_save = function()
});
// validate the form
if (!password || !confirm)
return alert(this.get_label('enigma.formerror'));
if (!password || !confirm) {
this.alert_dialog(this.get_label('enigma.formerror'));
return;
}
if (password != confirm)
return alert(this.get_label('enigma.passwordsdiffer'));
if (password != confirm) {
this.alert_dialog(this.get_label('enigma.passwordsdiffer'));
return;
}
if (!users.length)
return alert(this.get_label('enigma.noidentselected'));
if (!users.length) {
this.alert_dialog(this.get_label('enigma.noidentselected'));
return;
}
// generate keys
// use OpenPGP.js if browser supports required features
@ -182,14 +188,16 @@ rcube_webmail.prototype.enigma_delete = function()
{
var keys = this.keys_list.get_selection();
if (!keys.length || !confirm(this.get_label('enigma.keyremoveconfirm')))
if (!keys.length)
return;
var lock = this.display_message(this.get_label('enigma.keyremoving'), 'loading'),
this.confirm_dialog(this.get_label('enigma.keyremoveconfirm'), 'delete', function(e, ref) {
var lock = ref.display_message(ref.get_label('enigma.keyremoving'), 'loading'),
post = {_a: 'delete', _keys: keys};
// send request to server
this.http_post('plugin.enigmakeys', post, lock);
// send request to server
ref.http_post('plugin.enigmakeys', post, lock);
});
};
// Export key(s)
@ -268,7 +276,7 @@ rcube_webmail.prototype.enigma_import = function()
if (form = this.gui_objects.importform) {
file = document.getElementById('rcmimportfile');
if (file && !file.value) {
alert(this.get_label('selectimportfile'));
this.alert_dialog(this.get_label('selectimportfile'));
return;
}

@ -121,11 +121,13 @@ rcube_webmail.prototype.managesieve_add = function()
rcube_webmail.prototype.managesieve_del = function()
{
var id = this.filters_list.get_single_selection();
if (confirm(this.get_label('managesieve.filterdeleteconfirm'))) {
var lock = this.set_busy(true, 'loading');
this.http_post('plugin.managesieve-action',
'_act=delete&_fid='+this.filters_list.rows[id].uid, lock);
}
this.confirm_dialog(this.get_label('managesieve.filterdeleteconfirm'), 'delete', function(e, ref) {
var lock = ref.set_busy(true, 'loading');
ref.http_post('plugin.managesieve-action',
'_act=delete&_fid='+ref.filters_list.rows[id].uid, lock);
return true;
});
};
rcube_webmail.prototype.managesieve_act = function()
@ -218,14 +220,14 @@ rcube_webmail.prototype.managesieve_setact = function()
// Set delete request
rcube_webmail.prototype.managesieve_setdel = function()
{
if (!confirm(this.get_label('managesieve.setdeleteconfirm')))
return false;
var id = this.filtersets_list.get_single_selection(),
lock = this.set_busy(true, 'loading'),
script = this.env.filtersets[id];
this.http_post('plugin.managesieve-action', '_act=setdel&_set='+urlencode(script), lock);
this.confirm_dialog(this.get_label('managesieve.setdeleteconfirm'), 'delete', function(e, ref) {
lock = ref.set_busy(true, 'loading'),
ref.http_post('plugin.managesieve-action', '_act=setdel&_set='+urlencode(script), lock);
return true;
});
};
// Set edit raw request
@ -538,11 +540,12 @@ rcube_webmail.prototype.managesieve_ruledel = function(id)
if ($('#ruledel'+id).hasClass('disabled'))
return;
if (confirm(this.get_label('managesieve.ruledeleteconfirm'))) {
var row = document.getElementById('rulerow'+id);
row.parentNode.removeChild(row);
this.managesieve_formbuttons(document.getElementById('rules'));
}
this.confirm_dialog(this.get_label('managesieve.ruledeleteconfirm'), 'delete', function(e, ref) {
var row = document.getElementById('rulerow'+id);
row.parentNode.removeChild(row);
ref.managesieve_formbuttons(document.getElementById('rules'));
return true;
});
};
rcube_webmail.prototype.managesieve_actionadd = function(id)
@ -573,11 +576,12 @@ rcube_webmail.prototype.managesieve_actiondel = function(id)
if ($('#actiondel'+id).hasClass('disabled'))
return;
if (confirm(this.get_label('managesieve.actiondeleteconfirm'))) {
var row = document.getElementById('actionrow'+id);
row.parentNode.removeChild(row);
this.managesieve_formbuttons(document.getElementById('actions'));
}
this.confirm_dialog(this.get_label('managesieve.actiondeleteconfirm'), 'delete', function(e, ref) {
var row = document.getElementById('actionrow'+id);
row.parentNode.removeChild(row);
ref.managesieve_formbuttons(document.getElementById('actions'));
return true;
});
};
// insert rule/action row in specified place on the list
@ -1113,7 +1117,7 @@ rcube_webmail.prototype.managesieve_create = function(force)
// check if there's at least one checkbox checked
var hdrs = $('input[name="headers[]"]:checked', dialog);
if (!hdrs.length) {
alert(rcmail.get_label('managesieve.nodata'));
rcmail.alert_dialog(rcmail.get_label('managesieve.nodata'));
return;
}

@ -30,20 +30,28 @@ window.rcmail && rcmail.addEventListener('init', function(evt) {
input_confpasswd = rcube_find_object('_confpasswd');
if (input_curpasswd && input_curpasswd.value == '') {
alert(rcmail.get_label('nocurpassword', 'password'));
input_curpasswd.focus();
rcmail.alert_dialog(rcmail.get_label('nocurpassword', 'password'), function() {
input_curpasswd.focus();
return true;
});
}
else if (input_newpasswd && input_newpasswd.value == '') {
alert(rcmail.get_label('nopassword', 'password'));
input_newpasswd.focus();
rcmail.alert_dialog(rcmail.get_label('nopassword', 'password'), function() {
input_newpasswd.focus();
return true;
});
}
else if (input_confpasswd && input_confpasswd.value == '') {
alert(rcmail.get_label('nopassword', 'password'));
input_confpasswd.focus();
rcmail.alert_dialog(rcmail.get_label('nopassword', 'password'), function() {
input_confpasswd.focus();
return true;
});
}
else if (input_newpasswd && input_confpasswd && input_newpasswd.value != input_confpasswd.value) {
alert(rcmail.get_label('passwordinconsistency', 'password'));
input_newpasswd.focus();
rcmail.alert_dialog(rcmail.get_label('passwordinconsistency', 'password'), function() {
input_newpasswd.focus();
return true;
});
}
else {
rcmail.gui_objects.passform.submit();

@ -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');
'refreshing', 'windowopenerror', 'uploadingmany', 'close', 'save', 'cancel', 'alerttitle', 'confirmationtitle', 'delete', 'continue', 'ok');
return $this->output;
}

@ -720,14 +720,18 @@ function rcube_webmail()
// check input before leaving compose step
if (this.task == 'mail' && this.env.action == 'compose' && !this.env.server_error && command != 'save-pref'
&& $.inArray(command, this.env.compose_commands) < 0
&& $.inArray(command, this.env.compose_commands) < 0 && !this.compose_skip_unsavedcheck
) {
if (!this.env.is_sent && this.cmp_hash != this.compose_field_hash() && !confirm(this.get_label('notsentwarning')))
if (!this.env.is_sent && this.cmp_hash != this.compose_field_hash()) {
this.confirm_dialog(this.get_label('notsentwarning'), 'discard', function(e, ref) {
// remove copy from local storage if compose screen is left intentionally
ref.remove_compose_data(ref.env.compose_id);
ref.compose_skip_unsavedcheck = true;
ref.command(command, props, obj, event);
return true;
});
return false;
// remove copy from local storage if compose screen is left intentionally
this.remove_compose_data(this.env.compose_id);
this.compose_skip_unsavedcheck = true;
}
}
this.last_command = command;
@ -944,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.alert_dialog(this.get_label('nopagesizewarning'), function() {
input.focus();
return true;
});
break;
}
// contacts/identities
@ -957,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.alert_dialog(this.get_label('noemailwarning'), function() {
input.focus();
return true;
});
break;
}
}
@ -1199,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.alert_dialog(this.get_label('selectimportfile'));
aborted = true;
}
break;
@ -1351,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.alert_dialog(this.get_label('selectimportfile'));
aborted = true;
}
break;
@ -1366,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.alert_dialog(win.rcmail.get_label('selectimportfile'));
return;
}
@ -3155,8 +3163,10 @@ function rcube_webmail()
else {
// if shift was pressed delete it immediately
if ((list && list.modkey == SHIFT_KEY) || (event && rcube_event.get_modifier(event) == SHIFT_KEY)) {
if (confirm(this.get_label('deletemessagesconfirm')))
this.permanently_remove_messages();
this.confirm_dialog(this.get_label('deletemessagesconfirm'), 'delete', function(e, ref) {
ref.permanently_remove_messages();
return true;
});
}
else
this.move_messages(trash);
@ -3704,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.alert_dialog(ref.get_label('encryptnoattachments'));
$.each(ref.env.attachments, function(name, attach) {
ref.remove_from_attachment_list(name);
@ -3761,8 +3771,10 @@ function rcube_webmail()
if (!isvalid) {
if (!recipients.length) {
alert(ref.get_label('norecipientwarning'));
$("[name='_to']").focus();
ref.alert_dialog(ref.get_label('norecipientwarning'), function() {
$("[name='_to']").focus();
return true;
});
}
return false;
}
@ -3996,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.alert_dialog(ref.get_label('Key import was rejected'));
}
else {
var $key = keyid.substr(-8).toUpperCase();
@ -4036,17 +4048,19 @@ function rcube_webmail()
{
var lock, post_data = {_mbox: mbox};
if (!confirm(this.get_label('purgefolderconfirm')))
return false;
this.confirm_dialog(this.get_label('purgefolderconfirm'), 'delete', function(e, ref) {
// lock interface if it's the active mailbox
if (mbox == ref.env.mailbox) {
lock = ref.set_busy(true, 'loading');
post_data._reload = 1;
}
// lock interface if it's the active mailbox
if (mbox == this.env.mailbox) {
lock = this.set_busy(true, 'loading');
post_data._reload = 1;
}
// send request to server
ref.http_post('purge', post_data, lock);
return true;
});
// send request to server
this.http_post('purge', post_data, lock);
return false;
};
// test if purge command is allowed
@ -4515,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.alert_dialog(this.get_label('notuploadedwarning'));
return false;
}
}
@ -4597,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.alert_dialog(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.alert_dialog(this.get_label('norecipientwarning'), function() {
input_to.focus();
return true;
});
return false;
}
@ -4762,8 +4780,11 @@ function rcube_webmail()
}
// submit delete request
if (key && confirm(this.get_label('deleteresponseconfirm'))) {
this.http_post('settings/delete-response', { _key: key }, false);
if (key) {
this.confirm_dialog(this.get_label('deleteresponseconfirm'), 'delete', function(e, ref) {
ref.http_post('settings/delete-response', { _key: key }, false);
return true;
});
}
};
@ -6206,10 +6227,12 @@ function rcube_webmail()
{
var undelete = this.env.source && this.env.address_sources[this.env.source].undelete;
if (!undelete && !confirm(this.get_label('deletecontactconfirm')))
return;
return this._with_selected_contacts('delete');
if (!undelete) {
this.confirm_dialog(this.get_label('deletecontactconfirm'), 'delete', function(e, ref) {
ref._with_selected_contacts('delete');
return true;
});
}
};
this._with_selected_contacts = function(action, post_data)
@ -6391,9 +6414,12 @@ function rcube_webmail()
this.group_delete = function()
{
if (this.env.group && confirm(this.get_label('deletegroupconfirm'))) {
var lock = this.set_busy(true, 'groupdeleting');
this.http_post('group-delete', {_source: this.env.source, _gid: this.env.group}, lock);
if (this.env.group) {
this.confirm_dialog(this.get_label('deletegroupconfirm'), 'delete', function(e, ref) {
var lock = ref.set_busy(true, 'groupdeleting');
ref.http_post('group-delete', {_source: ref.env.source, _gid: ref.env.group}, lock);
return true;
});
}
};
@ -6926,8 +6952,12 @@ function rcube_webmail()
id = this.env.iid ? this.env.iid : selection[0];
// submit request with appended token
if (id && confirm(this.get_label('deleteidentityconfirm')))
this.http_post('settings/delete-identity', { _iid: id }, true);
if (id) {
this.confirm_dialog(this.get_label('deleteidentityconfirm'), 'delete', function(e, ref) {
ref.http_post('settings/delete-identity', { _iid: id }, true);
return true;
});
}
};
this.update_identity_row = function(id, name, add)
@ -7090,8 +7120,11 @@ function rcube_webmail()
if (!name)
name = this.env.mailbox;
if (name && confirm(this.get_label('deletefolderconfirm'))) {
this.http_post('delete-folder', {_mbox: name}, this.set_busy(true, 'folderdeleting'));
if (name) {
this.confirm_dialog(this.get_label('deletefolderconfirm'), 'delete', function(e, ref) {
ref.http_post('delete-folder', {_mbox: name}, ref.set_busy(true, 'folderdeleting'));
return true;
});
}
};
@ -7867,9 +7900,11 @@ function rcube_webmail()
var title = this.get_label(title),
cancel_label = (options || {}).cancel_button || 'cancel',
save_label = (options || {}).button || 'save',
save_class = (options || {}).button_class || save_label.replace(/^[^\.]+\./i, ''),
close_func = function(e, ui, dialog) { (ref.is_framed() ? parent.$ : $)(dialog || this).dialog('close'); },
obj = this.is_framed() ? parent.rcmail : this,
buttons = [{
text: ref.get_label(cancel_label),
text: this.get_label(cancel_label),
'class': 'cancel',
click: close_func
}];
@ -7879,13 +7914,41 @@ function rcube_webmail()
else
buttons.unshift({
text: this.get_label(save_label),
'class': 'mainaction ' + save_label.replace(/^[^\.]+\./i, ''),
click: function(e, ui) { if (action_func(e)) close_func(e, ui, this); }
'class': 'mainaction ' + save_class,
click: function(e, ui) { if (action_func(e, obj)) close_func(e, ui, this); }
});
return this.show_popup_dialog(content, title, buttons, options);
};
// show_popup_dialog() wrapper for alert() type dialogs
this.alert_dialog = function(content, action_func, options)
{
var title = (options || {}).title || 'alerttitle',
close_func = function(e, ui, dialog) { (ref.is_framed() ? parent.$ : $)(dialog || this).dialog('close'); },
obj = this.is_framed() ? parent.rcmail : this,
buttons = [{
text: this.get_label('ok'),
'class': 'mainaction ok',
click: function(e, ui) { if (!action_func || action_func(e, obj)) close_func(e, ui, this); }
}],
args = { close: buttons[0].click };
return this.show_popup_dialog(content, this.get_label(title), buttons, args);
};
// simple_dialog() wrapper for confirm() type dialogs
this.confirm_dialog = function(content, button_label, action_func, options)
{
var title = (options || {}).title || 'confirmationtitle',
args = {
button: button_label || 'continue',
button_class: (options || {}).button_class || ''
};
return this.simple_dialog(content, this.get_label(title), action_func, args);
};
// enable/disable buttons for page shifting
this.set_page_buttons = function()
{

@ -139,8 +139,9 @@ this.decorateTextarea = function(id)
this.checkSpellingState();
}
else if (this.report_ta_not_found)
alert('Text area not found');
else if (this.report_ta_not_found) {
rcmail.alert_dialog('Text area not found');
}
};
//////
@ -252,10 +253,12 @@ this.spellCheck = function(ignore)
$.ajax({ type: 'POST', url: this.getUrl(), data: this.createXMLReq(req_text), dataType: 'text',
error: function(o) {
if (ref.custom_ajax_error)
if (ref.custom_ajax_error) {
ref.custom_ajax_error(ref);
else
alert('An error was encountered on the server. Please try again later.');
}
else {
rcmail.alert_dialog('An error was encountered on the server. Please try again later.');
}
if (ref.main_controller) {
$(ref.spell_span).remove();
ref.removeIndicator();
@ -284,10 +287,12 @@ this.learnWord = function(word, id)
$.ajax({ type: 'POST', url: this.getUrl(), data: req_text, dataType: 'text',
error: function(o) {
if (ref.custom_ajax_error)
if (ref.custom_ajax_error) {
ref.custom_ajax_error(ref);
else
alert('An error was encountered on the server. Please try again later.');
}
else {
rcmail.alert_dialog('An error was encountered on the server. Please try again later.');
}
},
success: function(data) {
}

@ -361,6 +361,9 @@ $labels['edit'] = 'Edit';
$labels['cancel'] = 'Cancel';
$labels['save'] = 'Save';
$labels['delete'] = 'Delete';
$labels['discard'] = 'Discard';
$labels['continue'] = 'Continue';
$labels['ok'] = 'OK';
$labels['rename'] = 'Rename';
$labels['addphoto'] = 'Add';
$labels['replacephoto'] = 'Replace';

@ -76,6 +76,8 @@ $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?';
$messages['deletemessagesconfirm'] = 'Do you really want to delete the selected message(s)?';

@ -420,6 +420,9 @@ $labels['edit'] = 'Edit';
$labels['cancel'] = 'Cancel';
$labels['save'] = 'Save';
$labels['delete'] = 'Delete';
$labels['discard'] = 'Discard';
$labels['continue'] = 'Continue';
$labels['ok'] = 'OK';
$labels['rename'] = 'Rename';
$labels['addphoto'] = 'Add';
$labels['replacephoto'] = 'Replace';

@ -78,6 +78,8 @@ $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?';
$messages['deletemessagesconfirm'] = 'Do you really want to delete selected message(s)?';

@ -81,7 +81,7 @@ $OUTPUT->add_label('notuploadedwarning', 'savingmessage',
'selectimportfile', 'messageissent', 'loadingdata', 'nopubkeyfor', 'nopubkeyforsender',
'encryptnoattachments','encryptedsendialog','searchpubkeyservers', 'importpubkeys',
'encryptpubkeysfound', 'search', 'close', 'import', 'keyid', 'keylength', 'keyexpired',
'keyrevoked', 'keyimportsuccess', 'keyservererror', 'attaching', 'namex', 'attachmentrename'
'keyrevoked', 'keyimportsuccess', 'keyservererror', 'attaching', 'namex', 'attachmentrename', 'discard'
);
$OUTPUT->set_pagetitle($RCMAIL->gettext('compose'));

Loading…
Cancel
Save