Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace deprecated JQuery.isFunction() call for JQuery >= 3.3 #400

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/javascripts/jquery.selectBoxIt.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@

});

if($.type(listSize) === "number") {
if(typeof listSize === "number") {

// Stores the new `max-height` for later
self.maxHeight = self.listAnchors.outerHeight(true) * listSize;
Expand Down Expand Up @@ -823,7 +823,7 @@
var self = this;

// Checks to make sure the parameter passed in is a function
if ($.isFunction(callback)) {
if (typeof callback === "function") {

// Calls the method passed in as a parameter and sets the current `SelectBoxIt` object that is stored in the jQuery data method as the context(allows for `this` to reference the SelectBoxIt API Methods in the callback function. The `dropdown` DOM element that acts as the new dropdown list is also passed as the only parameter to the callback
callback.call(self, self.dropdown);
Expand Down Expand Up @@ -1826,7 +1826,7 @@
this._populate(data, function(data) {

var self = this,
dataType = $.type(data),
dataType = typeof data,
value,
x = 0,
dataLength,
Expand All @@ -1835,7 +1835,7 @@
parsedJSON = isJSON && self._parseJSON(data);

// If the passed data is a local or JSON array
if(data && (dataType === "array" || (isJSON && parsedJSON.data && $.type(parsedJSON.data) === "array")) || (dataType === "object" && data.data && $.type(data.data) === "array")) {
if(data && (dataType === "array" || (isJSON && parsedJSON.data && (typeof parsedJSON.data === "array"))) || (dataType === "object" && data.data && (typeof data.data === "array"))) {

// If the data is JSON
if(self._isJSON(data)) {
Expand Down Expand Up @@ -1868,7 +1868,7 @@
}

// If the currently traversed array item is a string
else if($.type(value) === "string") {
else if(typeof value === "string") {

// Adds an option to the elems array
elems.push($("<option/>", { text: value, value: value }));
Expand Down Expand Up @@ -1972,7 +1972,7 @@

var self = this;

data = $.isFunction(data) ? data.call() : data;
data = (typeof data === "function") ? data.call() : data;

if(self.isDeferred(data)) {

Expand Down Expand Up @@ -2289,7 +2289,7 @@ selectBoxIt._destroySelectBoxIt = function() {

selectBoxIt.disableOption = function(index, callback) {

var self = this, currentSelectBoxOption, hasNextEnabled, hasPreviousEnabled, type = $.type(index);
var self = this, currentSelectBoxOption, hasNextEnabled, hasPreviousEnabled, type = typeof index;

// If an index is passed to target an indropdownidual drop down option
if(type === "number") {
Expand Down Expand Up @@ -2391,7 +2391,7 @@ selectBoxIt._destroySelectBoxIt = function() {
var openDownClassName = 'selectboxit-open-down';

// If the `size` option is a number
if($.type(self.listSize) === "number") {
if(typeof self.listSize === "number") {

// Set's the max-height of the drop down list
self.list.css("max-height", self.maxHeight || "none");
Expand Down Expand Up @@ -2533,7 +2533,7 @@ selectBoxIt._destroySelectBoxIt = function() {

selectBoxIt.enableOption = function(index, callback) {

var self = this, currentSelectBoxOption, currentIndex = 0, hasNextEnabled, hasPreviousEnabled, type = $.type(index);
var self = this, currentSelectBoxOption, currentIndex = 0, hasNextEnabled, hasPreviousEnabled, type = typeof index;

// If an index is passed to target an indropdownidual drop down option
if(type === "number") {
Expand Down Expand Up @@ -2777,7 +2777,7 @@ selectBoxIt._destroySelectBoxIt = function() {
currentText = self.currentText,

// Option for how many characters a user must search to be treated as a full string search
numSearchCharacters = $.type(options.numSearchCharacters) === 'number' ? options.numSearchCharacters : 3;
numSearchCharacters = typeof options.numSearchCharacters === 'number' ? options.numSearchCharacters : 3;

// Loops through the text array to find a pattern match
for (x = currentIndex, arrayLength = textArray.length; x < arrayLength; x += 1) {
Expand Down Expand Up @@ -3095,7 +3095,7 @@ selectBoxIt._destroySelectBoxIt = function() {
selectBoxIt.remove = function(indexes, callback) {

var self = this,
dataType = $.type(indexes),
dataType = typeof indexes,
value,
x = 0,
dataLength,
Expand All @@ -3111,7 +3111,7 @@ selectBoxIt._destroySelectBoxIt = function() {
value = indexes[x];

// If the currently traversed array item is an object literal
if($.type(value) === "number") {
if(typeof value === "number") {

if(elems.length) {

Expand Down Expand Up @@ -3185,7 +3185,7 @@ selectBoxIt._destroySelectBoxIt = function() {

// Stores the plugin context inside of the self variable
var self = this,
type = $.type(val);
type = typeof val;

// Makes sure the passed in position is a number
if(type === "number") {
Expand Down Expand Up @@ -3223,7 +3223,7 @@ selectBoxIt._destroySelectBoxIt = function() {
var self = this;

//Makes sure a string is passed in
if($.type(key) === "string") {
if(typeof key === "string") {

// Sets the plugin option to the new value provided by the user
self.options[key] = value;
Expand Down
8 changes: 4 additions & 4 deletions src/javascripts/modules/jquery.selectBoxIt.add.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
this._populate(data, function(data) {

var self = this,
dataType = $.type(data),
dataType = typeof data,
value,
x = 0,
dataLength,
Expand All @@ -22,7 +22,7 @@
parsedJSON = isJSON && self._parseJSON(data);

// If the passed data is a local or JSON array
if(data && (dataType === "array" || (isJSON && parsedJSON.data && $.type(parsedJSON.data) === "array")) || (dataType === "object" && data.data && $.type(data.data) === "array")) {
if(data && (dataType === "array" || (isJSON && parsedJSON.data && typeof parsedJSON.data === "array")) || (dataType === "object" && data.data && typeof data.data === "array")) {

// If the data is JSON
if(self._isJSON(data)) {
Expand Down Expand Up @@ -55,7 +55,7 @@
}

// If the currently traversed array item is a string
else if($.type(value) === "string") {
else if(typeof value === "string") {

// Adds an option to the elems array
elems.push($("<option/>", { text: value, value: value }));
Expand Down Expand Up @@ -159,7 +159,7 @@

var self = this;

data = $.isFunction(data) ? data.call() : data;
data = (typeof data === "function") ? data.call() : data;

if(self.isDeferred(data)) {

Expand Down
4 changes: 2 additions & 2 deletions src/javascripts/modules/jquery.selectBoxIt.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@

});

if($.type(listSize) === "number") {
if(typeof listSize === "number") {

// Stores the new `max-height` for later
self.maxHeight = self.listAnchors.outerHeight(true) * listSize;
Expand Down Expand Up @@ -823,7 +823,7 @@
var self = this;

// Checks to make sure the parameter passed in is a function
if ($.isFunction(callback)) {
if (typeof callback === "function") {

// Calls the method passed in as a parameter and sets the current `SelectBoxIt` object that is stored in the jQuery data method as the context(allows for `this` to reference the SelectBoxIt API Methods in the callback function. The `dropdown` DOM element that acts as the new dropdown list is also passed as the only parameter to the callback
callback.call(self, self.dropdown);
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/modules/jquery.selectBoxIt.disable.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

selectBoxIt.disableOption = function(index, callback) {

var self = this, currentSelectBoxOption, hasNextEnabled, hasPreviousEnabled, type = $.type(index);
var self = this, currentSelectBoxOption, hasNextEnabled, hasPreviousEnabled, type = typeof index;

// If an index is passed to target an indropdownidual drop down option
if(type === "number") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
var openDownClassName = 'selectboxit-open-down';

// If the `size` option is a number
if($.type(self.listSize) === "number") {
if(typeof self.listSize === "number") {

// Set's the max-height of the drop down list
self.list.css("max-height", self.maxHeight || "none");
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/modules/jquery.selectBoxIt.enable.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

selectBoxIt.enableOption = function(index, callback) {

var self = this, currentSelectBoxOption, currentIndex = 0, hasNextEnabled, hasPreviousEnabled, type = $.type(index);
var self = this, currentSelectBoxOption, currentIndex = 0, hasNextEnabled, hasPreviousEnabled, type = typeof index;

// If an index is passed to target an indropdownidual drop down option
if(type === "number") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
currentText = self.currentText,

// Option for how many characters a user must search to be treated as a full string search
numSearchCharacters = $.type(options.numSearchCharacters) === 'number' ? options.numSearchCharacters : 3;
numSearchCharacters = typeof options.numSearchCharacters === 'number' ? options.numSearchCharacters : 3;

// Loops through the text array to find a pattern match
for (x = currentIndex, arrayLength = textArray.length; x < arrayLength; x += 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/javascripts/modules/jquery.selectBoxIt.remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
selectBoxIt.remove = function(indexes, callback) {

var self = this,
dataType = $.type(indexes),
dataType = typeof indexes,
value,
x = 0,
dataLength,
Expand All @@ -26,7 +26,7 @@
value = indexes[x];

// If the currently traversed array item is an object literal
if($.type(value) === "number") {
if(typeof value === "number") {

if(elems.length) {

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/modules/jquery.selectBoxIt.selectOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// Stores the plugin context inside of the self variable
var self = this,
type = $.type(val);
type = typeof val;

// Makes sure the passed in position is a number
if(type === "number") {
Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/modules/jquery.selectBoxIt.setOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
var self = this;

//Makes sure a string is passed in
if($.type(key) === "string") {
if(typeof key === "string") {

// Sets the plugin option to the new value provided by the user
self.options[key] = value;
Expand Down