1gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) { 2 var SITES = { 3 'github': { 4 'label': 'Github', 5 'icon': 'fa fa-github', 6 'onClick': function(e) { 7 e.preventDefault(); 8 var repo = $('meta[name="github-repo"]').attr('content'); 9 if (typeof repo === 'undefined') throw("Github repo not defined"); 10 window.open("https://github.com/"+repo); 11 } 12 }, 13 'facebook': { 14 'label': 'Facebook', 15 'icon': 'fa fa-facebook', 16 'onClick': function(e) { 17 e.preventDefault(); 18 window.open("http://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(location.href)); 19 } 20 }, 21 'twitter': { 22 'label': 'Twitter', 23 'icon': 'fa fa-twitter', 24 'onClick': function(e) { 25 e.preventDefault(); 26 window.open("http://twitter.com/intent/tweet?text="+document.title+"&url="+encodeURIComponent(location.href)+"&hashtags=rmarkdown,bookdown"); 27 } 28 }, 29 'linkedin': { 30 'label': 'LinkedIn', 31 'icon': 'fa fa-linkedin', 32 'onClick': function(e) { 33 e.preventDefault(); 34 window.open("https://www.linkedin.com/shareArticle?mini=true&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title)); 35 } 36 }, 37 'weibo': { 38 'label': 'Weibo', 39 'icon': 'fa fa-weibo', 40 'onClick': function(e) { 41 e.preventDefault(); 42 window.open("http://service.weibo.com/share/share.php?content=utf-8&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title)); 43 } 44 }, 45 'instapaper': { 46 'label': 'Instapaper', 47 'icon': 'fa fa-italic', 48 'onClick': function(e) { 49 e.preventDefault(); 50 window.open("http://www.instapaper.com/text?u="+encodeURIComponent(location.href)); 51 } 52 }, 53 'vk': { 54 'label': 'VK', 55 'icon': 'fa fa-vk', 56 'onClick': function(e) { 57 e.preventDefault(); 58 window.open("http://vkontakte.ru/share.php?url="+encodeURIComponent(location.href)); 59 } 60 } 61 }; 62 63 64 65 gitbook.events.bind("start", function(e, config) { 66 var opts = config.sharing; 67 if (!opts) return; 68 69 // Create dropdown menu 70 var menu = _.chain(opts.all) 71 .map(function(id) { 72 var site = SITES[id]; 73 if (!site) return; 74 return { 75 text: site.label, 76 onClick: site.onClick 77 }; 78 }) 79 .compact() 80 .value(); 81 82 // Create main button with dropdown 83 if (menu.length > 0) { 84 gitbook.toolbar.createButton({ 85 icon: 'fa fa-share-alt', 86 label: 'Share', 87 position: 'right', 88 dropdown: [menu] 89 }); 90 } 91 92 // Direct actions to share 93 _.each(SITES, function(site, sideId) { 94 if (!opts[sideId]) return; 95 96 gitbook.toolbar.createButton({ 97 icon: site.icon, 98 label: site.label, 99 title: site.label, 100 position: 'right', 101 onClick: site.onClick 102 }); 103 }); 104 }); 105});
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.