[TASK] Configuration: Make searchbox clearable and fix scroll position 02/45202/4
authorJosef Glatz <josef.glatz@typo3.org>
Thu, 10 Dec 2015 18:17:13 +0000 (19:17 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Fri, 11 Dec 2015 05:42:02 +0000 (06:42 +0100)
This patches ensures the page is scrolled to the right position
upon opening a subtree.
Additionally, the "clear search" button is added to the search field.

Releases: master
Resolves: #72155
Change-Id: I4227ab0d362b8be2bb531dd341fb30e5d50d37ab
Reviewed-on: https://review.typo3.org/45202
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/lowlevel/Classes/View/ConfigurationView.php
typo3/sysext/lowlevel/Resources/Public/JavaScript/ConfigurationView.js [new file with mode: 0644]

index bcf3b21..c9f3001 100644 (file)
@@ -88,6 +88,7 @@ class ConfigurationView extends BaseScriptClass
     {
         $this->menuConfig();
         $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
+        $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Lowlevel/ConfigurationView');
     }
 
     /**
diff --git a/typo3/sysext/lowlevel/Resources/Public/JavaScript/ConfigurationView.js b/typo3/sysext/lowlevel/Resources/Public/JavaScript/ConfigurationView.js
new file mode 100644 (file)
index 0000000..dbddb8c
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * Module: TYPO3/CMS/Lowlevel/ConfigurationView
+ * JavaScript for Configuration View
+ * @exports TYPO3/CMS/Lowlevel/ConfigurationView
+ */
+define(['jquery', 'TYPO3/CMS/Backend/jquery.clearable'], function($) {
+
+       var $searchFields = $('input[name="search_field"]');
+       var searchResultShown = ('' !== $searchFields.first().val());
+
+       // make search field clearable
+       $searchFields.clearable({
+               onClear: function() {
+                       if (searchResultShown) {
+                               $(this).closest('form').submit();
+                       }
+               }
+       });
+
+       // scroll page down, so the just opened subtree is visible after reload
+       // and not hidden by doc header
+       if (self.location.hash) {
+               window.scrollTo(window.pageXOffset, window.pageYOffset - 80);
+       }
+});