-
-
Save givanse/a3b945a47438d7119989 to your computer and use it in GitHub Desktop.
A Disqus component for Ember.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.CDisqusComponent = Em.Component.extend({ | |
didInsertElement: function () { | |
var page_id = window.location.href, | |
disqus_identifier = page_id, | |
disqus_url = page_id, | |
disqus_title = Em.$('title').text(), | |
disqus_shortname = 'disqus shortname', // CHANGE, USE YOURS | |
el_id = disqus_shortname + Date.now(); | |
this.set('page_id', el_id); | |
var dsq = document.createElement('script'); | |
dsq.type = 'text/javascript'; | |
dsq.async = true; | |
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js'; | |
dsq.id = el_id; | |
(document.getElementsByTagName('head')[0] || | |
document.getElementsByTagName('body')[0]).appendChild(dsq); | |
}, | |
willDestroyElement: function () { | |
Em.$('#' + this.get('page_id')).remove(); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment