Scroll to comment (#92)

* host pym locally

* host pym. fix some permalink styles

* get url from parent document

* reset copy dialog timeout

* use pym.parentUrl instead of depending on the parent document

* use a simpler method to find the url

* add some horrible setInterval code

* add some awesome polling

* merge master

* bail out of comment look up after 10 seconds

* re-update permalink attrs

* re-add my listeners to article.ejs

* allow for overriding the talk db name in an environment var
This commit is contained in:
Riley Davis
2016-11-29 17:19:56 -05:00
committed by Dan Zajdband
parent 3033abaa88
commit ef172cabfc
13 changed files with 145 additions and 74 deletions
+20 -8
View File
@@ -32,13 +32,25 @@
<div id='coralStreamEmbed'></div>
</main>
<!--- Script --->
<script type='text/javascript' src='https://pym.nprapps.org/pym.v1.min.js'></script>
<script>
var pymParent = new pym.Parent('coralStreamEmbed', '/embed/stream', {title: 'Talk Comments'});
pymParent.onMessage('height', function(height) {
document.querySelector('#coralStreamEmbed iframe').height = height + 'px';
});
</script>
<script type='text/javascript' src='<%= basePath %>/pym.v1.min.js'></script>
<script>
var ready = false;
var pymParent = new pym.Parent('coralStreamEmbed', '/embed/stream', {title: 'Talk Comments'});
pymParent.onMessage('height', function(height) {document.querySelector('#coralStreamEmbed iframe').height = height + 'px'})
pymParent.onMessage('childReady', function () {
var interval = setInterval(function () {
if (ready) {
window.clearInterval(interval);
pymParent.sendMessage('DOMContentLoaded', window.location.hash);
}
}, 100);
});
// wait till images and other iframes are loaded before scrolling the page.
// or do we want to be more aggressive and scroll when we hit DOM ready?
document.addEventListener('DOMContentLoaded', function () {
ready = true;
});
</script>
</body>
</html>