From: Alexander Ebert Date: Thu, 25 Aug 2016 17:19:35 +0000 (+0200) Subject: Added shortcut for submit X-Git-Tag: 3.0.0_Beta_1~500 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=db3f7abed0ea3307e935ceb0c5f8703cefff305f;p=GitHub%2FWoltLab%2FWCF.git Added shortcut for submit --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js index 5313e6d057..6ec4ffc4ce 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabKeydown.js @@ -45,6 +45,50 @@ $.Redactor.prototype.WoltLabKeydown = function() { return mpOnTab.call(this, e, key); }).bind(this); + + require(['Core', 'Environment'], (function (Core, Environment) { + if (Environment.platform() !== 'desktop') { + // ignore mobile devices + return; + } + + var container = this.$editor[0].closest('form, .message'); + if (container === null) return; + + var formSubmit = elBySel('.formSubmit', container); + if (formSubmit === null) return; + + var submitButton = elBySel('input[type="submit"], button[data-type="save"], button[accesskey="s"]', formSubmit); + if (submitButton) { + // remove access key + submitButton.removeAttribute('accesskey'); + + // mimic the same behavior which will also work with more + // than one editor instance on the page + this.WoltLabEvent.register('keydown', (function (data) { + // 83 = [S] + if (data.event.which === 83) { + var submit = false; + + if (window.navigator.platform.match(/^Mac/)) { + if (data.event.ctrlKey && data.event.altKey) { + submit = true; + } + } + else if (data.event.altKey && !data.event.ctrlKey) { + submit = true; + } + + if (submit) { + data.cancel = true; + + Core.triggerEvent(submitButton, WCF_CLICK_EVENT); + } + } + }).bind(this)); + } + }).bind(this)); + }, register: function (tag) {