From aedaac2b2456d5eb303e4dfcc68fba56dd01ad79 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 7 Apr 2014 03:32:47 -0700 Subject: [PATCH] get thread expansion working --- LICENSE | 2 +- builds/4chan-X.user.js | 16 +++++++++++++--- builds/crx/script.js | 16 +++++++++++++--- src/Miscellaneous/ExpandThread.coffee | 10 ++++++++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index 4b57426e8..03ecfa99a 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.7.1 - 2014-04-06 +* 4chan X - Version 1.7.1 - 2014-04-07 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index bc9f0e9de..610ca771a 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -24,7 +24,7 @@ // ==/UserScript== /* -* 4chan X - Version 1.7.1 - 2014-04-06 +* 4chan X - Version 1.7.1 - 2014-04-07 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -10996,14 +10996,24 @@ if (g.VIEW === 'thread' || !Conf['Thread Expansion']) { return; } - return $.on(d, 'IndexRefresh', this.onIndexRefresh); + if (Conf['JSON Navigation']) { + return $.on(d, 'IndexRefresh', this.onIndexRefresh); + } else { + return Thread.callbacks.push({ + name: 'Expand Thread', + cb: function() { + return ExpandThread.setButton(this); + } + }); + } }, setButton: function(thread) { var a; - if (!(a = $.x('following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root))) { + if (!(a = $.x('following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root))) { return; } a.textContent = ExpandThread.text.apply(ExpandThread, ['+'].concat(__slice.call(a.textContent.match(/\d+/g)))); + a.style.cursor = 'pointer'; return $.on(a, 'click', ExpandThread.cbToggle); }, disconnect: function(refresh) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 9144e3f61..d81c9c7da 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* 4chan X - Version 1.7.1 - 2014-04-06 +* 4chan X - Version 1.7.1 - 2014-04-07 * * Licensed under the MIT license. * https://github.com/ccd0/4chan-x/blob/master/LICENSE @@ -10999,14 +10999,24 @@ if (g.VIEW === 'thread' || !Conf['Thread Expansion']) { return; } - return $.on(d, 'IndexRefresh', this.onIndexRefresh); + if (Conf['JSON Navigation']) { + return $.on(d, 'IndexRefresh', this.onIndexRefresh); + } else { + return Thread.callbacks.push({ + name: 'Expand Thread', + cb: function() { + return ExpandThread.setButton(this); + } + }); + } }, setButton: function(thread) { var a; - if (!(a = $.x('following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root))) { + if (!(a = $.x('following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root))) { return; } a.textContent = ExpandThread.text.apply(ExpandThread, ['+'].concat(__slice.call(a.textContent.match(/\d+/g)))); + a.style.cursor = 'pointer'; return $.on(a, 'click', ExpandThread.cbToggle); }, disconnect: function(refresh) { diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee index beed897f5..30ad6d305 100755 --- a/src/Miscellaneous/ExpandThread.coffee +++ b/src/Miscellaneous/ExpandThread.coffee @@ -2,11 +2,17 @@ ExpandThread = statuses: {} init: -> return if g.VIEW is 'thread' or !Conf['Thread Expansion'] - $.on d, 'IndexRefresh', @onIndexRefresh + if Conf['JSON Navigation'] + $.on d, 'IndexRefresh', @onIndexRefresh + else + Thread.callbacks.push + name: 'Expand Thread' + cb: -> ExpandThread.setButton @ setButton: (thread) -> - return unless a = $.x 'following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root + return unless a = $.x 'following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root a.textContent = ExpandThread.text '+', a.textContent.match(/\d+/g)... + a.style.cursor = 'pointer' $.on a, 'click', ExpandThread.cbToggle disconnect: (refresh) ->