[TASK] Clear button in BE search missing 42/43542/6
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 24 Sep 2015 20:40:35 +0000 (22:40 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Fri, 25 Sep 2015 08:30:34 +0000 (10:30 +0200)
Resolves: #68366
Releases: master
Change-Id: I2ad5683d27448c5100c0deb9b9a1be5a1565a919
Reviewed-on: http://review.typo3.org/43542
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js

index 9756293..7acca7f 100644 (file)
@@ -11,7 +11,7 @@
  * The TYPO3 project - inspiring people to share!
  */
 
-define('TYPO3/CMS/Backend/ToggleSearchToolbox', ['jquery'], function($) {
+define('TYPO3/CMS/Backend/ToggleSearchToolbox', ['jquery', 'TYPO3/CMS/Backend/jquery.clearable'], function($) {
        $(document).ready(function() {
                var $toolbar = $('#db_list-searchbox-toolbar');
                $('.t3js-toggle-search-toolbox').on('click', function() {
@@ -21,5 +21,19 @@ define('TYPO3/CMS/Backend/ToggleSearchToolbox', ['jquery'], function($) {
                                $('#search_field').focus();
                        }
                });
+
+               var $searchFields = $('#search_field');
+               var searchResultShown = ('' !== $searchFields.val());
+
+               // make search field clearable
+               $searchFields.clearable(
+                       {
+                               onClear: function() {
+                                       if (searchResultShown) {
+                                               $(this).closest('form').submit();
+                                       }
+                               }
+                       }
+               );
        });
-});
+});
\ No newline at end of file