diff options
Diffstat (limited to 'layouts/partials/article_footer.html')
-rw-r--r-- | layouts/partials/article_footer.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/layouts/partials/article_footer.html b/layouts/partials/article_footer.html index 9aa84e2..582ac22 100644 --- a/layouts/partials/article_footer.html +++ b/layouts/partials/article_footer.html @@ -7,4 +7,69 @@ {{with .Site.Data.l10n.articles.comments}}{{.}}{{end}} </a> {{end}} + + <script> + (function ($) { + // Prevent duplicate binding + if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) { + __SHARE_BUTTON_BINDED__ = true; + } else { + return; + } + $('body').on('click', function() { + $('.article-share-box.on').removeClass('on'); + }).on('click', '.article-share-link', function(e) { + e.stopPropagation(); + + var $this = $(this), + url = $this.attr('data-url'), + encodedUrl = encodeURIComponent(url), + id = 'article-share-box-' + $this.attr('data-id'), + offset = $this.offset(), + box; + + if ($('#' + id).length) { + box = $('#' + id); + + if (box.hasClass('on')){ + box.removeClass('on'); + return; + } + } else { + var html = [ + '<div id="' + id + '" class="article-share-box">', + '<input class="article-share-input" value="' + url + '">', + '<div class="article-share-links">', + '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>', + '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>', + '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>', + '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>', + '</div>', + '</div>' + ].join(''); + + box = $(html); + + $('body').append(box); + } + + $('.article-share-box.on').hide(); + + box.css({ + top: offset.top + 25, + left: offset.left + }).addClass('on'); + + }).on('click', '.article-share-box', function (e) { + e.stopPropagation(); + }).on('click', '.article-share-box-input', function () { + $(this).select(); + }).on('click', '.article-share-box-link', function (e) { + e.preventDefault(); + e.stopPropagation(); + + window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450'); + }); + })(jQuery); + </script> </footer> |