Follow-up of #1664940: [Policy, patch] Decide on JSHint configuration and part of #1415788: [Meta] 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: autocomplete.js

Files: 
CommentFileSizeAuthor
#7 core-jshint-autocomplete-1684792-7.patch919 bytesnod_
PASSED: [[SimpleTest]]: [MySQL] 56,563 pass(es).
[ View ]
#2 autocomplete-jshint.patch1.34 KBdroplet
PASSED: [[SimpleTest]]: [MySQL] 37,297 pass(es).
[ View ]

Comments

core/misc/autocomplete.js: line 228, col 52, Don't make functions within a loop.
core/misc/autocomplete.js: line 229, col 55, Don't make functions within a loop.
core/misc/autocomplete.js: line 230, col 56, Don't make functions within a loop.
core/misc/autocomplete.js: line 315, col 9, 'alert' is not defined.

Status:Active» Needs review
StatusFileSize
new1.34 KB
PASSED: [[SimpleTest]]: [MySQL] 37,297 pass(es).
[ View ]

Status:Needs review» Postponed

Waiting on #675446: Use jQuery UI Autocomplete to get in to avoid reroll.

Issue tags:-JavaScript clean-up

When u have input fields with the same id for multiple autocomplete fields over a panel, or page, or smthg autocomplete fails.

You need to add the following lines in autocomplete.js:

Drupal.behaviors.autocomplete = function (context) {
  var acdb = [];
  $('input.autocomplete:not(.autocomplete-processed)', context).each(function () {
     var parentForm = $(this).closest("form"); //ADD THIS
     var idParent = '#'+parentForm.attr('id'); //ADD THIS
     var uri = this.value;
     if (!acdb[uri]) {
        acdb[uri] = new Drupal.ACDB(uri);
     }
      var input = $(idParent+' #' + this.id.substr(0, this.id.length - 13)).attr('autocomplete', 'OFF')[0]; //CHANGE THIS
     .
     .
     .

I know its a separate issue, than this post...

Issue tags:+JavaScript clean-up

If you know it, please create a new issue, this has nothing to do with JSHint. Thanks.

Restoring tags.

Status:Postponed» Needs work

Let's get rid of that, the other issue isn't moving very much.

core/misc/autocomplete.js: line 230, col 52, Don't make functions within a loop.
core/misc/autocomplete.js: line 231, col 55, Don't make functions within a loop.
core/misc/autocomplete.js: line 232, col 56, Don't make functions within a loop.

Status:Needs work» Needs review
StatusFileSize
new919 bytes
PASSED: [[SimpleTest]]: [MySQL] 56,563 pass(es).
[ View ]

event delegation ftw.

Status:Needs review» Needs work
Issue tags:-JavaScript clean-up

The last submitted patch, core-jshint-autocomplete-1684792-7.patch, failed testing.

Status:Needs work» Needs review

Status:Needs review» Needs work

The last submitted patch, core-jshint-autocomplete-1684792-7.patch, failed testing.

Status:Needs work» Needs review
Issue tags:+JavaScript clean-up

Status:Needs review» Reviewed & tested by the community

Just re-tested. It still works and still applies.

Status:Reviewed & tested by the community» Fixed

One more file to go and jshint can go into my pre-commit hook :)

Committed 9f69e00 and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.