Files

84 lines
3.0 KiB
JavaScript
Executable File

/*=========================================================================================
File Name: Components.js
Description: For Generic Components.
----------------------------------------------------------------------------------------
Item Name: Vuesax HTML Admin Template
Version: 1.1
Author: Pixinvent
Author URL: http://www.themeforest.net/user/pixinvent
==========================================================================================*/
(function (window, document, $) {
/***** Component Variables *****/
var alertValidationInput = $(".alert-validation"),
alertRegex = /^[0-9]+$/,
alertValidationMsg = $(".alert-validation-msg"),
accordion = $(".accordion"),
collapseTitle = $(".collapse-title"),
collapseHoverTitle = $(".collapse-hover-title"),
dropdownMenuIcon = $(".dropdown-icon-wrapper .dropdown-item");
/***** Alerts *****/
/* validation with alert */
alertValidationInput.on('input', function () {
if (alertValidationInput.val().match(alertRegex)) {
alertValidationMsg.css("display", "none");
} else {
alertValidationMsg.css("display", "block");
}
});
/***** Carousel *****/
// For Carousel With Enabled Keyboard Controls
$(document).on("keyup", function (e) {
if (e.which == 39) {
$('.carousel[data-keyboard="true"]').carousel('next');
} else if (e.which == 37) {
$('.carousel[data-keyboard="true"]').carousel('prev');
}
})
// To open Collapse on hover
if (accordion.attr("data-toggle-hover", "true")) {
collapseHoverTitle.closest(".card").on("mouseenter", function () {
$(this).children(".collapse").collapse("show");
});
}
// Accordion with Shadow - When Collapse open
$('.accordion-shadow .collapse-header .card-header').on("click", function () {
var $this = $(this);
$this.parent().siblings(".collapse-header.open").removeClass("open");
$this.parent(".collapse-header").toggleClass("open");
});
/***** Dropdown *****/
// For Dropdown With Icons
dropdownMenuIcon.on("click", function () {
$(".dropdown-icon-wrapper .dropdown-toggle i").remove();
$(this).find("i").clone().appendTo(".dropdown-icon-wrapper .dropdown-toggle");
$(".dropdown-icon-wrapper .dropdown-toggle .dropdown-item").removeClass("dropdown-item");
});
/***** Pagination *****/
// For Pagination styles
if ($(".pagination .page-item.prev-item").length > 0) {
$(".pagination .page-item.prev-item").next(".page-item").find(".page-link").css({
"border-top-left-radius": "20px",
"border-bottom-left-radius": "20px"
});
}
if ($(".pagination .page-item.next-item").length > 0) {
$(".pagination .page-item.next-item").prev(".page-item").find(".page-link").css({
"border-top-right-radius": "20px",
"border-bottom-right-radius": "20px"
});
}
/***** Chips *****/
// To close chips
$('.chip-closeable').on('click', function () {
$(this).closest('.chip').remove();
})
})(window, document, jQuery);