From 14259ce101fc6e7b5afa2bac325ae472f09cdba0 Mon Sep 17 00:00:00 2001 From: alecpl Date: Tue, 25 May 2010 08:42:39 +0000 Subject: - fixed parse error - support arguments of type object in enable_command() - simplify setting of state of message commands --- program/js/app.js | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 9b22eb24c..d948be82a 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -199,9 +199,11 @@ function rcube_webmail() if (this.env.trash_mailbox && this.env.mailbox != this.env.trash_mailbox) this.set_alttext('delete', 'movemessagetotrash'); + this.env.message_commands = ['show', 'reply', 'reply-all', 'forward', 'moveto', 'copy', 'delete', + 'open', 'mark', 'edit', 'viewsource', 'download', 'print', 'load-attachment', 'load-headers']; + if (this.env.action=='show' || this.env.action=='preview') { - this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'copy', 'delete', - 'open', 'mark', 'edit', 'viewsource', 'download', 'print', 'load-attachment', 'load-headers', true); + this.enable_command(this.env.message_commands, true); if (this.env.next_uid) { this.enable_command('nextmessage', 'lastmessage', true); @@ -1047,21 +1049,22 @@ function rcube_webmail() return obj ? false : true; }; - // set command enabled or disabled + // set command(s) enabled or disabled this.enable_command = function() { - var args = arguments, len = args.length; - if (!len) - return -1; - - var command, enable = args[len-1]; + var args = arguments, len = args.length, + command, enable = args[len-1]; for (var n=0, len=len-1; n 0 ? true : false)); // reset all-pages-selection @@ -2325,7 +2331,7 @@ function rcube_webmail() this.show_contentframe(false); // Hide message command buttons until a message is selected - this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', 'open', 'edit', 'viewsource', 'download', false); + this.enable_command(this.env.message_commands, false); this._with_selected_messages('moveto', lock, add_url); }; @@ -4930,6 +4936,7 @@ function rcube_webmail() if (response.callbacks && response.callbacks.length) { for (var i=0; i < response.callbacks.length; i++) this.triggerEvent(response.callbacks[i][0], response.callbacks[i][1]); + } // process the response data according to the sent action switch (response.action) { @@ -4944,7 +4951,7 @@ function rcube_webmail() case 'moveto': if (this.env.action == 'show') { // re-enable commands on move/delete error - this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', 'open', 'edit', 'viewsource', 'download', true); + this.enable_command(this.env.message_commands, true); } break; @@ -4955,8 +4962,7 @@ function rcube_webmail() if (this.env.contentframe) this.show_contentframe(false); // disable commands useless when mailbox is empty - this.enable_command('show', 'reply', 'reply-all', 'forward', 'moveto', 'copy', 'delete', - 'mark', 'viewsource', 'open', 'edit', 'download', 'print', 'load-attachment', + this.enable_command(this.env.message_commands, 'purge', 'expunge', 'select-all', 'select-none', 'sort', 'expand-all', 'expand-unread', 'collapse-all', false); } -- cgit v1.2.3