diff --git a/Build/types/TYPO3/index.d.ts b/Build/types/TYPO3/index.d.ts index 07966314d4923a886fb0c51e25862b39970f6ea1..fa9e06afdbe8b06d1f9e702781bc5fe877abf078 100644 --- a/Build/types/TYPO3/index.d.ts +++ b/Build/types/TYPO3/index.d.ts @@ -114,6 +114,6 @@ interface JQueryTypedEvent<T extends Event> extends JQueryEventObject { * Required to make jQuery plugins "available" in TypeScript */ interface JQuery { - clearable(): JQuery; + clearable(options?: any): JQuery; dragUploader(options?: DragUploaderOptions): JQuery; } diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/ToggleSearchToolbox.ts b/typo3/sysext/backend/Resources/Private/TypeScript/ToggleSearchToolbox.ts new file mode 100644 index 0000000000000000000000000000000000000000..eb3b1185385f36c893592553713a58b0ec96c24c --- /dev/null +++ b/typo3/sysext/backend/Resources/Private/TypeScript/ToggleSearchToolbox.ts @@ -0,0 +1,52 @@ +/* + * 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! + */ + +import * as $ from 'jquery'; +import DocumentHeader = require('./DocumentHeader'); +import 'TYPO3/CMS/Backend/jquery.clearable'; + +/** + * Module: TYPO3/CMS/Backend/ToggleSearchToolbox + * Toggle the search toolbox + * @exports TYPO3/CMS/Backend/ToggleSearchToolbox + */ +class ToggleSearchToolbox { + constructor() { + $((): void => { + this.initialize(); + }); + } + + private initialize(): void { + const $toolbar = $('#db_list-searchbox-toolbar'); + $('.t3js-toggle-search-toolbox').on('click', (): void => { + $toolbar.toggle(); + DocumentHeader.reposition(); + if ($toolbar.is(':visible')) { + $('#search_field').focus(); + } + }); + + const $searchFields = $('#search_field'); + const searchResultShown = ('' !== $searchFields.val()); + + // make search field clearable + $searchFields.clearable({ + onClear: (): void => { + if (searchResultShown) { + $(this).closest('form').submit(); + } + } + }); + } +} diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js b/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js index 79cb7dba09d3ee3d2fa61f69d27ce7a2329150a6..8a52727f5f61d01b8d9aece204e42748a009a461 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js @@ -10,35 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ - -/** - * Module: TYPO3/CMS/Backend/ToggleSearchToolbox - * Toggle the search toolbox - * @exports TYPO3/CMS/Backend/ToggleSearchToolbox - */ -define(['jquery', 'TYPO3/CMS/Backend/DocumentHeader', 'TYPO3/CMS/Backend/jquery.clearable'], function($, DocumentHeader) { - 'use strict'; - - $(function() { - var $toolbar = $('#db_list-searchbox-toolbar'); - $('.t3js-toggle-search-toolbox').on('click', function() { - $toolbar.toggle(); - DocumentHeader.reposition(); - if ($toolbar.is(':visible')) { - $('#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(); - } - } - }); - }); -}); +define(["require","exports","jquery","./DocumentHeader","TYPO3/CMS/Backend/jquery.clearable"],function(a,b,c,d){"use strict";Object.defineProperty(b,"__esModule",{value:!0});(function(){function a(){var a=this;c(function(){a.initialize()})}return a.prototype.initialize=function(){var a=this,b=c("#db_list-searchbox-toolbar");c(".t3js-toggle-search-toolbox").on("click",function(){b.toggle(),d.reposition(),b.is(":visible")&&c("#search_field").focus()});var e=c("#search_field"),f=""!==e.val();e.clearable({onClear:function(){f&&c(a).closest("form").submit()}})},a})()}); \ No newline at end of file