* Use `Danbooru.Autocomplete.render_item` for all menu item rendering.
Fixes usernames not being colorized when completing mentions, and post
counts not being shown when completing pools on the /pools page.
* Make the /pools page autocomplete pool names the same way that the
pool:<name> metatag does. Previously autocomplete on the /pools page
listed most recently updated pools first; now it lists largest pools first.
* Move all autocomplete code to autocomplete.js.
* Mark autocompleted fields with `data-autocomplete="<type>"` attributes,
instead of hardcoding input field IDs in the javascript.
* Disable autoFocus. This means that the first item in the autocomplete
menu isn't automatically selected.
* Add Tab keybinding, to make the Tab key work as normal with autoFocus disabled.
* Fix the Enter key to 1) insert the selected tag when inside the
autocomplete menu, and 2) submit the search as normal when not inside
the autocomplete menu.
-Otherwise, the last valid autocomplete result will remain
--Causes incorrect results on Tab/Enter completion
-This clears the autocomplete results instead
Previously we patched the jqueryui-autocomplete library in order to
customize how the Tab and Enter keys behaved. Specifically, we wanted to
prevent the Tab key from moving the focus out of the tag input box, and
we wanted to prevent the Enter key from submitting the page when editing tags.
These things can achieved without patching the library by using
`event.preventDefault` and `event.stopImmediatePropagation` to prevent
other event handlers from running after these keys trigger the
`autocompleteselect` event.
Fix bug in the double submit prevention from #2789. Rather than
unbinding the enter key on submit, have the enter key click the submit
button instead. This avoids form submission when the submit button is disabled.
Fix this test failure:
1) Failure:
RelatedTagCalculatorTest#test_: A related tag calculator should convert a hash into string format.
[test/unit/related_tag_calculator_test.rb:65]:
Expected: "aaa 3 bbb 3 ccc 2 ddd 1"
Actual: "bbb 3 aaa 3 ccc 2 ddd 1"
The related tag string didn't use a stable sort. Sort first by tag
count, then by tag name.