Throw 4chanXInitFinished on navigate

Also add "none" flag to Settings.open
$.event("openSettings", "none");
This commit is contained in:
Zixaphir 2014-07-30 10:00:10 -07:00
parent 715cfc7de7
commit 9d087ef5d6
6 changed files with 33 additions and 14 deletions

View File

@ -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. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE

View File

@ -28,7 +28,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* appchan x - Version 2.9.32 - 2014-07-29 * appchan x - Version 2.9.32 - 2014-07-30
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -5322,7 +5322,7 @@
} }
if (g.VIEW === 'thread') { if (g.VIEW === 'thread') {
if (Conf['Thread Updater']) { if (Conf['Thread Updater']) {
return ThreadUpdater.update(); ThreadUpdater.update();
} }
return; return;
} }
@ -16800,6 +16800,9 @@
Navigate.updateContext(view); Navigate.updateContext(view);
Navigate.clean(); Navigate.clean();
Navigate.reconnect(); Navigate.reconnect();
if (view === 'index') {
$.event('4chanXInitFinished');
}
} }
if (boardID === g.BOARD.ID) { if (boardID === g.BOARD.ID) {
Navigate.title = function() { Navigate.title = function() {
@ -16914,8 +16917,9 @@
QR.generatePostableThreadsList(); QR.generatePostableThreadsList();
Header.hashScroll.call(window); Header.hashScroll.call(window);
if (errors) { if (errors) {
return Main.handleErrors(errors); Main.handleErrors(errors);
} }
return $.event('4chanXInitFinished');
}, },
pushState: function(path) { pushState: function(path) {
history.pushState(null, '', path); history.pushState(null, '', path);
@ -17013,7 +17017,9 @@
} }
} }
$.add($('.sections-list', dialog), links); $.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($('.close', dialog), 'click', Settings.close);
$.on(overlay, 'click', Settings.close); $.on(overlay, 'click', Settings.close);
$.add(d.body, [overlay, dialog]); $.add(d.body, [overlay, dialog]);

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // 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. * Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE * https://github.com/zixaphir/appchan-x/blob/master/LICENSE
@ -5373,7 +5373,7 @@
} }
if (g.VIEW === 'thread') { if (g.VIEW === 'thread') {
if (Conf['Thread Updater']) { if (Conf['Thread Updater']) {
return ThreadUpdater.update(); ThreadUpdater.update();
} }
return; return;
} }
@ -16816,6 +16816,9 @@
Navigate.updateContext(view); Navigate.updateContext(view);
Navigate.clean(); Navigate.clean();
Navigate.reconnect(); Navigate.reconnect();
if (view === 'index') {
$.event('4chanXInitFinished');
}
} }
if (boardID === g.BOARD.ID) { if (boardID === g.BOARD.ID) {
Navigate.title = function() { Navigate.title = function() {
@ -16930,8 +16933,9 @@
QR.generatePostableThreadsList(); QR.generatePostableThreadsList();
Header.hashScroll.call(window); Header.hashScroll.call(window);
if (errors) { if (errors) {
return Main.handleErrors(errors); Main.handleErrors(errors);
} }
return $.event('4chanXInitFinished');
}, },
pushState: function(path) { pushState: function(path) {
history.pushState(null, '', path); history.pushState(null, '', path);
@ -17029,7 +17033,9 @@
} }
} }
$.add($('.sections-list', dialog), links); $.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($('.close', dialog), 'click', Settings.close);
$.on(overlay, 'click', Settings.close); $.on(overlay, 'click', Settings.close);
$.add(d.body, [overlay, dialog]); $.add(d.body, [overlay, dialog]);

View File

@ -514,9 +514,9 @@ Index =
{timeEl} = Index {timeEl} = Index
needed = needed =
# we're on the index, # we're on the index,
g.VIEW is 'index' and g.VIEW is 'index' and
# not currently refreshing # not currently refreshing
!Index.req and !Index.req and
timeEl.dataset.utc and timeEl.dataset.utc and
# more than 10 minutes have elapsed since the last refresh. # more than 10 minutes have elapsed since the last refresh.
timeEl.dataset.utc < Date.now() - (10 * $.MINUTE) timeEl.dataset.utc < Date.now() - (10 * $.MINUTE)
@ -525,7 +525,7 @@ Index =
update: (pageNum) -> update: (pageNum) ->
return unless navigator.onLine return unless navigator.onLine
if g.VIEW is 'thread' if g.VIEW is 'thread'
return ThreadUpdater.update() if Conf['Thread Updater'] ThreadUpdater.update() if Conf['Thread Updater']
return return
unless d.readyState is 'loading' or Index.root.parentElement unless d.readyState is 'loading' or Index.root.parentElement
$.replace $('.board'), Index.root $.replace $('.board'), Index.root
@ -817,7 +817,7 @@ Index =
else else
unless Conf['Index Mode'] is 'infinite' unless Conf['Index Mode'] is 'infinite'
pageNum = Index.getCurrentPage() pageNum = Index.getCurrentPage()
else else
return unless Index.searchInput.dataset.searching return unless Index.searchInput.dataset.searching
pageNum = Index.pageBeforeSearch pageNum = Index.pageBeforeSearch

View File

@ -255,6 +255,10 @@ Navigate =
Navigate.clean() Navigate.clean()
Navigate.reconnect() 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 if boardID is g.BOARD.ID
Navigate.title = -> d.title = $('.boardTitle').textContent if view is 'index' Navigate.title = -> d.title = $('.boardTitle').textContent if view is 'index'
else else
@ -357,6 +361,9 @@ Navigate =
Main.handleErrors errors if errors Main.handleErrors errors if errors
# Thrown after thread has been generated and features have been parsed, like 4chan X
$.event '4chanXInitFinished'
pushState: (path) -> pushState: (path) ->
history.pushState null, '', path history.pushState null, '', path
Navigate.path = window.location.pathname Navigate.path = window.location.pathname

View File

@ -74,7 +74,7 @@ Settings =
links.push link links.push link
sectionToOpen = link if section.title is openSection sectionToOpen = link if section.title is openSection
$.add $('.sections-list', dialog), links $.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 $('.close', dialog), 'click', Settings.close
$.on overlay, 'click', Settings.close $.on overlay, 'click', Settings.close