Sha256: 039aae6998c24bf3bea6504810a3b0b64d608eac5e053658c86a482a96bd346d

Contents?: true

Size: 1.81 KB

Versions: 5

Compression:

Stored size: 1.81 KB

Contents

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

  $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}']")

  $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}']")
  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

5 entries across 5 versions & 1 rubygems

Version Path
effective_bootstrap-0.6.25 app/assets/javascripts/effective_bootstrap/logic.js.coffee
effective_bootstrap-0.6.24 app/assets/javascripts/effective_bootstrap/logic.js.coffee
effective_bootstrap-0.6.23 app/assets/javascripts/effective_bootstrap/logic.js.coffee
effective_bootstrap-0.6.22 app/assets/javascripts/effective_bootstrap/logic.js.coffee
effective_bootstrap-0.6.21 app/assets/javascripts/effective_bootstrap/logic.js.coffee