[TASK] Migrate ToggleSearchToolbox to TypeScript 76/55776/4
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Sat, 17 Feb 2018 17:58:52 +0000 (18:58 +0100)
committerAndreas Wolf <andreas.wolf@typo3.org>
Sun, 18 Feb 2018 16:52:47 +0000 (17:52 +0100)
Change-Id: Ib06890d7697f0a819d436b679995162cba5543fe
Resolves: #82605
Releases: master
Reviewed-on: https://review.typo3.org/55776
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org>
Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
Build/types/TYPO3/index.d.ts
typo3/sysext/backend/Resources/Private/TypeScript/ToggleSearchToolbox.ts [new file with mode: 0644]
typo3/sysext/backend/Resources/Public/JavaScript/ToggleSearchToolbox.js

index 0796631..fa9e06a 100644 (file)
@@ -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 (file)
index 0000000..eb3b118
--- /dev/null
@@ -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();
+        }
+      }
+    });
+  }
+}
index 79cb7db..8a52727 100644 (file)
  *
  * 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