Sha256: c8e55221411d84fe8ce2d5da0dca87f9dc18fabe6976e2ad18ea3abede368de7
Contents?: true
Size: 1.48 KB
Versions: 4
Compression:
Stored size: 1.48 KB
Contents
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') 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') validate: (form) -> $form = $(form) # Clear any server side validation on individual inputs $form.find('.alert.is-invalid').remove() $form.find('.is-invalid').removeClass('is-invalid') $form.find('.is-valid').removeClass('is-valid') valid = form.checkValidity() if valid $form.addClass('form-is-valid').removeClass('form-is-invalid') setTimeout((-> $('button[type=submit],input[type=submit]').prop('disabled', true)), 0) else $form.addClass('was-validated').addClass('form-is-invalid').removeClass('form-is-valid') valid $ -> 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 'ajax:beforeSend', 'form[data-remote]', -> this.checkValidity()
Version data entries
4 entries across 4 versions & 1 rubygems