Sha256: 03fe46f0530998ebcce7f27c22ee241139d52bebceb193250696d42713168d16

Contents?: true

Size: 1.63 KB

Versions: 4

Compression:

Stored size: 1.63 KB

Contents

{I"
class:ETI"BundledAsset;FI"logical_path;TI"peoplefinder/tagging.js;FI"
pathname;TI"V/Users/jakub/code/moj/peoplefinder/app/assets/javascripts/peoplefinder/tagging.js;FI"content_type;TI"application/javascript;TI"
mtime;Tl+Ñ_WTI"length;Ti¶I"digest;TI"%1c201d767eba10b9c0e8f618c4241d84;FI"source;TI"¶/* global $, addToList */

$(window).load(function() {

 if($('#person_tag_chooser').length > 0)
  {
    var the_form = $('input[id=person_tags]').parents('form:first');
    var initial_tags = $('#person_tags').attr('value');
    var tag_list = $('#tag_list').attr('value').split(',');

    $('.person_tags').remove();

    // add a hidden field to store the selected tags
    $('<input>').attr({
      type: 'hidden',
      id: 'person_tags',
      name: 'person[tags]',
      value: initial_tags
    }).appendTo(the_form);

    // init the select2 widget
    $('#person_tag_chooser').select2({
      tags: tag_list,
      width: '480',
      dropdownCssClass: 'form-control',
      tokenSeparators: [','],
    });

    // set the default state of the select2 widget
    $('#person_tag_chooser').select2('val', [initial_tags]);

    // enable adding a tag with the enter key
    $('select2-search-field > input.select2-input').on('keyup', function(e) {
      if(e.keyCode === 13) { addToList($(this).val()); }
    });

    // set the hidden field when the form is submitted
    the_form.on('submit', function() {
      $('#person_tags')[0].value = $('#person_tag_chooser').select2('val');
    });
  }
});
;TI"required_assets_digest;TI"%d556c6db76cc1d033e31acf112e4c9f8;FI"
_version;TI"%01511319732b44ed6445e68132ed559b;F

Version data entries

4 entries across 2 versions & 1 rubygems

Version Path
peoplefinder-0.1.1 spec/dummy/tmp/cache/assets/development/sprockets/8c67ced1e92a4ab474be29a13882b33a
peoplefinder-0.1.1 spec/dummy/tmp/cache/assets/development/sprockets/d33f05197a1d37b0060856667c6e68f5
peoplefinder-0.1.0 spec/dummy/tmp/cache/assets/development/sprockets/8c67ced1e92a4ab474be29a13882b33a
peoplefinder-0.1.0 spec/dummy/tmp/cache/assets/development/sprockets/d33f05197a1d37b0060856667c6e68f5