<commit_before>ETahi.ChosenView = Ember.Select.extend
  multiple: false
  width: '200px'
  disableSearchThreshold: 10
  searchContains: true
  attributeBindings:['multiple', 'width', 'disableSearchThreshold', 'searchContains']
  changeAction: null
  change: ->
    action = @get('changeAction')
    @get('controller').send(action) if action

  setup: (->
    options =
      multiple: @get('multiple')
      width: @get('width')
      disable_search_threshold: @get('disableSearchThreshold')
      search_contains: @get('searchContains')
      no_results_text: @get('noResultsText')
      max_selected_options: @get('maxSelectedOptions')
      allow_single_deselect: @get('allowSingleDeselect')

    options.clean_search_text = @cleanSearchText
    options.calling_context = @

    if @get('multiple')
      options.placeholder_text_multiple = @get('prompt');
    else
      options.placeholder_text_single = @get('prompt');

    @.$().chosen(options)

    @addObserver @get("optionLabelPath").replace(/^content/, "content.@each"), =>
      @rerenderChosen()
  ).on('didInsertElement')

  cleanSearchText: (option, context) ->
    option.text

  rerenderChosen: -><commit_msg>Teardown Chosen events<commit_after>ETahi.ChosenView = Ember.Select.extend
  multiple: false
  width: '200px'
  disableSearchThreshold: 10
  searchContains: true
  attributeBindings:['multiple', 'width', 'disableSearchThreshold', 'searchContains']
  changeAction: null
  change: ->
    action = @get('changeAction')
    @get('controller').send(action) if action

  setup: (->
    options =
      multiple: @get('multiple')
      width: @get('width')
      disable_search_threshold: @get('disableSearchThreshold')
      search_contains: @get('searchContains')
      no_results_text: @get('noResultsText')
      max_selected_options: @get('maxSelectedOptions')
      allow_single_deselect: @get('allowSingleDeselect')

    options.clean_search_text = @cleanSearchText
    options.calling_context = @

    if @get('multiple')
      options.placeholder_text_multiple = @get('prompt');
    else
      options.placeholder_text_single = @get('prompt');

    @.$().chosen(options)

    @addObserver @get("optionLabelPath").replace(/^content/, "content.@each"), =>
      @rerenderChosen()
  ).on('didInsertElement')

  teardown: (->
    @.$().chosen('destroy')
  ).on('willDestroyElement')

  cleanSearchText: (option, context) ->
    option.text

  rerenderChosen: ->
{'fraction_non_alphanumeric': 0.14455852156057494, 'fraction_numerical': 0.004106776180698152, 'mean_word_length': 4.2956521739130435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '367211', 'n_tokens_mistral': 754, 'n_tokens_neox': 724, 'n_words': 123}