Fix broken tag autocomplete on multiple pages.

Mark all tag <input>s with a `data-autocomplete` attribute, instead of
hardcoding a list of html IDs to autocomplete in javascript.

This way should be less error prone. It fixes autocomplete in several places:

* Autocomplete for the search box on /posts didn't work in the
  responsive layout. This was because /posts has two search boxes that
  both have the id `tags`: one in the normal sidebar, and one in the
  responsive tag list. $("#tags") only initialized autocomplete on the
  first one.

* Autocomplete didn't work on the aliases or implications pages. This
  was due to selecting the wrong html ids.
This commit is contained in:
evazion
2017-04-21 19:44:03 -05:00
parent f403763d8b
commit 4631262374
24 changed files with 34 additions and 44 deletions

View File

@@ -6,7 +6,7 @@
<section id="search-box">
<h1>Search</h1>
<%= form_tag(path, :method => "get") do %>
<%= text_field_tag("tags", tags, :size => 20, :id => tags_dom_id) %>
<%= text_field_tag("tags", tags, :size => 20, :id => tags_dom_id, :data => { :autocomplete => "tag-query" }) %>
<% if params[:raw] %>
<%= hidden_field_tag :raw, params[:raw] %>
<% end %>

View File

@@ -3,7 +3,7 @@
<%= form_tag("/posts", :class => "simple_form", :method => :put, :id => "quick-edit-form") do %>
<div class="input">
<%= text_area_tag "post[tag_string]", "" %>
<%= text_area_tag "post[tag_string]", "", :data => { :autocomplete => "tag-edit" } %>
<%= submit_tag "Submit", :data => { :disable_with => "Submitting..." } %>
<%= submit_tag "Cancel" %>
</div>

View File

@@ -25,6 +25,6 @@
<% end %>
</select>
</form>
<input id="tag-script-field" placeholder="Enter tag script" style="display: none; margin-top: 0.5em;"></input>
<input id="tag-script-field" data-autocomplete="tag-edit" placeholder="Enter tag script" style="display: none; margin-top: 0.5em;"></input>
</section>
<% end %>

View File

@@ -79,7 +79,7 @@
<div class="input">
<div>
<%= f.label :tag_string, "Tags" %>
<%= f.text_area :tag_string, :size => "50x5", :value => post.presenter.categorized_tag_string + " " %>
<%= f.text_area :tag_string, :size => "50x5", :value => post.presenter.categorized_tag_string + " ", :data => { :autocomplete => "tag-edit" } %>
<span id="open-edit-dialog" class="ui-icon ui-icon-arrow-1-ne" title="detach" style="display: none;"/>
</div>