3 jQuery.fn.smoothScrollTo = function() {
4 if(this.length === 0) return;
6 scrollTop: this.offset().top - 60 // Adjust to change final scroll position top margin
7 }, 800); // Adjust to change animations speed (ms)
11 // Making contains text expression not worry about casing
12 $.expr[":"].contains = $.expr.createPseudo(function(arg) {
13 return function( elem ) {
14 return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
18 // Show a success message after the element it's called upon.
19 jQuery.fn.showSuccess = function (message) {
21 var success = $('<div class="text-pos" style="display:none;"><i class="zmdi zmdi-check-circle"></i>' + message + '</div>');
23 success.slideDown(400, function () {
24 setTimeout(function () {
25 success.slideUp(400, function () {
32 // Show a failure messages from laravel. Searches for the name of the inputs.
33 jQuery.fn.showFailure = function (messageMap) {
35 $.each(messageMap, function (key, messages) {
36 var input = elem.find('[name="' + key + '"]').last();
37 var fail = $('<div class="text-neg" style="display:none;"><i class="zmdi zmdi-alert-circle"></i>' + messages.join("\n") + '</div>');
39 fail.slideDown(400, function () {
40 setTimeout(function () {
41 fail.slideUp(400, function () {
50 // Submit the form that the called upon element sits in.
51 jQuery.fn.submitForm = function() {
52 $(this).closest('form').submit();
55 // Dropdown menu display
56 jQuery.fn.dropDown = function() {
57 var container = $(this),
58 menu = container.find('ul');
59 container.find('[data-dropdown-toggle]').on('click', function() {
60 menu.show().addClass('anim menuIn');
61 container.mouseleave(function() {
63 menu.removeClass('anim menuIn');