[BUGFIX] Ensure using jQuery objects in IRRE handling 32/36732/5
authorNicole Cordes <typo3@cordes.co>
Sat, 7 Feb 2015 19:29:45 +0000 (20:29 +0100)
committerNicole Cordes <typo3@cordes.co>
Mon, 9 Feb 2015 21:24:46 +0000 (22:24 +0100)
Certain Javascript functions for IRRE handling expect jQuery objects
as parameter.
This patch ensures to convert objects from HTML to jQuery.

Furthermore one forgotten objectId encoding is added to find a jQuery
object by its id.

Releases: master
Resolves: #64846
Change-Id: I8edb4f6a891c972a3d679595c1bf456bbed9bad2
Reviewed-on: http://review.typo3.org/36732
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.de>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js

index 78508db..9dd63d3 100644 (file)
@@ -436,12 +436,13 @@ var inline = {
                var recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + recordUid + '][' + unique.field + ']');
                var values = this.getValuesFromHashMap(unique.used);
                if (recordObj.length) {
-                                       if (recordObj[0].hasOwnProperty('options')) {
-                                               var selectedValue = recordObj[0].options[recordObj[0].selectedIndex].value;
-                                               for (var i = 0; i < values.length; i++) {
-                                                       if (values[i] != selectedValue) {
-                                                               this.removeSelectOption(recordObj[0], values[i]);
-                                                       }
+                       if (recordObj[0].hasOwnProperty('options')) {
+                               var selectedValue = recordObj[0].options[recordObj[0].selectedIndex].value;
+                               for (var i = 0; i < values.length; i++) {
+                                       if (values[i] != selectedValue) {
+                                               var $recordObject = TYPO3.jQuery(recordObj[0]);
+                                               this.removeSelectOption($recordObject, values[i]);
+                                       }
                                }
                        }
                }
@@ -464,8 +465,9 @@ var inline = {
                                if ($selector.length) {
                                        // remove all items from the new select-item which are already used in other children
                                        if (recordObj.length) {
+                                               var $recordObject = TYPO3.jQuery(recordObj[0]);
                                                for (var i = 0; i < values.length; i++) {
-                                                       this.removeSelectOption(recordObj[0], values[i]);
+                                                       this.removeSelectOption($recordObject, values[i]);
                                                }
                                                // set the selected item automatically to the first of the remaining items if no selector is used
                                                if (!unique.selector) {
@@ -489,7 +491,8 @@ var inline = {
                                        for (var i = 0; i < records.length; i++) {
                                                recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
                                                if (recordObj.length && records[i] != recordUid) {
-                                                       this.removeSelectOption(TYPO3.jQuery(recordObj[0]), selectedValue);
+                                                       var $recordObject = TYPO3.jQuery(recordObj[0]);
+                                                       this.removeSelectOption($recordObject, selectedValue);
                                                }
                                        }
                                }
@@ -846,9 +849,10 @@ var inline = {
                for (var i = 0; i < records.length; i++) {
                        recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
                        if (recordObj.length && recordObj[0] != srcElement) {
-                               this.removeSelectOption(recordObj[0], srcElement.value);
+                               var $recordObject = TYPO3.jQuery(recordObj[0]);
+                               this.removeSelectOption($recordObject, srcElement.value);
                                if (typeof oldValue != 'undefined') {
-                                       this.readdSelectOption(recordObj[0], oldValue, unique);
+                                       this.readdSelectOption($recordObject, oldValue, unique);
                                }
                        }
                }
@@ -872,7 +876,7 @@ var inline = {
 
                        if (unique.selector == 'select') {
                                if (!isNaN(fieldObj[0].value)) {
-                                       var $selector = TYPO3.jQuery('#' + objectPrefix + '_selector');
+                                       var $selector = TYPO3.jQuery('#' + this.escapeObjectId(objectPrefix) + '_selector');
                                        this.readdSelectOption($selector, fieldObj[0].value, unique);
                                }
                        }
@@ -893,7 +897,8 @@ var inline = {
                        for (var i = 0; i < records.length; i++) {
                                recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
                                if (recordObj.length) {
-                                       this.readdSelectOption(recordObj[0], fieldObj[0].value, unique);
+                                       var $recordObject = TYPO3.jQuery(recordObj[0]);
+                                       this.readdSelectOption($recordObject, fieldObj[0].value, unique);
                                }
                        }
                } else if (unique.type == 'groupdb') {