Last active
December 24, 2015 08:29
-
-
Save alejandro/6771308 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 root_url = "website url" | |
, page_id = window.location.href | |
, disqus_identifier = page_id | |
, disqus_title = Em.$('title').text() | |
, disqus_url = page_id | |
, disqus_shortname = 'disqus shortname' | |
, el_id = disqus_shortname + Date.now() | |
this.set('page_id', el_id) | |
!function() { | |
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