@@ -13,20 +13,16 @@ function doSubmit(el) {
13
13
}
14
14
15
15
$ ( ( ) => {
16
- const gettext =
17
- window . gettext ||
18
- function ( t ) {
19
- return t
20
- }
16
+ const gettext = window . gettext || ( ( t ) => t )
21
17
22
18
// AJAX modals
23
- const dismissModals = function ( ) {
19
+ const dismissModals = ( ) => {
24
20
// LOL, dismiss.
25
21
$ ( ".modal, .modal-backdrop" ) . remove ( )
26
22
$ ( document . body ) . removeClass ( "modal-open" ) . removeAttr ( "style" )
27
23
}
28
24
29
- const initModal = function ( data ) {
25
+ const initModal = ( data ) => {
30
26
dismissModals ( )
31
27
32
28
const $data = $ ( data )
@@ -48,7 +44,7 @@ $(() => {
48
44
}
49
45
50
46
window . initModal = initModal
51
- window . openModalFromUrl = function ( url ) {
47
+ window . openModalFromUrl = ( url ) => {
52
48
$ . ajax ( {
53
49
url,
54
50
success ( data ) {
@@ -124,7 +120,7 @@ $(() => {
124
120
125
121
const fd = new FormData ( form )
126
122
let params = new URLSearchParams ( )
127
- for ( let part of fd ) {
123
+ for ( const part of fd ) {
128
124
if ( part [ 1 ] ) params . append ( part [ 0 ] , part [ 1 ] )
129
125
}
130
126
params . sort ( )
@@ -146,12 +142,11 @@ $(() => {
146
142
// Calling debounce returns a new anonymous function
147
143
return function ( ) {
148
144
// reference the context and args for the setTimeout function
149
- let context = this ,
150
- args = arguments
145
+ const args = arguments
151
146
152
147
// Should the function be called now? If immediate is true
153
148
// and not already in a timeout then the answer is: Yes
154
- let callNow = immediate && ! timeout
149
+ const callNow = immediate && ! timeout
155
150
156
151
// This is the basic debounce behaviour where you can call this
157
152
// function several times, but it will only execute once
@@ -170,12 +165,12 @@ $(() => {
170
165
// Call the original function with apply
171
166
// apply lets you define the 'this' object as well as the arguments
172
167
// (both captured before setTimeout)
173
- func . apply ( context , args )
168
+ func . apply ( this , args )
174
169
}
175
170
} , wait )
176
171
177
172
// Immediate mode and no wait timer? Execute the function..
178
- if ( callNow ) func . apply ( context , args )
173
+ if ( callNow ) func . apply ( this , args )
179
174
}
180
175
}
181
176
@@ -304,17 +299,17 @@ $(() => {
304
299
$ ( document . body ) . on ( "click" , "[data-hours-button]" , function ( ) {
305
300
this . blur ( )
306
301
const value = prompt ( this . dataset . hoursButton )
307
- if ( parseFloat ( value ) ) {
302
+ if ( Number . parseFloat ( value ) ) {
308
303
$ ( "#id_modal-days" )
309
- . val ( ( parseFloat ( value ) / 8 ) . toFixed ( 2 ) )
304
+ . val ( ( Number . parseFloat ( value ) / 8 ) . toFixed ( 2 ) )
310
305
. focus ( )
311
306
}
312
307
} )
313
308
314
309
$ ( document . body ) . on ( "click" , "[data-multiply-cost]" , function ( e ) {
315
310
e . preventDefault ( )
316
- const factor = parseFloat ( this . dataset . multiplyCost ) ,
317
- tpc = parseFloat ( $ ( "#id_modal-third_party_costs" ) . val ( ) ) ,
311
+ const factor = Number . parseFloat ( this . dataset . multiplyCost ) ,
312
+ tpc = Number . parseFloat ( $ ( "#id_modal-third_party_costs" ) . val ( ) ) ,
318
313
cost = $ ( "#id_modal-cost" )
319
314
320
315
if ( tpc && factor ) {
@@ -467,7 +462,7 @@ function initWidgets() {
467
462
// const form = $(this)
468
463
//
469
464
const read = ( sel , root = document ) =>
470
- parseFloat ( root . querySelector ( sel ) . value ) || 0
465
+ Number . parseFloat ( root . querySelector ( sel ) . value ) || 0
471
466
const write = ( sel , value , root = document ) =>
472
467
( root . querySelector ( sel ) . value = value . toFixed ( 2 ) )
473
468
@@ -506,7 +501,7 @@ function initWidgets() {
506
501
507
502
window . addInlineForm = function addInlineForm ( slug , onComplete ) {
508
503
const totalForms = $ ( `#id_${ slug } -TOTAL_FORMS` ) ,
509
- newId = parseInt ( totalForms . val ( ) , 10 ) || 0
504
+ newId = Number . parseInt ( totalForms . val ( ) , 10 ) || 0
510
505
511
506
totalForms . val ( newId + 1 )
512
507
const empty = $ ( `#${ slug } -empty` ) ,
0 commit comments