* Fixed bug #7585: Invoking htmlArea RTE block style plugin from other plugin fails...
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 19 Feb 2008 06:22:33 +0000 (06:22 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 19 Feb 2008 06:22:33 +0000 (06:22 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3227 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/htmlarea/plugins/BlockStyle/block-style.js

index 683ec68..a527fea 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
        * Fixed bug #7583: htmlArea RTE should allow to markup text in absence of any block element
        * Fixed bug #7584: htmlArea RTE: pressing TAB in last cell of table should create new row
+       * Fixed bug #7585: Invoking htmlArea RTE block style plugin from other plugin fails in FF3 and IE7
 
 2008-02-19  Ingo Renner  <ingo@typo3.org>
 
index 4331f01..8bf1b7d 100644 (file)
@@ -2,6 +2,7 @@
 
        * Fixed bug #7583: htmlArea RTE should allow to markup text in absence of any block element
        * Fixed bug #7584: htmlArea RTE: pressing TAB in last cell of table should create new row
+       * Fixed bug #7585: Invoking htmlArea RTE block style plugin from other plugin fails in FF3 and IE7
 
 2008-02-17  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
index 2d98b98..ff586b8 100644 (file)
@@ -226,10 +226,7 @@ BlockStyle = HTMLArea.Plugin.extend({
         */
        updateValue : function(dropDownId) {
                var select = document.getElementById(this.editor._toolbarObjects[dropDownId].elementId);
-               while(select.options.length > 0) {
-                       select.options[select.length-1] = null;
-               }
-               select.options[0] = new Option(this.localize("No style"),"none");
+               this.initializeDropDown(select);
                select.disabled = true;
                
                var classNames = new Array();
@@ -257,31 +254,49 @@ BlockStyle = HTMLArea.Plugin.extend({
         */
        getClassNames : function (node) {
                var classNames = new Array();
-               if (node && node.className && /\S/.test(node.className)) {
-                       classNames = node.className.trim().split(" ");
-               }
-               if (HTMLArea.reservedClassNames.test(node.className)) {
-                       var cleanClassNames = new Array();
-                       var j = -1;
-                       for (var i = 0; i < classNames.length; ++i) {
-                               if (!HTMLArea.reservedClassNames.test(classNames[i])) {
-                                       cleanClassNames[++j] = classNames[i];
+               if (node) {
+                       if (node.className && /\S/.test(node.className)) {
+                               classNames = node.className.trim().split(" ");
+                       }
+                       if (HTMLArea.reservedClassNames.test(node.className)) {
+                               var cleanClassNames = new Array();
+                               var j = -1;
+                               for (var i = 0; i < classNames.length; ++i) {
+                                       if (!HTMLArea.reservedClassNames.test(classNames[i])) {
+                                               cleanClassNames[++j] = classNames[i];
+                                       }
                                }
+                               return cleanClassNames;
                        }
-                       return cleanClassNames;
                }
                return classNames;
        },
        
        /*
-        * This function builds the options to be displayed in the select box
+        * This function reinitializes the options of the dropdown
         */
-       buildDropDownOptions : function (select, tagName) {
-               var cssArray = new Array();
-               while(select.options.length > 0) {
-                       select.options[select.length-1] = null;
+       initializeDropDown : function (dropDown) {
+               if (HTMLArea.is_gecko) {
+                       while(dropDown.options.length > 0) {
+                               dropDown.remove(dropDown.options.length-1);
+                       }
+               } else {
+                       while(dropDown.options.length > 0) {
+                               dropDown.options[dropDown.options.length-1] = null;
+                       }
                }
-               select.options[0] = new Option(this.localize("No style"),"none");
+               var option = dropDown.ownerDocument.createElement("option");
+               option.value = "none";
+               option.innerHTML = this.localize("No style");
+               dropDown.appendChild(option);
+       },
+       
+       /*
+        * This function builds the options to be displayed in the dropDown box
+        */
+       buildDropDownOptions : function (dropDown, tagName) {
+               var cssArray = new Array();
+               this.initializeDropDown(dropDown);
                        // Get classes allowed for all tags
                if (typeof(this.cssArray.all) !== "undefined") {
                        if (this.tags && this.tags[tagName]) {
@@ -333,14 +348,18 @@ BlockStyle = HTMLArea.Plugin.extend({
                        }
                        cssArray = sortedCssArray;
                }
+               var doc = dropDown.ownerDocument;
                for (var cssClass in cssArray) {
                        if (cssArray.hasOwnProperty(cssClass) && cssArray[cssClass]) {
                                if (cssClass == "none") {
-                                       select.options[0] = new Option(cssArray[cssClass], cssClass);
+                                       dropDown.options[0].innerHTML = cssArray[cssClass];
                                } else {
-                                       select.options[select.options.length] = new Option(cssArray[cssClass], cssClass);
+                                       var option = doc.createElement("option");
+                                       option.value = cssClass;
+                                       option.innerHTML = cssArray[cssClass];
+                                       dropDown.appendChild(option);
                                        if (!this.editor.config.disablePCexamples && HTMLArea.classesValues && HTMLArea.classesValues[cssClass] && !HTMLArea.classesNoShow[cssClass]) {
-                                               select.options[select.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
+                                               dropDown.options[dropDown.options.length-1].setAttribute("style", HTMLArea.classesValues[cssClass]);
                                        }
                                }
                        }
@@ -348,7 +367,7 @@ BlockStyle = HTMLArea.Plugin.extend({
        },
        
        /*
-        * This function sets the selected option of the select box
+        * This function sets the selected option of the dropDown box
         */
        setSelectedOption : function (select, classNames, noUnknown) {
                select.selectedIndex = 0;