fixed jQuery dprecations

This commit is contained in:
Micha 2025-03-03 12:43:56 +01:00
parent d0d10a7e90
commit 30f1b9a6a9
15 changed files with 38 additions and 38 deletions

@ -2601,7 +2601,7 @@ List - abstract class for inputs that have source option loaded from js array or
onSourceReady: function (success, error) { onSourceReady: function (success, error) {
//run source if it function //run source if it function
var source; var source;
if ($.isFunction(this.options.source)) { if (typeof(this.options.source) === 'function') {
source = this.options.source.call(this.options.scope); source = this.options.source.call(this.options.scope);
this.sourceData = null; this.sourceData = null;
//note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed //note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed
@ -2718,7 +2718,7 @@ List - abstract class for inputs that have source option loaded from js array or
if(!Array.isArray(this.prependData)) { if(!Array.isArray(this.prependData)) {
//run prepend if it is function (once) //run prepend if it is function (once)
if ($.isFunction(this.options.prepend)) { if (typeof (this.options.prepend) === 'function') {
this.options.prepend = this.options.prepend.call(this.options.scope); this.options.prepend = this.options.prepend.call(this.options.scope);
} }
@ -3695,7 +3695,7 @@ $(function(){
if(!options.select2.tags && options.source) { if(!options.select2.tags && options.source) {
var source = options.source; var source = options.source;
//if source is function, call it (once!) //if source is function, call it (once!)
if ($.isFunction(options.source)) { if (typeof (options.source) === 'function') {
source = options.source.call(options.scope); source = options.source.call(options.scope);
} }

File diff suppressed because one or more lines are too long

@ -2601,7 +2601,7 @@ List - abstract class for inputs that have source option loaded from js array or
onSourceReady: function (success, error) { onSourceReady: function (success, error) {
//run source if it function //run source if it function
var source; var source;
if ($.isFunction(this.options.source)) { if (typeof(this.options.source) === 'function') {
source = this.options.source.call(this.options.scope); source = this.options.source.call(this.options.scope);
this.sourceData = null; this.sourceData = null;
//note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed //note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed
@ -2718,7 +2718,7 @@ List - abstract class for inputs that have source option loaded from js array or
if(!Array.isArray(this.prependData)) { if(!Array.isArray(this.prependData)) {
//run prepend if it is function (once) //run prepend if it is function (once)
if ($.isFunction(this.options.prepend)) { if (typeof (this.options.prepend) === 'function') {
this.options.prepend = this.options.prepend.call(this.options.scope); this.options.prepend = this.options.prepend.call(this.options.scope);
} }
@ -3695,7 +3695,7 @@ $(function(){
if(!options.select2.tags && options.source) { if(!options.select2.tags && options.source) {
var source = options.source; var source = options.source;
//if source is function, call it (once!) //if source is function, call it (once!)
if ($.isFunction(options.source)) { if (typeof (options.source) === 'function') {
source = options.source.call(options.scope); source = options.source.call(options.scope);
} }

File diff suppressed because one or more lines are too long

@ -2601,7 +2601,7 @@ List - abstract class for inputs that have source option loaded from js array or
onSourceReady: function (success, error) { onSourceReady: function (success, error) {
//run source if it function //run source if it function
var source; var source;
if ($.isFunction(this.options.source)) { if (typeof(this.options.source) === 'function') {
source = this.options.source.call(this.options.scope); source = this.options.source.call(this.options.scope);
this.sourceData = null; this.sourceData = null;
//note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed //note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed
@ -2718,7 +2718,7 @@ List - abstract class for inputs that have source option loaded from js array or
if(!Array.isArray(this.prependData)) { if(!Array.isArray(this.prependData)) {
//run prepend if it is function (once) //run prepend if it is function (once)
if ($.isFunction(this.options.prepend)) { if (typeof (this.options.prepend) === 'function') {
this.options.prepend = this.options.prepend.call(this.options.scope); this.options.prepend = this.options.prepend.call(this.options.scope);
} }
@ -3695,7 +3695,7 @@ $(function(){
if(!options.select2.tags && options.source) { if(!options.select2.tags && options.source) {
var source = options.source; var source = options.source;
//if source is function, call it (once!) //if source is function, call it (once!)
if ($.isFunction(options.source)) { if (typeof (options.source) === 'function') {
source = options.source.call(options.scope); source = options.source.call(options.scope);
} }

File diff suppressed because one or more lines are too long

@ -24,7 +24,7 @@
return typeof obj === "number"; return typeof obj === "number";
}, },
isArray: Array.isArray, isArray: Array.isArray,
isFunction: $.isFunction, isFunction: (object) => typeof object === "function" && typeof object.call === "function",
isObject: $.isPlainObject, isObject: $.isPlainObject,
isUndefined: function(obj) { isUndefined: function(obj) {
return typeof obj === "undefined"; return typeof obj === "undefined";
@ -33,7 +33,7 @@
bindAll: function(obj) { bindAll: function(obj) {
var val; var val;
for (var key in obj) { for (var key in obj) {
$.isFunction(val = obj[key]) && (obj[key] = $.proxy(val, obj)); typeof(val = obj[key]) === 'function' && (obj[key] = $.proxy(val, obj));
} }
}, },
indexOf: function(haystack, needle) { indexOf: function(haystack, needle) {

@ -2601,7 +2601,7 @@ List - abstract class for inputs that have source option loaded from js array or
onSourceReady: function (success, error) { onSourceReady: function (success, error) {
//run source if it function //run source if it function
var source; var source;
if ($.isFunction(this.options.source)) { if (typeof(this.options.source) === 'function') {
source = this.options.source.call(this.options.scope); source = this.options.source.call(this.options.scope);
this.sourceData = null; this.sourceData = null;
//note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed //note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed
@ -2718,7 +2718,7 @@ List - abstract class for inputs that have source option loaded from js array or
if(!Array.isArray(this.prependData)) { if(!Array.isArray(this.prependData)) {
//run prepend if it is function (once) //run prepend if it is function (once)
if ($.isFunction(this.options.prepend)) { if (typeof (this.options.prepend) === 'function') {
this.options.prepend = this.options.prepend.call(this.options.scope); this.options.prepend = this.options.prepend.call(this.options.scope);
} }
@ -3695,7 +3695,7 @@ $(function(){
if(!options.select2.tags && options.source) { if(!options.select2.tags && options.source) {
var source = options.source; var source = options.source;
//if source is function, call it (once!) //if source is function, call it (once!)
if ($.isFunction(options.source)) { if (typeof (options.source) === 'function') {
source = options.source.call(options.scope); source = options.source.call(options.scope);
} }

File diff suppressed because one or more lines are too long

@ -2601,7 +2601,7 @@ List - abstract class for inputs that have source option loaded from js array or
onSourceReady: function (success, error) { onSourceReady: function (success, error) {
//run source if it function //run source if it function
var source; var source;
if ($.isFunction(this.options.source)) { if (typeof(this.options.source) === 'function') {
source = this.options.source.call(this.options.scope); source = this.options.source.call(this.options.scope);
this.sourceData = null; this.sourceData = null;
//note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed //note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed
@ -2718,7 +2718,7 @@ List - abstract class for inputs that have source option loaded from js array or
if(!Array.isArray(this.prependData)) { if(!Array.isArray(this.prependData)) {
//run prepend if it is function (once) //run prepend if it is function (once)
if ($.isFunction(this.options.prepend)) { if (typeof (this.options.prepend) === 'function') {
this.options.prepend = this.options.prepend.call(this.options.scope); this.options.prepend = this.options.prepend.call(this.options.scope);
} }
@ -3695,7 +3695,7 @@ $(function(){
if(!options.select2.tags && options.source) { if(!options.select2.tags && options.source) {
var source = options.source; var source = options.source;
//if source is function, call it (once!) //if source is function, call it (once!)
if ($.isFunction(options.source)) { if (typeof (options.source) === 'function') {
source = options.source.call(options.scope); source = options.source.call(options.scope);
} }

File diff suppressed because one or more lines are too long

@ -24,7 +24,7 @@
return typeof obj === "number"; return typeof obj === "number";
}, },
isArray: Array.isArray, isArray: Array.isArray,
isFunction: $.isFunction, isFunction: (object) => typeof object === "function" && typeof object.call === "function",
isObject: $.isPlainObject, isObject: $.isPlainObject,
isUndefined: function(obj) { isUndefined: function(obj) {
return typeof obj === "undefined"; return typeof obj === "undefined";
@ -33,7 +33,7 @@
bindAll: function(obj) { bindAll: function(obj) {
var val; var val;
for (var key in obj) { for (var key in obj) {
$.isFunction(val = obj[key]) && (obj[key] = $.proxy(val, obj)); typeof(val = obj[key]) === 'function' && (obj[key] = $.proxy(val, obj));
} }
}, },
indexOf: function(haystack, needle) { indexOf: function(haystack, needle) {

@ -61,7 +61,7 @@ List - abstract class for inputs that have source option loaded from js array or
onSourceReady: function (success, error) { onSourceReady: function (success, error) {
//run source if it function //run source if it function
var source; var source;
if ($.isFunction(this.options.source)) { if (typeof(this.options.source) === 'function') {
source = this.options.source.call(this.options.scope); source = this.options.source.call(this.options.scope);
this.sourceData = null; this.sourceData = null;
//note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed //note: if function returns the same source as URL - sourceData will be taken from cahce and no extra request performed
@ -178,7 +178,7 @@ List - abstract class for inputs that have source option loaded from js array or
if(!Array.isArray(this.prependData)) { if(!Array.isArray(this.prependData)) {
//run prepend if it is function (once) //run prepend if it is function (once)
if ($.isFunction(this.options.prepend)) { if (typeof (this.options.prepend) === 'function') {
this.options.prepend = this.options.prepend.call(this.options.scope); this.options.prepend = this.options.prepend.call(this.options.scope);
} }

@ -434,7 +434,7 @@ the specific language governing permissions and limitations under the Apache Lic
if (handler) { handler.abort(); } if (handler) { handler.abort(); }
if (options.params) { if (options.params) {
if ($.isFunction(options.params)) { if (typeof (options.params) === 'function') {
$.extend(params, options.params.call(self)); $.extend(params, options.params.call(self));
} else { } else {
$.extend(params, options.params); $.extend(params, options.params);
@ -481,7 +481,7 @@ the specific language governing permissions and limitations under the Apache Lic
data = { results: tmp }; data = { results: tmp };
} }
if ($.isFunction(data) === false) { if (typeof (data) !== 'function') {
tmp = data; tmp = data;
data = function() { return tmp; }; data = function() { return tmp; };
} }
@ -490,7 +490,7 @@ the specific language governing permissions and limitations under the Apache Lic
if (dataItem.text) { if (dataItem.text) {
text = dataItem.text; text = dataItem.text;
// if text is not a function we assume it to be a key name // if text is not a function we assume it to be a key name
if (!$.isFunction(text)) { if (!typeof(text) === 'function') {
dataText = dataItem.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available dataText = dataItem.text; // we need to store this in a separate variable because in the next step data gets reset and data.text is no longer available
text = function (item) { return item[dataText]; }; text = function (item) { return item[dataText]; };
} }
@ -530,7 +530,7 @@ the specific language governing permissions and limitations under the Apache Lic
// TODO javadoc // TODO javadoc
function tags(data) { function tags(data) {
var isFunc = $.isFunction(data); var isFunc = typeof (data) === 'function';
return function (query) { return function (query) {
var t = query.term, filtered = {results: []}; var t = query.term, filtered = {results: []};
$(isFunc ? data() : data).each(function () { $(isFunc ? data() : data).each(function () {
@ -553,13 +553,13 @@ the specific language governing permissions and limitations under the Apache Lic
* @param formatter * @param formatter
*/ */
function checkFormatter(formatter, formatterName) { function checkFormatter(formatter, formatterName) {
if ($.isFunction(formatter)) return true; if (typeof (formatter) === 'function') return true;
if (!formatter) return false; if (!formatter) return false;
throw new Error(formatterName +" must be a function or a falsy value"); throw new Error(formatterName +" must be a function or a falsy value");
} }
function evaluate(val) { function evaluate(val) {
return $.isFunction(val) ? val() : val; return typeof (val) === 'function' ? val() : val;
} }
function countResults(results) { function countResults(results) {
@ -754,7 +754,7 @@ the specific language governing permissions and limitations under the Apache Lic
// dom it will trigger the popup close, which is not what we want // dom it will trigger the popup close, which is not what we want
this.dropdown.on("click mouseup mousedown", function (e) { e.stopPropagation(); }); this.dropdown.on("click mouseup mousedown", function (e) { e.stopPropagation(); });
if ($.isFunction(this.opts.initSelection)) { if (typeof (this.opts.initSelection) === 'function') {
// initialize selection based on the current value of the source element // initialize selection based on the current value of the source element
this.initSelection(); this.initSelection();
@ -976,7 +976,7 @@ the specific language governing permissions and limitations under the Apache Lic
$(splitVal(element.val(), opts.separator)).each(function () { $(splitVal(element.val(), opts.separator)).each(function () {
var obj = { id: this, text: this }, var obj = { id: this, text: this },
tags = opts.tags; tags = opts.tags;
if ($.isFunction(tags)) tags=tags(); if (typeof (tags) === 'function') tags=tags();
$(tags).each(function() { if (equal(this.id, obj.id)) { obj = this; return false; } }); $(tags).each(function() { if (equal(this.id, obj.id)) { obj = this; return false; } });
data.push(obj); data.push(obj);
}); });
@ -1785,7 +1785,7 @@ the specific language governing permissions and limitations under the Apache Lic
} }
return null; return null;
} else if ($.isFunction(this.opts.width)) { } else if (typeof(this.opts.width) === 'function') {
return this.opts.width(); return this.opts.width();
} else { } else {
return this.opts.width; return this.opts.width;
@ -2151,7 +2151,7 @@ the specific language governing permissions and limitations under the Apache Lic
} }
return is_match; return is_match;
}, },
callback: !$.isFunction(callback) ? $.noop : function() { callback: !typeof(callback) === 'function' ? $.noop : function() {
callback(match); callback(match);
} }
}); });
@ -2419,7 +2419,7 @@ the specific language governing permissions and limitations under the Apache Lic
} }
return is_match; return is_match;
}, },
callback: !$.isFunction(callback) ? $.noop : function() { callback: !typeof(callback) === 'function' ? $.noop : function() {
// reorder matches based on the order they appear in the ids array because right now // reorder matches based on the order they appear in the ids array because right now
// they are in the order in which they appear in data array // they are in the order in which they appear in data array
var ordered = []; var ordered = [];

@ -98,7 +98,7 @@ $(function(){
if(!options.select2.tags && options.source) { if(!options.select2.tags && options.source) {
var source = options.source; var source = options.source;
//if source is function, call it (once!) //if source is function, call it (once!)
if ($.isFunction(options.source)) { if (typeof (options.source) === 'function') {
source = options.source.call(options.scope); source = options.source.call(options.scope);
} }