From f147849bb05a48fe721851b2ebc2d0d746e2ca75 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Tue, 4 Feb 2014 22:48:51 +0100 Subject: Use standard dialog popups for the ACL permissions form; that will open it in the main window with enoough space and better UI integration --- plugins/acl/acl.js | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'plugins/acl/acl.js') diff --git a/plugins/acl/acl.js b/plugins/acl/acl.js index d6934780f..6da96f3cc 100644 --- a/plugins/acl/acl.js +++ b/plugins/acl/acl.js @@ -11,9 +11,11 @@ if (window.rcmail) { rcmail.acl_list_init(); // enable autocomplete on user input if (rcmail.env.acl_users_source) { - rcmail.init_address_input_events($('#acluser'), {action:'settings/plugin.acl-autocomplete'}); + var inst = rcmail.is_framed() ? parent.rcmail : rcmail; + inst.init_address_input_events($('#acluser'), {action:'settings/plugin.acl-autocomplete'}); + // fix inserted value - rcmail.addEventListener('autocomplete_insert', function(e) { + inst.addEventListener('autocomplete_insert', function(e) { if (e.field.id != 'acluser') return; @@ -64,14 +66,14 @@ rcube_webmail.prototype.acl_delete = function() // Save ACL data rcube_webmail.prototype.acl_save = function() { - var user = $('#acluser').val(), rights = '', type; + var user = $('#acluser', this.acl_form).val(), rights = '', type; - $(':checkbox', this.env.acl_advanced ? $('#advancedrights') : sim_ul = $('#simplerights')).map(function() { + $((this.env.acl_advanced ? '#advancedrights :checkbox' : '#simplerights :checkbox'), this.acl_form).map(function() { if (this.checked) rights += this.value; }); - if (type = $('input:checked[name=usertype]').val()) { + if (type = $('input:checked[name=usertype]', this.acl_form).val()) { if (type != 'user') user = type; } @@ -97,7 +99,7 @@ rcube_webmail.prototype.acl_save = function() rcube_webmail.prototype.acl_cancel = function() { this.ksearch_blur(); - this.acl_form.hide(); + this.acl_popup.dialog('close'); } // Update data after save (and hide form) @@ -115,7 +117,7 @@ rcube_webmail.prototype.acl_update = function(o) // hide autocomplete popup this.ksearch_blur(); // hide form - this.acl_form.hide(); + this.acl_popup.dialog('close'); } // Switch table display mode @@ -300,7 +302,6 @@ rcube_webmail.prototype.acl_init_form = function(id) if (id && (row = this.acl_list.rows[id])) { row = row.obj; li_elements.map(function() { - val = this.value; td = $('td.'+this.id, row); if (td.length && td.hasClass('enabled')) this.checked = true; @@ -312,22 +313,37 @@ rcube_webmail.prototype.acl_init_form = function(id) type = id; } // mark read (lrs) rights by default - else + else { li_elements.filter(function() { return this.id.match(/^acl([lrs]|read)$/); }).prop('checked', true); + } name_input.val(val); $('input[value='+type+']').prop('checked', true); this.acl_id = id; - // position the form horizontally - var bw = body.width(), mw = this.acl_form.width(); + var me = this, inst = window.rcmail, body = document.body; + var buttons = {}; + buttons[rcmail.gettext('save')] = function(e) { inst.command('acl-save'); }; + buttons[rcmail.gettext('cancel')] = function(e) { inst.command('acl-cancel'); }; + + // display it as popup + this.acl_popup = rcmail.show_popup_dialog( + '
 
', + id ? rcmail.gettext('acl.editperms') : rcmail.gettext('acl.newuser'), + buttons, + { + modal: true, + closeOnEscape: false, + close: function(e, ui) { + me.acl_form.appendTo(body).hide(); + $(this).remove(); + } + } + ); - if (bw >= mw) - this.acl_form.css({left: parseInt((bw - mw)/2)+'px'}); + this.acl_form.appendTo(this.acl_popup).show(); - // display it - this.acl_form.show(); if (type == 'user') name_input.focus(); -- cgit v1.2.3