diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-20 11:29:26 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-20 11:29:26 +0100 |
commit | 238cd9f7f09f11ecdb1717a5d07fc33642d29043 (patch) | |
tree | 72eac94839bda4f32cb41441b2b88532eed52603 /theme/javascript/utils/sharing.js | |
parent | bac25cdf297a7fa54f21977aa17d455e439cdf51 (diff) | |
download | gitbook-238cd9f7f09f11ecdb1717a5d07fc33642d29043.zip gitbook-238cd9f7f09f11ecdb1717a5d07fc33642d29043.tar.gz gitbook-238cd9f7f09f11ecdb1717a5d07fc33642d29043.tar.bz2 |
Add back theme
Diffstat (limited to 'theme/javascript/utils/sharing.js')
-rwxr-xr-x | theme/javascript/utils/sharing.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/theme/javascript/utils/sharing.js b/theme/javascript/utils/sharing.js new file mode 100755 index 0000000..f27e4a4 --- /dev/null +++ b/theme/javascript/utils/sharing.js @@ -0,0 +1,36 @@ +define([ + "jQuery" +], function($) { + var types = { + "twitter": function($el) { + window.open("http://twitter.com/home?status="+encodeURIComponent($("title").text()+" "+location.href)) + }, + "facebook": function($el) { + window.open("http://www.facebook.com/sharer/sharer.php?s=100&p[url]="+encodeURIComponent(location.href)) + }, + "google-plus": function($el) { + window.open("https://plus.google.com/share?url="+encodeURIComponent(location.href)) + }, + "weibo": function($el) { + window.open("http://service.weibo.com/share/share.php?content=utf-8&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent($("title").text())) + }, + "instapaper": function($el) { + window.open("http://www.instapaper.com/text?u="+encodeURIComponent(location.href)); + } + }; + + + // Bind all sharing button + var init = function() { + $(document).on("click", "a[data-sharing],button[data-sharing]", function(e) { + if (e) e.preventDefault(); + var type = $(this).data("sharing"); + + types[type]($(this)); + }) + }; + + return { + init: init + }; +}); |