From de86d54e2f93d2b020898a6f9bb436237fc1c696 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 21 Nov 2014 16:48:57 +0100 Subject: [PATCH] Trying to work-around a lag issue with .focus() on iOS --- .../3rdParty/redactor/plugins/wmonkeypatch.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) 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; -- 2.20.1