use skinned alert and confirm boxes in plugins

pull/6040/head
PhilW 7 years ago
parent 26f1b0770c
commit af52df68bf

@ -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.show_confirm(this.get_label('acl.deleteconfirm'), 'delete', function() {
rcmail.http_post('settings/plugin.acl', {
_act: 'delete',
_user: users.join(','),
_mbox: rcmail.env.mailbox
},
rcmail.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.show_alert(this.get_label('acl.nouser'));
return;
}
if (!rights) {
alert(this.get_label('acl.norights'));
this.show_alert(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.show_alert(this.get_label('enigma.formerror'));
return;
}
if (password != confirm)
return alert(this.get_label('enigma.passwordsdiffer'));
if (password != confirm) {
this.show_alert(this.get_label('enigma.passwordsdiffer'));
return;
}
if (!users.length)
return alert(this.get_label('enigma.noidentselected'));
if (!users.length) {
this.show_alert(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.show_confirm(this.get_label('enigma.keyremoveconfirm'), 'delete', function() {
var lock = rcmail.display_message(rcmail.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
rcmail.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.show_alert(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.show_confirm(this.get_label('managesieve.filterdeleteconfirm'), 'delete', function() {
var lock = rcmail.set_busy(true, 'loading');
rcmail.http_post('plugin.managesieve-action',
'_act=delete&_fid='+rcmail.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.show_confirm(this.get_label('managesieve.setdeleteconfirm'), 'delete', function() {
lock = rcmail.set_busy(true, 'loading'),
rcmail.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.show_confirm(this.get_label('managesieve.ruledeleteconfirm'), 'delete', function() {
var row = document.getElementById('rulerow'+id);
row.parentNode.removeChild(row);
rcmail.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.show_confirm(this.get_label('managesieve.actiondeleteconfirm'), 'delete', function() {
var row = document.getElementById('actionrow'+id);
row.parentNode.removeChild(row);
rcmail.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.show_alert(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.show_alert(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.show_alert(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.show_alert(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.show_alert(rcmail.get_label('passwordinconsistency', 'password'), function() {
input_newpasswd.focus();
return true;
});
}
else {
rcmail.gui_objects.passform.submit();

@ -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.show_alert('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.show_alert('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.show_alert('An error was encountered on the server. Please try again later.');
}
},
success: function(data) {
}

Loading…
Cancel
Save