Skip to content

Instantly share code, notes, and snippets.

@harentius
Created August 17, 2016 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harentius/5c7b611838c469c82dbb3513dc020297 to your computer and use it in GitHub Desktop.
Save harentius/5c7b611838c469c82dbb3513dc020297 to your computer and use it in GitHub Desktop.
((global, $) ->
'use strict'
$(() ->
initialized = { '#vk-comments': false, '#disqus_thread': false }
initComments = (type) ->
return if initialized[type]
pageUrl = 'page_url'
switch type
when '#disqus_thread'
# You need to set this params using your platform's appropriate way
discussUserName = 'discussUserName'
disqus_config = () ->
@.page.url = pageUrl
@.page.identifier = 'page_identifier'
(() ->
d = document
s = d.createElement('script')
s.src = "//#{discussUserName}.disqus.com/embed.js"
s.setAttribute('data-timestamp', +new Date())
(d.head || d.body).appendChild(s)
)()
when '#vk-comments'
VK.Widgets.Comments(
"vk-comments",
{ limit: 5, attach: "*", pageUrl: pageUrl }
)
else return
initialized[type] = true
$tabToggler = $('.comments-wrapper a[data-toggle="tab"]')
$tabToggler.on('shown.bs.tab', (e) ->
initComments($(e.target).attr("href"))
)
initComments($tabToggler.closest('.active').find('a[data-toggle="tab"]').attr('href'))
)
)(window, jQuery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment