From 5016ea3681c95a3ef174940543010da4db625c71 Mon Sep 17 00:00:00 2001 From: Andreas Fernandez <a.fernandez@scripting-base.de> Date: Sun, 10 May 2020 16:13:24 +0200 Subject: [PATCH] [!!!][TASK] Remove deprecated module jquery.clearable The module `jquery.clearable` has been removed in favor of TYPO3/CMS/Backend/Input/Clearable. Resolves: #91483 Releases: master Change-Id: I52d14faed7e871dab9e79af5e2af4e9ebd7b5c67 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64448 Tested-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Georg Ringer <georg.ringer@gmail.com> Tested-by: TYPO3com <noreply@typo3.com> Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Reviewed-by: Georg Ringer <georg.ringer@gmail.com> --- .../Public/JavaScript/jquery.clearable.js | 126 ------------------ ...g-91473-DeprecatedFunctionalityRemoved.rst | 2 + .../Public/JavaScript/RequireJSConfig.js | 1 - .../Public/JavaScript/jquery.clearable.js | 125 ----------------- 4 files changed, 2 insertions(+), 252 deletions(-) delete mode 100644 typo3/sysext/backend/Resources/Public/JavaScript/jquery.clearable.js delete mode 100644 typo3/sysext/install/Resources/Public/JavaScript/jquery.clearable.js diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/jquery.clearable.js b/typo3/sysext/backend/Resources/Public/JavaScript/jquery.clearable.js deleted file mode 100644 index cc77b9a53fc5..000000000000 --- a/typo3/sysext/backend/Resources/Public/JavaScript/jquery.clearable.js +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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! - */ - -/** - * This file provides a jQuery plugin for generating 'clearable' input fields. - * These fields show a "clear"-button when someone hovers over them and - * they are not empty. - * Options: - * * 'onClear': Function that is called after clearing. Takes no arguments, - * 'this' is set to the clearable input element. Defaults to an - * empty function. - */ -(function(factory) { - if (typeof define === "function" && define.amd) { - // AMD. Register as an anonymous module. - define(["jquery"], factory); - } else { - // Browser globals - factory(jQuery); - } -}(function($) { - $.fn.clearable = function(options) { - console.warn('jquery.clearable has been marked as deprecated and will be removed in TYPO3 v11. Use TYPO3/CMS/Backend/Input/Clearable and native HTMLInputElement instead.'); - - var defaults = { - 'onClear': function() { - } - }; - - // The inlined markup represent the current generated markup from the - // icon api for the icon actions-close that can be found in the official - // icon repository and is registered in the backend icon api. - // - // It´s not possible to use/open the backend icon api without opening - // new possible vectors for attackers to sniff system informations. - // - // When the icon definition of actions-close changes also the inlined - // icon should be updated. - // - // https://github.com/typo3/typo3.icons - var closeIcon = '<span class="t3js-icon icon icon-size-small icon-state-default icon-actions-close" data-identifier="actions-close">' + - '<span class="icon-markup">' + - '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M11.9 5.5L9.4 8l2.5 2.5c.2.2.2.5 0 .7l-.7.7c-.2.2-.5.2-.7 0L8 9.4l-2.5 2.5c-.2.2-.5.2-.7 0l-.7-.7c-.2-.2-.2-.5 0-.7L6.6 8 4.1 5.5c-.2-.2-.2-.5 0-.7l.7-.7c.2-.2.5-.2.7 0L8 6.6l2.5-2.5c.2-.2.5-.2.7 0l.7.7c.2.2.2.5 0 .7z" class="icon-color"/></svg>' + - '</span>' + - '</span>'; - - // Merge defaults and given options. Given options have higher priority - // because they are the last argument. - var settings = $.extend({}, defaults, options); - - // Iterate over the list of inputs and make each clearable. Return - // the list to allow chaining. - return this.each(function() { - - // The input element to make clearable. - var $input = $(this); - - // make sure the input field is not used twice for a clearable - // or the input field is a colorpicker, because it breaks the colorpicker. - if (!$input.data('clearable') && !$input.hasClass('t3js-color-picker')) { - $input.data('clearable', 'loaded'); - var hiddenClass = $input.hasClass('hidden') ? ' hidden' : ''; - - // Wrap it with a div and add a span that is the trigger for - // clearing. - $input.wrap('<div class="form-control-clearable" />'); - $input.after('<button type="button" class="close' + hiddenClass + '" tabindex="-1" aria-hidden="true">' + closeIcon + '</button>'); - $input.addClass('t3js-clearable'); - - var $clearer = $input.next(); - - // Register a listener the various events triggering the clearer to - // be shown or hidden. - var handler = function() { - var $element = $(this); - if ($element.next('input[type=hidden]').length) { - $element = $element.next('input[type=hidden]'); - } - var value = $element.val(); - var hasEmptyValue = (value.length === 0); - if (value === "0" && $element.closest('.t3js-datetimepicker').length) { - hasEmptyValue = true; - } - - // only show the clearing button if the value is set, or if the value is not "0" on a datetime field - if (!hasEmptyValue) { - $clearer.show(); - } else { - $clearer.hide(); - } - }; - $input.on('keyup', handler); - $input.on('mouseenter', handler); - $input.on('change', handler); - $input.on('initialize', handler); - - // The actual clearing action. Focus the input element afterwards, - // the user probably wants to type into it after clearing. - $clearer.click(function(e) { - e.preventDefault(); - $input.val('').change(); - if (!$input.hasClass("t3js-datetimepicker")) { - $input.focus(); - } - $input.trigger('keyup'); - - if ('function' === typeof(settings.onClear)) { - settings.onClear.call($input.get()); - } - }); - - $input.trigger('initialize'); - } - }); - }; -})); diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-91473-DeprecatedFunctionalityRemoved.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-91473-DeprecatedFunctionalityRemoved.rst index 61362ec70873..d29f42124719 100644 --- a/typo3/sysext/core/Documentation/Changelog/master/Breaking-91473-DeprecatedFunctionalityRemoved.rst +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-91473-DeprecatedFunctionalityRemoved.rst @@ -212,6 +212,8 @@ The following global JavaScript functions have been removed: The following JavaScript modules have been removed: +- :js:`jquery.clearable` + The following global instances have been removed: Impact diff --git a/typo3/sysext/install/Resources/Public/JavaScript/RequireJSConfig.js b/typo3/sysext/install/Resources/Public/JavaScript/RequireJSConfig.js index ba71efaec3ad..1ae401a989de 100644 --- a/typo3/sysext/install/Resources/Public/JavaScript/RequireJSConfig.js +++ b/typo3/sysext/install/Resources/Public/JavaScript/RequireJSConfig.js @@ -6,7 +6,6 @@ var require = { 'TYPO3/CMS/Backend': 'sysext/backend/Resources/Public/JavaScript', 'TYPO3/CMS/Install': 'sysext/install/Resources/Public/JavaScript', 'jquery': 'sysext/core/Resources/Public/JavaScript/Contrib/jquery/jquery.min', - 'jquery.clearable': 'sysext/backend/Resources/Public/JavaScript/jquery.clearable', 'TYPO3/CMS/Core/Contrib/jquery.minicolors': 'sysext/core/Resources/Public/JavaScript/Contrib/jquery.minicolors', 'bootstrap': 'sysext/core/Resources/Public/JavaScript/Contrib/bootstrap/bootstrap', 'chosen': 'sysext/install/Resources/Public/JavaScript/chosen.jquery.min', diff --git a/typo3/sysext/install/Resources/Public/JavaScript/jquery.clearable.js b/typo3/sysext/install/Resources/Public/JavaScript/jquery.clearable.js deleted file mode 100644 index 691dffbaa144..000000000000 --- a/typo3/sysext/install/Resources/Public/JavaScript/jquery.clearable.js +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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! - */ - -/** - * This file provides a jQuery plugin for generating 'clearable' input fields. - * These fields show a "clear"-button when someone hovers over them and - * they are not empty. - * Options: - * * 'onClear': Function that is called after clearing. Takes no arguments, - * 'this' is set to the clearable input element. Defaults to an - * empty function. - */ -(function(factory) { - if (typeof define === "function" && define.amd) { - // AMD. Register as an anonymous module. - define(["jquery"], factory); - } else { - // Browser globals - factory(jQuery); - } -}(function($) { - $.fn.clearable = function(options) { - - var defaults = { - 'onClear': function() { - } - }; - - // The inlined markup represent the current generated markup from the - // icon api for the icon actions-close that can be found in the official - // icon repository and is registered in the backend icon api. - // - // It´s not possible to use/open the backend icon api without opening - // new possible vectors for attackers to sniff system informations. - // - // When the icon definition of actions-close changes also the inlined - // icon should be updated. - // - // https://github.com/typo3/typo3.icons - var closeIcon = '<span class="t3js-icon icon icon-size-small icon-state-default icon-actions-close" data-identifier="actions-close">' + - '<span class="icon-markup">' + - '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M11.9 5.5L9.4 8l2.5 2.5c.2.2.2.5 0 .7l-.7.7c-.2.2-.5.2-.7 0L8 9.4l-2.5 2.5c-.2.2-.5.2-.7 0l-.7-.7c-.2-.2-.2-.5 0-.7L6.6 8 4.1 5.5c-.2-.2-.2-.5 0-.7l.7-.7c.2-.2.5-.2.7 0L8 6.6l2.5-2.5c.2-.2.5-.2.7 0l.7.7c.2.2.2.5 0 .7z" class="icon-color"/></svg>' + - '</span>' + - '</span>'; - - // Merge defaults and given options. Given options have higher priority - // because they are the last argument. - var settings = $.extend({}, defaults, options); - - // Iterate over the list of inputs and make each clearable. Return - // the list to allow chaining. - return this.each(function() { - - // The input element to make clearable. - var $input = $(this); - - // make sure the input field is not used twice for a clearable - // or the input field is a colorpicker, because it breaks the colorpicker. - if (!$input.data('clearable') && !$input.hasClass('t3js-color-picker')) { - $input.data('clearable', 'loaded'); - var hiddenClass = $input.hasClass('hidden') ? ' hidden' : ''; - - // Wrap it with a div and add a span that is the trigger for - // clearing. - $input.wrap('<div class="form-control-clearable" />'); - $input.after('<button type="button" class="close' + hiddenClass + '" tabindex="-1" aria-hidden="true">' + closeIcon + '</button>'); - $input.addClass('t3js-clearable'); - - var $clearer = $input.next(); - - // Register a listener the various events triggering the clearer to - // be shown or hidden. - var handler = function() { - var $element = $(this); - if ($element.next('input[type=hidden]').length) { - $element = $element.next('input[type=hidden]'); - } - var value = $element.val(); - var hasEmptyValue = (value.length === 0); - if (value === "0" && $element.closest('.t3js-datetimepicker').length) { - hasEmptyValue = true; - } - - // only show the clearing button if the value is set, or if the value is not "0" on a datetime field - if (!hasEmptyValue) { - $clearer.show(); - } else { - $clearer.hide(); - } - }; - $input.on('keyup', handler); - $input.on('mouseenter', handler); - $input.on('change', handler); - $input.on('initialize', handler); - - // The actual clearing action. Focus the input element afterwards, - // the user probably wants to type into it after clearing. - $clearer.click(function(e) { - e.preventDefault(); - $input.val('').change(); - if (!$input.hasClass("t3js-datetimepicker")) { - $input.focus(); - } - $input.trigger('keyup'); - - if ('function' === typeof(settings.onClear)) { - settings.onClear.call($input.get()); - } - }); - - $input.trigger('initialize'); - } - }); - }; -})); -- GitLab