improvements for plugins and frames

pull/6040/head
PhilW 7 years ago
parent e7311e0e5e
commit 8c250a27f8

@ -55,13 +55,13 @@ rcube_webmail.prototype.acl_delete = function()
var users = this.acl_get_usernames(); var users = this.acl_get_usernames();
if (users && users.length) { if (users && users.length) {
this.confirm_dialog(this.get_label('acl.deleteconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('acl.deleteconfirm'), 'delete', function(e, ref) {
rcmail.http_post('settings/plugin.acl', { ref.http_post('settings/plugin.acl', {
_act: 'delete', _act: 'delete',
_user: users.join(','), _user: users.join(','),
_mbox: rcmail.env.mailbox _mbox: rcmail.env.mailbox
}, },
rcmail.set_busy(true, 'acl.deleting')); ref.set_busy(true, 'acl.deleting'));
return true; return true;
}); });

@ -191,12 +191,12 @@ rcube_webmail.prototype.enigma_delete = function()
if (!keys.length) if (!keys.length)
return; return;
this.confirm_dialog(this.get_label('enigma.keyremoveconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('enigma.keyremoveconfirm'), 'delete', function(e, ref) {
var lock = rcmail.display_message(rcmail.get_label('enigma.keyremoving'), 'loading'), var lock = ref.display_message(ref.get_label('enigma.keyremoving'), 'loading'),
post = {_a: 'delete', _keys: keys}; post = {_a: 'delete', _keys: keys};
// send request to server // send request to server
rcmail.http_post('plugin.enigmakeys', post, lock); ref.http_post('plugin.enigmakeys', post, lock);
}); });
}; };

@ -122,10 +122,10 @@ rcube_webmail.prototype.managesieve_del = function()
{ {
var id = this.filters_list.get_single_selection(); var id = this.filters_list.get_single_selection();
this.confirm_dialog(this.get_label('managesieve.filterdeleteconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('managesieve.filterdeleteconfirm'), 'delete', function(e, ref) {
var lock = rcmail.set_busy(true, 'loading'); var lock = ref.set_busy(true, 'loading');
rcmail.http_post('plugin.managesieve-action', ref.http_post('plugin.managesieve-action',
'_act=delete&_fid='+rcmail.filters_list.rows[id].uid, lock); '_act=delete&_fid='+ref.filters_list.rows[id].uid, lock);
return true; return true;
}); });
}; };
@ -223,9 +223,9 @@ rcube_webmail.prototype.managesieve_setdel = function()
var id = this.filtersets_list.get_single_selection(), var id = this.filtersets_list.get_single_selection(),
script = this.env.filtersets[id]; script = this.env.filtersets[id];
this.confirm_dialog(this.get_label('managesieve.setdeleteconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('managesieve.setdeleteconfirm'), 'delete', function(e, ref) {
lock = rcmail.set_busy(true, 'loading'), lock = ref.set_busy(true, 'loading'),
rcmail.http_post('plugin.managesieve-action', '_act=setdel&_set='+urlencode(script), lock); ref.http_post('plugin.managesieve-action', '_act=setdel&_set='+urlencode(script), lock);
return true; return true;
}); });
}; };
@ -540,10 +540,10 @@ rcube_webmail.prototype.managesieve_ruledel = function(id)
if ($('#ruledel'+id).hasClass('disabled')) if ($('#ruledel'+id).hasClass('disabled'))
return; return;
this.confirm_dialog(this.get_label('managesieve.ruledeleteconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('managesieve.ruledeleteconfirm'), 'delete', function(e, ref) {
var row = document.getElementById('rulerow'+id); var row = document.getElementById('rulerow'+id);
row.parentNode.removeChild(row); row.parentNode.removeChild(row);
rcmail.managesieve_formbuttons(document.getElementById('rules')); ref.managesieve_formbuttons(document.getElementById('rules'));
return true; return true;
}); });
}; };
@ -576,10 +576,10 @@ rcube_webmail.prototype.managesieve_actiondel = function(id)
if ($('#actiondel'+id).hasClass('disabled')) if ($('#actiondel'+id).hasClass('disabled'))
return; return;
this.confirm_dialog(this.get_label('managesieve.actiondeleteconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('managesieve.actiondeleteconfirm'), 'delete', function(e, ref) {
var row = document.getElementById('actionrow'+id); var row = document.getElementById('actionrow'+id);
row.parentNode.removeChild(row); row.parentNode.removeChild(row);
rcmail.managesieve_formbuttons(document.getElementById('actions')); ref.managesieve_formbuttons(document.getElementById('actions'));
return true; return true;
}); });
}; };

@ -723,7 +723,7 @@ function rcube_webmail()
&& $.inArray(command, this.env.compose_commands) < 0 && !this.compose_skip_unsavedcheck && $.inArray(command, this.env.compose_commands) < 0 && !this.compose_skip_unsavedcheck
) { ) {
if (!this.env.is_sent && this.cmp_hash != this.compose_field_hash()) { if (!this.env.is_sent && this.cmp_hash != this.compose_field_hash()) {
this.confirm_dialog(this.get_label('notsentwarning'), 'discard', function() { this.confirm_dialog(this.get_label('notsentwarning'), 'discard', function(e, ref) {
// remove copy from local storage if compose screen is left intentionally // remove copy from local storage if compose screen is left intentionally
ref.remove_compose_data(ref.env.compose_id); ref.remove_compose_data(ref.env.compose_id);
ref.compose_skip_unsavedcheck = true; ref.compose_skip_unsavedcheck = true;
@ -3163,7 +3163,7 @@ function rcube_webmail()
else { else {
// if shift was pressed delete it immediately // if shift was pressed delete it immediately
if ((list && list.modkey == SHIFT_KEY) || (event && rcube_event.get_modifier(event) == SHIFT_KEY)) { if ((list && list.modkey == SHIFT_KEY) || (event && rcube_event.get_modifier(event) == SHIFT_KEY)) {
this.confirm_dialog(this.get_label('deletemessagesconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('deletemessagesconfirm'), 'delete', function(e, ref) {
ref.permanently_remove_messages(); ref.permanently_remove_messages();
return true; return true;
}); });
@ -4048,7 +4048,7 @@ function rcube_webmail()
{ {
var lock, post_data = {_mbox: mbox}; var lock, post_data = {_mbox: mbox};
this.confirm_dialog(this.get_label('purgefolderconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('purgefolderconfirm'), 'delete', function(e, ref) {
// lock interface if it's the active mailbox // lock interface if it's the active mailbox
if (mbox == ref.env.mailbox) { if (mbox == ref.env.mailbox) {
lock = ref.set_busy(true, 'loading'); lock = ref.set_busy(true, 'loading');
@ -4781,7 +4781,7 @@ function rcube_webmail()
// submit delete request // submit delete request
if (key) { if (key) {
this.confirm_dialog(this.get_label('deleteresponseconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('deleteresponseconfirm'), 'delete', function(e, ref) {
ref.http_post('settings/delete-response', { _key: key }, false); ref.http_post('settings/delete-response', { _key: key }, false);
return true; return true;
}); });
@ -6226,7 +6226,7 @@ function rcube_webmail()
var undelete = this.env.source && this.env.address_sources[this.env.source].undelete; var undelete = this.env.source && this.env.address_sources[this.env.source].undelete;
if (!undelete) { if (!undelete) {
this.confirm_dialog(this.get_label('deletecontactconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('deletecontactconfirm'), 'delete', function(e, ref) {
ref._with_selected_contacts('delete'); ref._with_selected_contacts('delete');
return true; return true;
}); });
@ -6413,7 +6413,7 @@ function rcube_webmail()
this.group_delete = function() this.group_delete = function()
{ {
if (this.env.group) { if (this.env.group) {
this.confirm_dialog(this.get_label('deletegroupconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('deletegroupconfirm'), 'delete', function(e, ref) {
var lock = ref.set_busy(true, 'groupdeleting'); var lock = ref.set_busy(true, 'groupdeleting');
ref.http_post('group-delete', {_source: ref.env.source, _gid: ref.env.group}, lock); ref.http_post('group-delete', {_source: ref.env.source, _gid: ref.env.group}, lock);
return true; return true;
@ -6951,7 +6951,7 @@ function rcube_webmail()
// submit request with appended token // submit request with appended token
if (id) { if (id) {
this.confirm_dialog(this.get_label('deleteidentityconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('deleteidentityconfirm'), 'delete', function(e, ref) {
ref.http_post('settings/delete-identity', { _iid: id }, true); ref.http_post('settings/delete-identity', { _iid: id }, true);
return true; return true;
}); });
@ -7119,7 +7119,7 @@ function rcube_webmail()
name = this.env.mailbox; name = this.env.mailbox;
if (name) { if (name) {
this.confirm_dialog(this.get_label('deletefolderconfirm'), 'delete', function() { this.confirm_dialog(this.get_label('deletefolderconfirm'), 'delete', function(e, ref) {
ref.http_post('delete-folder', {_mbox: name}, ref.set_busy(true, 'folderdeleting')); ref.http_post('delete-folder', {_mbox: name}, ref.set_busy(true, 'folderdeleting'));
return true; return true;
}); });
@ -7898,9 +7898,11 @@ function rcube_webmail()
var title = this.get_label(title), var title = this.get_label(title),
cancel_label = (options || {}).cancel_button || 'cancel', cancel_label = (options || {}).cancel_button || 'cancel',
save_label = (options || {}).button || 'save', 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'); }, close_func = function(e, ui, dialog) { (ref.is_framed() ? parent.$ : $)(dialog || this).dialog('close'); },
obj = this.is_framed() ? parent.rcmail : this,
buttons = [{ buttons = [{
text: ref.get_label(cancel_label), text: this.get_label(cancel_label),
'class': 'cancel', 'class': 'cancel',
click: close_func click: close_func
}]; }];
@ -7910,32 +7912,39 @@ function rcube_webmail()
else else
buttons.unshift({ buttons.unshift({
text: this.get_label(save_label), text: this.get_label(save_label),
'class': 'mainaction ' + save_label.replace(/^[^\.]+\./i, ''), 'class': 'mainaction ' + save_class,
click: function(e, ui) { if (action_func(e, ref)) close_func(e, ui, this); } click: function(e, ui) { if (action_func(e, obj)) close_func(e, ui, this); }
}); });
return this.show_popup_dialog(content, title, buttons, options); return this.show_popup_dialog(content, title, buttons, options);
}; };
// show_popup_dialog() wrapper for alert() type dialogs // show_popup_dialog() wrapper for alert() type dialogs
this.alert_dialog = function(content, action_func) this.alert_dialog = function(content, action_func, options)
{ {
var close_func = function(e, ui, dialog) { (ref.is_framed() ? parent.$ : $)(dialog || this).dialog('close'); }, 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 = [{ buttons = [{
text: ref.get_label('ok'), text: this.get_label('ok'),
'class': 'mainaction ok', 'class': 'mainaction ok',
click: function(e, ui) { if (!action_func || action_func(e, ref)) close_func(e, ui, this); } click: function(e, ui) { if (!action_func || action_func(e, obj)) close_func(e, ui, this); }
}], }],
options = { close: buttons[0].click }; args = { close: buttons[0].click };
return this.show_popup_dialog(content, this.get_label('alerttitle'), buttons, options); return this.show_popup_dialog(content, this.get_label(title), buttons, args);
}; };
// simple_dialog() wrapper for confirm() type dialogs // simple_dialog() wrapper for confirm() type dialogs
this.confirm_dialog = function(content, button_label, action_func) this.confirm_dialog = function(content, button_label, action_func, options)
{ {
var options = { button: button_label || 'continue' }; var title = (options || {}).title || 'confirmationtitle',
return this.simple_dialog(content, this.get_label('confirmationtitle'), action_func, options); 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 // enable/disable buttons for page shifting

Loading…
Cancel
Save