1+function ($) { "use strict"; 2 var ColorBoxModal = function($el, options) { 3 this.$el = $el; 4 this.$parent = $el.closest('.cta'); 5 this.options = options; 6 this.ctaVideo = ""; 7 8 this.initColorbox(); 9 } 10 11 ColorBoxModal.prototype.initColorbox = function(){ 12 var self = this; 13 14 self.$parent.find(".lb-class").each(function () { 15 $(this).colorbox($.extend(ColorBoxModal.defaults, $($(this).attr("href")).data())); 16 }); 17 18 $(document).bind('cbox_complete', {context: this}, this.cboxOpenCallBack); 19 $(document).bind('cbox_closed', {context: this}, this.cboxClosedCallBack); 20 } 21 22 ColorBoxModal.prototype.cboxOpenCallBack = function(event){ 23 event.data.context.formSizeHandler(event); 24 event.data.context.videoLoadHandler(event); 25 } 26 27 ColorBoxModal.prototype.cboxClosedCallBack = function(event) { 28 var currElemId = $.colorbox.element().attr('href'); 29 30 $(currElemId + ' [data-setup-run]').each(function(){ 31 $(this).remove(); 32 }); 33 } 34 35 ColorBoxModal.prototype.formSizeHandler = function(event) { 36 var currElemId = $.colorbox.element().attr("href"), 37 $currElemForm = $(currElemId).find("form"); 38 39 var observer = new MutationObserver(function (mutations) { 40 $.colorbox.resize(); 41 }); 42 43 var target = document.querySelector($currElemForm.selector); 44 45 if (target != null) { 46 observer.observe(target, { 47 attributes: true 48 }); 49 } 50 } 51 52 ColorBoxModal.prototype.videoLoadHandler = function(event) { 53 var currElemId = $.colorbox.element().attr('href'); 54 55 if($(currElemId + ' [data-setup-run]').length){ 56 event.data.context.ctaVideo = $(currElemId + ' [data-setup-run]')[0].outerHTML; 57 $(currElemId + ' [data-setup-run]').remove(); 58 } 59 60 if(event.data.context.ctaVideo){ 61 $(currElemId + ' .video').append($(event.data.context.ctaVideo)); 62 63 var $video = $(currElemId + ' [data-setup-run]'); 64 videojs($video[0], $video.data('setupRun'), function(){}); 65 } 66 } 67 68 ColorBoxModal.defaults = { 69 inline: true, 70 width: "50%", 71 transition: "fade", 72 returnFocus: false 73 } 74 75 $.fn.colorBoxModal = function(option) { 76 var args = arguments, 77 result; 78 79 this.each(function() { 80 var $this = $(this); 81 82 var options = $.extend({}, $this.data(), typeof option == 'object' && option); 83 var data = ''; 84 85 $this.data('ColorBoxModal', (data = new ColorBoxModal($this, options))); 86 87 if (typeof result != 'undefined') return false; 88 }); 89 90 return result ? result : this; 91 }; 92 93 $.fn.colorBoxModal.Constructor = ColorBoxModal 94 95 $.fn.colorBoxModal.noConflict = function () { 96 $.fn.colorBoxModal = old 97 return this 98 } 99 100 $(document).ready(function(){ 101 $('[data-control="colorbox-modal"]').colorBoxModal({}); 102 }); 103}(window.jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.