1/** 2 * Content Teaser 2 3 * Collection 4 */ 5(function( app ) { 6 /** 7 * Module Namespace 8 * Use to register module and events. 9 */ 10 var NAMESPACE = 'contentTeaser2'; 11 12 /** 13 * Default configuration 14 * Required configuration to ensure minimal functionality. 15 * 16 * @property {string} selector - selector string 17 * @property {object} magnificPopup - plugin settings, see http://dimsemenov.com/plugins/magnific-popup/documentation.html#options 18 */ 19 var defaults = { 20 selector: '.content-teaser-2', 21 autoStart: true 22 }; 23 24 /** 25 * Private variables/state 26 * Variables not to be exposed, nor inherited or modified. 27 * e.g. shortcuts to dependencies or variables to spare memory. 28 */ 29 var conf; 30 var $ = app.$; 31 var trackingApi; 32 33 // Module startup 34 // The DOM is ready to be manipulated 35 app.ready(function() { 36 // apply custom config if present 37 conf = _.defaults({}, app.getConfig(NAMESPACE), defaults); 38 39 // set private variables and check dependencies 40 if ( !app.contentVideo ) throw 'contentVideo module missing'; 41 trackingApi = app.tracking; 42 43 // Register Module 44 app.register(NAMESPACE, Module); 45 46 // Auto-initialize collection 47 if ( conf.autoStart === true ) { 48 $(conf.selector).each(function() { 49 Module({ 50 targetElem: $(this) 51 }); 52 }); 53 } 54 }); 55 56 /** 57 * Module api 58 * Return new instances of a prototype or plain functionality. 59 * Depending on options supplied you may choose what object/functionality to run/return. 60 */ 61 var Module = function( options ) { 62 return ContentTeaser2(_.extend({}, conf, options)); 63 }; 64 65 var ContentTeaser2 = function( options ) { 66 var $targetElem = $(options.targetElem); 67 if ( !$targetElem.length ) return; 68 var hasVideo = !!$targetElem.find('.content-teaser-2__target-video-wrap').length; 69 70 if ( hasVideo ) { 71 // Consent gate for video service 72 app.contentVideo.renderVideo({ 73 rootElement: $targetElem.find('.content-teaser-2__target-video-wrap')[0], 74 videoType: 'mi-24', 75 videoSelector: '.content-teaser-2__target-video', 76 onRender: function() { 77 $targetElem.removeClass('content-teaser-2--has-consent-gate'); 78 } 79 }) 80 } 81 82 // No methods yet 83 return {}; 84 }; 85 86}(app));
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.