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