From 9d087ef5d6234be27926f80adc89bab41f46ca71 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 30 Jul 2014 10:00:10 -0700 Subject: [PATCH] Throw 4chanXInitFinished on navigate Also add "none" flag to Settings.open $.event("openSettings", "none"); --- LICENSE | 2 +- builds/appchan-x.user.js | 14 ++++++++++---- builds/crx/script.js | 14 ++++++++++---- src/General/Index.coffee | 8 ++++---- src/General/Navigate.coffee | 7 +++++++ src/General/Settings.coffee | 2 +- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/LICENSE b/LICENSE index 8b2b53748..0dd018107 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* appchan x - Version 2.9.32 - 2014-07-29 +* appchan x - Version 2.9.32 - 2014-07-30 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 544544be1..d01773b92 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -28,7 +28,7 @@ // ==/UserScript== /* -* appchan x - Version 2.9.32 - 2014-07-29 +* appchan x - Version 2.9.32 - 2014-07-30 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -5322,7 +5322,7 @@ } if (g.VIEW === 'thread') { if (Conf['Thread Updater']) { - return ThreadUpdater.update(); + ThreadUpdater.update(); } return; } @@ -16800,6 +16800,9 @@ Navigate.updateContext(view); Navigate.clean(); Navigate.reconnect(); + if (view === 'index') { + $.event('4chanXInitFinished'); + } } if (boardID === g.BOARD.ID) { Navigate.title = function() { @@ -16914,8 +16917,9 @@ QR.generatePostableThreadsList(); Header.hashScroll.call(window); if (errors) { - return Main.handleErrors(errors); + Main.handleErrors(errors); } + return $.event('4chanXInitFinished'); }, pushState: function(path) { history.pushState(null, '', path); @@ -17013,7 +17017,9 @@ } } $.add($('.sections-list', dialog), links); - (sectionToOpen ? sectionToOpen : links[0]).click(); + if (openSection !== 'none') { + (sectionToOpen ? sectionToOpen : links[0]).click(); + } $.on($('.close', dialog), 'click', Settings.close); $.on(overlay, 'click', Settings.close); $.add(d.body, [overlay, dialog]); diff --git a/builds/crx/script.js b/builds/crx/script.js index 3400541d3..d8cf79950 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* appchan x - Version 2.9.32 - 2014-07-29 +* appchan x - Version 2.9.32 - 2014-07-30 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -5373,7 +5373,7 @@ } if (g.VIEW === 'thread') { if (Conf['Thread Updater']) { - return ThreadUpdater.update(); + ThreadUpdater.update(); } return; } @@ -16816,6 +16816,9 @@ Navigate.updateContext(view); Navigate.clean(); Navigate.reconnect(); + if (view === 'index') { + $.event('4chanXInitFinished'); + } } if (boardID === g.BOARD.ID) { Navigate.title = function() { @@ -16930,8 +16933,9 @@ QR.generatePostableThreadsList(); Header.hashScroll.call(window); if (errors) { - return Main.handleErrors(errors); + Main.handleErrors(errors); } + return $.event('4chanXInitFinished'); }, pushState: function(path) { history.pushState(null, '', path); @@ -17029,7 +17033,9 @@ } } $.add($('.sections-list', dialog), links); - (sectionToOpen ? sectionToOpen : links[0]).click(); + if (openSection !== 'none') { + (sectionToOpen ? sectionToOpen : links[0]).click(); + } $.on($('.close', dialog), 'click', Settings.close); $.on(overlay, 'click', Settings.close); $.add(d.body, [overlay, dialog]); diff --git a/src/General/Index.coffee b/src/General/Index.coffee index e249f3ff5..f324730ab 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -514,9 +514,9 @@ Index = {timeEl} = Index needed = # we're on the index, - g.VIEW is 'index' and + g.VIEW is 'index' and # not currently refreshing - !Index.req and + !Index.req and timeEl.dataset.utc and # more than 10 minutes have elapsed since the last refresh. timeEl.dataset.utc < Date.now() - (10 * $.MINUTE) @@ -525,7 +525,7 @@ Index = update: (pageNum) -> return unless navigator.onLine if g.VIEW is 'thread' - return ThreadUpdater.update() if Conf['Thread Updater'] + ThreadUpdater.update() if Conf['Thread Updater'] return unless d.readyState is 'loading' or Index.root.parentElement $.replace $('.board'), Index.root @@ -817,7 +817,7 @@ Index = else unless Conf['Index Mode'] is 'infinite' pageNum = Index.getCurrentPage() - + else return unless Index.searchInput.dataset.searching pageNum = Index.pageBeforeSearch diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 4425ca0d1..b72ee3cbd 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -255,6 +255,10 @@ Navigate = Navigate.clean() Navigate.reconnect() + # Thrown on index before index is generated. At this point, the page is blank. + # An IndexRefresh event will also be thrown after the index has been generated. + $.event '4chanXInitFinished' if view is 'index' + if boardID is g.BOARD.ID Navigate.title = -> d.title = $('.boardTitle').textContent if view is 'index' else @@ -357,6 +361,9 @@ Navigate = Main.handleErrors errors if errors + # Thrown after thread has been generated and features have been parsed, like 4chan X + $.event '4chanXInitFinished' + pushState: (path) -> history.pushState null, '', path Navigate.path = window.location.pathname diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index de872fcfe..eb7f9346d 100755 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -74,7 +74,7 @@ Settings = links.push link sectionToOpen = link if section.title is openSection $.add $('.sections-list', dialog), links - (if sectionToOpen then sectionToOpen else links[0]).click() + (if sectionToOpen then sectionToOpen else links[0]).click() unless openSection is 'none' $.on $('.close', dialog), 'click', Settings.close $.on overlay, 'click', Settings.close