Sha256: ab9756649f3b56b41fb7966c7d6d41192e11ee2a2797a36744fd266807daf347

Contents?: true

Size: 1.25 KB

Versions: 55

Compression:

Stored size: 1.25 KB

Contents

$(document).ready(function() {
  $.fn.wizard = function() {
    var form = this;

    var goToStage = function($newStage) {
      $(form).find('.wizard-current').removeClass('wizard-current');
      $newStage.addClass('wizard-current');
      $("html, body").animate({ scrollTop: 0 }, "slow");
      if ($newStage.find('.field_with_errors').length > 0) {
        $newStage.find(".field_with_errors").first().find(":input").focus();
      } else {
        $newStage.find(":input").first().focus();
      }
    };

    var nextStage = function() {
      if (!$(form).find('.wizard-current').validate('now')) {
        return false;
      }
      goToStage($(form).find('.wizard-current').next());
    };

    var previousStage = function() {
      goToStage($(form).find('.wizard-current').prev());
    };

    if ($(form).find('.field_with_errors').length > 0) {
      goToStage($(form).find('.field_with_errors').first().parents('.wizard-stage'));
    }
    $(this).find('[data-wizard=next]').each(function() {
      $(this).on('click', nextStage);
    });
    $(this).find('[data-wizard=previous]').each(function() {
      $(this).on('click', previousStage);
    });
    if ($(this).is('.wizard-skip-valid')) {
      nextStage.call(this);
    }
  };

  $('.wizard').wizard();
});

Version data entries

55 entries across 55 versions & 1 rubygems

Version Path
hackathon_manager-0.14.1 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.14.0 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.12 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.11 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.10 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.9 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.8 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.7 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.6 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.5 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.4 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.3 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.2 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.1 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.13.0 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.12.2 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.12.1 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.12.0 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.11.2 app/assets/javascripts/hackathon_manager/wizard.js
hackathon_manager-0.11.1 app/assets/javascripts/hackathon_manager/wizard.js