1//Share Module 2(function ($) { 3 if( $(".page-actions").length > 0 ) { 4 AddSocialButtonsToPage(); 5 } 6 $($("#citation-how-to button")[0]).click(function(){ 7 if ('es'==$("html").attr("lang")) { 8 window.location.href='https://medlineplus.gov/spanish/acercade/uso/citar/'; 9 } 10 else { 11 window.location.href='https://medlineplus.gov/about/using/citation/'; 12 } 13 }); 14 //Add Social Buttons Function 15 function AddSocialButtonsToPage(){ 16 17 //Share Buttons Location 18 $(".page-actions").html(""); //Clear any old html 19 $(".page-actions").append($('<div/>').addClass("share-buttons")); 20 var share = $('.share-buttons'); 21 $(share).hide() 22 23 //Set Root URL 24 var root_url = $("html").attr("data-root"); 25 if (root_url[root_url.length-1] == '/') root_url = root_url.substr(0,root_url.length-1); 26 27 //Set Page ID 28 var page_id = $("html").attr("id"); 29 30 //Set Buttons 31 var share_buttons = { 32 "pdf" : false, 33 "email": true, 34 "print": false, 35 "facebook": true, 36 "twitter": true, 37 "pinterest": true, 38 "rss": false 39 }; 40 41 // Django 42 switch(page_id) { 43 case "health_topic": 44 share_buttons["print"] = true; 45 share_buttons["rss"] = true; 46 break; 47 case "easy_to_read": 48 case "lab_test": 49 case "medmono": 50 case "home-infusion": 51 case "appendix": 52 case "chemo": 53 case "nmcd": 54 case "article": 55 case "carepoint": 56 case "recipe": 57 share_buttons["print"] = true; 58 break; 59 case "genetic_condition": 60 case "gene": 61 case "chromosome": 62 case "understanding_genetics": 63 share_buttons["pdf"] = true; 64 case "whats_new": 65 share_buttons["rss"] = true; 66 break; 67 } 68 69 //Set Language 70 var page_lang = $("html").attr("lang"); 71 72 //Set Title 73 var page_title = $("title").text(); 74 if(page_title == undefined) { //Set Fallback Defaults 75 page_title = "MedlinePlus"; 76 } 77 78 //Set URL 79 var page_url = $('link[rel="canonical"]').attr("href"); 80 if(page_url == undefined) { //Set Fallback Defaults 81 page_url = "https://medlineplus.gov/"; 82 if(page_lang == 'es') { 83 page_url = "https://medlineplus.gov/spanish/"; 84 } 85 } 86 87 //Email Share 88 if(share_buttons["email"]) { 89 //English 90 var email_label = "Email this page to a friend"; 91 var email_body = "I found this information on MedlinePlus.gov and I'd like to share it with you:\n\n" 92 + page_url + "?utm_source=email&utm_medium=share&utm_campaign=mplus_share" 93 + "\n\nMedlinePlus (https://medlineplus.gov): Trusted Health Information for you" 94 + "\n\nTo get updates by email when new information becomes available on MedlinePlus, " 95 +"sign up at https://medlineplus.gov/listserv.html."; 96 //Spanish 97 if(page_lang == 'es') { 98 email_label = "Enviar esta página a un amigo"; 99 email_body = "Encontré esta información en MedlinePlus.gov/espanol y me gustarÃa compartirla con usted:\n\n" 100 + page_url + "?utm_source=email&utm_medium=share&utm_campaign=mplus_share" 101 + "\n\nMedlinePlus en español (https://medlineplus.gov/espanol): Información de salud para usted" 102 + "\n\nPara recibir novedades por email cuando nueva información se encuentre disponible en MedlinePlus en español, " 103 +"suscrÃbase en https://medlineplus.gov/spanish/listserv.html"; 104 } 105 email_url = 'mailto:?subject='+encodeURIComponent(page_title)+'&body='+encodeURIComponent(email_body); 106 //Create Email Button 107 share.append( 108 '<span>' 109 +'<a target="EmailWin" class="email_icon" title="'+email_label+'" href="'+email_url+'">' 110 +'<img alt="'+email_label+'" class="share-icon" src="'+root_url+'/images/i_share_email.png"/>' 111 +'</a>' 112 +'</span> ' 113 ); 114 } 115 116 //Print Share 117 if(share_buttons["print"]) { 118 //English 119 var print_label = "Print"; 120 //Spanish 121 if(page_lang == 'es') { 122 print_label = "Imprimir"; 123 } 124 //Create Print Button 125 share.append( 126 '<span>' 127 +'<a class="mplus_print" title="'+print_label+'" href="#">' 128 +'<img alt="'+print_label+'" class="share-icon" src="'+root_url+'/images/i_share_print.png"/>' 129 +'</a>' 130 +'</span> ' 131 ); 132 //Print Event 133 if(page_id == "health_topic") { 134 var print_window_label = "Print Options"; 135 var print_close_label = "Close print options"; 136 var print_option_summary = "Topic Summary only"; 137 var print_option_full = "Full topic including all links"; 138 //Spanish 139 if(page_lang == 'es') { 140 print_window_label = "Opciones de impresión"; 141 print_close_label = "Cerrar opciones de impresión "; 142 print_option_summary = "Sólo la introducción"; 143 print_option_full = "Toda la página incluyendo enlaces"; 144 } 145 $("body").append( 146 '<div id="print-options" class="modal">' 147 +'<div class="modal-background"></div>' 148 +'<div class="modal-card">' 149 +'<header class="modal-card-head">' 150 +'<p class="modal-card-title">'+print_window_label+'</p>' 151 +'<button class="modal-close" role="button" title="'+print_close_label+'" aria-label="'+print_close_label+'"><span aria-hidden="true">X</span></button>' 152 +'</header>' 153 +'<section class="modal-card-body">' 154 +'<button id="print-summary-btn" role="button">'+print_option_summary+'</button>' 155 +'<button id="print-full-btn" role="button">'+print_option_full+'</button>' 156 +'</section>' 157 +'</div>' 158 +'</div>' 159 ); 160 var printmodal = $("#print-options"); 161 var printbutton = $(".mplus_print"); 162 function modalClose(button, modal) { 163 $('#mplus-wrap :focusable, #'+modal.attr('id')+' :focusable').removeAttr('tabindex'); 164 $('[role="button"]').attr('tabindex', '0'); 165 modal.hide() 166 $(button).focus(); 167 } 168 function modalOpen(button, modal) { 169 modal.show(); 170 $(".modal-background").click(function(e) { 171 modalClose(button, modal); 172 }); 173 $(".modal-close").focus(); 174 $('#'+modal.attr('id')+' :focusable').attr('tabindex', '1'); 175 $('#mplus-wrap :focusable').attr('tabindex', '-1'); 176 $( document ).on( 'keydown', function ( e ) { 177 if ( e.keyCode === 27 ) { // ESC 178 modalClose(button, modal); 179 } 180 }); 181 } 182 183 $(".modal-close").click(function(e) { 184 modalClose(printbutton, printmodal); 185 }); 186 $("#print-summary-btn").click(function(e) { 187 modalClose(printbutton, printmodal); 188 // add class to hide all other links in print 189 $("#mplus-content").addClass("print-summary-only"); 190 window.print(); 191 e.preventDefault(); 192 }); 193 $("#print-full-btn").click(function(e) { 194 modalClose(printbutton, printmodal); 195 //remove class to show all other links in print 196 $("#mplus-content").removeClass("print-summary-only"); 197 window.print(); 198 e.preventDefault(); 199 }); 200 $(printbutton).click(function(e) { 201 modalOpen(printbutton, printmodal); 202 }); 203 } 204 else { 205 $( ".mplus_print" ).click(function(e) { 206 window.print(); 207 e.preventDefault(); 208 }); 209 } 210 211 } 212 213 //Facebook Share 214 if(share_buttons["facebook"]) { 215 var facebook_label = "Facebook"; 216 //Create Facebook Button 217 share.append( 218 '<span>' 219 +'<a class="share-facebook" title="'+facebook_label+'" href="#">' 220 +'<img alt="'+facebook_label+'" class="share-icon" src="'+root_url+'/images/i_share_fb.png"/>' 221 +'</a>' 222 +'</span> ' 223 ); 224 //Facebook Event 225 $(".share-facebook").click(function(event) { 226 var appid = "1042245625821448"; 227 if (page_lang == "es") { 228 appid = "824697010995507"; 229 } 230 var fb_url = "https://www.facebook.com/dialog/share?app_id="+encodeURIComponent(appid)+"&display=popup&href=" 231 +encodeURIComponent(page_url+"?utm_source=facebook&utm_medium=share&utm_campaign=mplus_share");
232 window.open(fb_url, 'sharer', 'top='+((screen.height / 2) - (400 / 2))+', left='+((screen.width / 2) - (600 / 2)) 233 +', toolbar=0, status=0, width='+600+', height='+400); 234 event.preventDefault(); 235 }); 236 } 237 238 //Twitter Share 239 if(share_buttons["twitter"]) { 240 var twitter_label = "X"; 241 //Create Twitter Button 242 share.append( 243 '<span>' 244 +'<a class="share-twitter" title="'+twitter_label+'" href="#">' 245 +'<img alt="'+twitter_label+'" class="share-icon" src="'+root_url+'/images/i_share_twitter.png"/>' 246 +'</a>' 247 +'</span> ' 248 ); 249 //Twitter Event 250 $(".share-twitter").click(function(event) { 251 var tw_url = "https://twitter.com/intent/tweet?text="+encodeURIComponent(page_title)+"&url=" 252 +encodeURIComponent(page_url+"?utm_source=twitter&utm_medium=share&utm_campaign=mplus_share"); 253 window.open(tw_url, 'sharer', 'top='+((screen.height / 2) - (400 / 2))+', left='+((screen.width / 2) - (600 / 2)) 254 +', toolbar=0, status=0, width='+600+', height='+400); 255 event.preventDefault(); 256 }); 257 } 258 259 //Pinterest Pin 260 if(share_buttons["pinterest"]) { 261 var pinterest_label = "Pinterest"; 262 var pinterest_img = $('meta[property="og:image"]').attr('content'); 263 if (pinterest_img == undefined) { 264 if(page_lang == 'es') { 265 pinterest_img = 'https://medlineplus.gov/images/mplus_fb_sp.png'; 266 } 267 else { 268 pinterest_img = 'https://medlineplus.gov/images/mplus_fb.png'; 269 } 270 } 271 //Create Pinterest Buttonbutton 272 share.append( 273 '<span>' 274 +'<a class="share-pinterest" title="'+pinterest_label+'" href="#">' 275 +'<img alt="'+pinterest_label+'" class="share-icon" src="'+root_url+'/images/i_share_pinterest.png"/>' 276 +'</a>' 277 +'</span> ' 278 ); 279 //PinterestEvent 280 $(".share-pinterest").click(function(event) { 281 var pin_url = "https://pinterest.com/pin/create/button/" 282 +"?url="+encodeURIComponent(page_url+"?utm_source=pinterest&utm_medium=share&utm_campaign=mplus_share") 283 +"&media="+encodeURIComponent(pinterest_img) 284 +"&description="+encodeURIComponent(page_title); 285 window.open(pin_url, 'sharer', 'top='+((screen.height / 2) - (600 / 2))+', left='+((screen.width / 2) - (774 / 2)) 286 +', toolbar=0, status=0, width='+774+', height='+600); 287 event.preventDefault(); 288 }); 289 } 290 291 //RSS Share 292 if(share_buttons["rss"]){ 293 //English 294 var rss_label = "Subscribe to RSS"; 295 //Spanish 296 if(page_lang == 'es') { 297 rss_label = "SuscrÃbase al RSS"; 298 } 299 300 if (page_id === 'whats_new') { 301 if (page_lang === 'es') { 302 var rss_url = 'https://medlineplus.gov/spanish/feeds/whatsnew.xml' 303 } else { 304 var rss_url = 'https://medlineplus.gov/feeds/whatsnew.xml' 305 } 306 307 } else { 308 var rss_url = $('link[type="application/rss+xml"]').attr("href"); 309 } 310 311 //Create RSS Button 312 if (rss_url != undefined) { 313 share.append( 314 '<span>' 315 +'<a class="rss_feed_icon" title="'+rss_label+'" href="'+rss_url+'">' 316 +'<img class="share-icon" alt="'+rss_label+'" src="'+root_url+'/images/i_share_rss.png"/>' 317 +'</a>' 318 +'</span> ' 319 ); 320 } 321 322 } 323 //Pdf Share 324 if(share_buttons["pdf"]) { 325 var lang = $("html").attr("lang"); 326 var st = { 327 'es':{'ghr':'genetica','download':'download/spanish/genetica','pdf_label':'Descargar PDF','uri':'genetica/entender/'}, 328 'en':{'ghr':'genetics','download':'download/genetics','pdf_label':'Download PDF','uri':'genetics/understanding/'} 329 }; 330 //English 331 var pdf_label = st[lang]['pdf_label']; 332 var pdf_url = window.location.protocol+'//'+window.location.host+window.location.pathname; 333 pdf_url = pdf_url.replace('index.html',''); 334 pdf_url = pdf_url.replace('/spanish/','/'); 335 var hmug = pdf_url.split(st[lang]['uri']); 336 var name; 337 if (1!=hmug.length) { 338 var s1 = hmug.shift(); 339 hmug = hmug[0].split('/')[0]; 340 name = (''==hmug)?'primer.pdf':hmug + '.pdf'; 341 pdf_url = s1 + st[lang]['uri'] + name; 342 pdf_url = pdf_url.replace(st[lang]['ghr'],st[lang]['download']); 343 } 344 else { 345 pdf_url = pdf_url.replace(st[lang]['ghr'],st[lang]['download']); 346 if ('/'==pdf_url[pdf_url.length-1]) { 347 pdf_url = pdf_url.slice(0,-1); 348 } 349 var arr = pdf_url.split('/'); 350 name = arr[arr.length-2]; 351 pdf_url = pdf_url + ".pdf"; 352 } 353 //Create PDF Button 354 share.append( 355 '<span>' 356 +'<a target="PDFWin" class="pdf_icon" title="'+pdf_label+'" href="'+pdf_url+'">' 357 +'<img alt="'+pdf_label+'" class="share-icon" src="'+root_url+'/images/i_share_pdf.png"/>' 358 +'</a>' 359 +'</span> ' 360 ); 361 } 362 $(share).show() 363 } 364 365})(jQuery);
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.