Follow-up of #1664940: [Policy, patch] Decide on JSHint configuration and part of #1415788: Javascript winter clean-up
Run jshint on the files with the configuration from the parent issue or use jshint.com with the following options:
/*jshint forin:true, noarg:true, eqeqeq:true, undef:true, curly:true, browser:true, expr:true, latedef:true, newcap:true, trailing:true */
/*global Drupal, jQuery */
Fix any warnings or errors the tool finds.
Check manually that the fixes did not break any functionalities
Create patch and upload for the testbot.
Files: states.js
Comments
Comment #1
nod_Comment #2
nod_Comment #3
droplet commentedIt inverts A. Why we call 2nd parameter "invert"
Shouldn't it:
function invert (val, condition) {Comment #4
nod_it's not really a condition, it's more like the second parameter of the
.toggleClass()function of jQuery. They call thatstateVal. I went withinvertStateseems good enough.Comment #5
droplet commentedwhen "invert" is truelittle problem, other part are fine.
Comment #6
nod_thanks :)
Comment #7
sxnc commentedI ran JSHint locally using SublimeText 2 and had no issues, everything seems to have worked fine otherwise as well :)
Comment #8
pivica commentedTaking this one to review.
Comment #9
pivica commentedjshint runs cleanly now with patch from comment 6 and states in browser works as expected (tested on admin/config/regional/settings checked/visibility states).
Comment #10
oriol_e9gWhy are we doing this?
instead of replace the "self" occurrences by "this"?
Comment #11
nod_Because that won't work. this here resolves to the DOM element it's been bound to, this element won't have the update method available.
Comment #12
pivica commentedYeah you need to use js clousures for this kind of thing, take a look here http://stackoverflow.com/a/111200 for more detail explanation.
Comment #13
webchickSounds like this still needs more discussion..?
Comment #14
nod_nope just some JS weirdness oriol_e9g didn't catch, it's good to go
Comment #15
webchickOk, committed and pushed to 8.x. Thanks!