fixed jQuery dprecations
This commit is contained in:
22
src/inputs/select2/lib/select2.js
vendored
22
src/inputs/select2/lib/select2.js
vendored
@@ -434,7 +434,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
if (handler) { handler.abort(); }
|
||||
|
||||
if (options.params) {
|
||||
if ($.isFunction(options.params)) {
|
||||
if (typeof (options.params) === 'function') {
|
||||
$.extend(params, options.params.call(self));
|
||||
} else {
|
||||
$.extend(params, options.params);
|
||||
@@ -481,7 +481,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
data = { results: tmp };
|
||||
}
|
||||
|
||||
if ($.isFunction(data) === false) {
|
||||
if (typeof (data) !== 'function') {
|
||||
tmp = data;
|
||||
data = function() { return tmp; };
|
||||
}
|
||||
@@ -490,7 +490,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
if (dataItem.text) {
|
||||
text = dataItem.text;
|
||||
// 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
|
||||
text = function (item) { return item[dataText]; };
|
||||
}
|
||||
@@ -530,7 +530,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
|
||||
// TODO javadoc
|
||||
function tags(data) {
|
||||
var isFunc = $.isFunction(data);
|
||||
var isFunc = typeof (data) === 'function';
|
||||
return function (query) {
|
||||
var t = query.term, filtered = {results: []};
|
||||
$(isFunc ? data() : data).each(function () {
|
||||
@@ -553,13 +553,13 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
* @param formatter
|
||||
*/
|
||||
function checkFormatter(formatter, formatterName) {
|
||||
if ($.isFunction(formatter)) return true;
|
||||
if (typeof (formatter) === 'function') return true;
|
||||
if (!formatter) return false;
|
||||
throw new Error(formatterName +" must be a function or a falsy value");
|
||||
}
|
||||
|
||||
function evaluate(val) {
|
||||
return $.isFunction(val) ? val() : val;
|
||||
return typeof (val) === 'function' ? val() : val;
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
this.initSelection();
|
||||
|
||||
@@ -976,7 +976,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
$(splitVal(element.val(), opts.separator)).each(function () {
|
||||
var obj = { id: this, text: this },
|
||||
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; } });
|
||||
data.push(obj);
|
||||
});
|
||||
@@ -1785,7 +1785,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}
|
||||
|
||||
return null;
|
||||
} else if ($.isFunction(this.opts.width)) {
|
||||
} else if (typeof(this.opts.width) === 'function') {
|
||||
return this.opts.width();
|
||||
} else {
|
||||
return this.opts.width;
|
||||
@@ -2151,7 +2151,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}
|
||||
return is_match;
|
||||
},
|
||||
callback: !$.isFunction(callback) ? $.noop : function() {
|
||||
callback: !typeof(callback) === 'function' ? $.noop : function() {
|
||||
callback(match);
|
||||
}
|
||||
});
|
||||
@@ -2419,7 +2419,7 @@ the specific language governing permissions and limitations under the Apache Lic
|
||||
}
|
||||
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
|
||||
// they are in the order in which they appear in data array
|
||||
var ordered = [];
|
||||
|
Reference in New Issue
Block a user