From c2ac7e66b160581b5638059c02e33da24e5e19eb Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sat, 11 Jan 2014 11:28:33 -0700 Subject: [PATCH] Handle popstate on Chrome a bit better --- builds/4chan-X.user.js | 6 +++++- builds/crx/script.js | 19 ++++++++++--------- src/General/Navigate.coffee | 19 +++++++++---------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 7250184c4..4ce4b382e 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -11875,7 +11875,11 @@ if (g.VIEW === 'catalog' || g.BOARD.ID === 'f') { return; } - $.on(window, 'popstate', Navigate.popstate); + ({ + ready: function() { + return $.on(window, 'popstate', Navigate.popstate); + } + }); Thread.callbacks.push({ name: 'Navigate', cb: this.thread diff --git a/builds/crx/script.js b/builds/crx/script.js index ccb0112a3..94176b17f 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -11864,7 +11864,11 @@ if (g.VIEW === 'catalog' || g.BOARD.ID === 'f') { return; } - $.on(window, 'popstate', Navigate.popstate); + ({ + ready: function() { + return $.on(window, 'popstate', Navigate.popstate); + } + }); Thread.callbacks.push({ name: 'Navigate', cb: this.thread @@ -12194,15 +12198,12 @@ } }, popstate: function() { - $.off(window, 'popstate', Navigate.popstate); - return $.on(window, 'popstate', Navigate.popstate = function() { - var a; - a = $.el('a', { - href: window.location, - id: 'popState' - }); - return Navigate.navigate.call(a); + var a; + a = $.el('a', { + href: window.location, + id: 'popState' }); + return Navigate.navigate.call(a); } }; diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 863385516..e92e55255 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -1,7 +1,10 @@ Navigate = init: -> return if g.VIEW is 'catalog' or g.BOARD.ID is 'f' - $.on window, 'popstate', Navigate.popstate + + # blink/webkit throw a popstate on page load. Not what we want. + ready: -> + $.on window, 'popstate', Navigate.popstate Thread.callbacks.push name: 'Navigate' @@ -295,13 +298,9 @@ Navigate = Unread.read() Unread.update() - popstate: -> <% if (type === 'crx') { %> - $.off window, 'popstate', Navigate.popstate - $.on window, 'popstate', Navigate.popstate = -> -<% } %> # blink/webkit throw a popstate on page load. Not what we want. + popstate: -> + a = $.el 'a', + href: window.location + id: 'popState' - a = $.el 'a', - href: window.location - id: 'popState' - - Navigate.navigate.call a + Navigate.navigate.call a