Revert "[BUGFIX] In IE9, RTE does not work correctly in compat modes IE8/IE7"
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 3 Jul 2012 21:07:06 +0000 (23:07 +0200)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 3 Jul 2012 21:07:28 +0000 (23:07 +0200)
This reverts commit 5e4d5cfcc7843c3278b2f07ac9d394405910f52d

Avoid reliance on order of style sheets.

Change-Id: I68640bbc7e49a7643db2070e3a6a5c27056e9fab
Reviewed-on: http://review.typo3.org/12559
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/ContextMenu/context-menu.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Link/typo3link.js

index e6f04ac..777df02 100644 (file)
@@ -56,10 +56,6 @@ Ext.apply(HTMLArea, {
        RE_noClosingTag         : /^(area|base|br|col|command|embed|hr|img|input|keygen|meta|param|source|track|wbr)$/i,
        RE_numberOrPunctuation  : /[0-9.(),;:!¡?¿%#$'"_+=\\\/-]*/g,
        /***************************************************
-        * BROWSER IDENTIFICATION                          *
-        ***************************************************/
-       isIEBeforeIE9: Ext.isIE6 || Ext.isIE7 || Ext.isIE8 || (Ext.isIE && typeof(document.documentMode) !== 'undefined' && document.documentMode < 9),
-       /***************************************************
         * LOCALIZATION                                    *
         ***************************************************/
        localize: function (label, plural) {
@@ -1003,7 +999,7 @@ HTMLArea.Iframe = Ext.extend(Ext.BoxComponent, {
         * @return      void
         */
        initializeCustomTags: function () {
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8 || (Ext.isIE && this.document.documentMode < 9)) {
                        Ext.each(this.config.customTags, function (tag) {
                                this.document.createElement(tag);
                        }, this);
@@ -3055,7 +3051,7 @@ HTMLArea.DOM = function () {
                 * @return      string          the text inside the node
                 */
                getInnerText: function (node) {
-                       return HTMLArea.isIEBeforeIE9 ? node.innerText : node.textContent;;
+                       return (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) ? node.innerText : node.textContent;;
                },
                /*
                 * Get the block ancestors of a node within a given block
@@ -3181,7 +3177,7 @@ HTMLArea.DOM = function () {
                        var rangeIntersectsNode = false,
                                ownerDocument = node.ownerDocument;
                        if (ownerDocument) {
-                               if (HTMLArea.isIEBeforeIE9) {
+                               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                                        var nodeRange = ownerDocument.body.createTextRange();
                                        nodeRange.moveToElementText(node);
                                        rangeIntersectsNode = (range.compareEndPoints('EndToStart', nodeRange) == -1 && range.compareEndPoints('StartToEnd', nodeRange) == 1) ||
@@ -3612,7 +3608,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                var isEmpty = true;
                this.get();
                if (!Ext.isEmpty(this.selection)) {
-                       if (HTMLArea.isIEBeforeIE9) {
+                       if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                                switch (this.selection.type) {
                                        case 'None':
                                                isEmpty = true;
@@ -3638,7 +3634,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        createRange: function () {
                var range;
                this.get();
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        range = this.selection.createRange();
                } else {
                        if (Ext.isEmpty(this.selection)) {
@@ -3750,7 +3746,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        selectNode: function (node, endPoint) {
                this.get();
                if (!Ext.isEmpty(this.selection)) {
-                       if (HTMLArea.isIEBeforeIE9) {
+                       if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                                        // IE8/7/6 cannot set this type of selection
                                this.selectNodeContents(node, endPoint);
                        } else if (Ext.isWebKit && /^(img)$/i.test(node.nodeName)) {
@@ -3787,7 +3783,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                var range;
                this.get();
                if (!Ext.isEmpty(this.selection)) {
-                       if (HTMLArea.isIEBeforeIE9) {
+                       if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                                range = this.document.body.createTextRange();
                                range.moveToElementText(node);
                        } else {
@@ -3819,7 +3815,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                var parentElement,
                        range;
                this.get();
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        range = this.createRange();
                        switch (this.selection.type) {
                                case 'Text':
@@ -3948,7 +3944,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                        var range = this.createRange();
                        var ancestors = this.getAllAncestors();
                        Ext.each(ancestors, function (ancestor) {
-                               if (HTMLArea.isIEBeforeIE9) {
+                               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                                        isFullySelected = (type !== 'Control' && ancestor.innerText == range.text) || (type === 'Control' && ancestor.innerText == range.item(0).text);
                                } else {
                                        isFullySelected = (ancestor.textContent == range.toString());
@@ -3978,7 +3974,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                var range = this.createRange(),
                        parentStart,
                        parentEnd;
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        if (this.getType() === 'Control') {
                                parentStart = range.item(0);
                                parentEnd = parentStart;
@@ -4033,7 +4029,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        getHtml: function () {
                var range = this.createRange(),
                        html = '';
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        if (this.getType() === 'Control') {
                                        // We have a controlRange collection
                                var bodyRange = this.document.body.createTextRange();
@@ -4061,7 +4057,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
         * @return      object          this
         */
        insertNode: function (toBeInserted) {
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        this.insertHtml(toBeInserted.outerHTML);
                } else {
                        var range = this.createRange();
@@ -4081,7 +4077,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
         * @return      object          this
         */
        insertHtml: function (html) {
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        this.get();
                        if (this.getType() === 'Control') {
                                this.selection.clear();
@@ -4142,7 +4138,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
         */
        handleBackSpace: function () {
                var range = this.createRange();
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        if (this.getType() === 'Control') {
                                        // Deleting or backspacing on a control selection : delete the element
                                var element = this.getParentElement();
@@ -4572,7 +4568,7 @@ HTMLArea.DOM.BookMark = Ext.extend(HTMLArea.DOM.BookMark, {
         */
        get: function (range) {
                var bookMark;
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                                // Bookmarking will not work on control ranges
                        try {
                                bookMark = range.getBookmark();
@@ -4645,7 +4641,7 @@ HTMLArea.DOM.BookMark = Ext.extend(HTMLArea.DOM.BookMark, {
         */
        moveTo: function (bookMark) {
                var range = this.selection.createRange();
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        if (bookMark) {
                                range.moveToBookmark(bookMark);
                        }
@@ -4739,7 +4735,7 @@ HTMLArea.DOM.Node = Ext.extend(HTMLArea.DOM.Node, {
         * @return      void
         */
        wrapWithInlineElement: function (element, range) {
-               if (HTMLArea.isIEBeforeIE9) {
+               if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                        var nodeName = element.nodeName;
                        var bookMark = this.bookMark.get(range);
                        if (range.parentElement) {
@@ -5291,11 +5287,11 @@ HTMLArea.CSS.Parser = Ext.extend(Ext.util.Observable, {
                                this.error = 'Document.readyState not complete';
                        }
                } else {
-                       if (HTMLArea.isIEBeforeIE9) {
+                       if (Ext.isIE) {
                                try {
                                        var rules = this.editor.document.styleSheets[0].rules;
                                        var imports = this.editor.document.styleSheets[0].imports;
-                                       if (!rules.length && !imports.length && index != 1 && typeof(document.documentMode) === 'undefined') {
+                                       if (!rules.length && !imports.length) {
                                                this.cssLoaded = false;
                                                this.error = 'Empty rules and imports arrays';
                                        }
@@ -5317,11 +5313,11 @@ HTMLArea.CSS.Parser = Ext.extend(Ext.util.Observable, {
                        if (this.editor.document.styleSheets.length > 2) {
                                Ext.each(this.editor.document.styleSheets, function (styleSheet, index) {
                                        try {
-                                               if (HTMLArea.isIEBeforeIE9) {
+                                               if (Ext.isIE) {
                                                        var rules = styleSheet.rules;
                                                        var imports = styleSheet.imports;
                                                                // Default page style may contain only a comment
-                                                       if (!rules.length && !imports.length && index != 1 && typeof(document.documentMode) === 'undefined') {
+                                                       if (!rules.length && !imports.length && index != 1) {
                                                                this.cssLoaded = false;
                                                                this.error = 'Empty rules and imports arrays of styleSheets[' + index + ']';
                                                                return false;
index 4841915..13cf446 100644 (file)
@@ -177,7 +177,7 @@ HTMLArea.ContextMenu = Ext.extend(HTMLArea.Plugin, {
         */
        showMenu: function (target) {
                this.showContextItems(target);
-               if (!HTMLArea.isIEBeforeIE9) {
+               if (!(Ext.isIE6 || Ext.isIE7 || Ext.isIE8)) {
                        this.ranges = this.editor.getSelection().getRanges();
                }
                var iframeEl = this.editor.iframe.getEl();
@@ -236,7 +236,7 @@ HTMLArea.ContextMenu = Ext.extend(HTMLArea.Plugin, {
         * Handler invoked when a menu item is clicked on
         */
        onItemClick: function (item, event) {
-               if (!HTMLArea.isIEBeforeIE9) {
+               if (!(Ext.isIE6 || Ext.isIE7 || Ext.isIE8)) {
                        this.editor.getSelection().setRanges(this.ranges);
                }
                var button = this.getButton(item.getItemId());
index 48d6648..e88edc9 100644 (file)
@@ -229,7 +229,7 @@ HTMLArea.TYPO3Link = Ext.extend(HTMLArea.Plugin, {
                                // Cleanup selected range
                        range = this.editor.getSelection().createRange();
                                // Clean existing anchors otherwise Mozilla may create nested anchors while IE may update existing link
-                       if (HTMLArea.isIEBeforeIE9) {
+                       if (Ext.isIE8 || Ext.isIE7 || Ext.isIE6) {
                                this.cleanAllLinks(node, range, true);
                                this.editor.getSelection().execCommand('UnLink', false, null);
                        } else {
@@ -285,7 +285,7 @@ HTMLArea.TYPO3Link = Ext.extend(HTMLArea.Plugin, {
                }
                if (HTMLArea.classesAnchorSetup) {
                        var range = this.editor.getSelection().createRange();
-                       if (!HTMLArea.isIEBeforeIE9) {
+                       if (!(Ext.isIE6 || Ext.isIE7 || Ext.isIE8)) {
                                this.cleanAllLinks(node, range, false);
                        } else {
                                this.cleanAllLinks(node, range, true);
@@ -316,7 +316,7 @@ HTMLArea.TYPO3Link = Ext.extend(HTMLArea.Plugin, {
        setLinkAttributes: function(node, range, cur_target, cur_class, cur_title, imageNode, addIconAfterLink, additionalValues) {
                if (/^a$/i.test(node.nodeName)) {
                        var nodeInRange = false;
-                       if (!HTMLArea.isIEBeforeIE9) {
+                       if (!(Ext.isIE6 || Ext.isIE7 || Ext.isIE8)) {
                                this.editor.focus();
                                nodeInRange = HTMLArea.DOM.rangeIntersectsNode(range, node);
                        } else {
@@ -347,7 +347,7 @@ HTMLArea.TYPO3Link = Ext.extend(HTMLArea.Plugin, {
                                } else {
                                        if (!Ext.isOpera) {
                                                node.removeAttribute('class');
-                                               if (HTMLArea.isIEBeforeIE9) {
+                                               if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
                                                        node.removeAttribute('className');
                                                }
                                        } else {
@@ -411,7 +411,7 @@ HTMLArea.TYPO3Link = Ext.extend(HTMLArea.Plugin, {
        cleanAllLinks: function(node, range, keepLinks) {
                if (/^a$/i.test(node.nodeName)) {
                        var intersection = false;
-                       if (!HTMLArea.isIEBeforeIE9) {
+                       if (!(Ext.isIE6 || Ext.isIE7 || Ext.isIE8)) {
                                this.editor.focus();
                                intersection = HTMLArea.DOM.rangeIntersectsNode(range, node);
                        } else {