<commit_before>((E, $) ->
  'use strict'

  $(document).behave "load click", "form label input[name='parcel[delivery_mode]']", ->
    input = $(this)
    if input.is(':checked')
      form = input.closest('form')
      form.find("input[name='parcel[delivery_mode]']").each ->
        $("#delivery-mode-#{$(this).val()}").hide()
      $("#delivery-mode-#{input.val()}").show()

  $(document).behave "load click", "form label input[name='delivery[mode]']", ->
    input = $(this)
    if input.is(':checked')
      form = input.closest('form')
      form.find("input[name='delivery[mode]']").each ->
        $("##{$(this).val()}").hide()
      $("##{input.val()}").show()


  # Manage fields filling in sales/purchases
  $(document).on "selector:change", "*[data-product-of-delivery-item]", ->
    element = $(this)
    options = element.data("product-of-delivery-item")
    product_id = element.selector('value')
    reg = new RegExp("\\bRECORD_ID\\b", "g")
    scope = options['scope']
    if product_id?
      item = element.closest(".delivery-item")
      $.ajax
        url: options.url.replace(reg, product_id)
        dataType: "json"
        success: (data, status, request) ->
          unit = item.find(".item-population-unit-name")
          if data.unit_name
            unit.html(data.unit_name)
            item.attr('data-unit-name', data.unit_name)
          else
            unit.html('#')
          if data.variant
            item.find(".item-variant-name").html(data.variant.name)
          pop = item.find(".item-population")
          total = item.find(".item-population-total")
          if data.population<commit_msg>Change event trigger from selector:change to selector:set<commit_after>((E, $) ->
  'use strict'

  $(document).behave "load click", "form label input[name='parcel[delivery_mode]']", ->
    input = $(this)
    if input.is(':checked')
      form = input.closest('form')
      form.find("input[name='parcel[delivery_mode]']").each ->
        $("#delivery-mode-#{$(this).val()}").hide()
      $("#delivery-mode-#{input.val()}").show()

  $(document).behave "load click", "form label input[name='delivery[mode]']", ->
    input = $(this)
    if input.is(':checked')
      form = input.closest('form')
      form.find("input[name='delivery[mode]']").each ->
        $("##{$(this).val()}").hide()
      $("##{input.val()}").show()


  # Manage fields filling in sales/purchases
  $(document).on "selector:set", "*[data-product-of-delivery-item]", ->
    element = $(this)
    options = element.data("product-of-delivery-item")
    product_id = element.selector('value')
    reg = new RegExp("\\bRECORD_ID\\b", "g")
    scope = options['scope']
    if product_id?
      item = element.closest(".delivery-item")
      $.ajax
        url: options.url.replace(reg, product_id)
        dataType: "json"
        success: (data, status, request) ->
          unit = item.find(".item-population-unit-name")
          if data.unit_name
            unit.html(data.unit_name)
            item.attr('data-unit-name', data.unit_name)
          else
            unit.html('#')
          if data.variant
            item.find(".item-variant-name").html(data.variant.name)
          pop = item.find(".item-population")
          total = item.find(".item-population-total")
          if data.population
{'fraction_non_alphanumeric': 0.1989749773892071, 'fraction_numerical': 0.0, 'mean_word_length': 2.698996655518395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '670654', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1060, 'n_words': 175}