[TASK] RTE: Avoid use of Ext.isEmpty 09/33709/2
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 2 Nov 2014 06:09:43 +0000 (01:09 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Sun, 2 Nov 2014 13:19:12 +0000 (14:19 +0100)
Streamline code.

Releases: master
Resolves: #62619
Change-Id: I4218c0ae03289d71cba2c40547d0bc4f7a71868b
Reviewed-on: http://review.typo3.org/33709
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
16 files changed:
typo3/sysext/rtehtmlarea/htmlarea/Configuration/HTMLArea.Config.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.Iframe.js
typo3/sysext/rtehtmlarea/htmlarea/Editor/HTMLArea.StatusBar.js
typo3/sysext/rtehtmlarea/htmlarea/Editor/HTMLArea.Toolbar.js
typo3/sysext/rtehtmlarea/htmlarea/Extjs/ux/Ext.ux.form.HTMLAreaCombo.js
typo3/sysext/rtehtmlarea/htmlarea/HTMLArea.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/Acronym/acronym.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/EditElement/edit-element.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/Plugin.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TYPO3Color/typo3color.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TableOperations/table-operations.js
typo3/sysext/rtehtmlarea/htmlarea/plugins/TextStyle/text-style.js

index bbb65cd..436318c 100644 (file)
@@ -135,7 +135,7 @@ HTMLArea.Config = Ext.extend(HTMLArea.Config, {
                                                url: config.storeUrl
                                        });
                                }
-                               config.hideLabel = Ext.isEmpty(config.fieldLabel) || Ext.isIE6;
+                               config.hideLabel = typeof config.fieldLabel !== 'string' || !config.fieldLabel.length || Ext.isIE6;
                                config.helpTitle = config.tooltip;
                                break;
                        default:
@@ -156,7 +156,7 @@ HTMLArea.Config = Ext.extend(HTMLArea.Config, {
                if (typeof this.hotKeyList[hotKeyConfiguration.id] !== 'undefined') {
                        HTMLArea.appendToLog('', 'HTMLArea.Config', 'registerHotKey', 'A hotkey with the same key ' + hotKeyConfiguration.id + ' already exists and will be overidden.', 'warn');
                }
-               if (typeof hotKeyConfiguration.cmd !== 'undefined' && !Ext.isEmpty(hotKeyConfiguration.cmd) && typeof this.buttonsConfig[hotKeyConfiguration.cmd] !== 'undefined') {
+               if (typeof hotKeyConfiguration.cmd === 'string' && hotKeyConfiguration.cmd.length > 0 && typeof this.buttonsConfig[hotKeyConfiguration.cmd] !== 'undefined') {
                        this.hotKeyList[hotKeyConfiguration.id] = hotKeyConfiguration;
                        return true;
                } else {
index 7231de7..a84ab3f 100644 (file)
@@ -51,7 +51,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                        // By default set the type to "Text"
                var type = 'Text';
                this.get();
-               if (!Ext.isEmpty(this.selection)) {
+               if (typeof this.selection === 'object' && this.selection !== null) {
                        if (typeof this.selection.getRangeAt === 'function') {
                                        // Check if the current selection is a Control
                                if (this.selection && this.selection.rangeCount == 1) {
@@ -83,7 +83,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
         */
        empty: function () {
                this.get();
-               if (!Ext.isEmpty(this.selection)) {
+               if (typeof this.selection === 'object' && this.selection !== null) {
                        if (typeof this.selection.removeAllRanges === 'function') {
                                this.selection.removeAllRanges();
                        } else {
@@ -104,7 +104,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        isEmpty: function () {
                var isEmpty = true;
                this.get();
-               if (!Ext.isEmpty(this.selection)) {
+               if (typeof this.selection === 'object' && this.selection !== null) {
                        if (HTMLArea.isIEBeforeIE9) {
                                switch (this.selection.type) {
                                        case 'None':
@@ -134,7 +134,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                if (HTMLArea.isIEBeforeIE9) {
                        range = this.selection.createRange();
                } else {
-                       if (Ext.isEmpty(this.selection)) {
+                       if (typeof this.selection !== 'object' || this.selection === null) {
                                range = this.document.createRange();
                        } else {
                                        // Older versions of WebKit did not support getRangeAt
@@ -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) && typeof this.selection.getRangeAt === 'function') {
+               if (typeof this.selection === 'object' && this.selection !== null && typeof this.selection.getRangeAt === 'function') {
                        for (var i = this.selection.rangeCount; --i >= 0;) {
                                ranges.push(this.selection.getRangeAt(i));
                        }
@@ -189,7 +189,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
         */
        addRange: function (range) {
                this.get();
-               if (!Ext.isEmpty(this.selection)) {
+               if (typeof this.selection === 'object' && this.selection !== null) {
                        if (typeof this.selection.addRange === 'function') {
                                this.selection.addRange(range);
                        } else if (Ext.isWebKit) {
@@ -222,7 +222,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
         */
        selectRange: function (range) {
                this.get();
-               if (!Ext.isEmpty(this.selection)) {
+               if (typeof this.selection === 'object' && this.selection !== null) {
                        if (typeof this.selection.getRangeAt === 'function') {
                                this.empty().addRange(range);
                        } else {
@@ -242,7 +242,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
         */
        selectNode: function (node, endPoint) {
                this.get();
-               if (!Ext.isEmpty(this.selection)) {
+               if (typeof this.selection === 'object' && this.selection !== null) {
                        if (HTMLArea.isIEBeforeIE9) {
                                        // IE8/7/6 cannot set this type of selection
                                this.selectNodeContents(node, endPoint);
@@ -279,7 +279,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        selectNodeContents: function (node, endPoint) {
                var range;
                this.get();
-               if (!Ext.isEmpty(this.selection)) {
+               if (typeof this.selection === 'object' && this.selection !== null) {
                        if (HTMLArea.isIEBeforeIE9) {
                                range = this.document.body.createTextRange();
                                range.moveToElementText(node);
@@ -358,7 +358,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
        getElement: function () {
                var element = null;
                this.get();
-               if (!Ext.isEmpty(this.selection) && this.selection.anchorNode && this.selection.anchorNode.nodeType === HTMLArea.DOM.ELEMENT_NODE && this.getType() == 'Control') {
+               if (typeof this.selection === 'object' && this.selection !== null && this.selection.anchorNode && this.selection.anchorNode.nodeType === HTMLArea.DOM.ELEMENT_NODE && this.getType() == 'Control') {
                        element = this.selection.anchorNode.childNodes[this.selection.anchorOffset];
                                // For Safari, the anchor node for a control selection is the control itself
                        if (!element) {
@@ -732,7 +732,7 @@ HTMLArea.DOM.Selection = Ext.extend(HTMLArea.DOM.Selection, {
                if (!/^(a)$/i.test(this.getParentElement().nodeName)) {
                        var autoWrap = function (textNode, tag) {
                                var rightText = textNode.nextSibling;
-                               if (typeof(tag) === 'string') {
+                               if (typeof tag === 'string') {
                                        tag = editor.document.createElement(tag);
                                }
                                var a = textNode.parentNode.insertBefore(tag, rightText);
index 4288f56..2e7303b 100644 (file)
@@ -185,14 +185,14 @@ HTMLArea.DOM = function () {
                 * Get the deepest element ancestor of a given node that is of one of the specified types
                 *
                 * @param       object          node: the given node
-                * @param       array           types: an array of nodeNames
+                * @param       mixed           types: an array of nodeNames, or a nodeName
                 *
                 * @return      object          the found ancestor of one of the given types or null
                 */
                getFirstAncestorOfType: function (node, types) {
                        var ancestor = null,
                                parent = node;
-                       if (!Ext.isEmpty(types)) {
+                       if (typeof types !== 'undefined' && types.length > 0) {
                                if (typeof types === 'string') {
                                        var types = [types];
                                }
index 8590307..7fe5f60 100644 (file)
@@ -24,7 +24,7 @@ HTMLArea.Editor = Ext.extend(Ext.util.Observable, {
                        all: this.config.tceformsNested,
                        sorted: HTMLArea.util.TYPO3.simplifyNested(this.config.tceformsNested)
                };
-               this.isNested = !Ext.isEmpty(this.nestedParentElements.sorted);
+               this.isNested = this.nestedParentElements.sorted.length > 0;
                        // If in BE, get width of wizards
                if (Ext.get('typo3-docheader')) {
                        this.wizards = this.textArea.parent().parent().next();
@@ -231,7 +231,7 @@ HTMLArea.Editor = Ext.extend(Ext.util.Observable, {
                // Focus on the first editor that is not hidden
                for (var editorId in RTEarea) {
                        var RTE = RTEarea[editorId];
-                       if (typeof RTE.editor === 'undefined' || (RTE.editor.isNested && !HTMLArea.util.TYPO3.allElementsAreDisplayed(RTE.editor.nestedParentElements.sorted))) {
+                       if (typeof RTE.editor !== 'object' || RTE.editor === null || (RTE.editor.isNested && !HTMLArea.util.TYPO3.allElementsAreDisplayed(RTE.editor.nestedParentElements.sorted))) {
                                continue;
                        } else {
                                RTE.editor.focus();
@@ -388,7 +388,7 @@ HTMLArea.Editor = Ext.extend(Ext.util.Observable, {
        registerPlugin: function (pluginName) {
                var plugin = HTMLArea[pluginName],
                        isRegistered = false;
-               if (typeof plugin !== 'undefined' && typeof plugin === 'function') {
+               if (typeof plugin === 'function') {
                        var pluginInstance = new plugin(this, pluginName);
                        if (pluginInstance) {
                                var pluginInformation = pluginInstance.getPluginInformation();
index 7efc980..6bfe911 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 (typeof this.autoEl === 'string') {
+                       if (typeof this.autoEl === 'string' && this.autoEl.length > 0) {
                                this.el = document.createElement(this.autoEl);
                        } else {
                                        // ExtJS Default method will not work with iframe element
@@ -408,7 +408,7 @@ HTMLArea.Iframe = Ext.extend(Ext.BoxComponent, {
                }
                        // Make hot key map available, even if empty, so that plugins may add bindings
                this.hotKeyMap = new Ext.KeyMap(Ext.get(this.document.documentElement));
-               if (!Ext.isEmpty(hotKeys)) {
+               if (hotKeys.length > 0) {
                        this.hotKeyMap.addBinding({
                                key: hotKeys,
                                ctrl: true,
index 1a95817..43970c3 100644 (file)
@@ -171,7 +171,7 @@ HTMLArea.StatusBar = Ext.extend(Ext.Container, {
                if (this.getEditor().getMode() == 'wysiwyg') {
                                // Get the html content
                        var text = this.getEditor().getHTML();
-                       if (!Ext.isEmpty(text)) {
+                       if (typeof text === 'string' && text.length > 0) {
                                        // Replace html tags with spaces
                                text = text.replace(HTMLArea.RE_htmlTag, ' ');
                                        // Replace html space entities
index 4d253b2..ac8f8ab 100644 (file)
@@ -93,7 +93,7 @@ HTMLArea.Toolbar = Ext.extend(Ext.Container, {
                                        } else {
                                                // Get the item's config as registered by some plugin
                                                var itemConfig = editor.config.buttonsConfig[item];
-                                               if (!Ext.isEmpty(itemConfig)) {
+                                               if (typeof itemConfig === 'object' && itemConfig !== null) {
                                                        itemConfig.id = this.editorId + '-' + itemConfig.id;
                                                        this.add(itemConfig);
                                                        firstInGroup = firstInGroup && itemConfig.hidden;
index 7f4c08a..48546d2 100644 (file)
@@ -65,7 +65,7 @@ Ext.ux.form.HTMLAreaCombo = Ext.extend(Ext.form.ComboBox, {
                        var editor = this.getEditor();
                                // In IE, reclaim lost focus on the editor iframe and restore the bookmarked selection
                        if (Ext.isIE) {
-                               if (!Ext.isEmpty(this.savedRange)) {
+                               if (typeof this.savedRange === 'object' && this.savedRange !== null) {
                                        editor.getSelection().selectRange(this.savedRange);
                                        this.savedRange = null;
                                }
@@ -116,7 +116,7 @@ Ext.ux.form.HTMLAreaCombo = Ext.extend(Ext.form.ComboBox, {
         * Handler invoked in IE when the editor gets the focus back
         */
        restoreSelection: function (event) {
-               if (!Ext.isEmpty(this.savedRange) && this.triggered) {
+               if (typeof this.savedRange === 'object' && this.savedRange !== null && this.triggered) {
                        this.getEditor().getSelection().selectRange(this.savedRange);
                        this.triggered = false;
                }
index 852273a..c7b4830 100644 (file)
@@ -36,7 +36,7 @@ Ext.apply(HTMLArea, {
        localize: function (label, plural) {
                var i = plural || 0;
                var localized = HTMLArea.I18N.dialogs[label] || HTMLArea.I18N.tooltips[label] || HTMLArea.I18N.msg[label] || '';
-               if (typeof localized === 'object' && typeof localized[i] !== 'undefined') {
+               if (typeof localized === 'object' && localized !== null && typeof localized[i] !== 'undefined') {
                        localized = localized[i]['target'];
                }
                return localized;
@@ -112,7 +112,7 @@ Ext.apply(HTMLArea, {
                if (typeof type === 'undefined') {
                        var type = 'info';
                }
-               if (typeof console !== 'undefined' && typeof console === 'object') {
+               if (typeof console === 'object' && console !== null) {
                        // If console is TYPO3.Backend.DebugConsole, write only error messages
                        if (typeof console.addTab === 'function') {
                                if (type === 'error') {
index ce7c123..b309cca 100644 (file)
@@ -81,11 +81,11 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
                if (!abbr || !/^(acronym|abbr)$/i.test(abbr.nodeName)) {
                        abbr = editor.getSelection().getFirstAncestorOfType(['acronym', 'abbr']);
                }
-               var type = !Ext.isEmpty(abbr) ? abbr.nodeName.toLowerCase() : '';
+               var type = typeof abbr === 'object' && abbr !== null ? abbr.nodeName.toLowerCase() : '';
                this.params = {
                        abbr: abbr,
-                       title: !Ext.isEmpty(abbr) ? abbr.title : '',
-                       text: !Ext.isEmpty(abbr) ? abbr.innerHTML : this.editor.getSelection().getHtml()
+                       title: typeof abbr === 'object' && abbr !== null ? abbr.title : '',
+                       text: typeof abbr === 'object' && abbr !== null ? abbr.innerHTML : this.editor.getSelection().getHtml()
                };
                        // Open the dialogue window
                this.openDialogue(
@@ -154,7 +154,7 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
         * @return      object          the tab items configuration
         */
        buildTabItemsConfig: function (element) {
-               var type = !Ext.isEmpty(element) ? element.nodeName.toLowerCase() : '';
+               var type = typeof element === 'object' && element !== null ? element.nodeName.toLowerCase() : '';
                var tabItems = [];
                var abbrTabItems = [];
                        // abbr tab not shown if the current selection is an acronym
@@ -164,7 +164,7 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
                        }
                        this.addConfigElement(this.buildUseTermFieldsetConfig((type == 'abbr') ? element : null, 'abbr'), abbrTabItems);
                }
-               if (!Ext.isEmpty(abbrTabItems)) {
+               if (abbrTabItems.length > 0) {
                        tabItems.push({
                                title: this.localize('Abbreviation'),
                                itemId: 'abbr',
@@ -179,7 +179,7 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
                        }
                        this.addConfigElement(this.buildUseTermFieldsetConfig((type == 'abbr') ? element : null, 'abbr'), acronymTabItems);
                }
-               if (!Ext.isEmpty(acronymTabItems)) {
+               if (acronymTabItems.length > 0) {
                        tabItems.push({
                                title: this.localize('Acronym'),
                                itemId: 'acronym',
@@ -280,7 +280,7 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
                }, this.configDefaults['combo']));
                var languageObject = this.getPluginInstance('Language');
                if (this.getButton('Language')) {
-                       var selectedLanguage = !Ext.isEmpty(element) ? languageObject.getLanguageAttribute(element) : 'none';
+                       var selectedLanguage = typeof element === 'object' && element !== null ? languageObject.getLanguageAttribute(element) : 'none';
                        function initLanguageStore (store) {
                                if (selectedLanguage !== 'none') {
                                        store.removeAt(0);
@@ -420,7 +420,7 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
                abbrSelector.setValue(abbr);
                        // Update the language selector
                var languageSelector = tab.find('itemId', 'language');
-               if (!Ext.isEmpty(languageSelector)) {
+               if (languageSelector.length > 0) {
                        if (language) {
                                languageSelector[0].setValue(language);
                        } else {
@@ -443,7 +443,7 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
                termSelector.setValue(term);
                        // Update the language selector
                var languageSelector = tab.find('itemId', 'language');
-               if (!Ext.isEmpty(languageSelector)) {
+               if (languageSelector.length > 0) {
                        if (language) {
                                languageSelector[0].setValue(language);
                        } else {
@@ -484,7 +484,7 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
                var tab = this.dialog.findByType('tabpanel')[0].getActiveTab();
                var type = tab.getItemId();
                var languageSelector = tab.find('itemId', 'language');
-               var language = !Ext.isEmpty(languageSelector) ? languageSelector[0].getValue() : '';
+               var language = languageSelector.length > 0 ? languageSelector[0].getValue() : '';
                var term = tab.find('itemId', 'termSelector')[0].getValue();
                if (!this.params.abbr) {
                        var abbr = this.editor.document.createElement(type);
index 48193c0..5ae0c87 100644 (file)
@@ -57,7 +57,7 @@ HTMLArea.BlockStyle = Ext.extend(HTMLArea.Plugin, {
                 */
                var dropDownId = 'BlockStyle';
                var fieldLabel = this.pageTSconfiguration ? this.pageTSconfiguration.fieldLabel : '';
-               if (Ext.isEmpty(fieldLabel) && this.isButtonInToolbar('I[Block style label]')) {
+               if ((typeof fieldLabel !== 'string' || !fieldLabel.length) && this.isButtonInToolbar('I[Block style label]')) {
                        fieldLabel = this.localize('Block style label');
                }
                var dropDownConfiguration = {
index 3261476..f8cd914 100644 (file)
@@ -309,7 +309,7 @@ HTMLArea.EditElement = Ext.extend(HTMLArea.Plugin, {
                        languageConfigurationUrl = this.editorConfiguration.buttons.language.dataUrl;
                }
                if (languagePlugin && languageConfigurationUrl && this.removedProperties.indexOf('language') == -1) {
-                       var selectedLanguage = !Ext.isEmpty(element) ? languagePlugin.getLanguageAttribute(element) : 'none';
+                       var selectedLanguage = typeof element === 'object' && element !== null ? languagePlugin.getLanguageAttribute(element) : 'none';
                        function initLanguageStore (store) {
                                if (selectedLanguage !== 'none') {
                                        store.removeAt(0);
@@ -353,7 +353,7 @@ HTMLArea.EditElement = Ext.extend(HTMLArea.Plugin, {
                                        ]
                                }),
                                width: ((this.properties['direction'] && this.properties['dirrection'].width) ? this.properties['direction'].width : 200),
-                               value: !Ext.isEmpty(element) && element.dir ? element.dir : 'not set'
+                               value: typeof element === 'object' && element !== null && element.dir ? element.dir : 'not set'
                        }, this.configDefaults['combo']));
                }
                return {
index f86fba2..644c8cc 100644 (file)
@@ -58,7 +58,7 @@ HTMLArea.Plugin = Ext.extend(HTMLArea.Plugin, {
         * @return      boolean         true if the information was registered
         */
        registerPluginInformation: function (pluginInformation) {
-               if (typeof(pluginInformation) !== 'object') {
+               if (typeof pluginInformation !== 'object' || pluginInformation === null) {
                        this.appendToLog('registerPluginInformation', 'Plugin information was not provided', 'warn');
                        return false;
                } else {
@@ -152,7 +152,7 @@ HTMLArea.Plugin = Ext.extend(HTMLArea.Plugin, {
         */
        registerButton: function (buttonConfiguration) {
                if (this.isButtonInToolbar(buttonConfiguration.id)) {
-                       if (typeof buttonConfiguration.action === 'string' && typeof this[buttonConfiguration.action] === 'function') {
+                       if (typeof buttonConfiguration.action === 'string' && buttonConfiguration.action.length > 0 && 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 (typeof dropDownConfiguration.action === 'string' && typeof this[dropDownConfiguration.action] === 'function') {
+                       if (typeof dropDownConfiguration.action === 'string' && dropDownConfiguration.action.length > 0 && typeof this[dropDownConfiguration.action] === 'function') {
                                dropDownConfiguration.plugins = this;
                                dropDownConfiguration.hidden = dropDownConfiguration.hide;
                                dropDownConfiguration.xtype = 'htmlareacombo';
@@ -347,7 +347,7 @@ HTMLArea.Plugin = Ext.extend(HTMLArea.Plugin, {
        localize: function (label, plural) {
                var i = plural || 0;
                var localized = this.I18N[label];
-               if (typeof localized === 'object' && typeof localized[i] !== 'undefined') {
+               if (typeof localized === 'object' && localized !== null && typeof localized[i] !== 'undefined') {
                        localized = localized[i]['target'];
                } else {
                        localized = HTMLArea.localize(label, plural);
@@ -364,9 +364,9 @@ HTMLArea.Plugin = Ext.extend(HTMLArea.Plugin, {
         * @return      string          localized label with CSH markup
         */
        getHelpTip: function (fieldName, label, pluginName) {
-               if (typeof TYPO3.ContextHelp !== 'undefined') {
+               if (typeof TYPO3.ContextHelp !== 'undefined' && typeof fieldName === 'string') {
                        var pluginName = typeof pluginName !== 'undefined' ? pluginName : this.name;
-                       if (!Ext.isEmpty(fieldName)) {
+                       if (fieldName.length > 0) {
                                fieldName = fieldName.replace(/-|\s/gi, '_');
                        }
                        return '<span class="t3-help-link" href="#" data-table="xEXT_rtehtmlarea_' + pluginName + '" data-field="' + fieldName + '"><abbr class="t3-help-teaser">' + (this.localize(label) || label) + '</abbr></span>';
@@ -514,7 +514,7 @@ HTMLArea.Plugin = Ext.extend(HTMLArea.Plugin, {
         * @return      void
         */
        addConfigElement: function (configElement, configArray) {
-               if (!Ext.isEmpty(configElement)) {
+               if (typeof configElement === 'object'  && configElement !== null) {
                        configArray.push(configElement);
                }
        },
index 1b4a8f4..1b17896 100644 (file)
@@ -273,8 +273,9 @@ HTMLArea.TYPO3Color = Ext.extend(HTMLArea.Plugin, {
         * On after render handler: display the color
         */
        onAfterRender: function (field) {
-               if (!Ext.isEmpty(field.getValue())) {
-                       this.showColor(field.getValue());
+               var value = field.getValue();
+               if (typeof value === 'string' && value.length > 0) {
+                       this.showColor(value);
                }
        },
        /*
index b6e6743..631381d 100644 (file)
@@ -200,7 +200,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                                if (this.removedFieldsets.indexOf('description') === -1) {
                                        this.addConfigElement(this.buildDescriptionFieldsetConfig(element), generalTabItems);
                                }
-                               if (Ext.isEmpty(element) || this.removedProperties.indexOf('headers') === -1) {
+                               if (typeof element !== 'object' || element === null || this.removedProperties.indexOf('headers') === -1) {
                                        this.addConfigElement(this.buildSizeAndHeadersFieldsetConfig(element), generalTabItems);
                                }
                                break;
@@ -223,7 +223,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                if (this.removedFieldsets.indexOf('style') == -1 && this.getPluginInstance('BlockStyle')) {
                        this.addConfigElement(this.buildStylingFieldsetConfig(element, buttonId), generalTabItems);
                }
-               if (!Ext.isEmpty(generalTabItems)) {
+               if (generalTabItems.length > 0) {
                        tabItems.push({
                                title: this.localize('General'),
                                items: generalTabItems
@@ -236,7 +236,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                if (this.removedFieldsets.indexOf('layout') == -1) {
                        this.addConfigElement(this.buildLayoutFieldsetConfig(element), layoutTabItems);
                }
-               if (!Ext.isEmpty(layoutTabItems)) {
+               if (layoutTabItems.length > 0) {
                        tabItems.push({
                                title: this.localize('Layout'),
                                items: layoutTabItems
@@ -246,7 +246,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                if (this.removedFieldsets.indexOf('language') === -1 && (this.removedProperties.indexOf('language') === -1 || this.removedProperties.indexOf('direction') === -1) && (this.getButton('Language') || this.getButton('LeftToRight') || this.getButton('RightToLeft'))) {
                        this.addConfigElement(this.buildLanguageFieldsetConfig(element), languageTabItems);
                }
-               if (!Ext.isEmpty(languageTabItems)) {
+               if (languageTabItems.length > 0) {
                        tabItems.push({
                                title: this.localize('Language'),
                                items: languageTabItems
@@ -259,7 +259,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                if (this.removedFieldsets.indexOf('borders') === -1) {
                        this.addConfigElement(this.buildBordersFieldsetConfig(element), alignmentAndBordersTabItems);
                }
-               if (!Ext.isEmpty(alignmentAndBordersTabItems)) {
+               if (alignmentAndBordersTabItems.length > 0) {
                        tabItems.push({
                                title: this.localize('Alignment') + '/' + this.localize('Border'),
                                items: alignmentAndBordersTabItems
@@ -269,7 +269,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                if (this.removedFieldsets.indexOf('color') === -1) {
                        this.addConfigElement(this.buildColorsFieldsetConfig(element), colorTabItems);
                }
-               if (!Ext.isEmpty(colorTabItems)) {
+               if (colorTabItems.length > 0) {
                        tabItems.push({
                                title: this.localize('Background and colors'),
                                items: colorTabItems
@@ -1700,7 +1700,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
         * @return      object          the fieldset configuration object
         */
        buildDescriptionFieldsetConfig: function (table) {
-               if (!Ext.isEmpty(table)) {
+               if (typeof table === 'object' && table !== null) {
                        var caption = table.getElementsByTagName('caption')[0];
                }
                return {
@@ -1720,7 +1720,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                                },{
                                fieldLabel: this.getHelpTip('summary', 'Summary:'),
                                itemId: 'f_summary',
-                               value: !Ext.isEmpty(table) ? table.summary : '',
+                               value: typeof table === 'object' && table !== null ? table.summary : '',
                                width: 300,
                                helpTitle: typeof TYPO3.ContextHelp !== 'undefined' ? '' : this.localize('Summary of the table purpose and structure')
                        }]
@@ -1735,7 +1735,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
         */
        buildSizeAndHeadersFieldsetConfig: function (table) {
                var itemsConfig = [];
-               if (Ext.isEmpty(table)) {
+               if (typeof table !== 'object' || table === null) {
                        itemsConfig.push({
                                fieldLabel: this.getHelpTip('numberOfRows', 'Number of rows'),
                                labelSeparator: ':',
@@ -1768,7 +1768,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                                ]
                        });
                        this.removeOptions(store, 'headers');
-                       if (Ext.isEmpty(table)) {
+                       if (typeof table !== 'object' || table === null) {
                                var selected = (this.properties.headers && this.properties.headers.defaultValue) ? this.properties.headers.defaultValue : 'top';
                        } else {
                                var selected = 'none';
@@ -1797,7 +1797,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                }
                return {
                        xtype: 'fieldset',
-                       title: this.localize(Ext.isEmpty(table) ? 'Size and Headers' : 'Headers'),
+                       title: this.localize(typeof table !== 'object' || table === null ? 'Size and Headers' : 'Headers'),
                        defaultType: 'numberfield',
                        defaults: {
                                helpIcon: true
@@ -1909,7 +1909,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                var itemsConfig = [];
                var languageObject = this.getPluginInstance('Language');
                if (this.removedProperties.indexOf('language') == -1 && this.getButton('Language')) {
-                       var selectedLanguage = !Ext.isEmpty(element) ? languageObject.getLanguageAttribute(element) : 'none';
+                       var selectedLanguage = typeof element === 'object' && element !== null ? languageObject.getLanguageAttribute(element) : 'none';
                        function initLanguageStore (store) {
                                if (selectedLanguage !== 'none') {
                                        store.removeAt(0);
@@ -1955,7 +1955,7 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                                        ]
                                }),
                                width: (this.properties['direction'] && this.properties['dirrection'].width) ? this.properties['direction'].width : 200,
-                               value: !Ext.isEmpty(element) && element.dir ? element.dir : 'not set'
+                               value: typeof element === 'object' && element !== null && element.dir ? element.dir : 'not set'
                        }, this.configDefaults['combo']));
                }
                return {
@@ -1983,14 +1983,14 @@ HTMLArea.TableOperations = Ext.extend(HTMLArea.Plugin, {
                        items: [{
                                fieldLabel: this.getHelpTip('cellSpacing', 'Cell spacing:'),
                                itemId: 'f_spacing',
-                               value: !Ext.isEmpty(table) ? table.cellSpacing : '',
+                               value: typeof table === 'object' && table !== null ? table.cellSpacing : '',
                                width: 30,
                                minValue: 0,
                                helpTitle: typeof TYPO3.ContextHelp !== 'undefined' ? '' : this.localize('Space between adjacent cells')
                                },{
                                fieldLabel: this.getHelpTip('cellPadding', 'Cell padding:'),
                                itemId: 'f_padding',
-                               value: !Ext.isEmpty(table) ? table.cellPadding : '',
+                               value: typeof table === 'object' && table !== null ? table.cellPadding : '',
                                width: 30,
                                minValue: 0,
                                helpTitle: typeof TYPO3.ContextHelp !== 'undefined' ? '' : this.localize('Space between content and border in cell')
index 01cf163..c0b9b88 100644 (file)
@@ -70,7 +70,7 @@ HTMLArea.TextStyle = Ext.extend(HTMLArea.Plugin, {
                 */
                var buttonId = 'TextStyle';
                var fieldLabel = this.pageTSconfiguration ? this.pageTSconfiguration.fieldLabel : '';
-               if (Ext.isEmpty(fieldLabel) && this.isButtonInToolbar('I[text_style]')) {
+               if ((typeof fieldLabel !== 'string' || !fieldLabel.length) && this.isButtonInToolbar('I[text_style]')) {
                        fieldLabel = this.localize('text_style');
                }
                var dropDownConfiguration = {