<commit_before>binders = Rivets.binders = {}

binders.text = (el, value) ->
  if el.textContent?
    el.textContent = if value? then value else ''
  else
    el.innerText = if value? then value else ''

binders.html = (el, value) ->
  value = value.outerHTML if (value instanceof HTMLElement)

  return this.text(el, value) if typeof value? is 'string'

  el.innerHTML = if value? then value else ''

binders.show = (el, value) -> el.style.display = if value then '' else 'none'
binders.hide = (el, value) -> el.style.display = if value then 'none' else ''

binders.enabled = (el, value) -> el.disabled = !value
binders.disabled = (el, value) -> el.disabled = !!value

binders.value =
  publishes: true
  priority: 3000

  bind: (el) ->
    unless el.tagName is 'INPUT' and el.type is 'radio'
      @event = if el.tagName is 'SELECT' then 'change' else 'input'
      el.addEventListener @event, @publish

  unbind: (el) ->
    unless el.tagName is 'INPUT' and el.type is 'radio'
      el.removeEventListener @event, @publish

  routine: (el, value) ->
    if el.tagName is 'INPUT' and el.type is 'radio'
      el.setAttribute 'value', value
    else if window.jQuery?
      el = jQuery el

      if value?.toString() isnt el.val()?.toString()
        el.val if value? then value else ''
    else
      if el.type is 'select-multiple'
        o.selected = o.value in value for o in el if value?
      else if value?.toString() isnt el.value?.toString()
        el.value = if value? then value else ''

binders.if =
  block: true
  priority: 4000

  bind: (el) ->
    unless @marker?
      attr = ['cb', @type].join('-').replace '--', '-'
      declaration = el.getAttribute attr

      @marker = document.createComment " rivets: #{@type} #{declaration} "
      @bound = false

      el.removeAttribute attr
      el.parentNode.insertBefore @marker, el
      el.parentNode.removeChild el

  unbind: -> @nested?.unbind()
  routine: (el, value) ->
    if !!value is not @bound
      if value
        models = {}
        models[key] = model for key, model of @view.models<commit_msg>Simplified value binder<commit_after>binders = Rivets.binders = {}

binders.text = (el, value) ->
  if el.textContent?
    el.textContent = if value? then value else ''
  else
    el.innerText = if value? then value else ''

binders.html = (el, value) ->
  value = value.outerHTML if (value instanceof HTMLElement)

  return this.text(el, value) if typeof value? is 'string'

  el.innerHTML = if value? then value else ''

binders.show = (el, value) -> el.style.display = if value then '' else 'none'
binders.hide = (el, value) -> el.style.display = if value then 'none' else ''

binders.enabled = (el, value) -> el.disabled = !value
binders.disabled = (el, value) -> el.disabled = !!value

binders.value =
  publishes: true
  priority: 3000

  bind: (el) ->
    unless el.tagName is 'INPUT' and el.type is 'radio'
      @event = if el.tagName is 'SELECT' then 'change' else 'input'
      el.addEventListener @event, @publish

  unbind: (el) ->
    unless el.tagName is 'INPUT' and el.type is 'radio'
      el.removeEventListener @event, @publish

  routine: (el, value) ->
    if el.tagName is 'INPUT' and el.type is 'radio'
      el.setAttribute 'value', value
    else if value?.toString() isnt el.value?.toString()
      el.value = if value? then value else ''

binders.if =
  block: true
  priority: 4000

  bind: (el) ->
    unless @marker?
      attr = ['cb', @type].join('-').replace '--', '-'
      declaration = el.getAttribute attr

      @marker = document.createComment " rivets: #{@type} #{declaration} "
      @bound = false

      el.removeAttribute attr
      el.parentNode.insertBefore @marker, el
      el.parentNode.removeChild el

  unbind: -> @nested?.unbind()
  routine: (el, value) ->
    if !!value is not @bound
      if value
        models = {}
        models[key] = model for key, model of @view.models
{'fraction_non_alphanumeric': 0.1371194678946022, 'fraction_numerical': 0.004093118444614991, 'mean_word_length': 2.807205452775073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '3553417', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1247, 'n_words': 402}