From 2a3c067a8595082558172ddf8e42414c32e7a688 Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Mon, 30 Dec 2024 20:40:48 -0800 Subject: this seems sketchy but we ball --- keys.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) (limited to 'keys.js') diff --git a/keys.js b/keys.js index b9074a4..b07ba56 100644 --- a/keys.js +++ b/keys.js @@ -6,13 +6,60 @@ window.rcmail && window.rcmail.addEventListener('init', function () { rcmail.gui_objects.keyslist, {multiselect: true, draggable: false, keyboard: true}); rcmail.inbox_keys_list - .addEventListener('select', - list => rcmail.enable_command( - 'plugin.inbox_keys_delete', list.get_selection().length > 0)) + .addEventListener('select', rcmail.inbox_keys_select) .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; + } +}; -- cgit v1.2.3