diff options
Diffstat (limited to 'keys.js')
| -rw-r--r-- | keys.js | 53 |
1 files changed, 50 insertions, 3 deletions
@@ -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; + } +}; |
