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