-
-
Save JanTvrdik/4202718 to your computer and use it in GitHub Desktop.
Return to the position before expanding
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
<script> | |
/** | |
* @author Chamurappi | |
* @param {DOMElement} element | |
* @return {function()} callback for restoring saved position | |
*/ | |
function savePosition(element) | |
{ | |
if (!element.getBoundingClientRect) return function(){}; | |
var top = element.getBoundingClientRect().top; | |
return function() { | |
window.scrollBy(0, element.getBoundingClientRect().top - top); | |
}; | |
} | |
$(document).ready(function() { | |
$('.showcomm').on('click', function() { | |
var topic = $(this).closest('.topic'); | |
var restorePosition = savePosition(topic[0]); | |
topic.find('.comments-all, .comments-marked, .closecommin, .showcommin').slideToggle(500, restorePosition); | |
return false; | |
}); | |
var keywords = {$highlightKeywords}; | |
var message = $('.message'); | |
for (var i = 0; i < keywords.length; i++) { | |
message.highlight(keywords[i]); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment