1/** 2 * Content img 3 * Collection 4 */ 5(function( app ) { 6 /** 7 * Module Namespace 8 * Use to register module and events. 9 */ 10 var NAMESPACE = 'contentImg'; 11 12 /** 13 * Default configuration 14 * Required configuration to ensure minimal functionality. 15 */ 16 var defaults = { 17 selector: '.content-img', 18 autoStart: true, 19 magnificPopup: { 20 type: 'image', 21 image: { 22 cursor: null 23 }, 24 // use mmKit cross icon plainly due to issues in IE 11 ('use' can be used as soon as IE 11 is not to be supported anymore) 25 closeMarkup: '<button title="%title%" type="button" class="content-img-popup__close-btn mfp-close"><svg class="svg-icon svg-icon--cross" xmlns="http://www.w3.org/2000/svg" width="422.6" height="422.6" viewBox="0 0 422.6 422.6"><path d="M246.7 211.3L415.3 42.7c9.8-9.8 9.8-25.6 0-35.4-9.8-9.8-25.6-9.8-35.4 0L211.3 175.9 42.7 7.3c-9.8-9.8-25.6-9.8-35.4 0-9.8 9.8-9.8 25.6 0 35.4l168.6 168.6L7.3 379.9c-9.8 9.8-9.8 25.6 0 35.4 4.9 4.9 11.3 7.3 17.7 7.3s12.8-2.4 17.7-7.3l168.6-168.6 168.6 168.6c4.9 4.9 11.3 7.3 17.7 7.3s12.8-2.4 17.7-7.3c9.8-9.8 9.8-25.6 0-35.4L246.7 211.3z"/></svg></button>', 26 mainClass: 'content-img-popup', 27 fixedContentPos: true, 28 overflowY: 'scroll' 29 } 30 }; 31 32 /** 33 * Private variables/state 34 * Variables not to be exposed, nor inherited or modified. 35 * e.g. shortcuts to dependencies or variables to spare memory. 36 */ 37 var conf; 38 var $ = app.$; 39 40 // Module startup 41 // The DOM is ready to be manipulated 42 app.ready(function() { 43 // apply custom config if present 44 conf = _.defaults({}, app.getConfig(NAMESPACE), defaults); 45 46 // set private variables and check dependencies 47 if ( !$.fn.magnificPopup ) throw 'jQuery magnificPopup plugin missing'; 48 49 // Register Module 50 app.register(NAMESPACE, Module); 51 52 // Auto-initialize collection 53 if ( conf.autoStart === true ) { 54 $(conf.selector).each(function() { 55 Module({ 56 targetElem: $(this) 57 }); 58 }); 59 } 60 }); 61 62 /** 63 * Module api 64 * Return new instances of a prototype or plain functionality. 65 * Depending on options supplied you may choose what object/functionality to run/return. 66 */ 67 var Module = function( options ) { 68 options = _.extend({}, conf, options); 69 var $targetElem = $(options.targetElem); 70 71 if ( $targetElem.hasClass('content-img--popup') ) { 72 return ContentImagePopup(options); 73 } 74 }; 75 76 var ContentImagePopup = function( options ) { 77 var $targetElem = $(options.targetElem); 78 if ( !$targetElem.length ) return; 79 80 $targetElem.children('.content-img__link') 81 .magnificPopup(options.magnificPopup); 82 83 // no methods yet 84 return { 85 86 }; 87 }; 88 89}(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.