Sha256: 020a9726ff8ccb7a7a556fcd5f4501007814a30336534a084d7ab0945f9a3c54

Contents?: true

Size: 1.27 KB

Versions: 28

Compression:

Stored size: 1.27 KB

Contents

$(document).on('turbolinks:load', function () {
  $(document).on('click', '.form_submit', function(e) {
    e.preventDefault();
    var submit = [];
    var form_class = $(this).data('form-class');
    $("." + form_class + " input.required, ." + form_class + " textarea.required").each(function() {
      $(this).removeClass('error');
      if ($(this).val().trim().length === 0) {
        $(this).addClass('error');
        window.scrollTo(top);
        submit.push(true);
      }
    });
    $("." + form_class + " select.required").each(function() {
      $(this).removeClass('error');
      if ($(this).val().trim().length === 0) {
        $(this).parent().find('.select2').addClass('error');
        window.scrollTo(top);
        submit.push(true);
      }
    });
    $('.nested_input_validation').each(function() {
      var class_name;
      class_name = $(this).data('class-name');
      $(this).parents(':nth(1)').find('.' + class_name).addClass('hidden');
      if ($(this).val().trim().length === 0) {
        $(this).parents(':nth(1)').find('.' + class_name).removeClass('hidden');
        window.scrollTo(top);
        submit.push(true);
      }
    });
    if (submit.length === 0) {
      $('.' + form_class).submit();
      return $('.form_submit').button('loading');
    }
  });
});

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
cm-admin-1.0.5 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.0.3 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.0.2 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-1.0.0 app/assets/javascripts/cm_admin/form_validation.js
cm-admin-0.9.1 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.9.0 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.9 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.8 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.7 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.6 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.5 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.4 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.3 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.2 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.1 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.8.0 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.7.8 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.7.7 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.7.6 app/javascript/packs/cm_admin/form_validation.js
cm-admin-0.7.5 app/javascript/packs/cm_admin/form_validation.js