1(function() { 2 function initSocialShare(button) { 3 button.addEventListener('click', function(event){ 4 event.preventDefault(); 5 var social = button.getAttribute('data-social'); 6 var url = getSocialUrl(button, social); 7 (social == 'mail') 8 ? window.location.href = url 9 : window.open(url, social+'-share-dialog', 'width=626,height=436'); 10 }); 11 } 12 13 function getSocialUrl(button, social) { 14 var params = getSocialParams(social); 15 var newUrl = ''; 16 for(var i = 0; i < params.length; i++) { 17 var paramValue = button.getAttribute('data-'+params[i]); 18 if(params[i] == 'hashtags') paramValue = encodeURI(paramValue.replace(/\#| /g, '')); 19 if(paramValue) { 20 (social == 'facebook') 21 ? newUrl = newUrl + 'u='+encodeURIComponent(paramValue)+'&' 22 : newUrl = newUrl + params[i]+'='+encodeURIComponent(paramValue)+'&'; 23 } 24 } 25 if(social == 'linkedin') newUrl = 'mini=true&'+newUrl; 26 return button.getAttribute('href')+'?'+newUrl; 27 } 28 29 function getSocialParams(social) { 30 var params = []; 31 switch (social) { 32 case 'twitter': 33 params = ['text', 'hashtags']; 34 break; 35 case 'facebook': 36 case 'linkedin': 37 params = ['url']; 38 break; 39 case 'pinterest': 40 params = ['url', 'media', 'description']; 41 break; 42 case 'mail': 43 params = ['subject', 'body']; 44 break; 45 } 46 return params; 47 } 48 49 var socialShare = document.getElementsByClassName('js-social-share'); 50 if(socialShare.length > 0) { 51 for( var i = 0; i < socialShare.length; i++) { 52 53 (function(i){initSocialShare(socialShare[i])})(i); 54 55 } 56 } 57}());
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.