Sha256: ca02e2053b0f2419fd3407c9380c3ab5710c0c09f722d740198606abbf6844cd

Contents?: true

Size: 987 Bytes

Versions: 5

Compression:

Stored size: 987 Bytes

Contents

/**
 * Version 0.0.1
 * Display a message letting the user know the form is being submitted
 * Didier Lafforgue
 */
$.fn.formSubmitNotification = function(settings) {

  function show() {
    $('#form-submit-notification').fadeIn()
  }

  function hide() {
    $('#form-submit-notification').fadeOut()
  }

  function create(message) {
    if ($('#form-submit-notification').size() == 0) {
      var element = $("<div id=\"form-submit-notification\"><div>" + message + "</div></div>").hide();
      $('body').append(element);
    }
  }

  return this.each(function() {
    var form    = $(this);
    var message = form.attr('data-sending-form-message');

    if (typeof(message) == 'undefined')
      message = form.find('input[type=submit]').attr('data-sending-form-message');

    if (typeof(message) == 'undefined')
      return ;

    create(message);

    form.bind('ajax:beforeSend', function(event) { show() });
    form.bind('ajax:complete', function(event) { hide() });

  });
}

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc9 vendor/assets/javascripts/locomotive/form_submit_notification.js
locomotive_cms-2.0.0.rc8 vendor/assets/javascripts/locomotive/form_submit_notification.js
locomotive_cms-2.0.0.rc7 vendor/assets/javascripts/locomotive/form_submit_notification.js
locomotive_cms-2.0.0.rc6 vendor/assets/javascripts/locomotive/form_submit_notification.js
locomotive_cms-2.0.0.rc5 vendor/assets/javascripts/locomotive/form_submit_notification.js