tooltip&popover.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. (function($) {
  2. "use strict";
  3. //colored tooltip
  4. var tooltip = new bootstrap.Tooltip(document.querySelector('[data-bs-toggle="tooltip-primary"]'), {
  5. template: '<div class="tooltip tooltip-primary" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  6. })
  7. var tooltip = new bootstrap.Tooltip(document.querySelector('[data-bs-toggle="tooltip-secondary"]'), {
  8. template: '<div class="tooltip tooltip-secondary" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  9. })
  10. var tooltip = new bootstrap.Tooltip(document.querySelector('[data-bs-toggle="tooltip-danger"]'), {
  11. template: '<div class="tooltip tooltip-danger" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  12. })
  13. var tooltip = new bootstrap.Tooltip(document.querySelector('[data-bs-toggle="tooltip-info"]'), {
  14. template: '<div class="tooltip tooltip-info" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
  15. })
  16. //Colored Head Popover
  17. var popover = new bootstrap.Popover(document.querySelector('[data-bs-popover-color="head-primary"]'), {
  18. template: '<div class="popover popover-head-primary" role="tooltip"><div class="popover-arrow"><\/div><h3 class="popover-header"><\/h3><div class="popover-body"><\/div><\/div>'
  19. })
  20. var popover = new bootstrap.Popover(document.querySelector('[data-bs-popover-color="head-secondary"]'), {
  21. template: '<div class="popover popover-head-secondary" role="tooltip"><div class="popover-arrow"><\/div><h3 class="popover-header"><\/h3><div class="popover-body"><\/div><\/div>'
  22. })
  23. //Full Colored Popover
  24. var popover = new bootstrap.Popover(document.querySelector('[data-bs-popover-color="primary"]'), {
  25. template: '<div class="popover popover-primary" role="tooltip"><div class="popover-arrow"><\/div><h3 class="popover-header"><\/h3><div class="popover-body"><\/div><\/div>'
  26. })
  27. var popover = new bootstrap.Popover(document.querySelector('[data-bs-popover-color="secondary"]'), {
  28. template: '<div class="popover popover-secondary" role="tooltip"><div class="popover-arrow"><\/div><h3 class="popover-header"><\/h3><div class="popover-body"><\/div><\/div>'
  29. })
  30. //Popover
  31. $(document).on('click', function(e) {
  32. $('[data-bs-toggle="popover"]').each(function() {
  33. //the 'is' for buttons that trigger popups
  34. //the 'has' for icons within a button that triggers a popup
  35. if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
  36. (($(this).popover('hide').data('bs.popover') || {}).inState || {}).click = false
  37. }
  38. });
  39. });
  40. })(jQuery);