1/** 2 * Component facebook 3 * @module Facebook 4 * @param {jQuery} $ Instance of jQuery 5 * @param {Document} document Instance of Document 6 * @return {Object} List of Facebook methods 7 */ 8XA.component.facebook = (function($, document) { 9 /** 10 * This object stores all public api methods 11 * @type {Object.<Methods>} 12 * @memberOf module:Facebook 13 */ 14 var api = {}; 15 /** 16 * initInstance method sets up facebook properties and 17 * adds facebook script 18 * @memberOf module:Facebook 19 * @method 20 * @alias module:Facebook.initInstance 21 */ 22 api.initInstance = function() { 23 (function(d, s, id) { 24 var js, 25 script = d.getElementsByTagName(s)[0]; 26 if (d.getElementById(id)) { 27 return; 28 } 29 js = d.createElement(s); 30 js.id = id; 31 js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.7"; 32 script.insertBefore(js, script.firstChild); 33 })(document, "script", "facebook-jssdk"); 34 }; 35 /** 36 * init method calls in a loop for each 37 * facebook component on a page and runs Facebook's 38 * [".initInstance"]{@link module:Facebook.initInstance} method. 39 * @memberOf module:Facebook 40 * @alias module:Facebook.init 41 */ 42 api.init = function() { 43 var facebook = $(".fb-comments:not(.initialized)"); 44 45 facebook.each(function() { 46 api.initInstance(); 47 $(this).addClass("initialized"); 48 }); 49 }; 50 51 return api; 52})(jQuery, document); 53 54XA.register("facebook", XA.component.facebook);
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.