1App.SocialShare = function(){ 2 3 var chil_host = window.location.protocol + "//" + window.location.host; 4 var link_twitter = 'https://twitter.com/intent/tweet?&text='; 5 var link_fb = 'http://www.facebook.com/sharer.php?s=100' 6 var link_in = "http://www.linkedin.com/shareArticle?mini=true"; 7 8 //Center a popup window 9 function popUpCenter(pageURL, title, w, h) { 10 var left = (screen.width / 2) - (w / 2); 11 var top = (screen.height / 2) - (h / 2); 12 var targetWin = window.open(pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left); 13 } 14 15 //Share on Twitter 16 function shareOnTw(data) { 17 // NOTES: 18 // Select max 110 chrs from post 19 // The blank spaces must be replaced for %20. 20 // Add this code if is necessary: <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> 21 // Goal: Get the author's link to generate the url. 22 23 data = data || {}; 24 25 var via_tw = '&via=red_chil'; 26 var index = $(".twitter").index(this); 27 var message = $.trim(data.message); 28 var finalPos = message.length; 29 30 /*if (message.length >= 100) 31 finalPos = 109;*/ 32 33 //replace blank spaces for %20 34 message = message.slice(0, finalPos); 35 message = message.replace(/\s/g, "%20"); 36 37 var link = link_twitter + message + (data.via ? "&via=" + data.via : ""); 38 39 //open popup window 40 popUpCenter(link, 'Twitter', 550, 420); 41 } 42 43 //Share on Facebook 44 function shareOnFb(data) { 45 data = data || {}; 46 47 var link = link_fb; 48 49 if (data.url) 50 link += '&p[url]=' + data.url; 51 else 52 link += '&p[url]=' + chil_host; 53 54 if (data.title) 55 link += '&p[title]=' + $.trim(data.title).replace(/\s/g, "%20"); 56 57 if (data.summary) 58 link += '&p[summary]=' + data.summary; 59 60 if (data.images) 61 link += '&p[images][0]=' + data.images; 62 63 popUpCenter(link, 'Facebook', 550, 420); 64 } 65 66 //Share on LinkedIn 67 function shareOnIn(data){ 68 data = data || {}; 69 var link = link_in; 70 71 if (data.url) 72 link += "&url=" + data.url; 73 74 if (data.title) 75 link += "&title=" + data.title; 76 77 if (data.summary) 78 link += "&summary=" + data.summary; 79 80 if (data.source) 81 link += "&source=" + data.source; 82 83 popUpCenter(link, 'LinkedIn', 550, 420); 84 } 85 86 //Share By Email 87 function shareByEmail(data){ 88 if (typeof(data) == "string"){ 89 popUpCenter('/share-link-by-email?url=' + data, 'Chil: Share by email', 550, 350); 90 return; 91 } 92 93 var url = "/share-link-by-email?url=" + data.url; 94 95 var popupTitle = data.popupTitle == null ? "Chil: Share by email" : data.popupTitle; 96 url += "&title=" + popupTitle; 97 98 if (data.subject) 99 url += "&subject=" + data.subject; 100 101 if (data.actor) 102 url += "&actor=" + data.actor; 103 104 popUpCenter(url, popupTitle, 550, 350); 105 } 106 107 return { 108 TWITTER_VIA: 'red_chil', 109 shareOnTw: shareOnTw, 110 shareOnFb: shareOnFb, 111 shareOnIn: shareOnIn, 112 shareByEmail: shareByEmail 113 } 114}(); 115 116//for compatibility 117chil.widgets.socialShare = App.SocialShare;
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.