[TASK] Show edit icon on hovering the page title 31/39331/5
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 7 May 2015 12:27:27 +0000 (14:27 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 9 May 2015 00:07:04 +0000 (02:07 +0200)
If an user hovers the page title in "List" or in "Page" module,
show an edit icon next to the page title to indicate an action.

Resolves: #66836
Releases: master
Change-Id: I894c17d89afb30c1594dc20cac3bbdae1b0cfca5
Reviewed-on: http://review.typo3.org/39331
Reviewed-by: Frank Nägler <typo3@naegler.net>
Tested-by: Frank Nägler <typo3@naegler.net>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Resources/Public/JavaScript/PageActions.js

index c0f9dd9..fe7c3a4 100644 (file)
@@ -35,6 +35,23 @@ define('TYPO3/CMS/Backend/PageActions', ['jquery'], function($) {
                if (!(PageActions.settings.pageId > 0 && PageActions.settings.canEditPage)) {
                        return;
                }
+
+               var $editActionLink = $('<a class="hidden" href="#" data-action="edit"><span class="t3-icon fa fa-pencil"></span></a>');
+               $editActionLink.on('click', function(e) {
+                       e.preventDefault();
+                       PageActions.editPageTitle();
+               });
+               PageActions.identifier.$pageTitle
+                       .on('dblclick', PageActions.editPageTitle)
+                       .on('mouseover', function() { $editActionLink.removeClass('hidden'); })
+                       .on('mouseout', function() { $editActionLink.addClass('hidden'); })
+                       .append($editActionLink);
+       };
+
+       /**
+        * Changes the h1 to an edit form
+        */
+       PageActions.editPageTitle = function() {
                var $inputFieldWrap = $(
                                '<form class="row">' +
                                        '<div class="col-lg-4 col-md-6 col-sm-12">' +
@@ -72,21 +89,20 @@ define('TYPO3/CMS/Backend/PageActions', ['jquery'], function($) {
                        return false;
                });
 
-               PageActions.identifier.$pageTitle.on('dblclick', function() {
-                       var $h1 = $(this);
-                       $h1.replaceWith($inputFieldWrap);
-                       $inputField.val($h1.text()).focus();
-
-                       $inputField.on('keyup', function(e) {
-                               switch (e.which) {
-                                       case 13: // enter
-                                               $inputFieldWrap.find('[data-action=submit]').trigger('click');
-                                               break;
-                                       case 27: // escape
-                                               $inputFieldWrap.find('[data-action=cancel]').trigger('click');
-                                               break;
-                               }
-                       });
+               var $h1 = PageActions.identifier.$pageTitle;
+               $h1.children().last().remove();
+               $h1.replaceWith($inputFieldWrap);
+               $inputField.val($h1.text()).focus();
+
+               $inputField.on('keyup', function(e) {
+                       switch (e.which) {
+                               case 13: // enter
+                                       $inputFieldWrap.find('[data-action=submit]').trigger('click');
+                                       break;
+                               case 27: // escape
+                                       $inputFieldWrap.find('[data-action=cancel]').trigger('click');
+                                       break;
+                       }
                });
        };
 
@@ -138,6 +154,7 @@ define('TYPO3/CMS/Backend/PageActions', ['jquery'], function($) {
                        DataHandler.process(parameters).done(function(result) {
                                $inputFieldWrap.find('[data-action=cancel]').trigger('click');
                                PageActions.identifier.$pageTitle.text($field.val());
+                               PageActions.initializePageTitleRenaming();
                                top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
                        }).fail(function() {
                                $inputFieldWrap.find('[data-action=cancel]').trigger('click');