[BUGFIX] RTE: JS error raised in Abbreviation dialogue 69/34269/2
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 17 Nov 2014 15:10:03 +0000 (10:10 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 17 Nov 2014 15:42:16 +0000 (16:42 +0100)
When no abbreviation and/or acronym is pre-defined, hitting the ok
button of the dialogue raises a js error.

Releases: master, 6.2
Resolves: #63030
Change-Id: I4df0b3896a53808ef2bd8ef6ee8ba71da7030735
Reviewed-on: http://review.typo3.org/34269
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/htmlarea/plugins/Acronym/acronym.js

index ce7c123..339fb7e 100644 (file)
@@ -484,13 +484,15 @@ 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 term = tab.find('itemId', 'termSelector')[0].getValue();
+               var language = languageSelector && languageSelector.length > 0 ? languageSelector[0].getValue() : '';
+               var termSelector = tab.find('itemId', 'termSelector');
+               var term = termSelector && termSelector.length > 0 ? termSelector[0].getValue() : '';
+               var abbrSelector = tab.find('itemId', 'abbrSelector');
                if (!this.params.abbr) {
                        var abbr = this.editor.document.createElement(type);
                        abbr.title = tab.find('itemId', 'useTerm')[0].getValue();
-                       if (term == abbr.title) {
-                               abbr.innerHTML = tab.find('itemId', 'abbrSelector')[0].getValue();
+                       if (term == abbr.title && abbrSelector && abbrSelector.length > 0) {
+                               abbr.innerHTML = abbrSelector[0].getValue();
                        } else {
                                abbr.innerHTML = this.params.text;
                        }
@@ -511,8 +513,8 @@ HTMLArea.Acronym = Ext.extend(HTMLArea.Plugin, {
                        if (language) {
                                this.getPluginInstance('Language').setLanguageAttributes(abbr, language);
                        }
-                       if (term == abbr.title) {
-                               abbr.innerHTML = tab.find('itemId', 'abbrSelector')[0].getValue();
+                       if (term == abbr.title && abbrSelector && abbrSelector.length > 0) {
+                               abbr.innerHTML = abbrSelector[0].getValue();
                        }
                }
                this.close();