Skip to content

Instantly share code, notes, and snippets.

@tajo
Created December 4, 2012 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tajo/4201256 to your computer and use it in GitHub Desktop.
Save tajo/4201256 to your computer and use it in GitHub Desktop.
Return to the position before expanding
<script>
function saveLoc(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');
saveLoc(topic[0]);
topic.find('.comments-all, .comments-marked, .closecommin, .showcommin').slideToggle();
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