diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..6223617fa --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,262 @@ +module.exports = { + env: { + browser: true, + es6: true, + }, + extends: [ + 'airbnb-base', + 'plugin:unicorn/recommended', + ], + parserOptions: { + ecmaVersion: '2020', + sourceType: 'module', + }, + ignorePatterns: [ + '!.*', + '/vendor', + '/public_html', + '/plugins/jqueryui/js', + ], + rules: { + 'class-methods-use-this': 'off', + 'comma-dangle': ['error', { + arrays: 'always-multiline', + exports: 'always-multiline', + functions: 'never', + imports: 'always-multiline', + objects: 'always-multiline', + }], + 'consistent-return': 'off', + curly: ['error', 'all'], + 'default-case': 'off', + 'func-names': 'off', + 'import/no-unresolved': 'off', + 'import/prefer-default-export': 'off', + indent: ['error', 4, { + SwitchCase: 1, + }], + 'linebreak-style': ['error', 'unix'], + 'max-len': 'off', + 'no-console': 'off', + 'no-continue': 'off', + 'no-lonely-if': 'off', + 'no-multi-spaces': ['error', { + exceptions: { + Property: true, + VariableDeclarator: true, + }, + }], + 'no-nested-ternary': 'off', + 'no-param-reassign': 'off', + 'no-plusplus': 'off', + 'no-restricted-syntax': 'off', + 'no-underscore-dangle': 'off', + 'no-unused-vars': 'off', + 'object-shorthand': ['error', 'never'], + 'padding-line-between-statements': ['error', { + blankLine: 'always', + next: ['continue', 'break', 'export', 'return', 'throw'], + prev: '*', + }], + 'prefer-destructuring': 'off', + 'prefer-template': 'off', + 'spaced-comment': ['error', 'always', { + block: { + balanced: true, + exceptions: ['*'], + markers: ['!'], + }, + line: { + exceptions: ['-', '+'], + markers: ['/'], + }, + }], + strict: 'off', + 'unicorn/catch-error-name': 'off', + 'unicorn/no-array-callback-reference': 'off', + 'unicorn/no-lonely-if': 'off', + 'unicorn/no-negated-condition': 'off', + 'unicorn/no-null': 'off', + 'unicorn/no-this-assignment': 'off', + 'unicorn/numeric-separators-style': 'off', + 'unicorn/prefer-array-find': 'off', + 'unicorn/prefer-array-some': 'off', // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2007 + 'unicorn/prefer-module': 'off', + 'unicorn/prevent-abbreviations': 'off', + 'wrap-iife': ['error', 'inside'], + + // TODO rules to be removed/fixed later as fixes are not compatible with IE11 + 'guard-for-in': 'off', // refactor to "for of" + 'no-restricted-globals': 'off', + 'no-restricted-properties': 'off', + 'no-var': 'off', + 'one-var': 'off', + 'prefer-const': 'off', + 'prefer-exponentiation-operator': 'off', + 'prefer-rest-params': 'off', + 'prefer-spread': 'off', + 'semi-style': 'off', + 'unicorn/no-array-for-each': 'off', + 'unicorn/no-for-loop': 'off', // autofixes to "for of" + 'unicorn/prefer-code-point': 'off', + 'unicorn/prefer-includes': 'off', + 'unicorn/prefer-node-protocol': 'off', // needs Node 14+ + 'unicorn/prefer-number-properties': 'off', + 'unicorn/prefer-optional-catch-binding': 'off', + 'unicorn/prefer-prototype-methods': 'off', + 'unicorn/prefer-reflect-apply': 'off', + 'unicorn/prefer-spread': 'off', + 'unicorn/prefer-top-level-await': 'off', // needs Node 14+ + 'vars-on-top': 'off', + + // TODO + 'space-infix-ops': 'off', + 'quotes': 'off', + 'no-tabs': 'off', + 'space-before-function-paren': 'off', + 'no-undef': 'off', + 'no-shadow': 'off', + 'key-spacing': 'off', + 'block-spacing': 'off', + 'camelcase': 'off', + 'object-curly-spacing': 'off', + 'unicorn/prevent-abbreviations': 'off', // eslint-disable-line no-dupe-keys + 'no-var': 'off', // eslint-disable-line no-dupe-keys + 'one-var-declaration-per-line': 'off', + 'curly': 'off', // eslint-disable-line no-dupe-keys + 'space-in-parens': 'off', + 'space-before-blocks': 'off', + 'nonblock-statement-body-position': 'off', + 'brace-style': 'off', + 'eqeqeq': 'off', + 'array-bracket-spacing': 'off', + 'one-var': 'off', // eslint-disable-line no-dupe-keys + 'keyword-spacing': 'off', + 'yoda': 'off', + 'no-unused-expressions': 'off', + 'padding-line-between-statements': 'off', // eslint-disable-line no-dupe-keys + 'no-use-before-define': 'off', + 'prefer-arrow-callback': 'off', + 'no-sequences': 'off', + 'vars-on-top': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/no-null': 'off', // eslint-disable-line no-dupe-keys + 'block-scoped-var': 'off', + 'object-curly-newline': 'off', + 'no-return-assign': 'off', + 'unicorn/explicit-length-check': 'off', + 'unicorn/switch-case-braces': 'off', + 'no-mixed-operators': 'off', + 'no-cond-assign': 'off', + 'padded-blocks': 'off', + 'switch-colon-spacing': 'off', + 'comma-dangle': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-module': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-number-properties': 'off', // eslint-disable-line no-dupe-keys + 'strict': 'off', // eslint-disable-line no-dupe-keys + 'no-redeclare': 'off', + 'no-extra-semi': 'off', + 'function-paren-newline': 'off', + 'unicorn/no-this-assignment': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/no-nested-ternary': 'off', + 'unicorn/no-negated-condition': 'off', // eslint-disable-line no-dupe-keys + 'computed-property-spacing': 'off', + 'no-restricted-globals': 'off', // eslint-disable-line no-dupe-keys + 'quote-props': 'off', + 'no-multiple-empty-lines': 'off', + 'wrap-iife': 'off', // eslint-disable-line no-dupe-keys + 'no-multi-assign': 'off', + 'no-multi-spaces': 'off', // eslint-disable-line no-dupe-keys + 'newline-per-chained-call': 'off', + 'unicorn/prefer-query-selector': 'off', + 'unicorn/better-regex': 'off', + 'unicorn/prefer-string-replace-all': 'off', + 'no-void': 'off', + 'prefer-rest-params': 'off', // eslint-disable-line no-dupe-keys + 'no-bitwise': 'off', + 'spaced-comment': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-string-slice': 'off', + 'unicorn/catch-error-name': 'off', // eslint-disable-line no-dupe-keys + 'no-useless-escape': 'off', + 'guard-for-in': 'off', // eslint-disable-line no-dupe-keys + 'object-property-newline': 'off', + 'unicorn/consistent-function-scoping': 'off', + 'unicorn/prefer-regexp-test': 'off', + 'unicorn/prefer-optional-catch-binding': 'off', // eslint-disable-line no-dupe-keys + 'dot-notation': 'off', + 'unicorn/prefer-includes': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-spread': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-reflect-apply': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/no-array-callback-reference': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-dom-node-append': 'off', + 'unicorn/numeric-separators-style': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-add-event-listener': 'off', + 'unicorn/no-lonely-if': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-date-now': 'off', + 'unicorn/prefer-code-point': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-logical-operator-over-ternary': 'off', + 'no-unneeded-ternary': 'off', + 'no-empty': 'off', + 'new-cap': 'off', + 'function-call-argument-newline': 'off', + 'unicorn/filename-case': 'off', + 'no-else-return': 'off', + 'unicorn/prefer-ternary': 'off', + 'new-parens': 'off', + 'no-fallthrough': 'off', + 'operator-linebreak': 'off', + 'space-unary-ops': 'off', + 'radix': 'off', + 'unicorn/no-array-method-this-argument': 'off', + 'no-floating-decimal': 'off', + 'array-callback-return': 'off', + 'prefer-spread': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-string-starts-ends-with': 'off', + 'unicorn/require-array-join-separator': 'off', + 'unicorn/prefer-at': 'off', + 'unicorn/no-typeof-undefined': 'off', + 'unicorn/prefer-dom-node-remove': 'off', + 'no-throw-literal': 'off', + 'no-loop-func': 'off', + 'prefer-exponentiation-operator': 'off', // eslint-disable-line no-dupe-keys + 'no-restricted-properties': 'off', // eslint-disable-line no-dupe-keys + 'operator-assignment': 'off', + 'no-alert': 'off', + 'unicorn/escape-case': 'off', + 'unicorn/prefer-dom-node-dataset': 'off', + 'unicorn/empty-brace-spaces': 'off', + 'unicorn/no-for-loop': 'off', // eslint-disable-line no-dupe-keys + 'lines-around-directive': 'off', + 'unicorn/no-hex-escape': 'off', + 'no-script-url': 'off', + 'no-extend-native': 'off', + 'no-shadow-restricted-names': 'off', + 'unicorn/prefer-math-trunc': 'off', + 'no-labels': 'off', + 'unicorn/prefer-modern-math-apis': 'off', + 'no-eval': 'off', + 'unicorn/new-for-builtins': 'off', + 'unicorn/no-array-for-each': 'off', // eslint-disable-line no-dupe-keys + 'unicorn/prefer-modern-dom-apis': 'off', + 'no-extra-boolean-cast': 'off', + 'no-control-regex': 'off', + 'no-label-var': 'off', + 'global-require': 'off', + 'prefer-regex-literals': 'off', + 'no-array-constructor': 'off', + 'eol-last': 'off', + 'unicorn/no-new-array': 'off', + 'no-debugger': 'off', + 'no-whitespace-before-property': 'off', + 'no-constant-condition': 'off', + 'no-implied-eval': 'off', + 'unicorn/no-document-cookie': 'off', + 'unicorn/prefer-default-parameters': 'off', + 'unicorn/prefer-negative-index': 'off', + 'no-regex-spaces': 'off', + 'unicorn/no-useless-undefined': 'off', + }, + reportUnusedDisableDirectives: true, + globals: { + jQuery: true, + }, +}; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e0dae0ef..4ef78554b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,12 +33,17 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-interaction --no-progress - - name: Check Coding Style + - name: Check Coding Style - PHP run: vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --diff --verbose - name: Check composer.json format run: composer validate --strict --no-check-lock && composer normalize --dry-run --no-check-lock + - name: Check Coding Style - JS + run: | + npm add -D eslint eslint-plugin-import eslint-config-airbnb-base eslint-plugin-unicorn + npx eslint --ext .js . + phpstan: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" diff --git a/.gitignore b/.gitignore index ec830e407..7b36d6da6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,11 @@ program/js/jstz.min.js program/js/publickey.js program/js/tinymce/ +# eslint dependencies +/node_modules +/package.json +/package-lock.json + # skin customization files skins/elastic/styles/_styles.less skins/elastic/styles/_variables.less diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 54dc0a2d0..24808749c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -5,7 +5,6 @@ $finder = PhpCsFixer\Finder::create() ->exclude(['vendor']) ->ignoreDotFiles(false) ->name('*.php.dist') - ->name('*.dist.php') ->name('*.sh'); return (new PhpCsFixer\Config()) diff --git a/installer/client.js b/installer/client.js index e08ce22fa..f74125fc1 100644 --- a/installer/client.js +++ b/installer/client.js @@ -15,34 +15,34 @@ function toggleblock(id, link) { - var block = document.getElementById(id); + var block = document.getElementById(id); - return false; + return false; } function addhostfield() { - var container = document.getElementById('defaulthostlist'); - var row = document.createElement('div'); - var input = document.createElement('input'); - var link = document.createElement('a'); + var container = document.getElementById('defaulthostlist'); + var row = document.createElement('div'); + var input = document.createElement('input'); + var link = document.createElement('a'); - input.name = '_imap_host[]'; - input.size = '30'; - link.href = '#'; - link.onclick = function() { removehostfield(this.parentNode); return false }; - link.className = 'removelink'; - link.innerHTML = 'remove'; + input.name = '_imap_host[]'; + input.size = '30'; + link.href = '#'; + link.onclick = function() { removehostfield(this.parentNode); return false; }; + link.className = 'removelink'; + link.innerHTML = 'remove'; - row.appendChild(input); - row.appendChild(link); - container.appendChild(row); + row.appendChild(input); + row.appendChild(link); + container.appendChild(row); } function removehostfield(row) { - var container = document.getElementById('defaulthostlist'); - container.removeChild(row); + var container = document.getElementById('defaulthostlist'); + container.removeChild(row); } diff --git a/plugins/acl/acl.js b/plugins/acl/acl.js index 531248d63..2129fe1a8 100644 --- a/plugins/acl/acl.js +++ b/plugins/acl/acl.js @@ -51,7 +51,7 @@ if (window.rcmail) { rcube_webmail.prototype.acl_create = function() { this.acl_init_form(); -} +}; // Display ACL edit form rcube_webmail.prototype.acl_edit = function() @@ -60,7 +60,7 @@ rcube_webmail.prototype.acl_edit = function() var id = this.acl_list.get_single_selection(); if (id) this.acl_init_form(id); -} +}; // ACL entry delete rcube_webmail.prototype.acl_delete = function() @@ -76,7 +76,7 @@ rcube_webmail.prototype.acl_delete = function() }, ref.set_busy(true, 'acl.deleting')); }); } -} +}; // Save ACL data rcube_webmail.prototype.acl_save = function() @@ -107,21 +107,21 @@ rcube_webmail.prototype.acl_save = function() _user: user, _acl: rights, _mbox: this.env.mailbox - } + }; if (this.acl_id) { data._old = this.acl_id; } this.http_post('settings/plugin.acl', data, this.set_busy(true, 'acl.saving')); -} +}; // Cancel/Hide form rcube_webmail.prototype.acl_cancel = function() { this.ksearch_blur(); this.acl_popup.dialog('close'); -} +}; // Update data after save (and hide form) rcube_webmail.prototype.acl_update = function(o) @@ -139,7 +139,7 @@ rcube_webmail.prototype.acl_update = function(o) this.ksearch_blur(); // hide form this.acl_popup.dialog('close'); -} +}; // Switch table display mode rcube_webmail.prototype.acl_mode_switch = function(elem) @@ -149,8 +149,8 @@ rcube_webmail.prototype.acl_mode_switch = function(elem) this.http_request('settings/plugin.acl', '_act=list' + '&_mode='+(this.env.acl_advanced ? 'advanced' : 'simple') + '&_mbox='+urlencode(this.env.mailbox), - this.set_busy(true, 'loading')); -} + this.set_busy(true, 'loading')); +}; // ACL table initialization rcube_webmail.prototype.acl_list_init = function() @@ -166,7 +166,7 @@ rcube_webmail.prototype.acl_list_init = function() .addEventListener('dblclick', function(o) { rcmail.acl_list_dblclick(o); }) .addEventListener('keypress', function(o) { rcmail.acl_list_keypress(o); }) .init(); -} +}; // ACL table row selection handler rcube_webmail.prototype.acl_list_select = function(list) @@ -174,13 +174,13 @@ rcube_webmail.prototype.acl_list_select = function(list) rcmail.enable_command('acl-delete', list.get_selection().length > 0); rcmail.enable_command('acl-edit', list.get_selection().length == 1); list.focus(); -} +}; // ACL table double-click handler rcube_webmail.prototype.acl_list_dblclick = function(list) { this.acl_edit(); -} +}; // ACL table keypress handler rcube_webmail.prototype.acl_list_keypress = function(list) @@ -190,14 +190,14 @@ rcube_webmail.prototype.acl_list_keypress = function(list) else if (list.key_pressed == list.DELETE_KEY || list.key_pressed == list.BACKSPACE_KEY) if (!this.acl_form || !this.acl_form.is(':visible')) this.command('acl-delete'); -} +}; // Reloads ACL table rcube_webmail.prototype.acl_list_update = function(html) { $(this.gui_objects.acltable).html(html); this.acl_list_init(); -} +}; // Returns names of users in selected rows rcube_webmail.prototype.acl_get_usernames = function() @@ -216,7 +216,7 @@ rcube_webmail.prototype.acl_get_usernames = function() } return users; -} +}; // Removes ACL table row rcube_webmail.prototype.acl_remove_row = function(id) @@ -232,7 +232,7 @@ rcube_webmail.prototype.acl_remove_row = function(id) this.enable_command('acl-delete', list.get_selection().length > 0); this.enable_command('acl-edit', list.get_selection().length == 1); -} +}; // Adds ACL table row rcube_webmail.prototype.acl_add_row = function(o, sel) @@ -295,7 +295,7 @@ rcube_webmail.prototype.acl_add_row = function(o, sel) if (sel) list.select_row(o.id); -} +}; // Initializes and shows ACL create/edit form rcube_webmail.prototype.acl_init_form = function(id) @@ -377,7 +377,7 @@ rcube_webmail.prototype.acl_init_form = function(id) name_input.focus(); else $('input:checked', type_list).focus(); -} +}; // Returns class name according to ACL comparison result rcube_webmail.prototype.acl_class = function(acl1, acl2) @@ -397,4 +397,4 @@ rcube_webmail.prototype.acl_class = function(acl1, acl2) return 'partial'; return 'disabled'; -} +}; diff --git a/plugins/archive/archive.js b/plugins/archive/archive.js index 0975dff07..13217ee95 100644 --- a/plugins/archive/archive.js +++ b/plugins/archive/archive.js @@ -17,65 +17,65 @@ function rcmail_archive(prop) { - if (rcmail_is_archive()) - return; + if (rcmail_is_archive()) + return; - var post_data = rcmail.selection_post_data(); + var post_data = rcmail.selection_post_data(); - // exit if selection is empty - if (!post_data._uid) - return; + // exit if selection is empty + if (!post_data._uid) + return; - // Disable message command buttons until a message is selected - rcmail.enable_command(rcmail.env.message_commands, false); - rcmail.enable_command('plugin.archive', false); + // Disable message command buttons until a message is selected + rcmail.enable_command(rcmail.env.message_commands, false); + rcmail.enable_command('plugin.archive', false); - // let the server sort the messages to the according subfolders - rcmail.with_selected_messages('move', post_data, null, 'plugin.move2archive'); + // let the server sort the messages to the according subfolders + rcmail.with_selected_messages('move', post_data, null, 'plugin.move2archive'); - // Reset preview (must be after with_selected_messages() call) - rcmail.show_contentframe(false); + // Reset preview (must be after with_selected_messages() call) + rcmail.show_contentframe(false); } function rcmail_is_archive() { - // check if current folder is an archive folder or one of its children - return rcmail.env.mailbox == rcmail.env.archive_folder + // check if current folder is an archive folder or one of its children + return rcmail.env.mailbox == rcmail.env.archive_folder || rcmail.env.mailbox.startsWith(rcmail.env.archive_folder + rcmail.env.delimiter); } // callback for app-onload event if (window.rcmail) { - rcmail.addEventListener('init', function(evt) { + rcmail.addEventListener('init', function(evt) { // register command (directly enable in message view mode) - rcmail.register_command('plugin.archive', rcmail_archive, rcmail.env.uid && !rcmail_is_archive()); + rcmail.register_command('plugin.archive', rcmail_archive, rcmail.env.uid && !rcmail_is_archive()); - // add event-listener to message list - if (rcmail.message_list) - rcmail.message_list.addEventListener('select', function(list) { - rcmail.enable_command('plugin.archive', list.get_selection().length > 0 && !rcmail_is_archive()); - }); + // add event-listener to message list + if (rcmail.message_list) + rcmail.message_list.addEventListener('select', function(list) { + rcmail.enable_command('plugin.archive', list.get_selection().length > 0 && !rcmail_is_archive()); + }); - // set css style for archive folder - var li; - if (rcmail.env.archive_folder) { - // in Settings > Folders - if (rcmail.subscription_list) - li = rcmail.subscription_list.get_item(rcmail.env.archive_folder); - // in folders list - else - li = rcmail.get_folder_li(rcmail.env.archive_folder, '', true); + // set css style for archive folder + var li; + if (rcmail.env.archive_folder) { + // in Settings > Folders + if (rcmail.subscription_list) + li = rcmail.subscription_list.get_item(rcmail.env.archive_folder); + // in folders list + else + li = rcmail.get_folder_li(rcmail.env.archive_folder, '', true); - if (li) - $(li).addClass('archive'); + if (li) + $(li).addClass('archive'); - // in folder selector popup - rcmail.addEventListener('menu-open', function(p) { - if (p.name == 'folder-selector') { - var search = rcmail.env.archive_folder; - $('a', p.obj).filter(function() { return $(this).data('id') == search; }).parent().addClass('archive'); + // in folder selector popup + rcmail.addEventListener('menu-open', function(p) { + if (p.name == 'folder-selector') { + var search = rcmail.env.archive_folder; + $('a', p.obj).filter(function() { return $(this).data('id') == search; }).parent().addClass('archive'); + } + }); } - }); - } - }); + }); } diff --git a/plugins/attachment_reminder/attachment_reminder.js b/plugins/attachment_reminder/attachment_reminder.js index 633922a51..828d38488 100644 --- a/plugins/attachment_reminder/attachment_reminder.js +++ b/plugins/attachment_reminder/attachment_reminder.js @@ -17,71 +17,71 @@ function rcmail_get_compose_message() { - var msg = rcmail.editor.get_content({ nosig: true }); + var msg = rcmail.editor.get_content({ nosig: true }); - if (rcmail.editor.is_html()) { + if (rcmail.editor.is_html()) { // Remove quoted content, all HTML tags, and some entities - msg = msg.replace(/]*>(.|[\r\n])*<\/blockquote>/gmi, '') - .replace(/<[^>]+>/gm, ' ') - .replace(/ /g, ' '); - } - else { + msg = msg.replace(/]*>(.|[\r\n])*<\/blockquote>/gmi, '') + .replace(/<[^>]+>/gm, ' ') + .replace(/ /g, ' '); + } + else { // Remove quoted content - msg = msg.replace(/^>.*$/gmi, ''); - } + msg = msg.replace(/^>.*$/gmi, ''); + } - return msg; + return msg; }; function rcmail_check_message(msg) { - var i, rx, keywords = rcmail.get_label('keywords', 'attachment_reminder').split(",").concat([".doc", ".pdf"]); + var i, rx, keywords = rcmail.get_label('keywords', 'attachment_reminder').split(",").concat([".doc", ".pdf"]); - keywords = $.map(keywords, function(n) { return RegExp.escape(n); }); - rx = new RegExp('(' + keywords.join('|') + ')', 'i'); + keywords = $.map(keywords, function(n) { return RegExp.escape(n); }); + rx = new RegExp('(' + keywords.join('|') + ')', 'i'); - return msg.search(rx) != -1; + return msg.search(rx) != -1; }; function rcmail_have_attachments() { - return rcmail.env.attachments && $('li', rcmail.gui_objects.attachmentlist).length; + return rcmail.env.attachments && $('li', rcmail.gui_objects.attachmentlist).length; }; function rcmail_attachment_reminder_dialog() { - var buttons = {}; + var buttons = {}; - buttons[rcmail.get_label('addattachment')] = function() { - $(this).remove(); - $('#messagetoolbar a.attach, .toolbar a.attach').first().click(); - }; - buttons[rcmail.get_label('send')] = function(e) { - $(this).remove(); - rcmail.env.attachment_reminder = true; - rcmail.command('send', '', e); - }; + buttons[rcmail.get_label('addattachment')] = function() { + $(this).remove(); + $('#messagetoolbar a.attach, .toolbar a.attach').first().click(); + }; + buttons[rcmail.get_label('send')] = function(e) { + $(this).remove(); + rcmail.env.attachment_reminder = true; + rcmail.command('send', '', e); + }; - rcmail.env.attachment_reminder = false; - rcmail.show_popup_dialog( - rcmail.get_label('attachment_reminder.forgotattachment'), - rcmail.get_label('attachment_reminder.missingattachment'), - buttons, - {button_classes: ['mainaction attach', 'send']} - ); + rcmail.env.attachment_reminder = false; + rcmail.show_popup_dialog( + rcmail.get_label('attachment_reminder.forgotattachment'), + rcmail.get_label('attachment_reminder.missingattachment'), + buttons, + {button_classes: ['mainaction attach', 'send']} + ); }; if (window.rcmail) { - rcmail.addEventListener('beforesend', function(evt) { - var msg = rcmail_get_compose_message(), - subject = $('#compose-subject').val(); + rcmail.addEventListener('beforesend', function(evt) { + var msg = rcmail_get_compose_message(), + subject = $('#compose-subject').val(); - if (!rcmail.env.attachment_reminder && !rcmail_have_attachments() + if (!rcmail.env.attachment_reminder && !rcmail_have_attachments() && (rcmail_check_message(msg) || rcmail_check_message(subject)) - ) { - rcmail_attachment_reminder_dialog(); - return false; - } - }); + ) { + rcmail_attachment_reminder_dialog(); + return false; + } + }); } diff --git a/plugins/enigma/enigma.js b/plugins/enigma/enigma.js index 647b22ba5..9b90ec70e 100644 --- a/plugins/enigma/enigma.js +++ b/plugins/enigma/enigma.js @@ -198,10 +198,10 @@ rcube_webmail.prototype.enigma_key_create_save = function() openpgp.generateKey(options).then(function(keypair) { // success var post = { - _a: 'import', - _keys: keypair.privateKey, - _generated: 1, - _passwd: password + _a: 'import', + _keys: keypair.privateKey, + _generated: 1, + _passwd: password }; // send request to server @@ -306,7 +306,7 @@ rcube_webmail.prototype.enigma_export_submit = function(data) var id = 'keyexport-' + new Date().getTime(), form = $('
').attr({target: id, method: 'post', style: 'display:none', action: '?_action=plugin.enigmakeys&_task=settings&_a=export'}), - iframe = $('