Skip to content

Instantly share code, notes, and snippets.

Forked from tajo/returning
Created December 4, 2012 11:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Return to the position before expanding
* @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++) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment