[CLEANUP] Streamline toggle search toolbox 97/42997/4
authorFlorian Peters <florian.peters@wmdb.de>
Thu, 3 Sep 2015 13:07:27 +0000 (15:07 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 3 Sep 2015 13:49:58 +0000 (15:49 +0200)
Remove the toggle functionality from the HTML template and use
jQuery + require.js for page and list.

Resolves: #69500
Releases: master
Change-Id: I815239acdf74e94c4f0af3a74aacab565c8f5d03
Reviewed-on: http://review.typo3.org/42997
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Resources/Private/Templates/db_layout.html
typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js [new file with mode: 0644]
typo3/sysext/recordlist/Classes/RecordList.php
typo3/sysext/recordlist/Resources/Private/Templates/db_list.html

index 8a6b866..80b4eee 100755 (executable)
@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Type\Bitmask\Permission;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
@@ -1079,7 +1080,8 @@ class PageLayoutController {
                }
                // Making search form:
                if (!$this->modTSconfig['properties']['disableSearchBox'] && !empty($tableOutput)) {
-                       $this->markers['BUTTONLIST_ADDITIONAL'] = '<a href="#" onclick="toggleSearchToolbox(); return false;" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon', TRUE) . '">'.IconUtility::getSpriteIcon('apps-toolbar-menu-search').'</a>';
+                       $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
+                       $this->markers['BUTTONLIST_ADDITIONAL'] = '<a href="#" class="t3js-toggle-search-toolbox" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon', TRUE) . '">'.IconUtility::getSpriteIcon('apps-toolbar-menu-search') . '</a>';
                        $this->markers['SEARCHBOX'] = $dbList->getSearchBox(0);
                }
                // Additional footer content
@@ -1438,4 +1440,12 @@ class PageLayoutController {
                return $GLOBALS['TYPO3_DB'];
        }
 
+       /**
+        * Returns current PageRenderer
+        *
+        * @return PageRenderer
+        */
+       protected function getPageRenderer() {
+               return GeneralUtility::makeInstance(PageRenderer::class);
+       }
 }
index 347f5e9..860a29f 100644 (file)
                </div>
                ###SEARCHBOX###
        </div>
-       <script>
-               function toggleSearchToolbox() {
-                       if (document.getElementById('db_list-searchbox-toolbar').style.display == 'none') {
-                               document.getElementById('db_list-searchbox-toolbar').style.display = 'block';
-                       } else {
-                               document.getElementById('db_list-searchbox-toolbar').style.display = 'none';
-                       }
-               }
-       </script>
        <div id="typo3-docbody">
                <div id="typo3-inner-docbody">
                        ###CONTENT###
diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js b/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js
new file mode 100644 (file)
index 0000000..8e4f8ad
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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!
+ */
+
+define('TYPO3/CMS/Backend/ToggleSearchToolbox', ['jquery'], function($) {
+       $(document).ready(function() {
+               $('.t3js-toggle-search-toolbox').on('click', function() {
+                       $('#db_list-searchbox-toolbar').toggle();
+               });
+       });
+});
index 7e209f0..bf4b8ee 100644 (file)
@@ -541,9 +541,8 @@ class RecordList {
                // searchbox toolbar
                if (!$this->modTSconfig['properties']['disableSearchBox'] && ($dblist->HTMLcode || !empty($dblist->searchString))) {
                        $markers['SEARCHBOX'] = $dblist->getSearchBox();
-                       $markers['BUTTONLIST_ADDITIONAL'] = '<a href="#" onclick="toggleSearchToolbox(); return false;" title="'
-                               . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon', TRUE) . '">'
-                               . IconUtility::getSpriteIcon('apps-toolbar-menu-search').'</a>';
+                       $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/ToggleSearchToolbox');
+                       $markers['BUTTONLIST_ADDITIONAL'] = '<a href="#" class="t3js-toggle-search-toolbox" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon', TRUE) . '">' . IconUtility::getSpriteIcon('apps-toolbar-menu-search') . '</a>';
                }
                // Build the <body> for the module
                $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
index 0122bb1..08b8ec1 100644 (file)
                </div>
         ###SEARCHBOX###
        </div>
-    <script>
-        function toggleSearchToolbox() {
-           if (document.getElementById('db_list-searchbox-toolbar').style.display == 'none') {
-               document.getElementById('db_list-searchbox-toolbar').style.display = 'block';
-           } else {
-               document.getElementById('db_list-searchbox-toolbar').style.display = 'none';
-           }
-        }
-    </script>
        <div id="typo3-docbody">
                <div id="typo3-inner-docbody">
                        ###CONTENT###