[TASK] RTE: Avoid use of Ext.isString and Ext.isFunction 06/33706/4
authorStanislas Rolland <typo3@sjbr.ca>
Sat, 1 Nov 2014 20:36:02 +0000 (16:36 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Sat, 1 Nov 2014 20:50:45 +0000 (21:50 +0100)
Avoid useless overhead.

Releases: master
Resolves:#62617
Change-Id: Ibb722b405d8c95335f655c78faa05fe3be8a4ea6
Reviewed-on: http://review.typo3.org/33706
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/htmlarea/Ajax/HTMLArea.Ajax.js
typo3/sysext/rtehtmlarea/htmlarea/DOM/HTMLArea.DOM.Selection.js
typo3/sysext/rtehtmlarea/htmlarea/DOM/HTMLArea.DOM.js
typo3/sysext/rtehtmlarea/htmlarea/Editor/HTMLArea.Editor.js
typo3/sysext/rtehtmlarea/htmlarea/Editor/HTMLArea.Framework.js
typo3/sysext/rtehtmlarea/htmlarea/Editor/HTMLArea.Iframe.js
typo3/sysext/rtehtmlarea/htmlarea/HTMLArea.js
typo3/sysext/rtehtmlarea/htmlarea/Util/HTMLArea.util.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/Plugin.js

index bfbfd2d..f39ec6f 100644 (file)
@@ -55,7 +55,7 @@ HTMLArea.Ajax = Ext.extend(HTMLArea.Ajax, {
                        },
                        url: url,
                        params: params,
-                       callback: Ext.isFunction(callback) ? callback: function (options, success, response) {
+                       callback: typeof callback === 'function' ? callback : function (options, success, response) {
                                if (!success) {
                                        self.editor.appendToLog('HTMLArea.Ajax', 'postData', 'Post request to ' + url + ' failed. Server reported ' + response.status, 'error');
                                }
index 3b1bbf9..7231de7 100644 (file)
@@ -52,7 +52,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                var type = 'Text';
                this.get();
                if (!Ext.isEmpty(this.selection)) {
-                       if (Ext.isFunction(this.selection.getRangeAt)) {
+                       if (typeof this.selection.getRangeAt === 'function') {
                                        // Check if the current selection is a Control
                                if (this.selection && this.selection.rangeCount == 1) {
                                        var range = this.selection.getRangeAt(0);
@@ -84,7 +84,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        empty: function () {
                this.get();
                if (!Ext.isEmpty(this.selection)) {
-                       if (Ext.isFunction(this.selection.removeAllRanges)) {
+                       if (typeof this.selection.removeAllRanges === 'function') {
                                this.selection.removeAllRanges();
                        } else {
                                        // IE8, IE7 or old version of WebKit
@@ -138,7 +138,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                                range = this.document.createRange();
                        } else {
                                        // Older versions of WebKit did not support getRangeAt
-                               if (Ext.isWebKit && !Ext.isFunction(this.selection.getRangeAt)) {
+                               if (Ext.isWebKit && typeof this.selection.getRangeAt !== 'function') {
                                        range = this.document.createRange();
                                        if (this.selection.baseNode == null) {
                                                range.setStart(this.document.body, 0);
@@ -171,7 +171,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                this.get();
                var ranges = [];
                        // Older versions of WebKit, IE7 and IE8 did not support getRangeAt
-               if (!Ext.isEmpty(this.selection) && Ext.isFunction(this.selection.getRangeAt)) {
+               if (!Ext.isEmpty(this.selection) && typeof this.selection.getRangeAt === 'function') {
                        for (var i = this.selection.rangeCount; --i >= 0;) {
                                ranges.push(this.selection.getRangeAt(i));
                        }
@@ -190,7 +190,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        addRange: function (range) {
                this.get();
                if (!Ext.isEmpty(this.selection)) {
-                       if (Ext.isFunction(this.selection.addRange)) {
+                       if (typeof this.selection.addRange === 'function') {
                                this.selection.addRange(range);
                        } else if (Ext.isWebKit) {
                                this.selection.setBaseAndExtent(range.startContainer, range.startOffset, range.endContainer, range.endOffset);
@@ -223,7 +223,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        selectRange: function (range) {
                this.get();
                if (!Ext.isEmpty(this.selection)) {
-                       if (Ext.isFunction(this.selection.getRangeAt)) {
+                       if (typeof this.selection.getRangeAt === 'function') {
                                this.empty().addRange(range);
                        } else {
                                        // IE8 or IE7
index d5ee213..4288f56 100644 (file)
@@ -105,7 +105,7 @@ HTMLArea.DOM = function () {
                        if (node) {
                                HTMLArea.DOM.removeClass(node, className);
                                        // Remove classes configured to be incompatible with the class to be added
-                               if (node.className && HTMLArea.classesXOR && HTMLArea.classesXOR[className] && Ext.isFunction(HTMLArea.classesXOR[className].test)) {
+                               if (node.className && HTMLArea.classesXOR && HTMLArea.classesXOR[className] && typeof HTMLArea.classesXOR[className].test === 'function') {
                                        var classNames = node.className.trim().split(' ');
                                        for (var i = classNames.length; --i >= 0;) {
                                                if (HTMLArea.classesXOR[className].test(classNames[i])) {
@@ -193,7 +193,7 @@ HTMLArea.DOM = function () {
                        var ancestor = null,
                                parent = node;
                        if (!Ext.isEmpty(types)) {
-                               if (Ext.isString(types)) {
+                               if (typeof types === 'string') {
                                        var types = [types];
                                }
                                types = new RegExp( '^(' + types.join('|') + ')$', 'i');
@@ -243,7 +243,7 @@ HTMLArea.DOM = function () {
                 hasAllowedAttributes: function (node, allowedAttributes) {
                        var value,
                                hasAllowedAttributes = false;
-                       if (Ext.isString(allowedAttributes)) {
+                       if (typeof allowedAttributes === 'string') {
                                allowedAttributes = [allowedAttributes];
                        }
                        allowedAttributes = allowedAttributes || [];
index 1a8e09d..8590307 100644 (file)
@@ -388,7 +388,7 @@ HTMLArea.Editor = Ext.extend(Ext.util.Observable, {
        registerPlugin: function (pluginName) {
                var plugin = HTMLArea[pluginName],
                        isRegistered = false;
-               if (typeof plugin !== 'undefined' && Ext.isFunction(plugin)) {
+               if (typeof plugin !== 'undefined' && typeof plugin === 'function') {
                        var pluginInstance = new plugin(this, pluginName);
                        if (pluginInstance) {
                                var pluginInformation = pluginInstance.getPluginInformation();
index d39600f..6195674 100644 (file)
@@ -52,7 +52,7 @@ HTMLArea.Framework = Ext.extend(Ext.Panel, {
                        // If the textarea is inside a form, on reset, re-initialize the HTMLArea content and update the toolbar
                var form = this.textArea.dom.form;
                if (form) {
-                       if (Ext.isFunction(form.onreset)) {
+                       if (typeof form.onreset === 'function') {
                                if (typeof form.htmlAreaPreviousOnReset === 'undefined') {
                                        form.htmlAreaPreviousOnReset = [];
                                }
index 77c87be..7efc980 100644 (file)
@@ -119,7 +119,7 @@ HTMLArea.Iframe = Ext.extend(Ext.BoxComponent, {
        onRender: function (ct, position){
                        // from Ext.Component
                if (!this.el && this.autoEl) {
-                       if (Ext.isString(this.autoEl)) {
+                       if (typeof this.autoEl === 'string') {
                                this.el = document.createElement(this.autoEl);
                        } else {
                                        // ExtJS Default method will not work with iframe element
index ce8cb8b..852273a 100644 (file)
@@ -52,7 +52,7 @@ Ext.apply(HTMLArea, {
                                editorSkin      : HTMLArea.editorUrl + 'skins/default/',
                                editorCSS       : HTMLArea.editorUrl + 'skins/default/htmlarea.css'
                        });
-                       if (!Ext.isString(HTMLArea.editedContentCSS)) {
+                       if (typeof HTMLArea.editedContentCSS !== 'string' || HTMLArea.editedContentCSS === '') {
                                HTMLArea.editedContentCSS = HTMLArea.editorSkin + 'htmlarea-edited-content.css';
                        }
                        HTMLArea.isReady = true;
@@ -114,7 +114,7 @@ Ext.apply(HTMLArea, {
                }
                if (typeof console !== 'undefined' && typeof console === 'object') {
                        // If console is TYPO3.Backend.DebugConsole, write only error messages
-                       if (Ext.isFunction(console.addTab)) {
+                       if (typeof console.addTab === 'function') {
                                if (type === 'error') {
                                        console[type](str);
                                }
index 094f471..092d3e4 100644 (file)
@@ -15,7 +15,7 @@ Ext.apply(HTMLArea.util, {
                return str;
        },
        htmlEncode: function (str) {
-               if (typeof(str) != 'string') {
+               if (typeof str !== 'string') {
                        str = str.toString();
                }
                str = str.replace(/&/g, '&amp;');
index c02eaf3..f86fba2 100644 (file)
@@ -152,7 +152,7 @@ HTMLArea.Plugin = Ext.extend(HTMLArea.Plugin, {
         */
        registerButton: function (buttonConfiguration) {
                if (this.isButtonInToolbar(buttonConfiguration.id)) {
-                       if (Ext.isString(buttonConfiguration.action) && Ext.isFunction(this[buttonConfiguration.action])) {
+                       if (typeof buttonConfiguration.action === 'string' && typeof this[buttonConfiguration.action] === 'function') {
                                buttonConfiguration.plugins = this;
                                if (buttonConfiguration.dialog) {
                                        if (!buttonConfiguration.dimensions) {
@@ -204,7 +204,7 @@ HTMLArea.Plugin = Ext.extend(HTMLArea.Plugin, {
         */
        registerDropDown: function (dropDownConfiguration) {
                if (this.isButtonInToolbar(dropDownConfiguration.id)) {
-                       if (Ext.isString(dropDownConfiguration.action) && Ext.isFunction(this[dropDownConfiguration.action])) {
+                       if (typeof dropDownConfiguration.action === 'string' && typeof this[dropDownConfiguration.action] === 'function') {
                                dropDownConfiguration.plugins = this;
                                dropDownConfiguration.hidden = dropDownConfiguration.hide;
                                dropDownConfiguration.xtype = 'htmlareacombo';