mirror of
https://github.com/wassname/talk.git
synced 2026-09-12 13:01:11 +08:00
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:
committed by
Dan Zajdband
parent
3033abaa88
commit
ef172cabfc
+20
-8
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user