Sha256: df3e7c50fd351e3aaf6dcd063d45ad4e7dce7cf9523ef603c62de16e9a02a8bf

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

(this.EffectiveBootstrap || {}).effective_hide_if = ($element, options) ->
  $affects = $element.closest('form').find("input[name='#{options.name}'],select[name='#{options.name}']").first()

  $affects.on 'change', (event) ->
    if $(event.target).val() == options.value
      $element.hide()
      $element.find('input,textarea,select').prop('disabled', true)
    else
      $element.fadeIn()
      $element.find('input,textarea,select').removeAttr('disabled')

  # Maybe disable it now
  if options.needDisable
    $element.find('input,textarea,select').prop('disabled', true)


(this.EffectiveBootstrap || {}).effective_show_if = ($element, options) ->
  $affects = $element.closest('form').find("input[name='#{options.name}'],select[name='#{options.name}']").first()

  $affects.on 'change', (event) ->
    if $(event.target).val() == options.value
      $element.fadeIn()
      $element.find('input,textarea,select').removeAttr('disabled')
    else
      $element.hide()
      $element.find('input,textarea,select').prop('disabled', true)

  # Maybe disable it now
  if options.needDisable
    $element.find('input,textarea,select').prop('disabled', true)

(this.EffectiveBootstrap || {}).effective_show_if_any = ($element, options) ->
  $affects = $element.closest('form').find("input[name='#{options.name}'],select[name='#{options.name}']").first()
  values = JSON.parse(options.value)

  $affects.on 'change', (event) ->
    selected = $(event.target).val()
    found = values.find((value) => (value == selected || "#{value}" == "#{selected}"))

    if found
      $element.fadeIn()
      $element.find('input,textarea,select').removeAttr('disabled')
    else
      $element.hide()
      $element.find('input,textarea,select').prop('disabled', true)

  # Maybe disable it now
  if options.needDisable
    $element.find('input,textarea,select').prop('disabled', true)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
effective_bootstrap-0.6.20 app/assets/javascripts/effective_bootstrap/logic.js.coffee
effective_bootstrap-0.6.19 app/assets/javascripts/effective_bootstrap/logic.js.coffee