diff --git a/build/build-modules-js/init/minify-vendor.mjs b/build/build-modules-js/init/minify-vendor.mjs index 848887b2107d..5772170ce31f 100644 --- a/build/build-modules-js/init/minify-vendor.mjs +++ b/build/build-modules-js/init/minify-vendor.mjs @@ -8,7 +8,6 @@ const RootPath = process.cwd(); const folders = [ 'media/vendor/accessibility/js', - 'media/vendor/chosen/js', 'media/vendor/debugbar', 'media/vendor/diff/js', 'media/vendor/es-module-shims/js', diff --git a/build/build-modules-js/init/patches.mjs b/build/build-modules-js/init/patches.mjs index 1a20efff1c51..d18f546ff799 100644 --- a/build/build-modules-js/init/patches.mjs +++ b/build/build-modules-js/init/patches.mjs @@ -10,22 +10,9 @@ const RootPath = process.cwd(); * * @returns {Promise} */ -export const patchPackages = async (options) => { +export const patchPackages = async () => { const mediaVendorPath = join(RootPath, 'media/vendor'); - // Joomla's hack to expose the chosen base classes so we can extend it ourselves - // (it was better than the many hacks we had before. But I'm still ashamed of myself). - const dest = join(mediaVendorPath, 'chosen'); - const chosenPath = `${dest}/${options.settings.vendors['chosen-js'].js['chosen.jquery.js']}`; - let ChosenJs = await readFile(chosenPath, { encoding: 'utf8' }); - ChosenJs = ChosenJs.replace( - '}).call(this);', - ` document.AbstractChosen = AbstractChosen; - document.Chosen = Chosen; -}).call(this);`, - ); - await writeFile(chosenPath, ChosenJs, { encoding: 'utf8', mode: 0o644 }); - // Include the v5 shim for Font Awesome const faPath = join(mediaVendorPath, 'fontawesome-free/scss/fontawesome.scss'); const newScss = (await readFile(faPath, { encoding: 'utf8' })).concat(` diff --git a/build/build-modules-js/settings.json b/build/build-modules-js/settings.json index 7b376a12bd9d..4ce05cd8544e 100644 --- a/build/build-modules-js/settings.json +++ b/build/build-modules-js/settings.json @@ -631,40 +631,6 @@ } ] }, - "chosen-js": { - "name": "chosen", - "js": { - "chosen.jquery.js": "js/chosen.jquery.js" - }, - "css": { - "chosen.css": "css/chosen.css", - "chosen-sprite.png": "css/chosen-sprite.png", - "chosen-sprite@2x.png": "css/chosen-sprite@2x.png" - }, - "provideAssets": [ - { - "name": "chosen", - "type": "style", - "uri": "chosen.css" - }, - { - "name": "chosen", - "type": "script", - "uri": "chosen.jquery.js", - "dependencies": [ - "jquery" - ] - }, - { - "name": "chosen", - "type": "preset", - "dependencies": [ - "chosen#style", - "chosen#script" - ] - } - ] - }, "accessibility": { "name": "accessibility", "licenseFilename": "LICENSE", diff --git a/build/media_source/legacy/js/ajax-chosen.es5.js b/build/media_source/legacy/js/ajax-chosen.es5.js deleted file mode 100644 index 9790e596793e..000000000000 --- a/build/media_source/legacy/js/ajax-chosen.es5.js +++ /dev/null @@ -1,161 +0,0 @@ -/** - * @copyright (C) 2013 Open Source Matters, Inc. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/** - * ajaxChosen javascript behavior - * - * Used for displaying tags - * - * @package Joomla.JavaScript - * @since 1.5 - * @version 1.0 - */ -(function($) { - return $.fn.ajaxChosen = function(settings, callback, chosenOptions) { - var chosenXhr, defaultOptions, options, select; - if (settings == null) { - settings = {}; - } - if (callback == null) { - callback = {}; - } - if (chosenOptions == null) { - chosenOptions = function() {}; - } - defaultOptions = { - minTermLength: 3, - afterTypeDelay: 500, - jsonTermKey: "term", - keepTypingMsg: Joomla.Text._('JGLOBAL_KEEP_TYPING'), - lookingForMsg: Joomla.Text._('JGLOBAL_LOOKING_FOR') - }; - select = this; - chosenXhr = null; - options = $.extend({}, defaultOptions, $(select).data(), settings); - this.jchosen(chosenOptions ? chosenOptions : {}); - return this.each(function() { - return $(this).next('.chosen-container').find(".search-field > input, .chosen-search > input").bind('keyup', function() { - var field, msg, success, untrimmed_val, val; - untrimmed_val = $(this).val(); - val = $.trim($(this).val()); - msg = val.length < options.minTermLength ? options.keepTypingMsg : options.lookingForMsg + (" '" + val + "'"); - select.next('.chosen-container').find('.no-results').text(msg); - if (val === $(this).data('prevVal')) { - return false; - } - $(this).data('prevVal', val); - if (this.timer) { - clearTimeout(this.timer); - } - if (val.length < options.minTermLength) { - return false; - } - field = $(this); - if (!(options.data != null)) { - options.data = {}; - } - options.data[options.jsonTermKey] = val; - if (options.dataCallback != null) { - options.data = options.dataCallback(options.data); - } - success = options.success; - options.success = function(data) { - var items, nbItems, selected_values; - if (!(data != null)) { - return; - } - selected_values = []; - select.find('option').each(function() { - if (!$(this).is(":selected")) { - return $(this).remove(); - } else { - return selected_values.push($(this).val() + "-" + $(this).text()); - } - }); - select.find('optgroup:empty').each(function() { - return $(this).remove(); - }); - items = callback.apply(null, data); - nbItems = 0; - $.each(items, function(i, element) { - var group, text, value; - nbItems++; - if (element.group) { - group = select.find("optgroup[label='" + element.text + "']"); - if (!group.size()) { - group = $(""); - } - group.attr('label', element.text).appendTo(select); - return $.each(element.items, function(i, element) { - var text, value; - if (typeof element === "string") { - value = i; - text = element; - } else { - value = element.value; - text = element.text; - } - if ($.inArray(value + "-" + text, selected_values) === -1) { - return $("'); - group.append(option); - this.form_field_jq.append(group); - this.form_field.options[this.form_field.options.length - 1].selected = true; - if (!evt.metaKey) { - this.results_hide(); - } - return this.results_build(); - } - - return JoomlaChosen.__super__.result_select.apply(this, arguments); - }; - - JoomlaChosen.prototype.find_custom_group = function () { - var found, group, _i, _len, _ref; - _ref = $('optgroup', this.form_field); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - group = _ref[_i]; - if (group.getAttribute('label') === this.custom_group_text) { - found = group; - } - } - return found; - }; - - JoomlaChosen.prototype.add_unique_custom_group = function () { - var group; - group = this.find_custom_group(); - if (!group) { - group = $(''); - } - return $(group); - }; - - /** - * We choose to override this function so deliberately don't call super - */ - JoomlaChosen.prototype.container_width = function () { - if (this.options.width != null) { - return this.options.width; - } else { - // Original: return "" + this.form_field.offsetWidth + "px"; - return this.form_field_jq.css("width") || "" + this.form_field.offsetWidth + "px"; - } - }; - - return JoomlaChosen; - - })(Chosen); -})(jQuery, document.Chosen, document.AbstractChosen); diff --git a/build/media_source/system/js/fields/tag.es5.js b/build/media_source/system/js/fields/tag.es5.js deleted file mode 100644 index 0cc2af0634be..000000000000 --- a/build/media_source/system/js/fields/tag.es5.js +++ /dev/null @@ -1,66 +0,0 @@ -/** - * @copyright (C) 2016 Open Source Matters, Inc. - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -/** - * Field user - */ -jQuery(document).ready(function ($) { - - if (Joomla.getOptions('field-tag-custom')) { - - var options = Joomla.getOptions('field-tag-custom'), - customTagPrefix = '#new#'; - - // Method to add tags pressing enter - $(options.selector + '_chosen input').keyup(function(event) { - - var tagOption; - - // Tag is greater than the minimum required chars and enter pressed - if (this.value && this.value.length >= options.minTermLength && (event.which === 13 || event.which === 188)) { - - // Search a highlighted result - var highlighted = $(options.selector + '_chosen').find('li.active-result.highlighted').first(); - - // Add the highlighted option - if (event.which === 13 && highlighted.text() !== '') - { - // Extra check. If we have added a custom tag with this text remove it - var customOptionValue = customTagPrefix + highlighted.text(); - $(options.selector + ' option').filter(function () { return $(this).val() == customOptionValue; }).remove(); - - // Select the highlighted result - tagOption = $(options.selector + ' option').filter(function () { return $(this).html() == highlighted.text(); }); - tagOption.attr('selected', 'selected'); - } - // Add the custom tag option - else - { - var customTag = this.value; - - // Extra check. Search if the custom tag already exists (typed faster than AJAX ready) - tagOption = $(options.selector + ' option').filter(function () { return $(this).html() == customTag; }); - if (tagOption.text() !== '') - { - tagOption.attr('selected', 'selected'); - } - else - { - var option = $('