From 84533ac38fc033c952f4f0c893f1c78efe0ce2c6 Mon Sep 17 00:00:00 2001 From: roykho Date: Thu, 4 Feb 2021 14:06:08 -0800 Subject: [PATCH] Update deprecated jQuery functions for selectWoo.full.js --- assets/js/selectWoo/selectWoo.full.js | 58 +++++++++++++-------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/assets/js/selectWoo/selectWoo.full.js b/assets/js/selectWoo/selectWoo.full.js index 49cb11ee692..4c4daf83fc9 100644 --- a/assets/js/selectWoo/selectWoo.full.js +++ b/assets/js/selectWoo/selectWoo.full.js @@ -1430,7 +1430,7 @@ S2.define('select2/selection/base',[ // This needs to be delayed as the active element is the body when the // key is pressed. window.setTimeout(function () { - self.$selection.focus(); + self.$selection.trigger( 'focus' ); }, 1); self._detachCloseHandler(container); @@ -1486,8 +1486,8 @@ S2.define('select2/selection/base',[ // Remove any focus when dropdown is closed by clicking outside the select area. // Timeout of 1 required for close to finish wrapping up. setTimeout(function(){ - $this.find('*:focus').blur(); - $target.focus(); + $this.find('*:focus').trigger( 'blur' ); + $target.trigger( 'focus' ); }, 1); }); }); @@ -1591,7 +1591,7 @@ S2.define('select2/selection/single',[ container.on('focus', function (evt) { if (!container.isOpen()) { - self.$selection.focus(); + self.$selection.trigger( 'focus' ); } }); @@ -1737,7 +1737,7 @@ S2.define('select2/selection/multiple',[ // This gets reset automatically when focus is triggered. self._keyUpPrevented = true; - self.$search.focus(); + self.$search.trigger( 'focus' ); }, 1); } } @@ -2109,7 +2109,7 @@ S2.define('select2/selection/search',[ this.resizeSearch(); if (searchHadFocus) { - this.$search.focus(); + this.$search.trigger( 'focus' ); } }; @@ -3547,7 +3547,7 @@ S2.define('select2/data/ajax',[ if (this._request != null) { // JSONP requests cannot always be aborted - if ($.isFunction(this._request.abort)) { + if ('function' === typeof this._request.abort) { this._request.abort(); } @@ -3572,7 +3572,7 @@ S2.define('select2/data/ajax',[ if (self.options.get('debug') && window.console && console.error) { // Check to make sure that the response included a `results` key. - if (!results || !results.results || !$.isArray(results.results)) { + if (!results || !results.results || !Array.isArray(results.results)) { console.error( 'Select2: The AJAX results did not return an array in the ' + '`results` key of the response.' @@ -3631,7 +3631,7 @@ S2.define('select2/data/tags',[ decorated.call(this, $element, options); - if ($.isArray(tags)) { + if (Array.isArray(tags)) { for (var t = 0; t < tags.length; t++) { var tag = tags[t]; var item = this._normalizeItem(tag); @@ -3707,7 +3707,7 @@ S2.define('select2/data/tags',[ }; Tags.prototype.createTag = function (decorated, params) { - var term = $.trim(params.term); + var term = 'string' === typeof params.term ? params.term.trim() : ''; if (term === '') { return null; @@ -3800,7 +3800,7 @@ S2.define('select2/data/tokenizer',[ // Replace the search term if we have the search box if (this.$search.length) { this.$search.val(tokenData.term); - this.$search.focus(); + this.$search.trigger( 'focus' ); } params.term = tokenData.term; @@ -4047,10 +4047,10 @@ S2.define('select2/dropdown/search',[ container.on('open', function () { self.$search.attr('tabindex', 0); self.$search.attr('aria-owns', resultsId); - self.$search.focus(); + self.$search.trigger( 'focus' ); window.setTimeout(function () { - self.$search.focus(); + self.$search.trigger( 'focus' ); }, 0); }); @@ -4063,7 +4063,7 @@ S2.define('select2/dropdown/search',[ container.on('focus', function () { if (!container.isOpen()) { - self.$search.focus(); + self.$search.trigger( 'focus' ); } }); @@ -4878,7 +4878,7 @@ S2.define('select2/defaults',[ } } - if ($.isArray(options.language)) { + if (Array.isArray(options.language)) { var languages = new Translation(); options.language.push('en'); @@ -4941,7 +4941,7 @@ S2.define('select2/defaults',[ function matcher (params, data) { // Always return the object if there is nothing to compare - if ($.trim(params.term) === '') { + if ( 'undefined' === typeof params.term || ( 'string' === typeof params.term && '' === params.term.trim() ) ) { return data; } @@ -5513,7 +5513,7 @@ S2.define('select2/core',[ self.focusOnActiveElement(); } else { // Focus on the search if user starts typing. - $searchField.focus(); + $searchField.trigger( 'focus' ); // Focus back to active selection when finished typing. // Small delay so typed character can be read by screen reader. setTimeout(function(){ @@ -5533,7 +5533,7 @@ S2.define('select2/core',[ Select2.prototype.focusOnActiveElement = function () { // Don't mess with the focus on touchscreens because it causes havoc with on-screen keyboards. if (this.isOpen() && ! Utils.isTouchscreen()) { - this.$results.find('li.select2-results__option--highlighted').focus(); + this.$results.find('li.select2-results__option--highlighted').trigger( 'focus' ); } }; @@ -5724,7 +5724,7 @@ S2.define('select2/core',[ var newVal = args[0]; - if ($.isArray(newVal)) { + if (Array.isArray(newVal)) { newVal = $.map(newVal, function (obj) { return obj.toString(); }); @@ -5801,7 +5801,7 @@ S2.define('select2/compat/utils',[ function syncCssClasses ($dest, $src, adapter) { var classes, replacements = [], adapted; - classes = $.trim($dest.attr('class')); + classes = 'string' === typeof $dest.attr('class') ? $dest.attr('class').trim() : ''; if (classes) { classes = '' + classes; // for IE which returns object @@ -5814,7 +5814,7 @@ S2.define('select2/compat/utils',[ }); } - classes = $.trim($src.attr('class')); + classes = 'string' === typeof $src.attr('class') ? $src.attr('class').trim() : ''; if (classes) { classes = '' + classes; // for IE which returns object @@ -5855,7 +5855,7 @@ S2.define('select2/compat/containerCss',[ var containerCssClass = this.options.get('containerCssClass') || ''; - if ($.isFunction(containerCssClass)) { + if ('function' === typeof containerCssClass) { containerCssClass = containerCssClass(this.$element); } @@ -5881,7 +5881,7 @@ S2.define('select2/compat/containerCss',[ var containerCss = this.options.get('containerCss') || {}; - if ($.isFunction(containerCss)) { + if ('function' === typeof containerCss) { containerCss = containerCss(this.$element); } @@ -5912,7 +5912,7 @@ S2.define('select2/compat/dropdownCss',[ var dropdownCssClass = this.options.get('dropdownCssClass') || ''; - if ($.isFunction(dropdownCssClass)) { + if ('function' === typeof dropdownCssClass) { dropdownCssClass = dropdownCssClass(this.$element); } @@ -5938,7 +5938,7 @@ S2.define('select2/compat/dropdownCss',[ var dropdownCss = this.options.get('dropdownCss') || {}; - if ($.isFunction(dropdownCss)) { + if ('function' === typeof dropdownCss) { dropdownCss = dropdownCss(this.$element); } @@ -5985,7 +5985,7 @@ S2.define('select2/compat/initSelection',[ this.initSelection.call(null, this.$element, function (data) { self._isInitialized = true; - if (!$.isArray(data)) { + if (!Array.isArray(data)) { data = [data]; } @@ -6131,7 +6131,7 @@ S2.define('select2/compat/matcher',[ function wrappedMatcher (params, data) { var match = $.extend(true, {}, data); - if (params.term == null || $.trim(params.term) === '') { + if ( params.term == null || ( 'string' === typeof params.term && '' === params.term.trim() ) ) { return match; } @@ -6374,11 +6374,11 @@ S2.define('select2/selection/stopPropagation',[ $.fn.extend({ mousewheel: function(fn) { - return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel'); + return fn ? this.on('mousewheel', fn) : this.trigger('mousewheel'); }, unmousewheel: function(fn) { - return this.unbind('mousewheel', fn); + return this.off('mousewheel', fn); } });