gallery.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //[Javascript]
  2. $(function () {
  3. "use strict";
  4. // delegate calls to data-toggle="lightbox"
  5. $(document).delegate('*[data-bs-toggle="lightbox"]:not([data-bs-gallery="navigateTo"])', 'click', function(event) {
  6. event.preventDefault();
  7. return $(this).ekkoLightbox({
  8. onShown: function() {
  9. if (window.console) {
  10. return console.log('Checking our the events huh?');
  11. }
  12. },
  13. onNavigate: function(direction, itemIndex) {
  14. if (window.console) {
  15. return console.log('Navigating ' + direction + '. Current item: ' + itemIndex);
  16. }
  17. }
  18. });
  19. });
  20. //Programatically call
  21. $('#open-image').click(function(e) {
  22. e.preventDefault();
  23. $(this).ekkoLightbox();
  24. });
  25. $('#open-youtube').click(function(e) {
  26. e.preventDefault();
  27. $(this).ekkoLightbox();
  28. });
  29. // navigateTo
  30. $(document).delegate('*[data-bs-gallery="navigateTo"]', 'click', function(event) {
  31. event.preventDefault();
  32. var lb;
  33. return $(this).ekkoLightbox({
  34. onShown: function() {
  35. lb = this;
  36. $(lb.modal_content).on('click', '.modal-footer a', function(e) {
  37. e.preventDefault();
  38. lb.navigateTo(2);
  39. });
  40. }
  41. });
  42. });
  43. }); // End of use strict