jQuery.fn.smoothScrollTo = function() { if(this.length === 0) return; $('body').animate({ scrollTop: this.offset().top - 60 // Adjust to change final scroll position top margin }, 800); // Adjust to change animations speed (ms) return this; }; $.expr[":"].contains = $.expr.createPseudo(function(arg) { return function( elem ) { return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; }; }); jQuery.fn.showSuccess = function (message) { var elem = $(this); var success = $(''); elem.after(success); success.slideDown(400, function () { setTimeout(function () { success.slideUp(400, function () { success.remove(); }) }, 2000); }); }; jQuery.fn.showFailure = function (messageMap) { var elem = $(this); $.each(messageMap, function (key, messages) { var input = elem.find('[name="' + key + '"]').last(); var fail = $(''); input.after(fail); fail.slideDown(400, function () { setTimeout(function () { fail.slideUp(400, function () { fail.remove(); }) }, 2000); }); }); }; jQuery.fn.submitForm = function() { $(this).closest('form').submit(); };