2015-09-01 10:35:11 -04:00
|
|
|
|
2015-09-03 11:51:10 -04:00
|
|
|
// Smooth scrolling
|
2015-09-01 10:35:11 -04:00
|
|
|
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;
|
|
|
|
};
|
2015-09-03 11:51:10 -04:00
|
|
|
|
|
|
|
// Making contains text expression not worry about casing
|
2015-09-01 10:35:11 -04:00
|
|
|
$.expr[":"].contains = $.expr.createPseudo(function(arg) {
|
|
|
|
return function( elem ) {
|
|
|
|
return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2015-09-03 11:51:10 -04:00
|
|
|
// Show a success message after the element it's called upon.
|
2015-09-01 10:35:11 -04:00
|
|
|
jQuery.fn.showSuccess = function (message) {
|
|
|
|
var elem = $(this);
|
|
|
|
var success = $('<div class="text-pos" style="display:none;"><i class="zmdi zmdi-check-circle"></i>' + message + '</div>');
|
|
|
|
elem.after(success);
|
|
|
|
success.slideDown(400, function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
success.slideUp(400, function () {
|
|
|
|
success.remove();
|
|
|
|
})
|
|
|
|
}, 2000);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2015-09-03 11:51:10 -04:00
|
|
|
// Show a failure messages from laravel. Searches for the name of the inputs.
|
2015-09-01 10:35:11 -04:00
|
|
|
jQuery.fn.showFailure = function (messageMap) {
|
|
|
|
var elem = $(this);
|
|
|
|
$.each(messageMap, function (key, messages) {
|
|
|
|
var input = elem.find('[name="' + key + '"]').last();
|
|
|
|
var fail = $('<div class="text-neg" style="display:none;"><i class="zmdi zmdi-alert-circle"></i>' + messages.join("\n") + '</div>');
|
|
|
|
input.after(fail);
|
|
|
|
fail.slideDown(400, function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
fail.slideUp(400, function () {
|
|
|
|
fail.remove();
|
|
|
|
})
|
|
|
|
}, 2000);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-09-01 13:28:50 -04:00
|
|
|
};
|
|
|
|
|
2015-09-03 11:51:10 -04:00
|
|
|
// Submit the form that the called upon element sits in.
|
2015-09-01 13:28:50 -04:00
|
|
|
jQuery.fn.submitForm = function() {
|
|
|
|
$(this).closest('form').submit();
|
2015-09-03 11:51:10 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// Dropdown menu display
|
|
|
|
jQuery.fn.dropDown = function() {
|
|
|
|
var container = $(this),
|
|
|
|
menu = container.find('ul');
|
2015-10-08 18:49:18 -04:00
|
|
|
container.find('[data-dropdown-toggle]').on('click', function() {
|
2015-09-03 11:51:10 -04:00
|
|
|
menu.show().addClass('anim menuIn');
|
|
|
|
container.mouseleave(function() {
|
|
|
|
menu.hide();
|
|
|
|
menu.removeClass('anim menuIn');
|
|
|
|
});
|
|
|
|
});
|
2015-09-01 10:35:11 -04:00
|
|
|
};
|