[TASK] Migrate Toolbar to TypeScript 91/55891/2
authorAndreas Fernandez <a.fernandez@scripting-base.de>
Sun, 25 Feb 2018 12:16:23 +0000 (13:16 +0100)
committerBenni Mack <benni@typo3.org>
Mon, 26 Feb 2018 14:21:46 +0000 (15:21 +0100)
Change-Id: Iab7de8a076a8d0d9249504dd487278e57a6b9ba4
Resolves: #82606
Releases: master
Reviewed-on: https://review.typo3.org/55891
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Build/types/TYPO3/index.d.ts
typo3/sysext/backend/Resources/Private/TypeScript/Toolbar.ts [new file with mode: 0644]
typo3/sysext/backend/Resources/Public/JavaScript/Toolbar.js

index 880ba92..50e9f1c 100644 (file)
@@ -8,6 +8,7 @@ declare namespace TYPO3 {
   export let DebugConsole: any;
   export let Icons: any;
   export let InfoWindow: any;
+  export let ModuleMenu: any;
   export let Notification: any;
   export let Popover: any;
   export let Severity: any;
diff --git a/typo3/sysext/backend/Resources/Private/TypeScript/Toolbar.ts b/typo3/sysext/backend/Resources/Private/TypeScript/Toolbar.ts
new file mode 100644 (file)
index 0000000..ddcaa6a
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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';
+
+/**
+ * Module: TYPO3/CMS/Backend/Toolbar
+ * Toolbar component of the TYPO3 backend
+ * @exports TYPO3/CMS/Backend/Toolbar
+ */
+class Toolbar {
+  public static initialize(): void {
+    Toolbar.initializeEvents();
+  }
+
+  private static initializeEvents(): void {
+    $('.t3js-toolbar-item').parent().on('hidden.bs.dropdown', (): void => {
+      $('.scaffold')
+        .removeClass('scaffold-toolbar-expanded')
+        .removeClass('scaffold-search-expanded');
+    });
+    $(document).on('click', '.toolbar-item [data-modulename]', (evt: JQueryEventObject): void => {
+      evt.preventDefault();
+      require(['TYPO3/CMS/Backend/ModuleMenu'], (): void => {
+        const moduleName = $(evt.target).closest('[data-modulename]').data('modulename');
+        TYPO3.ModuleMenu.App.showModule(moduleName);
+      });
+    });
+    $(document).on('click', '.t3js-topbar-button-toolbar', (): void => {
+      $('.scaffold')
+        .removeClass('scaffold-modulemenu-expanded')
+        .removeClass('scaffold-search-expanded')
+        .toggleClass('scaffold-toolbar-expanded');
+    });
+    $(document).on('click', '.t3js-topbar-button-search', (): void => {
+      $('.scaffold')
+        .removeClass('scaffold-modulemenu-expanded')
+        .removeClass('scaffold-toolbar-expanded')
+        .toggleClass('scaffold-search-expanded');
+    });
+  }
+}
+
+$((): void => {
+  Toolbar.initialize();
+});
index 886731b..defbb61 100644 (file)
  *
  * The TYPO3 project - inspiring people to share!
  */
-
-/**
- * Module: TYPO3/CMS/Backend/Toolbar
- * Toolbar component of the TYPO3 backend
- * @exports TYPO3/CMS/Backend/Toolbar
- */
-require(
-  [
-    'jquery',
-    'TYPO3/CMS/Backend/Icons',
-    'TYPO3/CMS/Backend/ModuleMenu'
-  ],
-  function($) {
-
-    TYPO3.Toolbar = {};
-    TYPO3.Toolbar.App = {
-      initialize: function() {
-        this.initializeEvents();
-      },
-      initializeEvents: function() {
-        $('.t3js-toolbar-item').parent().on('hidden.bs.dropdown', function() {
-          $('.scaffold')
-            .removeClass('scaffold-toolbar-expanded')
-            .removeClass('scaffold-search-expanded');
-        });
-        $(document).on('click', '.toolbar-item [data-modulename]', function(evt) {
-          var moduleName = $(this).data('modulename');
-          TYPO3.ModuleMenu.App.showModule(moduleName);
-          evt.preventDefault();
-        });
-        $(document).on('click', '.t3js-topbar-button-toolbar', function() {
-          $('.scaffold')
-            .removeClass('scaffold-modulemenu-expanded')
-            .removeClass('scaffold-search-expanded')
-            .toggleClass('scaffold-toolbar-expanded');
-        });
-        $(document).on('click', '.t3js-topbar-button-search', function() {
-          $('.scaffold')
-            .removeClass('scaffold-modulemenu-expanded')
-            .removeClass('scaffold-toolbar-expanded')
-            .toggleClass('scaffold-search-expanded');
-        });
-      }
-    };
-    // start the module menu app
-    TYPO3.Toolbar.App.initialize();
-  }
-);
+define(["require","exports","jquery"],function(a,b,c){"use strict";Object.defineProperty(b,"__esModule",{value:!0});var d=function(){function b(){}return b.initialize=function(){b.initializeEvents()},b.initializeEvents=function(){c(".t3js-toolbar-item").parent().on("hidden.bs.dropdown",function(){c(".scaffold").removeClass("scaffold-toolbar-expanded").removeClass("scaffold-search-expanded")}),c(document).on("click",".toolbar-item [data-modulename]",function(b){b.preventDefault(),a(["TYPO3/CMS/Backend/ModuleMenu"],function(){var a=c(b.target).closest("[data-modulename]").data("modulename");TYPO3.ModuleMenu.App.showModule(a)})}),c(document).on("click",".t3js-topbar-button-toolbar",function(){c(".scaffold").removeClass("scaffold-modulemenu-expanded").removeClass("scaffold-search-expanded").toggleClass("scaffold-toolbar-expanded")}),c(document).on("click",".t3js-topbar-button-search",function(){c(".scaffold").removeClass("scaffold-modulemenu-expanded").removeClass("scaffold-toolbar-expanded").toggleClass("scaffold-search-expanded")})},b}();c(function(){d.initialize()})});
\ No newline at end of file