-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from Kitcham/canary
feat(comments): add "Disqus_click_to_load" to improve in-GFW-users
- Loading branch information
Showing
13 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<div id="disqus_thread"></div> | ||
<!-- include js --> | ||
<script src="/js/ripple.js"></script> | ||
|
||
<!-- add animation --> | ||
<style> | ||
.ripple-container { | ||
} | ||
.ripple-container .ripple{ | ||
background-color: rgba(255,255,255,0.4); | ||
animation: ripple 2s forwards cubic-bezier(0, 0, 0.2, 1); | ||
} | ||
@keyframes ripple { | ||
0% { | ||
transform: scale(0); | ||
opacity: 1; | ||
} | ||
80% { | ||
transform: scale(1); | ||
} | ||
100% { | ||
opacity: 0; | ||
} | ||
} | ||
button { | ||
background-color: dodgerblue; | ||
color: white; | ||
padding: 10px 20px; | ||
border:0; | ||
font-size: 14px; | ||
cursor: pointer | ||
} | ||
</style> | ||
|
||
<!-- add data-ripple attribute --> | ||
<div class="btn1"> | ||
<button data-ripple><%= __('post.comments_load_button') %></button> | ||
</div> | ||
|
||
<script> | ||
// add effect to elements | ||
Array.prototype.forEach.call(document.querySelectorAll('[data-ripple]'), function(element){ | ||
// find all elements and attach effect | ||
new RippleEffect(element); // element is instance of javascript element node | ||
}); | ||
</script> | ||
|
||
<script> | ||
$('html').ready(function() { | ||
$(".btn1").click(function() { //click to load comments | ||
var disqus_config = function () { | ||
this.page.url = '<%- config.url + url_for(path) %>'; // Replace PAGE_URL with your page's canonical URL variable | ||
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable | ||
}; | ||
(function() { // DON'T EDIT BELOW THIS LINE | ||
var d = document; | ||
var s = d.createElement('script'); | ||
s.src = '//<%= theme.comment.shortname %>.disqus.com/embed.js'; | ||
s.setAttribute('data-timestamp', + new Date()); | ||
(d.head || d.body).appendChild(s); | ||
})(); | ||
}); | ||
}); | ||
</script> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* | ||
* | ||
*/ | ||
function RippleEffect(element){ | ||
this.element = element; | ||
this.element.addEventListener('click', this.run.bind(this), false); | ||
} | ||
RippleEffect.prototype = { | ||
run: function(event){ | ||
var ripplerContainer = this.element.querySelector('.ripple-container'); | ||
var offsetInfo = this.element.getBoundingClientRect(); | ||
if(ripplerContainer) { | ||
ripplerContainer.remove(); | ||
} | ||
var rippleContainer = document.createElement('div'); | ||
rippleContainer.style.position = 'fixed'; | ||
rippleContainer.style.zIndex = 99; | ||
rippleContainer.style.width = offsetInfo.width + 'px'; | ||
rippleContainer.style.left = offsetInfo.left + 'px'; | ||
rippleContainer.style.top = offsetInfo.top + 'px'; | ||
rippleContainer.style.height = offsetInfo.height + 'px'; | ||
rippleContainer.className = 'ripple-container'; | ||
rippleContainer.style.overflow = 'hidden'; | ||
this.element.appendChild(rippleContainer); | ||
|
||
// fixed the bug | ||
var maxLength = offsetInfo.width > offsetInfo.height ? offsetInfo.width : offsetInfo.height; | ||
var circleD = maxLength * 2; | ||
|
||
var ripple = document.createElement('div'); | ||
ripple.style.position = 'absolute'; | ||
ripple.style.width = circleD + 'px'; | ||
ripple.style.height = circleD + 'px'; | ||
ripple.style.borderRadius = '500px'; | ||
ripple.style.left = ((event.pageX - offsetInfo.left) - circleD/2) + 'px'; | ||
ripple.style.top = ((event.pageY - offsetInfo.top) - circleD/2) + 'px'; | ||
ripple.className = 'ripple'; | ||
rippleContainer.appendChild(ripple); | ||
ripple.addEventListener('animationend', function(){ | ||
rippleContainer.remove(); | ||
}.bind(this), false); | ||
} | ||
}; |