From: Alexander Ebert Date: Tue, 25 Mar 2014 18:08:56 +0000 (+0100) Subject: Firefox is broken :( X-Git-Tag: 2.1.0_Alpha_1~966 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=60c1c067ddd93743444176d3e679fa31dcee4ddf;p=GitHub%2FWoltLab%2FWCF.git Firefox is broken :( --- diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index 19f589b90e..88c8555abe 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -3052,10 +3052,9 @@ WCF.Message.UserMention = Class.extend({ */ _getDropdownMenuPosition: function() { var $range = this._redactor.getSelection().getRangeAt(0); - var $orgRange = $range.cloneRange(); + var $startOffset = $range.startOffset; - // insert span before the '@' to prevent node splitting (or at least node splitting in between the username and the @) - $range.setStart($range.startContainer, $range.startOffset - (this._mentionStart.length + 1)); + $range.setStart($range.startContainer, $range.startOffset - this._mentionStart.length); $range.collapse(true); var $element = document.createElement('span'); @@ -3069,8 +3068,13 @@ WCF.Message.UserMention = Class.extend({ $jElement.remove(); + // inserting the node caused the text node to be split, merge them again + // using stupid DOM manipulation since .normalize() is broken in Internet Explorer 11 + $range.startContainer.nodeValue += $range.startContainer.nextSibling.textContent; + $range.startContainer.parentNode.removeChild($range.startContainer.nextSibling); + // move to end of node - $range.setEnd($orgRange.startContainer, $orgRange.startOffset); + $range.setEnd($range.startContainer, $startOffset); $range.collapse(false); return $offsets; @@ -3230,7 +3234,7 @@ WCF.Message.UserMention = Class.extend({ this._redactor.bufferSet(); var $range = this._redactor.getSelection().getRangeAt(0); - $range.setStart($range.startContainer, $range.startOffset - (this._mentionStart.length + 1)); + $range.setStart($range.startContainer, $range.startOffset - this._mentionStart.length); $range.deleteContents(); $range.collapse(true); @@ -3244,7 +3248,7 @@ WCF.Message.UserMention = Class.extend({ } // use native API to prevent issues in Internet Explorer - var $text = document.createTextNode('@' + username); + var $text = document.createTextNode(username); $range.insertNode($text); this._hideList(); @@ -3304,9 +3308,10 @@ WCF.Message.UserMention = Class.extend({ * Updates the position of the suggestion list. */ _updateSuggestionListPosition: function() { - try { + //try { var $dropdownMenuPosition = this._getDropdownMenuPosition(); $dropdownMenuPosition.top += 5 + this._lineHeight; // add little vertical gap + $dropdownMenuPosition.left -= 16; this._dropdownMenu.css($dropdownMenuPosition); this._selectItem(0); @@ -3320,10 +3325,10 @@ WCF.Message.UserMention = Class.extend({ else { this._dropdownMenu.removeClass('dropdownArrowBottom'); } - } + /*} catch (e) { // ignore errors that are caused by pressing enter to // often in a short period of time - } + }*/ } }); diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index fbcc4dfcf1..7dea10b0d8 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -180,8 +180,14 @@ function shuffle(array) { // detect smartphones jQuery.browser.smartphone = ($('html').css('caption-side') == 'bottom'); - // CKEditor support (disabled for Android & Windows Phone) - jQuery.browser.ckeditor = (navigator.userAgent.match(/(Android|Windows Phone)/i)) ? false : true; + // allow plugins to detect the used editor, value should be the same as the $.browser. key + jQuery.browser.editor = 'redactor'; + + // CKEditor support (removed in WCF 2.1), do NOT remove this variable for the sake for compatibility + jQuery.browser.ckeditor = false; + + // Redactor support + jQuery.browser.redactor = true; // properly detect IE11 if (jQuery.browser.mozilla && ua.match(/trident/)) {