Reduce local variables usage in CoffeeScript

Local variables are one of the things CoffeeScript doesn't compile to
modern JavaScript automatically: it uses `var` instead of `const` or
`let`.

Besides, using `$this = $(this)` is usually done to reference the
current object in another function where the current object is a
different one. Here we were using it with no clear purpose.
This commit is contained in:
Javi Martín
2019-07-01 17:11:54 +02:00
parent ba325526ae
commit cc7e0d586b
16 changed files with 33 additions and 63 deletions

View File

@@ -4,9 +4,8 @@ App.CheckboxToggle =
initialize: ->
$("[data-checkbox-toggle]").on "change", ->
$this = $(this)
$target = $($this.data("checkbox-toggle"))
if $this.is(":checked")
$target = $($(this).data("checkbox-toggle"))
if $(this).is(":checked")
$target.show()
else
$target.hide()