Created
June 29, 2012 21:04
-
-
Save bjornstar/3020644 to your computer and use it in GitHub Desktop.
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
Event.observe(window, 'dom:loaded', function () { | |
$$('.post .pin').each(function (pin) { | |
var up, down; | |
Event.observe(pin, 'mouseenter', function (event) { | |
clearInterval(down); | |
var step = 1; | |
up = window.setInterval(function () { | |
if (step == 11) { | |
clearInterval(up); | |
return | |
} | |
pin.addClassName('step_' + step); | |
step++ | |
}, | |
10) | |
}); | |
Event.observe(pin, 'mouseleave', function (event) { | |
clearInterval(up); | |
var step = 10; | |
down = window.setInterval(function () { | |
if (step == 1) { | |
clearInterval(down); | |
return | |
} | |
pin.removeClassName('step_' + step); | |
step-- | |
}, | |
10) | |
}); | |
Event.observe(pin, 'click', function (event) { | |
clearInterval(up); | |
clearInterval(down); | |
Event.stopObserving(pin); | |
pin.addClassName('unpinned'); | |
var post = pin.up('li'); | |
var clone = post.cloneNode(false); | |
clone.removeClassName('promotion_pinned').addClassName('promotion_pinned_clone'); | |
var bottom_margin = parseInt(post.getStyle('marginBottom'), 10) ? 10 : 0; | |
clone.style.height = post.getHeight() + parseInt(post.getStyle('marginTop'), 10) + bottom_margin + 'px'; | |
post.addClassName('unpinned'); | |
post.insert({ | |
after: clone | |
}); | |
var form_key = $('form_key') && $('form_key').value; | |
new Ajax.Request('/unpin', { | |
method: 'post', | |
parameters: { | |
post_id: post.id.replace('post_', ''), | |
form_key: form_key | |
} | |
}); | |
setTimeout(function () { | |
post.addClassName('falloff'); | |
setTimeout(function () { | |
post.addClassName('falloff_animated'); | |
clone.addClassName('collapse'); | |
setTimeout(function () { | |
post.remove() | |
}, | |
800); | |
setTimeout(function () { | |
clone.remove() | |
}, | |
2000) | |
}, | |
0) | |
}, | |
300) | |
}) | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment