<commit_before>= form.send field.view_helper, field.method_name, field.html_attributes

- tag_suggestions(field, :length => 5, :order => { :count => :desc }).each do |tag|
  = link_to tag, '#', :class => 'tag_suggestion', :data => { :input_id => form.dom_id(field) }

:javascript
  jQuery(function(){
    var input_id = '#{form.dom_id(field)}'
    $('.tag_suggestion[data-input-id=' + input_id + ']').click(function(event){
      var tag_list, current_values, new_values, tag;
      tag_list = $(this).siblings('input#' + input_id);
      // Get the current values by splitting on a comma and stripping whitespace.
      current_values = jQuery.map(tag_list.val().split(','), function(val){ return jQuery.trim(val) });
      tag = $(this).text();
      // Remove the current tag, if present.
      new_values = jQuery.grep(current_values, function(n) {
        return jQuery.trim(n) != tag
      });
      // Add the current tag, unless we've altered the values already.
      if (new_values.length == current_values.length) {
        new_values[new_values.length] = tag
      }
      tag_list.val(new_values.join(', '));

      return false;
    });
  });

%style
  :sass
    .tag_suggestion
      color: #777
      border-bottom: 1px dotted #b94a48
      &:hover
        color: #aaa
        border-bottom: 1px dotted #953b39
        text-decoration: none<commit_msg>Revert "Suggestion links toggle tags, instead of just adding them."<commit_after>= form.send field.view_helper, field.method_name, field.html_attributes

- tag_suggestions(field, :length => 5, :order => { :count => :desc }).each do |tag|
  = link_to tag, '#', :class => 'tag_suggestion', :data => { :input_id => form.dom_id(field) }

:javascript
  jQuery(function(){
    var input_id = '#{form.dom_id(field)}'
    $('.tag_suggestion[data-input-id=' + input_id + ']').click(function(event){
      var tag_list, new_value;
      tag_list = $(this).siblings('input#' + input_id);

      if (!tag_list.val().match(/\S/)) {
        new_value = this.innerHTML;
      } else {
        new_value = [tag_list.val(), this.innerHTML].join(', ');
      };
      tag_list.val(new_value);

      event.preventDefault();
      return false;
    });
  });

%style
  :sass
    .tag_suggestion
      color: #777
      border-bottom: 1px dotted #b94a48
      &:hover
        color: #aaa
        border-bottom: 1px dotted #953b39
        text-decoration: none
{'fraction_non_alphanumeric': 0.1570419609472372, 'fraction_numerical': 0.012463647694225177, 'mean_word_length': 2.9933665008291874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2142075', 'n_tokens_mistral': 834, 'n_tokens_neox': 789, 'n_words': 177}