Skip to content

Commit

Permalink
Replace "var" variable declarations with modern "let"
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 4, 2022
1 parent ef5639d commit f372c1a
Show file tree
Hide file tree
Showing 64 changed files with 941 additions and 940 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ module.exports = {
semi: ['error'],
'no-extra-semi': ['error'],
'no-trailing-spaces': ['error'],
'no-var': ['error'],
},
reportUnusedDisableDirectives: true,
};
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Set-up
*******************************/

var
let
gulp = require('gulp'),

// read user config to know what task to load
Expand Down
48 changes: 24 additions & 24 deletions src/definitions/behaviors/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
: Function('return this')();

$.api = $.fn.api = function (parameters) {
var
let
// use window context if none specified
$allModules = isFunction(this)
? $(window)
Expand All @@ -42,7 +42,7 @@
;

$allModules.each(function () {
var
let
settings = ($.isPlainObject(parameters))
? $.extend(true, {}, $.fn.api.settings, parameters)
: $.extend({}, $.fn.api.settings),
Expand Down Expand Up @@ -110,7 +110,7 @@

bind: {
events: function () {
var
let
triggerEvent = module.get.event()
;
if (triggerEvent) {
Expand Down Expand Up @@ -141,7 +141,7 @@

read: {
cachedResponse: function (url) {
var
let
response
;
if (window.Storage === undefined) {
Expand Down Expand Up @@ -352,7 +352,7 @@

add: {
urlData: function (url, urlData) {
var
let
requiredVariables,
optionalVariables
;
Expand All @@ -363,7 +363,7 @@
if (requiredVariables) {
module.debug('Looking for required URL variables', requiredVariables);
$.each(requiredVariables, function (index, templatedString) {
var
let
// allow legacy {$var} style
variable = (templatedString.indexOf('$') !== -1)
? templatedString.slice(2, -1)
Expand Down Expand Up @@ -394,7 +394,7 @@
if (optionalVariables) {
module.debug('Looking for optional URL variables', requiredVariables);
$.each(optionalVariables, function (index, templatedString) {
var
let
// allow legacy {/$var} style
variable = (templatedString.indexOf('$') !== -1)
? templatedString.slice(3, -1)
Expand Down Expand Up @@ -427,7 +427,7 @@
return url;
},
formData: function (data) {
var
let
formData = {},
hasOtherData,
useFormDataApi = settings.serializeForm === 'formdata'
Expand All @@ -440,7 +440,7 @@
settings.processData = typeof settings.processData !== 'undefined' ? settings.processData : false;
settings.contentType = typeof settings.contentType !== 'undefined' ? settings.contentType : false;
} else {
var
let
formArray = $form.serializeArray(),
pushes = {},
pushValues = {},
Expand All @@ -460,7 +460,7 @@
if (!settings.regExp.validate.test(el.name)) {
return;
}
var
let
isCheckbox = $('[name="' + el.name + '"]', $form).attr('type') === 'checkbox',
floatValue = parseFloat(el.value),
value = (isCheckbox && el.value === 'on')
Expand Down Expand Up @@ -541,7 +541,7 @@
// nothing special
},
done: function (response, textStatus, xhr) {
var
let
context = this,
elapsedTime = (new Date().getTime() - requestStartTime),
timeLeft = (settings.loadingDuration - elapsedTime),
Expand Down Expand Up @@ -570,7 +570,7 @@
}, timeLeft);
},
fail: function (xhr, status, httpMessage) {
var
let
context = this,
elapsedTime = (new Date().getTime() - requestStartTime),
timeLeft = (settings.loadingDuration - elapsedTime)
Expand Down Expand Up @@ -600,7 +600,7 @@
settings.onSuccess.call(context, response, $module, xhr);
},
complete: function (firstParameter, secondParameter) {
var
let
xhr,
response
;
Expand All @@ -616,7 +616,7 @@
settings.onComplete.call(context, response, $module, xhr);
},
fail: function (xhr, status, httpMessage) {
var
let
// pull response from xhr if available
response = module.get.responseFromXHR(xhr),
errorMessage = module.get.errorFromRequest(response, status, httpMessage)
Expand Down Expand Up @@ -664,7 +664,7 @@
},

mockedXHR: function () {
var
let
// xhr does not simulate these properties of xhr but must return them
textStatus = false,
status = false,
Expand Down Expand Up @@ -710,7 +710,7 @@
},

xhr: function () {
var
let
xhr
;
// ajax request promise
Expand Down Expand Up @@ -773,7 +773,7 @@
return module.xhr || false;
},
settings: function () {
var
let
runSettings
;
runSettings = settings.beforeSend.call($module, settings);
Expand Down Expand Up @@ -806,7 +806,7 @@
: $.extend(true, {}, settings);
},
urlEncodedValue: function (value) {
var
let
decodedValue = window.decodeURIComponent(value),
encodedValue = window.encodeURIComponent(value),
alreadyEncoded = (decodedValue !== value)
Expand All @@ -821,7 +821,7 @@
return encodedValue;
},
defaultData: function () {
var
let
data = {}
;
if (!isWindow(element)) {
Expand Down Expand Up @@ -883,7 +883,7 @@
},

abort: function () {
var
let
xhr = module.get.xhr()
;
if (xhr && xhr.state() !== 'resolved') {
Expand Down Expand Up @@ -949,7 +949,7 @@
},
performance: {
log: function (message) {
var
let
currentTime,
executionTime,
previousTime
Expand All @@ -970,7 +970,7 @@
module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function () {
var
let
title = settings.name + ':',
totalTime = 0
;
Expand Down Expand Up @@ -998,7 +998,7 @@
},
},
invoke: function (query, passedArguments, context) {
var
let
object = instance,
maxDepth,
found,
Expand All @@ -1010,7 +1010,7 @@
query = query.split(/[\. ]/);
maxDepth = query.length - 1;
$.each(query, function (depth, value) {
var camelCaseValue = (depth != maxDepth)
let camelCaseValue = (depth != maxDepth)
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
: query
;
Expand Down
Loading

0 comments on commit f372c1a

Please sign in to comment.