1
0
mirror of https://github.com/mbirth/wiki.git synced 2024-11-13 13:56:46 +00:00
wiki.mbirth.de/javascripts/comments.coffee

38 lines
1.2 KiB
CoffeeScript
Raw Normal View History

---
---
$(document).ready ->
2015-06-28 16:37:34 +01:00
$('ul#comments-tabs li').not('.static').click ->
addScript = (script) ->
scr = document.createElement 'script'
scr.type = 'text/javascript'
scr.async = true
scr.src = script
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild scr
tab_id = $(this).attr 'data-div'
2015-06-28 22:15:28 +01:00
service = $(this).attr 'data-service'
switch service
when 'disqus'
# load Disqus
addScript("//#{disqus_shortname}.disqus.com/embed.js")
2015-06-28 22:15:28 +01:00
$(this).removeAttr 'data-service'
when 'google'
# load Google+
addScript('//apis.google.com/js/plusone.js')
$(this).removeAttr 'data-service'
when 'spotim'
# load spot.im
addScript('//www.spot.im/launcher/bundle.js')
2015-06-28 22:15:28 +01:00
$(this).removeAttr 'data-service'
2015-06-28 23:09:06 +01:00
$('ul#comments-tabs li.hint').remove()
2015-06-28 23:07:45 +01:00
$('ul#comments-tabs li').removeClass 'current'
$('.comments-tab').removeClass 'current'
$(this).addClass 'current'
$("##{tab_id}").addClass 'current'