From f8fe8ccc815fb111574c05fb7cf51adaea57dc0b Mon Sep 17 00:00:00 2001 From: Andreas Fernandez Date: Fri, 9 Feb 2018 23:53:06 +0100 Subject: [PATCH] [TASK] Apply uglify to TypeScript builds The Grunt task `copy:ts_files` now modifies the uglify configuration on-the-fly to minify the files compiled by TypeScript. Resolves: #83251 Releases: master Change-Id: I11faf7ae39f2605b4e8a8a6972f4f16c4b80138f Reviewed-on: https://review.typo3.org/55639 Tested-by: TYPO3com Reviewed-by: Joerg Boesche Reviewed-by: Frank Naegler Tested-by: Frank Naegler Reviewed-by: Benjamin Kott Tested-by: Benjamin Kott --- Build/Gruntfile.js | 39 +- .../Public/JavaScript/BackendException.js | 15 +- .../Public/JavaScript/ColorPicker.js | 39 +- .../Public/JavaScript/ContextHelp.js | 147 +--- .../Public/JavaScript/DebugConsole.js | 189 +--- .../Public/JavaScript/Event/ClientRequest.js | 25 +- .../Public/JavaScript/Event/Consumable.js | 5 +- .../Public/JavaScript/Event/ConsumerScope.js | 35 +- .../JavaScript/Event/InteractionRequest.js | 37 +- .../Event/InteractionRequestAssignment.js | 5 +- .../JavaScript/Event/InteractionRequestMap.js | 52 +- .../Public/JavaScript/Event/TriggerRequest.js | 49 +- .../Public/JavaScript/FormEngineReview.js | 113 +-- .../Resources/Public/JavaScript/GridEditor.js | 833 +----------------- .../Public/JavaScript/ImageManipulation.js | 809 +---------------- .../Resources/Public/JavaScript/Login.js | 142 +-- .../Resources/Public/JavaScript/Popover.js | 107 +-- .../Resources/Public/JavaScript/RenameFile.js | 71 +- .../Resources/Public/JavaScript/Storage.js | 106 +-- .../Public/JavaScript/Storage/Client.js | 58 +- .../Public/JavaScript/Storage/Persistent.js | 198 +---- .../Resources/Public/JavaScript/Tabs.js | 64 +- .../Public/JavaScript/UserPassLogin.js | 94 +- .../Resources/Public/JavaScript/Utility.js | 70 +- .../JavaScript/Wizard/NewContentElement.js | 27 +- .../Tests/JavaScript/BackendExceptionTest.js | 15 +- .../Tests/JavaScript/GridEditorTest.js | 15 +- .../Resources/Public/JavaScript/T3editor.js | 83 +- 28 files changed, 64 insertions(+), 3378 deletions(-) diff --git a/Build/Gruntfile.js b/Build/Gruntfile.js index 4ba83f27747f..9eb05d3b971f 100644 --- a/Build/Gruntfile.js +++ b/Build/Gruntfile.js @@ -238,7 +238,22 @@ module.exports = function (grunt) { rename: function (dest, src) { var srccleaned = src.replace('Resources/Private/TypeScript', 'Resources/Public/JavaScript'); srccleaned = srccleaned.replace('Tests/TypeScript', 'Tests/JavaScript'); - return dest + srccleaned; + var destination = dest + srccleaned; + + // Apply uglify configuration for regular files only + var config = { + uglify: { + typescript: { + files: [] + } + } + }; + var uglyfile = {}; + uglyfile[destination] = destination; + config.uglify.typescript.files.push(uglyfile); + grunt.config.merge(config); + + return destination; } }] }, @@ -494,6 +509,26 @@ module.exports = function (grunt) { } } ] + }, + typescript: { + options: { + banner: '/*\n' + + ' * This file is part of the TYPO3 CMS project.\n' + + ' *\n' + + ' * It is free software; you can redistribute it and/or modify it under\n' + + ' * the terms of the GNU General Public License, either version 2\n' + + ' * of the License, or any later version.\n' + + ' *\n' + + ' * For the full copyright and license information, please read the\n' + + ' * LICENSE.txt file that was distributed with this source code.\n' + + ' *\n' + + ' * The TYPO3 project - inspiring people to share!' + + '\n' + + ' */' + + '\n' + }, + // Generated by copy:ts_files task + files: {} } } }); @@ -573,7 +608,7 @@ module.exports = function (grunt) { * - 2) Compiles all TypeScript files (*.ts) which are located in sysext//Resources/Private/TypeScript/*.ts * - 3) Copy all generated JavaScript and Map files to public folders */ - grunt.registerTask('scripts', ['tsconfig', 'tslint', 'tsclean', 'exec:ts', 'copy:ts_files']); + grunt.registerTask('scripts', ['tsconfig', 'tslint', 'tsclean', 'exec:ts', 'copy:ts_files', 'uglify:typescript']); /** * grunt tsclean task diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/BackendException.js b/typo3/sysext/backend/Resources/Public/JavaScript/BackendException.js index 3f752b124560..49c589e8baac 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/BackendException.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/BackendException.js @@ -10,17 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - var BackendException = (function () { - function BackendException(message, code) { - if (message === void 0) { message = ''; } - if (code === void 0) { code = 0; } - this.message = message; - this.code = code; - } - return BackendException; - }()); - exports.BackendException = BackendException; -}); +define(["require","exports"],function(a,b){"use strict";Object.defineProperty(b,"__esModule",{value:!0});var c=function(){function a(a,b){void 0===a&&(a=""),void 0===b&&(b=0),this.message=a,this.code=b}return a}();b.BackendException=c}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ColorPicker.js b/typo3/sysext/backend/Resources/Public/JavaScript/ColorPicker.js index 6f027e83fe1b..775814a469d8 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ColorPicker.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ColorPicker.js @@ -10,41 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require", "exports", "jquery", "TYPO3/CMS/Core/Contrib/jquery.minicolors"], function (require, exports, $) { - "use strict"; - /** - * Module: TYPO3/CMS/Backend/ColorPicker - * contains all logic for the color picker used in FormEngine - * @exports TYPO3/CMS/Backend/ColorPicker - */ - var ColorPicker = (function () { - /** - * The constructor, set the class properties default values - */ - function ColorPicker() { - this.selector = '.t3js-color-picker'; - } - /** - * Initialize the color picker for the given selector - */ - ColorPicker.prototype.initialize = function () { - $(this.selector).minicolors({ - format: 'hex', - position: 'bottom left', - theme: 'bootstrap', - }); - $(document).on('change', '.t3js-colorpicker-value-trigger', function (event) { - var $element = $(event.target); - if ($element.val() !== '') { - $element.closest('.t3js-formengine-field-item') - .find('.t3js-color-picker') - .val($element.val()) - .trigger('paste'); - $element.val(''); - } - }); - }; - return ColorPicker; - }()); - return new ColorPicker(); -}); +define(["require","exports","jquery","TYPO3/CMS/Core/Contrib/jquery.minicolors"],function(a,b,c){"use strict";var d=function(){function a(){this.selector=".t3js-color-picker"}return a.prototype.initialize=function(){c(this.selector).minicolors({format:"hex",position:"bottom left",theme:"bootstrap"}),c(document).on("change",".t3js-colorpicker-value-trigger",function(a){var b=c(a.target);""!==b.val()&&(b.closest(".t3js-formengine-field-item").find(".t3js-color-picker").val(b.val()).trigger("paste"),b.val(""))})},a}();return new d}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/ContextHelp.js b/typo3/sysext/backend/Resources/Public/JavaScript/ContextHelp.js index c8b00f69c015..bf9be08fe038 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/ContextHelp.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/ContextHelp.js @@ -10,149 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require", "exports", "jquery", "./Popover", "bootstrap"], function (require, exports, $, Popover) { - "use strict"; - /** - * Module: TYPO3/CMS/Backend/ContextHelp - * API for context help. - * @exports TYPO3/CMS/Backend/ContextHelp - */ - var ContextHelp = (function () { - function ContextHelp() { - this.ajaxUrl = TYPO3.settings.ajaxUrls.context_help; - this.trigger = 'click'; - this.placement = 'auto'; - this.selector = '.t3-help-link'; - this.initialize(); - } - /** - * @return {Window} - */ - ContextHelp.resolveBackend = function () { - if (typeof window.opener !== 'undefined' && window.opener !== null) { - return window.opener.top; - } - else { - return top; - } - }; - ContextHelp.prototype.initialize = function () { - var _this = this; - var backendWindow = ContextHelp.resolveBackend(); - if (typeof backendWindow.TYPO3.settings.ContextHelp !== 'undefined') { - this.helpModuleUrl = backendWindow.TYPO3.settings.ContextHelp.moduleUrl; - } - if (typeof TYPO3.ShortcutMenu === 'undefined' && typeof backendWindow.TYPO3.ShortcutMenu === 'undefined') { - // @FIXME: if we are in the popup... remove the bookmark / shortcut button - // @TODO: make it possible to use the bookmark button also in popup mode - $('.icon-actions-system-shortcut-new').closest('.btn').hide(); - } - var title = ' '; - if (typeof backendWindow.TYPO3.lang !== 'undefined') { - title = backendWindow.TYPO3.lang.csh_tooltip_loading; - } - var $element = $(this.selector); - $element - .attr('data-loaded', 'false') - .attr('data-html', 'true') - .attr('data-original-title', title) - .attr('data-placement', this.placement) - .attr('data-trigger', this.trigger); - Popover.popover($element); - $(document).on('show.bs.popover', this.selector, function (e) { - var $me = $(e.currentTarget); - var description = $me.data('description'); - if (typeof description !== 'undefined' && description !== '') { - Popover.setOptions($me, { - title: $me.data('title'), - content: description - }); - } - else if ($me.attr('data-loaded') === 'false' && $me.data('table')) { - _this.loadHelp($me); - } - // if help icon is in DocHeader, force open to bottom - if ($me.closest('.t3js-module-docheader').length) { - Popover.setOption($me, 'placement', 'bottom'); - } - }).on('shown.bs.popover', this.selector, function (e) { - var $popover = $(e.target).data('bs.popover').$tip; - if (!$popover.find('.popover-title').is(':visible')) { - $popover.addClass('no-title'); - } - }).on('click', '.tipIsLinked', function (e) { - $('.popover').each(function (index, popover) { - var $popover = $(popover); - if ($popover.has(e.target).length) { - console.log($popover.data('bs.popover')); - _this.showHelpPopup($popover.data('bs.popover').$element); - } - }); - }).on('click', 'body', function (e) { - $(_this.selector).each(function (index, triggerElement) { - var $triggerElement = $(triggerElement); - // the 'is' for buttons that trigger popups - // the 'has' for icons within a button that triggers a popup - if (!$triggerElement.is(e.target) - && $triggerElement.has(e.target).length === 0 - && $('.popover').has(e.target).length === 0) { - Popover.hide($triggerElement); - } - }); - }); - }; - /** - * Open the help popup - * - * @param {JQuery} $trigger - */ - ContextHelp.prototype.showHelpPopup = function ($trigger) { - try { - var cshWindow = window.open(this.helpModuleUrl + - '&tx_documentation_help_documentationcshmanual[table]=' + $trigger.data('table') + - '&tx_documentation_help_documentationcshmanual[field]=' + $trigger.data('field'), 'ContextHelpWindow', 'height=400,width=600,status=0,menubar=0,scrollbars=1'); - cshWindow.focus(); - Popover.hide($trigger); - return cshWindow; - } - catch (e) { - // do nothing - } - }; - /** - * Load help data - * - * @param {JQuery} $trigger - */ - ContextHelp.prototype.loadHelp = function ($trigger) { - var table = $trigger.data('table'); - var field = $trigger.data('field'); - // If a table is defined, use ajax call to get the tooltip's content - if (table) { - // Load content - $.getJSON(this.ajaxUrl, { - params: { - action: 'getContextHelp', - table: table, - field: field - } - }).done(function (data) { - var title = data.title || ''; - var content = data.content || '

'; - Popover.setOptions($trigger, { - title: title, - content: content - }); - $trigger - .attr('data-loaded', 'true') - .one('hidden.bs.popover', function () { - Popover.show($trigger); - }); - Popover.hide($trigger); - }); - } - }; - return ContextHelp; - }()); - return new ContextHelp(); -}); +define(["require","exports","jquery","./Popover","bootstrap"],function(a,b,c,d){"use strict";var e=function(){function a(){this.ajaxUrl=TYPO3.settings.ajaxUrls.context_help,this.trigger="click",this.placement="auto",this.selector=".t3-help-link",this.initialize()}return a.resolveBackend=function(){return"undefined"!=typeof window.opener&&null!==window.opener?window.opener.top:top},a.prototype.initialize=function(){var b=this,e=a.resolveBackend();"undefined"!=typeof e.TYPO3.settings.ContextHelp&&(this.helpModuleUrl=e.TYPO3.settings.ContextHelp.moduleUrl),"undefined"==typeof TYPO3.ShortcutMenu&&"undefined"==typeof e.TYPO3.ShortcutMenu&&c(".icon-actions-system-shortcut-new").closest(".btn").hide();var f=" ";"undefined"!=typeof e.TYPO3.lang&&(f=e.TYPO3.lang.csh_tooltip_loading);var g=c(this.selector);g.attr("data-loaded","false").attr("data-html","true").attr("data-original-title",f).attr("data-placement",this.placement).attr("data-trigger",this.trigger),d.popover(g),c(document).on("show.bs.popover",this.selector,function(a){var e=c(a.currentTarget),f=e.data("description");"undefined"!=typeof f&&""!==f?d.setOptions(e,{title:e.data("title"),content:f}):"false"===e.attr("data-loaded")&&e.data("table")&&b.loadHelp(e),e.closest(".t3js-module-docheader").length&&d.setOption(e,"placement","bottom")}).on("shown.bs.popover",this.selector,function(a){var b=c(a.target).data("bs.popover").$tip;b.find(".popover-title").is(":visible")||b.addClass("no-title")}).on("click",".tipIsLinked",function(a){c(".popover").each(function(d,e){var f=c(e);f.has(a.target).length&&(console.log(f.data("bs.popover")),b.showHelpPopup(f.data("bs.popover").$element))})}).on("click","body",function(a){c(b.selector).each(function(b,e){var f=c(e);f.is(a.target)||0!==f.has(a.target).length||0!==c(".popover").has(a.target).length||d.hide(f)})})},a.prototype.showHelpPopup=function(a){try{var b=window.open(this.helpModuleUrl+"&tx_documentation_help_documentationcshmanual[table]="+a.data("table")+"&tx_documentation_help_documentationcshmanual[field]="+a.data("field"),"ContextHelpWindow","height=400,width=600,status=0,menubar=0,scrollbars=1");return b.focus(),d.hide(a),b}catch(a){}},a.prototype.loadHelp=function(a){var b=a.data("table"),e=a.data("field");b&&c.getJSON(this.ajaxUrl,{params:{action:"getContextHelp",table:b,field:e}}).done(function(b){var c=b.title||"",e=b.content||"

";d.setOptions(a,{title:c,content:e}),a.attr("data-loaded","true").one("hidden.bs.popover",function(){d.show(a)}),d.hide(a)})},a}();return new e}); \ No newline at end of file diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/DebugConsole.js b/typo3/sysext/backend/Resources/Public/JavaScript/DebugConsole.js index c5ddfc1e8838..6fda0a1f018e 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/DebugConsole.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/DebugConsole.js @@ -10,191 +10,4 @@ * * The TYPO3 project - inspiring people to share! */ -define(["require", "exports", "jquery"], function (require, exports, $) { - "use strict"; - /** - * Module: TYPO3/CMS/Backend/DebugConsole - * The debug console shown at the bottom of the backend - * @exports TYPO3/CMS/Backend/DebugConsole - */ - var DebugConsole = (function () { - function DebugConsole() { - var _this = this; - this.settings = { - autoscroll: true, - }; - $(function () { - _this.createDom(); - }); - } - /** - * Increment the counter of unread messages in the given tab - * - * @param {JQuery} $tab - */ - DebugConsole.incrementInactiveTabCounter = function ($tab) { - if (!$tab.hasClass('active')) { - var $badge = $tab.find('.badge'); - var value = parseInt($badge.text(), 10); - if (isNaN(value)) { - value = 0; - } - $badge.text(++value); - } - }; - /** - * Add the debug message to the console - * - * @param {String} message - * @param {String} header - * @param {String} [group=Debug] - */ - DebugConsole.prototype.add = function (message, header, group) { - this.attachToViewport(); - var $line = $('

').html(message); - if (typeof header !== 'undefined' && header.length > 0) { - $line.prepend($('').text(header)); - } - if (typeof group === 'undefined' || group.length === 0) { - group = 'Debug'; - } - var tabIdentifier = 'debugtab-' + group.toLowerCase().replace(/\W+/g, '-'); - var $debugTabs = this.$consoleDom.find('.t3js-debuggroups'); - var $tabContent = this.$consoleDom.find('.t3js-debugcontent'); - var $tab = this.$consoleDom.find('.t3js-debuggroups li[data-identifier=' + tabIdentifier + ']'); - // check if group tab exists - if ($tab.length === 0) { - // create new tab - $tab = - $('

  • ', { role: 'presentation', 'data-identifier': tabIdentifier }).append($('', { - 'aria-controls': tabIdentifier, - 'data-toggle': 'tab', - href: '#' + tabIdentifier, - role: 'tab' - }).text(group + ' ').append($('', { 'class': 'badge' }))).on('shown.bs.tab', function (e) { - $(e.currentTarget).find('.badge').text(''); - }); - $debugTabs.append($tab); - $tabContent.append($('
    ', { role: 'tabpanel', 'class': 'tab-pane', id: tabIdentifier }).append($('
    ', { 'class': 't3js-messages messages' }))); - } - // activate the first tab if no one is active - if ($debugTabs.find('.active').length === 0) { - $debugTabs.find('a:first').tab('show'); - } - DebugConsole.incrementInactiveTabCounter($tab); - this.incrementUnreadMessagesIfCollapsed(); - var $messageBox = $('#' + tabIdentifier + ' .t3js-messages'); - var isMessageBoxActive = $messageBox.parent().hasClass('active'); - $messageBox.append($line); - if (this.settings.autoscroll && isMessageBoxActive) { - $messageBox.scrollTop($messageBox.prop('scrollHeight')); - } - }; - DebugConsole.prototype.createDom = function () { - var _this = this; - if (typeof this.$consoleDom !== 'undefined') { - return; - } - this.$consoleDom = - $('
    ', { id: 'typo3-debug-console' }).append($('
    ', { 'class': 't3js-topbar topbar' }).append($('

    ', { 'class': 'pull-left' }).text(' TYPO3 Debug Console').prepend($('', { 'class': 'fa fa-terminal topbar-icon' })).append($('', { 'class': 'badge' })), $('

    ', { 'class': 't3js-buttons btn-group pull-right' })), $('
    ').append($('
    ', { role: 'tabpanel' }).append($('