Advertisement
briank

Kartra Click-To-Pop-And-Load Video

Jan 21st, 2022
1,582
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. /*
  3.  * Kartra click-to-pop-and-load video (add to FOOTER tracking)
  4.  * Author: Brian Katzung <briank@kappacs.com>
  5.  * Create a content pop button with only a full-width video placeholder.
  6.  * That button will be hidden at page load.
  7.  * Add an external-link button for each video with the .mp4 URL as target.
  8.  */
  9. (function ($) {
  10.     // Pause video when closing modal
  11.     function pause () {
  12.     $('.modal-body video').each(function () { this.pause(); });
  13.     }
  14.     $(document).on('click', '.closer[data-dismiss="modal"]', pause);
  15.     $(document).on('click', '.popup-modal', function (ev) {
  16.     if (ev.currentTarget == ev.target) pause();
  17.     });
  18.     function popMP4 (ev) {
  19.     ev.preventDefault();
  20.     // Open modal if closed
  21.     $('body:not(.modal-open) a.toggle_contentbox').click();
  22.     // Load the selected video into the modal
  23.     $('.js_kartra_component_holder .kartra_video').html('<video controls="" controlslist="nodownload" style="display: block; width: 100%;"><source src="' + ev.target.href + '" type="video/mp4"></video>');
  24.     }
  25.     $(function () {
  26.     $('a.toggle_contentbox').parent().hide();
  27.     $('a[href$=".mp4"]').click(popMP4);
  28.     });
  29. })(jQuery);
  30. </script>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement