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(); var users = this.acl_get_usernames();
if (users && users.length && confirm(this.get_label('acl.deleteconfirm'))) { if (users && users.length) {
this.http_post('settings/plugin.acl', { this.show_confirm(this.get_label('acl.deleteconfirm'), 'delete', function() {
_act: 'delete', rcmail.http_post('settings/plugin.acl', {
_user: users.join(','), _act: 'delete',
_mbox: this.env.mailbox _user: users.join(','),
}, _mbox: rcmail.env.mailbox
this.set_busy(true, 'acl.deleting')); },
rcmail.set_busy(true, 'acl.deleting'));
return true;
});
} }
} }
@ -80,11 +84,11 @@ rcube_webmail.prototype.acl_save = function()
} }
if (!user) { if (!user) {
alert(this.get_label('acl.nouser')); this.show_alert(this.get_label('acl.nouser'));
return; return;
} }
if (!rights) { if (!rights) {
alert(this.get_label('acl.norights')); this.show_alert(this.get_label('acl.norights'));
return; return;
} }

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

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

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

@ -139,8 +139,9 @@ this.decorateTextarea = function(id)
this.checkSpellingState(); this.checkSpellingState();
} }
else if (this.report_ta_not_found) else if (this.report_ta_not_found) {
alert('Text area 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', $.ajax({ type: 'POST', url: this.getUrl(), data: this.createXMLReq(req_text), dataType: 'text',
error: function(o) { error: function(o) {
if (ref.custom_ajax_error) if (ref.custom_ajax_error) {
ref.custom_ajax_error(ref); 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) { if (ref.main_controller) {
$(ref.spell_span).remove(); $(ref.spell_span).remove();
ref.removeIndicator(); ref.removeIndicator();
@ -284,10 +287,12 @@ this.learnWord = function(word, id)
$.ajax({ type: 'POST', url: this.getUrl(), data: req_text, dataType: 'text', $.ajax({ type: 'POST', url: this.getUrl(), data: req_text, dataType: 'text',
error: function(o) { error: function(o) {
if (ref.custom_ajax_error) if (ref.custom_ajax_error) {
ref.custom_ajax_error(ref); 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) { success: function(data) {
} }

Loading…
Cancel
Save