1
0
mirror of https://github.com/mbirth/wiki.git synced 2024-11-09 13:16:45 +00:00

Load comment scripts on first click.

This commit is contained in:
Markus Birth 2015-06-28 23:15:28 +02:00
parent f7a0ca6069
commit 60f10bbdc6
2 changed files with 24 additions and 13 deletions

View File

@ -1,29 +1,20 @@
<ul id="comments-tabs">
<li class="static">Comments:</li>
<li class="current" data-div="comments_disqus">Disqus</li>
<li data-div="comments_google">Google+</li>
<li data-service="disqus" data-div="comments_disqus">Disqus</li>
<li data-service="google" data-div="comments_google">Google+</li>
</ul>
<div id="comments_disqus" class="comments-tab current">
<div id="disqus_thread"></div>
<div id="comments_disqus" class="comments-tab">
<div id="disqus_thread">Loading <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus</a></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES * * */
var disqus_shortname = 'mb-wiki';
var disqus_identifier = '{% if page.id %}{{ page.id }}{% else %}/index{% endif %}';
var disqus_title = '{{ page.title }}';
var disqus_url = '{{ site.url }}{{ page.url }}';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
</div>
<div id="comments_google" class="comments-tab">
<script src="//apis.google.com/js/plusone.js" type="text/javascript"></script>
<div class="g-comments" data-href="{{ site.url }}{{ page.url }}" data-width="868" data-first_party_property="BLOGGER" data-view_type="FILTERED_POSTMOD">Loading Google+ comments…</div>
</div>

View File

@ -3,6 +3,26 @@
$(document).ready ->
$('ul#comments-tabs li').not('.static').click ->
tab_id = $(this).attr 'data-div'
service = $(this).attr 'data-service'
switch service
when 'disqus'
# load Disqus
dsq = document.createElement 'script'
dsq.type = 'text/javascript'
dsq.async = true
dsq.src = "//#{disqus_shortname}.disqus.com/embed.js"
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild dsq
$(this).removeAttr 'data-service'
when 'google'
# load Google+
gog = document.createElement 'script'
gog.type = 'text/javascript'
gog.async = true
gog.src = '//apis.google.com/js/plusone.js'
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild gog
$(this).removeAttr 'data-service'
$('ul#comments-tabs li').removeClass 'current'
$('.comments-tab').removeClass 'current'