[BUGFIX] RTE: JS error raised in Abbreviation dialogue 67/34267/2
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 12 Nov 2014 20:10:39 +0000 (15:10 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 17 Nov 2014 14:46:11 +0000 (15:46 +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/34267
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
typo3/sysext/rtehtmlarea/Resources/Public/JavaScript/Plugins/abbreviation.js

index d74e8fe..e55f68e 100644 (file)
@@ -486,13 +486,15 @@ HTMLArea.Abbreviation = Ext.extend(HTMLArea.Plugin, {
                var tab = this.dialog.findByType('tabpanel')[0].getActiveTab();
                var type = tab.getItemId();
                var languageSelector = tab.find('itemId', 'language');
-               var language = languageSelector.length > 0 ? 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;
                        }
@@ -513,8 +515,8 @@ HTMLArea.Abbreviation = 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();