[BUGFIX] Fix some small issuses of the evalfield patch 73/41273/3
authorFrank Nägler <typo3@naegler.net>
Wed, 15 Jul 2015 11:48:50 +0000 (13:48 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 15 Jul 2015 12:04:37 +0000 (14:04 +0200)
This patch fix event binding ordering and handling of password fields.

Resolves: #68162
Related: #67852
Releases: master
Change-Id: I3c28f1decef6915fe2981402a65df2378179d7f9
Reviewed-on: http://review.typo3.org/41273
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Nicole Cordes <typo3@cordes.co>
Tested-by: Nicole Cordes <typo3@cordes.co>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Resources/Public/JavaScript/FormEngineValidation.js

index a8cff87..fa14a2a 100644 (file)
@@ -44,23 +44,6 @@ define('TYPO3/CMS/Backend/FormEngineValidation', ['jquery', 'TYPO3/CMS/Backend/F
        FormEngineValidation.initialize = function() {
                $(document).find('.' + FormEngineValidation.errorClass).removeClass(FormEngineValidation.errorClass);
 
-               // Bind to field changes
-               $(document).on('change', FormEngineValidation.rulesSelector, function() {
-                       // we need to wait, because the update of the select fields needs some time
-                       window.setTimeout(function() {
-                               FormEngineValidation.validate();
-                       }, 500);
-                       var $paletteField = $(this).closest('.t3js-formengine-palette-field');
-                       $paletteField.addClass('has-change');
-               });
-
-               // Bind to datepicker changes
-               $(document).on('dp.change', FormEngineValidation.dateTimeSelector, function(event) {
-                       FormEngineValidation.validate();
-                       var $paletteField = $(this).closest('.t3js-formengine-palette-field');
-                       $paletteField.addClass('has-change');
-               });
-
                // Initialize input fields
                $(document).find(FormEngineValidation.inputSelector).each(function() {
                        var config = $(this).data('formengine-input-params');
@@ -69,6 +52,25 @@ define('TYPO3/CMS/Backend/FormEngineValidation', ['jquery', 'TYPO3/CMS/Backend/F
                        $field.data('main-field', fieldName);
                        $field.data('config', config);
                        FormEngineValidation.initializeInputField(fieldName);
+               }).promise().done(function () {
+                       // Bind to field changes
+                       $(document).on('change', FormEngineValidation.rulesSelector, function() {
+                               // we need to wait, because the update of the select fields needs some time
+                               window.setTimeout(function() {
+                                       FormEngineValidation.validate();
+                               }, 500);
+                               var $paletteField = $(this).closest('.t3js-formengine-palette-field');
+                               $paletteField.addClass('has-change');
+                       });
+
+                       // Bind to datepicker change event, but wait some milliseconds, because the init is not so fast
+                       window.setTimeout(function() {
+                               $(document).on('dp.change', FormEngineValidation.dateTimeSelector, function(event) {
+                                       FormEngineValidation.validate();
+                                       var $paletteField = $(this).closest('.t3js-formengine-palette-field');
+                                       $paletteField.addClass('has-change');
+                               });
+                       }, 500);
                });
 
                var today = new Date();
@@ -215,14 +217,12 @@ define('TYPO3/CMS/Backend/FormEngineValidation', ['jquery', 'TYPO3/CMS/Backend/F
                        if (typeof typeConfig !== 'undefined' && typeConfig.length) {
                                type = typeConfig[0].type;
                        }
-                       switch (type) {
-                               case 'password':
-                                       $mainField.val(origValue);
-                                       $humanReadableField.val(newValue);
-                                       break;
-                               default:
-                                       $mainField.val(newValue);
-                                       $humanReadableField.val(newValue);
+                       if ($.inArray('password', evalList)) {
+                               $mainField.val(origValue);
+                               $humanReadableField.val(newValue);
+                       } else {
+                               $mainField.val(newValue);
+                               $humanReadableField.val(newValue);
                        }
                }
        };