[BUGFIX] Bring back inline page title editing 37/41037/2
authorMarkus Klein <markus.klein@typo3.org>
Thu, 9 Jul 2015 12:06:38 +0000 (14:06 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 9 Jul 2015 12:51:13 +0000 (14:51 +0200)
Prevent a race condition in the initialization by registering
a ready-function in case DOM is not ready yet.

Resolves: #68006
Releases: master
Change-Id: I80e9af2f71850ddc2856d76a3865f0b0c5e71adb
Reviewed-on: http://review.typo3.org/41037
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/backend/Resources/Public/JavaScript/PageActions.js

index 7f7cfc1..1948571 100644 (file)
@@ -15,6 +15,8 @@
  * JavaScript implementations for page actions
  */
 define('TYPO3/CMS/Backend/PageActions', ['jquery'], function($) {
+       'use strict';
+
        var PageActions = {
                settings: {
                        pageId: 0,
@@ -29,14 +31,21 @@ define('TYPO3/CMS/Backend/PageActions', ['jquery'], function($) {
                elements: {
                        $pageTitle: null,
                        $showHiddenElementsCheckbox: null
-               }
+               },
+               documentIsReady: false
        };
 
        /**
         * Initialize page title renaming
         */
        PageActions.initializePageTitleRenaming = function() {
-               if (!(PageActions.settings.pageId > 0 && PageActions.settings.canEditPage)) {
+               if (!PageActions.documentIsReady) {
+                       $(document).ready(function() {
+                               PageActions.initializePageTitleRenaming();
+                       });
+                       return;
+               }
+               if (PageActions.settings.pageId <= 0 || !PageActions.settings.canEditPage) {
                        return;
                }
 
@@ -186,11 +195,12 @@ define('TYPO3/CMS/Backend/PageActions', ['jquery'], function($) {
                        recordUid = PageActions.settings.language.pageOverlayId;
                }
 
-               parameters['data'] = {};
-               parameters['data'][pagesTable] = {};
-               parameters['data'][pagesTable][recordUid] = {title: $field.val()};
+               parameters.data = {};
+               parameters.data[pagesTable] = {};
+               parameters.data[pagesTable][recordUid] = {title: $field.val()};
+
                require(['TYPO3/CMS/Backend/AjaxDataHandler'], function(DataHandler) {
-                       DataHandler.process(parameters).done(function(result) {
+                       DataHandler.process(parameters).done(function() {
                                $inputFieldWrap.find('[data-action=cancel]').trigger('click');
                                PageActions.elements.$pageTitle.text($field.val());
                                PageActions.initializePageTitleRenaming();
@@ -204,6 +214,7 @@ define('TYPO3/CMS/Backend/PageActions', ['jquery'], function($) {
        $(document).ready(function() {
                PageActions.initializeElements();
                PageActions.initializeEvents();
+               PageActions.documentIsReady = true;
        });
 
        return PageActions;