From: Alexander Ebert Date: Fri, 21 Nov 2014 15:48:57 +0000 (+0100) Subject: Trying to work-around a lag issue with .focus() on iOS X-Git-Tag: 2.1.0_Beta_1~207 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=de86d54e2f93d2b020898a6f9bb436237fc1c696;p=GitHub%2FWoltLab%2FWCF.git Trying to work-around a lag issue with .focus() on iOS --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js index d3fab51bce..d3ee1b8768 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js +++ b/wcfsetup/install/files/js/3rdParty/redactor/plugins/wmonkeypatch.js @@ -124,6 +124,49 @@ RedactorPlugins.wmonkeypatch = function() { * - resolves a selection issue if start === end when setting the caret offsets */ caret: function() { + // this.caret.set + this.caret.set = (function(orgn, orgo, focn, foco) { + // focus + // WoltLab fix below [#1970] + //if (!this.utils.browser('msie')) this.$editor.focus(); + if (!this.utils.browser('msie')) { + if (this.utils.isMobile() && this.utils.browser('webkit') && navigator.userAgent.match(/(iPad|iPhone|iPod)/i)) { + if (document.activeElement !== this.$editor[0]) { + this.$editor.focus(); + } + } + else { + this.$editor.focus(); + } + } + + orgn = orgn[0] || orgn; + focn = focn[0] || focn; + + if (this.utils.isBlockTag(orgn.tagName) && orgn.innerHTML === '') + { + orgn.innerHTML = this.opts.invisibleSpace; + } + + if (orgn.tagName == 'BR' && this.opts.linebreaks === false) + { + var par = $(this.opts.emptyHtml)[0]; + $(orgn).replaceWith(par); + orgn = par; + focn = orgn; + } + + this.selection.get(); + + try { + this.range.setStart(orgn, orgo); + this.range.setEnd(focn, foco); + } + catch (e) {} + + this.selection.addRange(); + }).bind(this); + this.caret.setOffset = (function(start, end) { if (typeof end == 'undefined') end = start;