summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-16 09:42:17 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-16 09:42:17 +1100
commit1d7381554d3647c92db3b8b1b1f7a96d6f2653dd (patch)
tree6b6b36a9ef984933f1a8aa8393b848d29aacf4de /js
parenta5739602296251b698aab834205829ac37edca1b (diff)
Don't show post when it's already in view. Highlight it instead.
Diffstat (limited to 'js')
-rw-r--r--js/post-hover.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/js/post-hover.js b/js/post-hover.js
index 06dd55a2..335e3ac4 100644
--- a/js/post-hover.js
+++ b/js/post-hover.js
@@ -20,17 +20,26 @@ $(document).ready(function(){
}
var post = $('div.post#reply_' + id);
+ if(post.length == 0)
+ return;
+
$(this).hover(function(e) {
- post.clone()
- .attr('id', 'post-hover-' + id)
- .addClass('post-hover')
- .css('position', 'absolute')
- .css('left', e.pageX + 15)
- .css('top', e.pageY - post.height() - 15)
- .css('border-style', 'solid')
- .css('box-shadow', '1px 1px 1px #999')
- .insertAfter($(this).parent());
+ if($(window).scrollTop() <= post.offset().top + post.height()) {
+ // post is in view
+ post.attr('style', 'border-style: none dashed dashed none; background: ' + post.css('border-right-color'));
+ } else {
+ post.clone()
+ .attr('id', 'post-hover-' + id)
+ .addClass('post-hover')
+ .css('position', 'absolute')
+ .css('left', e.pageX + 15)
+ .css('top', e.pageY - post.height() - 15)
+ .css('border-style', 'solid')
+ .css('box-shadow', '1px 1px 1px #999')
+ .insertAfter($(this).parent());
+ }
}, function() {
+ post.attr('style', '');
$('.post-hover').remove();
}).mousemove(function(e) {
$('#post-hover-' + id)