Sha256: 390671f83aea917eef5d5df6f508512a48bcda3b7935d95bf8735b837f11017a

Contents?: true

Size: 1.17 KB

Versions: 85

Compression:

Stored size: 1.17 KB

Contents

# This initializes all the effective_* form inputs also in this gem
this.EffectiveBootstrap ||= new class
  initialize: (target) ->
    $(target || document).find('[data-input-js-options]:not(.initialized)').each (i, element) ->
      $element = $(element)
      options = $element.data('input-js-options')

      return true unless (options['method_name'] || '').length > 0

      method_name = options['method_name']
      delete options['method_name']

      unless EffectiveBootstrap[method_name]
        return console.error("EffectiveBootstrap #{method_name} has not been implemented")

      EffectiveBootstrap[method_name].call(this, $element, options)
      $element.addClass('initialized')

$ -> EffectiveBootstrap.initialize()
$(document).on 'turbolinks:load', -> EffectiveBootstrap.initialize()
$(document).on 'cocoon:after-insert', -> EffectiveBootstrap.initialize()
$(document).on 'effective-bootstrap:initialize', (event) -> EffectiveBootstrap.initialize(event.currentTarget)

$(document).on 'effective-bootstrap:reinitialize', (event) ->
  $(event.currentTarget).find('[data-input-js-options].initialized').removeClass('initialized')
  EffectiveBootstrap.initialize(event.currentTarget)

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
effective_bootstrap-1.19.10 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.9 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.8 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.7 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.6 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.5 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.4 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.3 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.2 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.1 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.19.0 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.18.7 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.18.4 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.18.3 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.18.2 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.18.1 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.18.0 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.17.6 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.17.5 app/assets/javascripts/effective_bootstrap/base.js.coffee
effective_bootstrap-1.17.4 app/assets/javascripts/effective_bootstrap/base.js.coffee