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 className: 'ctaColorBox' 74 } 75 76 $.fn.colorBoxModal = function(option) { 77 var args = arguments, 78 result; 79 80 this.each(function() { 81 var $this = $(this); 82 83 var options = $.extend({}, $this.data(), typeof option == 'object' && option); 84 var data = ''; 85 86 $this.data('ColorBoxModal', (data = new ColorBoxModal($this, options))); 87 88 if (typeof result != 'undefined') return false; 89 }); 90 91 return result ? result : this; 92 }; 93 94 $.fn.colorBoxModal.Constructor = ColorBoxModal 95 96 $.fn.colorBoxModal.noConflict = function () { 97 $.fn.colorBoxModal = old 98 return this 99 } 100 101 $(document).ready(function(){ 102 $('[data-control="colorbox-modal"]').colorBoxModal({}); 103 }); 104}(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.