Reflow a ton of navigate and index shit to fix broken shit
This commit is contained in:
parent
e451410ef1
commit
7a7a7facf7
@ -2517,10 +2517,14 @@
|
||||
return;
|
||||
}
|
||||
this.board = "" + g.BOARD;
|
||||
if (g.VIEW !== 'index') {
|
||||
$.ready(this.setupNavLinks);
|
||||
return;
|
||||
}
|
||||
this.button = $.el('a', {
|
||||
className: 'index-refresh-shortcut fa fa-refresh',
|
||||
title: 'Refresh',
|
||||
href: 'javascript:;',
|
||||
textContent: 'Refresh Index'
|
||||
});
|
||||
$.on(this.button, 'click', this.update);
|
||||
Header.addShortcut(this.button, 1);
|
||||
if (g.BOARD.ID === 'f') {
|
||||
return;
|
||||
}
|
||||
@ -2533,14 +2537,6 @@
|
||||
name: 'Catalog Features',
|
||||
cb: this.catalogNode
|
||||
});
|
||||
this.button = $.el('a', {
|
||||
className: 'index-refresh-shortcut fa fa-refresh',
|
||||
title: 'Refresh',
|
||||
href: 'javascript:;',
|
||||
textContent: 'Refresh Index'
|
||||
});
|
||||
$.on(this.button, 'click', this.update);
|
||||
Header.addShortcut(this.button, 1);
|
||||
modeEntry = {
|
||||
el: $.el('span', {
|
||||
textContent: 'Index mode'
|
||||
@ -2675,17 +2671,16 @@
|
||||
return $('.board', doc) || d.readyState !== 'loading';
|
||||
}), function() {
|
||||
var board, navLink, _l, _len3, _ref3;
|
||||
if (g.VIEW === 'index') {
|
||||
board = $('.board');
|
||||
$.replace(board, Index.root);
|
||||
d.implementation.createDocument(null, null, null).appendChild(board);
|
||||
}
|
||||
_ref3 = $$('.navLinks');
|
||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
||||
navLink = _ref3[_l];
|
||||
$.rm(navLink);
|
||||
}
|
||||
return $.after($.x('child::form/preceding-sibling::hr[1]'), Index.navLinks);
|
||||
$.after($.x('child::form/preceding-sibling::hr[1]'), Index.navLinks);
|
||||
return g.VIEW !== 'index';
|
||||
board = $('.board');
|
||||
$.replace(board, Index.root);
|
||||
return d.implementation.createDocument(null, null, null).appendChild(board);
|
||||
});
|
||||
this.cb.toggleCatalogMode();
|
||||
return $.asap((function() {
|
||||
@ -2757,6 +2752,9 @@
|
||||
}
|
||||
},
|
||||
threadNode: function() {
|
||||
if (g.VIEW !== 'index') {
|
||||
return;
|
||||
}
|
||||
if (!Index.db.get({
|
||||
boardID: this.board.ID,
|
||||
threadID: this.ID
|
||||
@ -5825,7 +5823,6 @@
|
||||
});
|
||||
$.on(sc, 'click', function() {
|
||||
if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) {
|
||||
$.event('CloseMenu');
|
||||
QR.open();
|
||||
QR.nodes.com.focus();
|
||||
return $.rmClass(this, 'disabled');
|
||||
@ -5883,14 +5880,8 @@
|
||||
$.on(d, 'dragover', QR.dragOver);
|
||||
$.on(d, 'drop', QR.dropFile);
|
||||
$.on(d, 'dragstart dragend', QR.drag);
|
||||
({
|
||||
index: function() {
|
||||
return $.on(d, 'IndexRefresh', QR.generatePostableThreadsList);
|
||||
},
|
||||
thread: function() {
|
||||
return $.on(d, 'ThreadUpdate', QR.statusCheck);
|
||||
}
|
||||
})[g.VIEW]();
|
||||
$.on(d, 'IndexRefresh', QR.generatePostableThreadsList);
|
||||
$.on(d, 'ThreadUpdate', QR.statusCheck);
|
||||
if (!Conf['Persistent QR']) {
|
||||
return;
|
||||
}
|
||||
@ -12636,45 +12627,35 @@
|
||||
];
|
||||
}
|
||||
if (error) {
|
||||
Main.handleErrors(error);
|
||||
return Main.handleErrors(error);
|
||||
}
|
||||
return QR.generatePostableThreadsList();
|
||||
},
|
||||
updateContext: function(view) {
|
||||
var oldView;
|
||||
g.DEAD = false;
|
||||
if (view !== g.VIEW) {
|
||||
$.rmClass(doc, g.VIEW);
|
||||
$.addClass(doc, view);
|
||||
if (view === 'thread') {
|
||||
g.THREADID = +window.location.pathname.split('/')[3];
|
||||
}
|
||||
oldView = g.VIEW;
|
||||
g.VIEW = view;
|
||||
return {
|
||||
if (view === g.VIEW) {
|
||||
return;
|
||||
}
|
||||
$.rmClass(doc, g.VIEW);
|
||||
$.addClass(doc, view);
|
||||
({
|
||||
index: function() {
|
||||
if (oldView === g.VIEW) {
|
||||
return;
|
||||
}
|
||||
delete g.THREADID;
|
||||
QR.link.textContent = 'Start a Thread';
|
||||
$.off(d, 'ThreadUpdate', QR.statusCheck);
|
||||
$.on(d, 'IndexRefresh', QR.generatePostableThreadsList);
|
||||
if (Conf['Index Mode'] === 'catalog') {
|
||||
return $.addClass(doc, 'catalog-mode');
|
||||
}
|
||||
},
|
||||
thread: function() {
|
||||
g.THREADID = +window.location.pathname.split('/')[3];
|
||||
if (oldView === g.VIEW) {
|
||||
return;
|
||||
}
|
||||
QR.link.textContent = 'Reply to Thread';
|
||||
$.on(d, 'ThreadUpdate', QR.statusCheck);
|
||||
$.off(d, 'IndexRefresh', QR.generatePostableThreadsList);
|
||||
if (Conf['Index Mode'] === 'catalog') {
|
||||
return $.rmClass(doc, 'catalog-mode');
|
||||
}
|
||||
}
|
||||
}[g.VIEW]();
|
||||
})[view]();
|
||||
return g.VIEW = view;
|
||||
},
|
||||
updateBoard: function(boardID) {
|
||||
var fullBoardList;
|
||||
@ -12718,7 +12699,7 @@
|
||||
},
|
||||
updateSFW: function(sfw) {
|
||||
var findStyle, style;
|
||||
Favicon.el.href = "//s.4cdn.org/image/favicon" + (sfw ? '-ws' : '') + ".ico";
|
||||
Favicon.el.href = Favicon["default"] = "//s.4cdn.org/image/favicon" + (sfw ? '-ws' : '') + ".ico";
|
||||
$.add(d.head, Favicon.el);
|
||||
if (Favicon.SFW === sfw) {
|
||||
return;
|
||||
@ -12805,10 +12786,10 @@
|
||||
return Navigate.updateBoard(boardID);
|
||||
};
|
||||
}
|
||||
Navigate.updateSFW(Favicon.SFW);
|
||||
if (view === 'index') {
|
||||
return Index.update(pageNum);
|
||||
}
|
||||
Navigate.updateSFW(Favicon.SFW);
|
||||
load = Navigate.load;
|
||||
Navigate.req = $.ajax("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", {
|
||||
onabort: load,
|
||||
@ -12886,6 +12867,7 @@
|
||||
Main.callbackNodes(Post, posts);
|
||||
Navigate.ready('Quote Threading', QuoteThreading.force, Conf['Quote Threading'] && !Conf['Unread Count']);
|
||||
Navigate.buildThread();
|
||||
QR.generatePostableThreadsList();
|
||||
return Header.hashScroll.call(window);
|
||||
},
|
||||
buildThread: function() {
|
||||
|
||||
@ -2576,10 +2576,14 @@
|
||||
return;
|
||||
}
|
||||
this.board = "" + g.BOARD;
|
||||
if (g.VIEW !== 'index') {
|
||||
$.ready(this.setupNavLinks);
|
||||
return;
|
||||
}
|
||||
this.button = $.el('a', {
|
||||
className: 'index-refresh-shortcut fa fa-refresh',
|
||||
title: 'Refresh',
|
||||
href: 'javascript:;',
|
||||
textContent: 'Refresh Index'
|
||||
});
|
||||
$.on(this.button, 'click', this.update);
|
||||
Header.addShortcut(this.button, 1);
|
||||
if (g.BOARD.ID === 'f') {
|
||||
return;
|
||||
}
|
||||
@ -2592,14 +2596,6 @@
|
||||
name: 'Catalog Features',
|
||||
cb: this.catalogNode
|
||||
});
|
||||
this.button = $.el('a', {
|
||||
className: 'index-refresh-shortcut fa fa-refresh',
|
||||
title: 'Refresh',
|
||||
href: 'javascript:;',
|
||||
textContent: 'Refresh Index'
|
||||
});
|
||||
$.on(this.button, 'click', this.update);
|
||||
Header.addShortcut(this.button, 1);
|
||||
modeEntry = {
|
||||
el: $.el('span', {
|
||||
textContent: 'Index mode'
|
||||
@ -2734,17 +2730,16 @@
|
||||
return $('.board', doc) || d.readyState !== 'loading';
|
||||
}), function() {
|
||||
var board, navLink, _l, _len3, _ref3;
|
||||
if (g.VIEW === 'index') {
|
||||
board = $('.board');
|
||||
$.replace(board, Index.root);
|
||||
d.implementation.createDocument(null, null, null).appendChild(board);
|
||||
}
|
||||
_ref3 = $$('.navLinks');
|
||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
||||
navLink = _ref3[_l];
|
||||
$.rm(navLink);
|
||||
}
|
||||
return $.after($.x('child::form/preceding-sibling::hr[1]'), Index.navLinks);
|
||||
$.after($.x('child::form/preceding-sibling::hr[1]'), Index.navLinks);
|
||||
return g.VIEW !== 'index';
|
||||
board = $('.board');
|
||||
$.replace(board, Index.root);
|
||||
return d.implementation.createDocument(null, null, null).appendChild(board);
|
||||
});
|
||||
this.cb.toggleCatalogMode();
|
||||
return $.asap((function() {
|
||||
@ -2816,6 +2811,9 @@
|
||||
}
|
||||
},
|
||||
threadNode: function() {
|
||||
if (g.VIEW !== 'index') {
|
||||
return;
|
||||
}
|
||||
if (!Index.db.get({
|
||||
boardID: this.board.ID,
|
||||
threadID: this.ID
|
||||
@ -5877,7 +5875,6 @@
|
||||
});
|
||||
$.on(sc, 'click', function() {
|
||||
if (Conf['Persistent QR'] || !QR.nodes || QR.nodes.el.hidden) {
|
||||
$.event('CloseMenu');
|
||||
QR.open();
|
||||
QR.nodes.com.focus();
|
||||
return $.rmClass(this, 'disabled');
|
||||
@ -5936,14 +5933,8 @@
|
||||
$.on(d, 'dragover', QR.dragOver);
|
||||
$.on(d, 'drop', QR.dropFile);
|
||||
$.on(d, 'dragstart dragend', QR.drag);
|
||||
({
|
||||
index: function() {
|
||||
return $.on(d, 'IndexRefresh', QR.generatePostableThreadsList);
|
||||
},
|
||||
thread: function() {
|
||||
return $.on(d, 'ThreadUpdate', QR.statusCheck);
|
||||
}
|
||||
})[g.VIEW]();
|
||||
$.on(d, 'IndexRefresh', QR.generatePostableThreadsList);
|
||||
$.on(d, 'ThreadUpdate', QR.statusCheck);
|
||||
if (!Conf['Persistent QR']) {
|
||||
return;
|
||||
}
|
||||
@ -12650,45 +12641,35 @@
|
||||
];
|
||||
}
|
||||
if (error) {
|
||||
Main.handleErrors(error);
|
||||
return Main.handleErrors(error);
|
||||
}
|
||||
return QR.generatePostableThreadsList();
|
||||
},
|
||||
updateContext: function(view) {
|
||||
var oldView;
|
||||
g.DEAD = false;
|
||||
if (view !== g.VIEW) {
|
||||
$.rmClass(doc, g.VIEW);
|
||||
$.addClass(doc, view);
|
||||
if (view === 'thread') {
|
||||
g.THREADID = +window.location.pathname.split('/')[3];
|
||||
}
|
||||
oldView = g.VIEW;
|
||||
g.VIEW = view;
|
||||
return {
|
||||
if (view === g.VIEW) {
|
||||
return;
|
||||
}
|
||||
$.rmClass(doc, g.VIEW);
|
||||
$.addClass(doc, view);
|
||||
({
|
||||
index: function() {
|
||||
if (oldView === g.VIEW) {
|
||||
return;
|
||||
}
|
||||
delete g.THREADID;
|
||||
QR.link.textContent = 'Start a Thread';
|
||||
$.off(d, 'ThreadUpdate', QR.statusCheck);
|
||||
$.on(d, 'IndexRefresh', QR.generatePostableThreadsList);
|
||||
if (Conf['Index Mode'] === 'catalog') {
|
||||
return $.addClass(doc, 'catalog-mode');
|
||||
}
|
||||
},
|
||||
thread: function() {
|
||||
g.THREADID = +window.location.pathname.split('/')[3];
|
||||
if (oldView === g.VIEW) {
|
||||
return;
|
||||
}
|
||||
QR.link.textContent = 'Reply to Thread';
|
||||
$.on(d, 'ThreadUpdate', QR.statusCheck);
|
||||
$.off(d, 'IndexRefresh', QR.generatePostableThreadsList);
|
||||
if (Conf['Index Mode'] === 'catalog') {
|
||||
return $.rmClass(doc, 'catalog-mode');
|
||||
}
|
||||
}
|
||||
}[g.VIEW]();
|
||||
})[view]();
|
||||
return g.VIEW = view;
|
||||
},
|
||||
updateBoard: function(boardID) {
|
||||
var fullBoardList;
|
||||
@ -12732,7 +12713,7 @@
|
||||
},
|
||||
updateSFW: function(sfw) {
|
||||
var findStyle, style;
|
||||
Favicon.el.href = "//s.4cdn.org/image/favicon" + (sfw ? '-ws' : '') + ".ico";
|
||||
Favicon.el.href = Favicon["default"] = "//s.4cdn.org/image/favicon" + (sfw ? '-ws' : '') + ".ico";
|
||||
$.add(d.head, Favicon.el);
|
||||
if (Favicon.SFW === sfw) {
|
||||
return;
|
||||
@ -12819,10 +12800,10 @@
|
||||
return Navigate.updateBoard(boardID);
|
||||
};
|
||||
}
|
||||
Navigate.updateSFW(Favicon.SFW);
|
||||
if (view === 'index') {
|
||||
return Index.update(pageNum);
|
||||
}
|
||||
Navigate.updateSFW(Favicon.SFW);
|
||||
load = Navigate.load;
|
||||
Navigate.req = $.ajax("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", {
|
||||
onabort: load,
|
||||
@ -12900,6 +12881,7 @@
|
||||
Main.callbackNodes(Post, posts);
|
||||
Navigate.ready('Quote Threading', QuoteThreading.force, Conf['Quote Threading'] && !Conf['Unread Count']);
|
||||
Navigate.buildThread();
|
||||
QR.generatePostableThreadsList();
|
||||
return Header.hashScroll.call(window);
|
||||
},
|
||||
buildThread: function() {
|
||||
|
||||
@ -5,9 +5,14 @@ Index =
|
||||
|
||||
@board = "#{g.BOARD}"
|
||||
|
||||
if g.VIEW isnt 'index'
|
||||
$.ready @setupNavLinks
|
||||
return
|
||||
@button = $.el 'a',
|
||||
className: 'index-refresh-shortcut fa fa-refresh'
|
||||
title: 'Refresh'
|
||||
href: 'javascript:;'
|
||||
textContent: 'Refresh Index'
|
||||
$.on @button, 'click', @update
|
||||
Header.addShortcut @button, 1
|
||||
|
||||
return if g.BOARD.ID is 'f'
|
||||
|
||||
@db = new DataBoard 'pinnedThreads'
|
||||
@ -19,14 +24,6 @@ Index =
|
||||
name: 'Catalog Features'
|
||||
cb: @catalogNode
|
||||
|
||||
@button = $.el 'a',
|
||||
className: 'index-refresh-shortcut fa fa-refresh'
|
||||
title: 'Refresh'
|
||||
href: 'javascript:;'
|
||||
textContent: 'Refresh Index'
|
||||
$.on @button, 'click', @update
|
||||
Header.addShortcut @button, 1
|
||||
|
||||
modeEntry =
|
||||
el: $.el 'span', textContent: 'Index mode'
|
||||
subEntries: [
|
||||
@ -124,20 +121,21 @@ Index =
|
||||
|
||||
@update() if g.VIEW is 'index'
|
||||
$.asap (-> $('.board', doc) or d.readyState isnt 'loading'), ->
|
||||
if g.VIEW is 'index'
|
||||
board = $ '.board'
|
||||
$.replace board, Index.root
|
||||
# Hacks:
|
||||
# - When removing an element from the document during page load,
|
||||
# its ancestors will still be correctly created inside of it.
|
||||
# - Creating loadable elements inside of an origin-less document
|
||||
# will not download them.
|
||||
# - Combine the two and you get a download canceller!
|
||||
# Does not work on Firefox unfortunately. bugzil.la/939713
|
||||
d.implementation.createDocument(null, null, null).appendChild board
|
||||
|
||||
$.rm navLink for navLink in $$ '.navLinks'
|
||||
$.after $.x('child::form/preceding-sibling::hr[1]'), Index.navLinks
|
||||
|
||||
return g.VIEW isnt 'index'
|
||||
|
||||
board = $ '.board'
|
||||
$.replace board, Index.root
|
||||
# Hacks:
|
||||
# - When removing an element from the document during page load,
|
||||
# its ancestors will still be correctly created inside of it.
|
||||
# - Creating loadable elements inside of an origin-less document
|
||||
# will not download them.
|
||||
# - Combine the two and you get a download canceller!
|
||||
# Does not work on Firefox unfortunately. bugzil.la/939713
|
||||
d.implementation.createDocument(null, null, null).appendChild board
|
||||
|
||||
@cb.toggleCatalogMode()
|
||||
|
||||
@ -187,6 +185,7 @@ Index =
|
||||
true
|
||||
|
||||
threadNode: ->
|
||||
return if g.VIEW isnt 'index'
|
||||
return unless Index.db.get {boardID: @board.ID, threadID: @ID}
|
||||
@pin()
|
||||
|
||||
|
||||
@ -83,33 +83,28 @@ Navigate =
|
||||
error: err
|
||||
]
|
||||
Main.handleErrors error if error
|
||||
QR.generatePostableThreadsList()
|
||||
|
||||
updateContext: (view) ->
|
||||
g.DEAD = false
|
||||
g.DEAD = false
|
||||
g.THREADID = +window.location.pathname.split('/')[3] if view is 'thread'
|
||||
|
||||
unless view is g.VIEW
|
||||
$.rmClass doc, g.VIEW
|
||||
$.addClass doc, view
|
||||
return if view is g.VIEW
|
||||
|
||||
$.rmClass doc, g.VIEW
|
||||
$.addClass doc, view
|
||||
|
||||
oldView = g.VIEW
|
||||
g.VIEW = view
|
||||
{
|
||||
index: ->
|
||||
return if oldView is g.VIEW
|
||||
delete g.THREADID
|
||||
QR.link.textContent = 'Start a Thread'
|
||||
$.off d, 'ThreadUpdate', QR.statusCheck
|
||||
$.on d, 'IndexRefresh', QR.generatePostableThreadsList
|
||||
$.addClass doc, 'catalog-mode' if Conf['Index Mode'] is 'catalog'
|
||||
|
||||
thread: ->
|
||||
g.THREADID = +window.location.pathname.split('/')[3]
|
||||
return if oldView is g.VIEW
|
||||
QR.link.textContent = 'Reply to Thread'
|
||||
$.on d, 'ThreadUpdate', QR.statusCheck
|
||||
$.off d, 'IndexRefresh', QR.generatePostableThreadsList
|
||||
$.rmClass doc, 'catalog-mode' if Conf['Index Mode'] is 'catalog'
|
||||
}[g.VIEW]()
|
||||
}[view]()
|
||||
|
||||
g.VIEW = view
|
||||
|
||||
updateBoard: (boardID) ->
|
||||
fullBoardList = $ '#full-board-list', Header.boardList
|
||||
@ -139,14 +134,16 @@ Navigate =
|
||||
Navigate.updateSFW !!board.ws_board
|
||||
|
||||
updateSFW: (sfw) ->
|
||||
# TODO: think of a better name for this. Changes style, too.
|
||||
Favicon.el.href = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico"
|
||||
$.add d.head, Favicon.el # Changing the href alone doesn't update the icon on Firefox
|
||||
Favicon.el.href = Favicon.default = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico"
|
||||
|
||||
# Changing the href alone doesn't update the icon on Firefox
|
||||
$.add d.head, Favicon.el
|
||||
|
||||
return if Favicon.SFW is sfw # Board SFW status hasn't changed
|
||||
|
||||
Favicon.SFW = sfw
|
||||
Favicon.update()
|
||||
|
||||
findStyle = (type, base) ->
|
||||
style = d.cookie.match new RegExp "\b#{type}\_style\=([^;]+);\b"
|
||||
return ["#{type}_style", (if style then style[1] else base)]
|
||||
@ -217,11 +214,12 @@ Navigate =
|
||||
g.BOARD = new Board boardID
|
||||
Navigate.title = -> Navigate.updateBoard boardID
|
||||
|
||||
Navigate.updateSFW Favicon.SFW
|
||||
|
||||
if view is 'index'
|
||||
return Index.update pageNum
|
||||
|
||||
|
||||
# Moving from index to thread or thread to thread
|
||||
Navigate.updateSFW Favicon.SFW
|
||||
{load} = Navigate
|
||||
Navigate.req = $.ajax "//a.4cdn.org/#{boardID}/res/#{threadID}.json",
|
||||
onabort: load
|
||||
@ -293,6 +291,7 @@ Navigate =
|
||||
Navigate.ready 'Quote Threading', QuoteThreading.force, Conf['Quote Threading'] and not Conf['Unread Count']
|
||||
|
||||
Navigate.buildThread()
|
||||
QR.generatePostableThreadsList()
|
||||
Header.hashScroll.call window
|
||||
|
||||
buildThread: ->
|
||||
|
||||
@ -17,7 +17,6 @@ QR =
|
||||
|
||||
$.on sc, 'click', ->
|
||||
if Conf['Persistent QR'] or !QR.nodes or QR.nodes.el.hidden
|
||||
$.event 'CloseMenu'
|
||||
QR.open()
|
||||
QR.nodes.com.focus()
|
||||
$.rmClass @, 'disabled'
|
||||
@ -66,14 +65,12 @@ QR =
|
||||
$.on d, 'dragover', QR.dragOver
|
||||
$.on d, 'drop', QR.dropFile
|
||||
$.on d, 'dragstart dragend', QR.drag
|
||||
{
|
||||
index: ->
|
||||
$.on d, 'IndexRefresh', QR.generatePostableThreadsList
|
||||
thread: ->
|
||||
$.on d, 'ThreadUpdate', QR.statusCheck
|
||||
}[g.VIEW]()
|
||||
|
||||
return unless Conf['Persistent QR']
|
||||
# We can thread update and index refresh without loading a new page, so...
|
||||
$.on d, 'IndexRefresh', QR.generatePostableThreadsList
|
||||
$.on d, 'ThreadUpdate', QR.statusCheck
|
||||
|
||||
return if !Conf['Persistent QR']
|
||||
QR.open()
|
||||
QR.hide() if Conf['Auto-Hide QR']
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user