window.rcmail && window.rcmail.addEventListener('init', function () { if (rcmail.env.task === 'settings' && rcmail.env.action === 'plugin.inbox_keys') { if (rcmail.gui_objects.keyslist) { rcmail.inbox_keys_list = new rcube_list_widget( rcmail.gui_objects.keyslist, {multiselect: true, draggable: false, keyboard: true}); rcmail.inbox_keys_list .addEventListener('select', list => rcmail.inbox_keys_select(list)) .addEventListener('keypress', list => rcmail.list_keypress(list, {del: 'plugin.inbox_keys_delete'})) .init() .focus(); } rcmail.register_command('plugin.inbox_keys_generate', () => rcmail.inbox_keys_generate()); rcmail.register_command('plugin.inbox_keys_import', () => rcmail.inbox_keys_import()); rcmail.register_command('plugin.inbox_keys_delete', () => rcmail.inbox_keys_delete()); } }); rcube_webmail.prototype.inbox_keys_select = function (list) { this.enable_command('plugin.inbox_keys_delete', list.get_selection().length > 0); }; rcube_webmail.prototype.inbox_keys_generate = function () { this.inbox_keys_reload('&_action=plugin.inbox_keys_generate'); }; rcube_webmail.prototype.inbox_keys_import = function () { this.inbox_keys_reload('&_action=plugin.inbox_keys_import'); }; rcube_webmail.prototype.inbox_keys_delete = function () { var keys = this.inbox_keys_list.get_selection(); if (!keys.length) return; this.confirm_dialog( this.get_label('inbox_settings.confirm_delete_key'), 'delete', function (_evt, ref) { var lock = ref.display_message( ref.get_label('inbox_settings.deleting_key', 'loading')); ref.http_post('plugin.inbox_keys_delete', {keys}, lock); // TODO: maybe reload }); }; rcube_webmail.prototype.inbox_keys_reload = function(url) { var win; if (win = this.get_frame_window(this.env.contentframe)) { if (!url) { if (win.location && win.location.href.indexOf(this.env.blankpage) < 0) { win.location.href = this.env.blankpage; } if (this.env.frame_lock) { this.set_busy(false, null, this.env.frame_lock); } return; } this.env.frame_lock = this.set_busy(true, 'loading'); win.location.href = this.env.comm_path + '&_framed=1' + url; } };