components.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*=========================================================================================
  2. File Name: Components.js
  3. Description: For Generic Components.
  4. ----------------------------------------------------------------------------------------
  5. Item name: Vuexy - Vuejs, HTML & Laravel Admin Dashboard Template
  6. Author: Pixinvent
  7. Author URL: http://www.themeforest.net/user/pixinvent
  8. ==========================================================================================*/
  9. (function (window, document, $) {
  10. /***** Component Variables *****/
  11. var alertValidationInput = $(".alert-validation"),
  12. alertRegex = /^[0-9]+$/,
  13. alertValidationMsg = $(".alert-validation-msg"),
  14. accordion = $(".accordion"),
  15. collapseTitle = $(".collapse-title"),
  16. collapseHoverTitle = $(".collapse-hover-title"),
  17. dropdownMenuIcon = $(".dropdown-icon-wrapper .dropdown-item");
  18. /***** Alerts *****/
  19. /* validation with alert */
  20. alertValidationInput.on('input', function () {
  21. if (alertValidationInput.val().match(alertRegex)) {
  22. alertValidationMsg.css("display", "none");
  23. } else {
  24. alertValidationMsg.css("display", "block");
  25. }
  26. });
  27. /***** Carousel *****/
  28. // For Carousel With Enabled Keyboard Controls
  29. $(document).on("keyup", function (e) {
  30. if (e.which == 39) {
  31. $('.carousel[data-keyboard="true"]').carousel('next');
  32. } else if (e.which == 37) {
  33. $('.carousel[data-keyboard="true"]').carousel('prev');
  34. }
  35. })
  36. // To open Collapse on hover
  37. if (accordion.attr("data-toggle-hover", "true")) {
  38. collapseHoverTitle.closest(".card").on("mouseenter", function () {
  39. $(this).children(".collapse").collapse("show");
  40. });
  41. }
  42. // Accordion with Shadow - When Collapse open
  43. $('.accordion-shadow .collapse-header .card-header').on("click", function () {
  44. var $this = $(this);
  45. $this.parent().siblings(".collapse-header.open").removeClass("open");
  46. $this.parent(".collapse-header").toggleClass("open");
  47. });
  48. /***** Dropdown *****/
  49. // For Dropdown With Icons
  50. dropdownMenuIcon.on("click", function () {
  51. $(".dropdown-icon-wrapper .dropdown-toggle i").remove();
  52. $(this).find("i").clone().appendTo(".dropdown-icon-wrapper .dropdown-toggle");
  53. $(".dropdown-icon-wrapper .dropdown-toggle .dropdown-item").removeClass("dropdown-item");
  54. });
  55. /***** Chips *****/
  56. // To close chips
  57. $('.chip-closeable').on('click', function () {
  58. $(this).closest('.chip').remove();
  59. })
  60. })(window, document, jQuery);