summaryrefslogtreecommitdiff
path: root/js/post-hover.js
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-18 23:55:01 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-18 23:55:01 +1100
commit21a1152ebead57c60c76c341d4f8ec8bc737949b (patch)
treed4fbc7268872167d1377f67427773f48ecfcaf0a /js/post-hover.js
parent8208d7151bc952462c9220304877525dcc398cea (diff)
custom event for new posts, so auto-reload.js etc will work with forced-anon.js and post-hover.js
Diffstat (limited to 'js/post-hover.js')
-rw-r--r--js/post-hover.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/js/post-hover.js b/js/post-hover.js
index f6ac69aa..c76ca0d8 100644
--- a/js/post-hover.js
+++ b/js/post-hover.js
@@ -13,17 +13,19 @@
$(document).ready(function(){
var dont_fetch_again = [];
- $('p.body a:not([rel="nofollow"])').each(function() {
+ var init_hover = function() {
+ var link = $(this);
+
var id;
- if(id = $(this).text().match(/^>>(\d+)$/)) {
+ if(id = $(link).text().match(/^>>(\d+)$/)) {
id = id[1];
}
var post = false;
var hovering = false;
var hovered_at;
- $(this).hover(function(e) {
+ $(link).hover(function(e) {
hovering = true;
hovered_at = {'x': e.pageX, 'y': e.pageY};
@@ -52,7 +54,7 @@ $(document).ready(function(){
start_hover(this);
} else {
var link = this;
- var url = $(this).attr('href').replace(/#.*$/, '');
+ var url = $(link).attr('href').replace(/#.*$/, '');
if($.inArray(url, dont_fetch_again) != -1) {
return;
@@ -64,13 +66,10 @@ $(document).ready(function(){
context: document.body,
success: function(data) {
$(data).find('div.post.reply').each(function() {
- if($('#' + $(this).attr('id')).length == 0)
- $('div.post:first').prepend($(this).css('display', 'none').addClass('hidden'));
+ if($('#' + $(link).attr('id')).length == 0)
+ $('div.post:first').prepend($(link).css('display', 'none').addClass('hidden'));
});
- if(typeof window.enable_fa == 'function' && localStorage['forcedanon'])
- enable_fa();
-
post = $('div.post#reply_' + id);
if(hovering && post.length > 0)
start_hover(link);
@@ -105,6 +104,13 @@ $(document).ready(function(){
hover.css('left', (e.pageX ? e.pageX : hovered_at['x'])).css('top', top);
});
+ };
+
+ $('p.body a:not([rel="nofollow"])').each(init_hover);
+
+ // allow to work with auto-reload.js, etc.
+ $(document).bind('new_post', function(e, post) {
+ $(post).find('p.body a:not([rel="nofollow"])').each(init_hover);
});
});