1(function( app ) { 2 /** 3 * Module Namespace 4 * Use to register module and events. 5 */ 6 var NAMESPACE = 'contentText'; 7 8 /** 9 * Default configuration 10 * Required configuration to ensure minimal functionality. 11 * 12 * @property {string} selector - selector string 13 * See toggleWidget documentation for the following options 14 */ 15 var defaults = { 16 selector: '.content-text--toggle', 17 toggleBtnSelector: '.content-text__toggle-btn', 18 toggleContentSelector: '.content-text__toggle-content', 19 openClass: 'content-text--toggle-is-open' 20 }; 21 22 /** 23 * Private variables/state 24 * Variables not to be exposed, nor inherited or modified. 25 * e.g. shortcuts to dependencies or variables to spare memory. 26 */ 27 var conf; 28 var $ = app.$; 29 30 // Module startup 31 // The DOM is ready to be manipulated 32 app.ready(function() { 33 // apply custom config if present 34 conf = _.defaults({}, app.getConfig(NAMESPACE), defaults); 35 36 // set private variables and check dependencies 37 if ( !$.fn.toggleWidget ) throw 'jQuery ToggletWidget plugin missing'; 38 39 // Register Module 40 app.register(NAMESPACE, Module); 41 42 $(conf.selector).each(function() { 43 Module({ 44 targetElem: $(this) 45 }); 46 }); 47 }); 48 49 /** 50 * Module api 51 * Return new instances of a prototype or plain functionality. 52 * Depending on options supplied you may choose what object/functionality to run/return. 53 */ 54 var Module = function( options ) { 55 options = _.extend({}, conf, options); 56 57 options.targetElem.toggleWidget(options); 58 59 return {}; 60 }; 61 62}(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.