Merge Mayhem X

This commit is contained in:
Jordan Bates 2013-05-27 16:14:36 -07:00
commit 33c1d58d5f
5 changed files with 79 additions and 60 deletions

View File

@ -1436,18 +1436,22 @@
return Polyfill.visibility(); return Polyfill.visibility();
}, },
visibility: function() { visibility: function() {
var event, prefix, property; if (!('webkitHidden' in document)) {
if ('visibilityState' in document || !(prefix = ('webkitVisibilityState' in document ? 'webkit' : 'mozVisibilityState' in document ? 'moz' : void 0))) {
return; return;
} }
property = prefix + 'VisibilityState'; Object.defineProperties(HTMLDocument.prototype, {
event = prefix + 'visibilitychange'; visibilityState: {
d.visibilityState = d[property]; get: function() {
d.hidden = d.visibilityState === 'hidden'; return this.webkitVisibilityState;
return $.on(d, event, function() { }
d.visibilityState = d[property]; },
d.hidden = d.visibilityState === 'hidden'; hidden: {
get: function() {
return this.webkitHidden;
}
}
});
return $.on(d, 'webkitvisibilitychange', function() {
return $.event('visibilitychange'); return $.event('visibilitychange');
}); });
} }
@ -3821,12 +3825,16 @@
return Unread.readSinglePost(post); return Unread.readSinglePost(post);
}, },
rm: function(quotelink, boardID, threadID, postID, context) { rm: function(quotelink, boardID, threadID, postID, context) {
var el, inlined, isBacklink, post, root, _ref; var el, inlined, isBacklink, post, qroot, root, _ref;
isBacklink = $.hasClass(quotelink, 'backlink'); isBacklink = $.hasClass(quotelink, 'backlink');
root = QuoteInline.findRoot(quotelink, isBacklink); root = QuoteInline.findRoot(quotelink, isBacklink);
root = $.x("following-sibling::div[@id='i" + postID + "'][1]", root); root = $.x("following-sibling::div[@id='i" + postID + "'][1]", root);
qroot = $.x('ancestor::*[contains(@class,"postContainer")][1]', root);
$.rm(root); $.rm(root);
if (!$('.inline', qroot)) {
$.rmClass(qroot, 'hasInline');
}
if (!(el = root.firstElementChild)) { if (!(el = root.firstElementChild)) {
return; return;
} }
@ -9030,7 +9038,7 @@
} }
}, },
hl: function(delta, thread) { hl: function(delta, thread) {
var headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len; var axe, headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len;
if (Conf['Fixed Header'] && Conf['Bottom header']) { if (Conf['Fixed Header'] && Conf['Bottom header']) {
topMargin = 0; topMargin = 0;
@ -9043,7 +9051,8 @@
rect = postEl.getBoundingClientRect(); rect = postEl.getBoundingClientRect();
if (rect.bottom >= topMargin && rect.top <= doc.clientHeight) { if (rect.bottom >= topMargin && rect.top <= doc.clientHeight) {
root = postEl.parentNode; root = postEl.parentNode;
next = $.x('child::div[contains(@class,"post reply")]', delta === +1 ? root.nextElementSibling : root.previousElementSibling); axe = delta === +1 ? 'following' : 'preceding';
next = $.x("" + axe + "-sibling::div[contains(@class,'replyContainer')][1]/child::div[contains(@class,'reply')]", root);
if (!next) { if (!next) {
this.focus(postEl); this.focus(postEl);
return; return;

View File

@ -1432,18 +1432,22 @@
return Polyfill.visibility(); return Polyfill.visibility();
}, },
visibility: function() { visibility: function() {
var event, prefix, property; if (!('webkitHidden' in document)) {
if ('visibilityState' in document || !(prefix = ('webkitVisibilityState' in document ? 'webkit' : 'mozVisibilityState' in document ? 'moz' : void 0))) {
return; return;
} }
property = prefix + 'VisibilityState'; Object.defineProperties(HTMLDocument.prototype, {
event = prefix + 'visibilitychange'; visibilityState: {
d.visibilityState = d[property]; get: function() {
d.hidden = d.visibilityState === 'hidden'; return this.webkitVisibilityState;
return $.on(d, event, function() { }
d.visibilityState = d[property]; },
d.hidden = d.visibilityState === 'hidden'; hidden: {
get: function() {
return this.webkitHidden;
}
}
});
return $.on(d, 'webkitvisibilitychange', function() {
return $.event('visibilitychange'); return $.event('visibilitychange');
}); });
} }
@ -3817,12 +3821,16 @@
return Unread.readSinglePost(post); return Unread.readSinglePost(post);
}, },
rm: function(quotelink, boardID, threadID, postID, context) { rm: function(quotelink, boardID, threadID, postID, context) {
var el, inlined, isBacklink, post, root, _ref; var el, inlined, isBacklink, post, qroot, root, _ref;
isBacklink = $.hasClass(quotelink, 'backlink'); isBacklink = $.hasClass(quotelink, 'backlink');
root = QuoteInline.findRoot(quotelink, isBacklink); root = QuoteInline.findRoot(quotelink, isBacklink);
root = $.x("following-sibling::div[@id='i" + postID + "'][1]", root); root = $.x("following-sibling::div[@id='i" + postID + "'][1]", root);
qroot = $.x('ancestor::*[contains(@class,"postContainer")][1]', root);
$.rm(root); $.rm(root);
if (!$('.inline', qroot)) {
$.rmClass(qroot, 'hasInline');
}
if (!(el = root.firstElementChild)) { if (!(el = root.firstElementChild)) {
return; return;
} }
@ -9024,7 +9032,7 @@
} }
}, },
hl: function(delta, thread) { hl: function(delta, thread) {
var headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len; var axe, headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len;
if (Conf['Fixed Header'] && Conf['Bottom header']) { if (Conf['Fixed Header'] && Conf['Bottom header']) {
topMargin = 0; topMargin = 0;
@ -9037,7 +9045,8 @@
rect = postEl.getBoundingClientRect(); rect = postEl.getBoundingClientRect();
if (rect.bottom >= topMargin && rect.top <= doc.clientHeight) { if (rect.bottom >= topMargin && rect.top <= doc.clientHeight) {
root = postEl.parentNode; root = postEl.parentNode;
next = $.x('child::div[contains(@class,"post reply")]', delta === +1 ? root.nextElementSibling : root.previousElementSibling); axe = delta === +1 ? 'following' : 'preceding';
next = $.x("" + axe + "-sibling::div[contains(@class,'replyContainer')][1]/child::div[contains(@class,'reply')]", root);
if (!next) { if (!next) {
this.focus(postEl); this.focus(postEl);
return; return;

View File

@ -1434,18 +1434,22 @@
return Polyfill.visibility(); return Polyfill.visibility();
}, },
visibility: function() { visibility: function() {
var event, prefix, property; if (!('webkitHidden' in document)) {
if ('visibilityState' in document || !(prefix = ('webkitVisibilityState' in document ? 'webkit' : 'mozVisibilityState' in document ? 'moz' : void 0))) {
return; return;
} }
property = prefix + 'VisibilityState'; Object.defineProperties(HTMLDocument.prototype, {
event = prefix + 'visibilitychange'; visibilityState: {
d.visibilityState = d[property]; get: function() {
d.hidden = d.visibilityState === 'hidden'; return this.webkitVisibilityState;
return $.on(d, event, function() { }
d.visibilityState = d[property]; },
d.hidden = d.visibilityState === 'hidden'; hidden: {
get: function() {
return this.webkitHidden;
}
}
});
return $.on(d, 'webkitvisibilitychange', function() {
return $.event('visibilitychange'); return $.event('visibilitychange');
}); });
} }
@ -3819,12 +3823,16 @@
return Unread.readSinglePost(post); return Unread.readSinglePost(post);
}, },
rm: function(quotelink, boardID, threadID, postID, context) { rm: function(quotelink, boardID, threadID, postID, context) {
var el, inlined, isBacklink, post, root, _ref; var el, inlined, isBacklink, post, qroot, root, _ref;
isBacklink = $.hasClass(quotelink, 'backlink'); isBacklink = $.hasClass(quotelink, 'backlink');
root = QuoteInline.findRoot(quotelink, isBacklink); root = QuoteInline.findRoot(quotelink, isBacklink);
root = $.x("following-sibling::div[@id='i" + postID + "'][1]", root); root = $.x("following-sibling::div[@id='i" + postID + "'][1]", root);
qroot = $.x('ancestor::*[contains(@class,"postContainer")][1]', root);
$.rm(root); $.rm(root);
if (!$('.inline', qroot)) {
$.rmClass(qroot, 'hasInline');
}
if (!(el = root.firstElementChild)) { if (!(el = root.firstElementChild)) {
return; return;
} }
@ -9007,7 +9015,7 @@
} }
}, },
hl: function(delta, thread) { hl: function(delta, thread) {
var headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len; var axe, headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len;
if (Conf['Fixed Header'] && Conf['Bottom header']) { if (Conf['Fixed Header'] && Conf['Bottom header']) {
topMargin = 0; topMargin = 0;
@ -9020,7 +9028,8 @@
rect = postEl.getBoundingClientRect(); rect = postEl.getBoundingClientRect();
if (rect.bottom >= topMargin && rect.top <= doc.clientHeight) { if (rect.bottom >= topMargin && rect.top <= doc.clientHeight) {
root = postEl.parentNode; root = postEl.parentNode;
next = $.x('child::div[contains(@class,"post reply")]', delta === +1 ? root.nextElementSibling : root.previousElementSibling); axe = delta === +1 ? 'following' : 'preceding';
next = $.x("" + axe + "-sibling::div[contains(@class,'replyContainer')][1]/child::div[contains(@class,'reply')]", root);
if (!next) { if (!next) {
this.focus(postEl); this.focus(postEl);
return; return;

View File

@ -3,21 +3,10 @@ Polyfill =
Polyfill.visibility() Polyfill.visibility()
visibility: -> visibility: ->
# page visibility API # page visibility API
return if 'visibilityState' of document or not ( return unless 'webkitHidden' of document
prefix = ( Object.defineProperties HTMLDocument.prototype,
if 'webkitVisibilityState' of document visibilityState:
'webkit' get: -> @webkitVisibilityState
else if 'mozVisibilityState' of document hidden:
'moz' get: -> @webkitHidden
) $.on d, 'webkitvisibilitychange', -> $.event 'visibilitychange'
)
property = prefix + 'VisibilityState'
event = prefix + 'visibilitychange'
d.visibilityState = d[property]
d.hidden = d.visibilityState is 'hidden'
$.on d, event, ->
d.visibilityState = d[property]
d.hidden = d.visibilityState is 'hidden'
$.event 'visibilitychange'

View File

@ -204,8 +204,11 @@ Keybinds =
rect = postEl.getBoundingClientRect() rect = postEl.getBoundingClientRect()
if rect.bottom >= topMargin and rect.top <= doc.clientHeight # We're at least partially visible if rect.bottom >= topMargin and rect.top <= doc.clientHeight # We're at least partially visible
root = postEl.parentNode root = postEl.parentNode
next = $.x 'child::div[contains(@class,"post reply")]', axe = if delta is +1
if delta is +1 then root.nextElementSibling else root.previousElementSibling 'following'
else
'preceding'
next = $.x "#{axe}-sibling::div[contains(@class,'replyContainer')][1]/child::div[contains(@class,'reply')]", root
unless next unless next
@focus postEl @focus postEl
return return
@ -228,4 +231,4 @@ Keybinds =
return return
focus: (post) -> focus: (post) ->
$.addClass post, 'highlight' $.addClass post, 'highlight'