Merge branch 'v3'

This commit is contained in:
Zixaphir 2014-01-11 21:03:55 -07:00
commit 9a5a4cc03c
3 changed files with 80 additions and 48 deletions

View File

@ -15633,14 +15633,13 @@
}; };
Navigate = { Navigate = {
path: window.location.pathname,
init: function() { init: function() {
if (g.VIEW === 'catalog' || g.BOARD.ID === 'f') { if (g.VIEW === 'catalog' || g.BOARD.ID === 'f') {
return; return;
} }
({ $.ready(function() {
ready: function() { return $.on(window, 'popstate', Navigate.popstate);
return $.on(window, 'popstate', Navigate.popstate);
}
}); });
Thread.callbacks.push({ Thread.callbacks.push({
name: 'Navigate', name: 'Navigate',
@ -15660,12 +15659,20 @@
return $.on(replyLink, 'click', Navigate.navigate); return $.on(replyLink, 'click', Navigate.navigate);
}, },
post: function() { post: function() {
var postLink; var hashlink, postlink, _i, _len, _ref;
if (g.VIEW === 'thread' && this.thread.ID === g.THREADID) { if (g.VIEW === 'thread' && this.thread.ID === g.THREADID) {
return; return;
} }
postLink = $('a[title="Highlight this post"]', this.nodes.info); postlink = $('a[title="Highlight this post"]', this.nodes.info);
return $.on(postLink, 'click', Navigate.navigate); $.on(postlink, 'click', Navigate.navigate);
if (!Conf['Quote Hash Navigation']) {
return;
}
_ref = $$('.hashlink', this.nodes.comment);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
hashlink = _ref[_i];
$.on(hashlink, 'click', Navigate.navigate);
}
}, },
clean: function() { clean: function() {
var posts, threads; var posts, threads;
@ -15833,13 +15840,12 @@
return $('.boardTitle').textContent = d.title = "/" + board + "/ - " + title; return $('.boardTitle').textContent = d.title = "/" + board + "/ - " + title;
}, },
navigate: function(e) { navigate: function(e) {
var boardID, hash, onload, pageNum, path, threadID, view; var boardID, onload, pageNum, path, threadID, view;
if (this.hostname !== 'boards.4chan.org' || window.location.hostname === 'rs.4chan.org' || (e && (e.shiftKey || (e.type === 'click' && e.button !== 0)))) { if (this.hostname !== 'boards.4chan.org' || window.location.hostname === 'rs.4chan.org' || (e && (e.shiftKey || (e.type === 'click' && e.button !== 0)))) {
return; return;
} }
$.addClass(Index.button, 'fa-spin'); $.addClass(Index.button, 'fa-spin');
path = this.pathname.split('/'); path = this.pathname.split('/');
hash = this.hash;
if (path[0] === '') { if (path[0] === '') {
path.shift(); path.shift();
} }
@ -15847,12 +15853,17 @@
if (view === 'catalog' || ('f' === boardID || 'f' === g.BOARD.ID)) { if (view === 'catalog' || ('f' === boardID || 'f' === g.BOARD.ID)) {
return; return;
} }
path = this.pathname;
if (this.hash) {
path += this.hash;
}
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
if (this.id !== 'popState') { if (this.id !== 'popState') {
history.pushState(null, '', this.pathname); history.pushState(null, '', path);
} }
Navigate.path = this.pathname;
if (threadID) { if (threadID) {
view = 'thread'; view = 'thread';
} else { } else {
@ -15871,14 +15882,10 @@
} else { } else {
Navigate.updateBoard(boardID); Navigate.updateBoard(boardID);
} }
if (Conf['Index Mode'] === 'paged' && pageNum) { return Index.update(pageNum);
return Index.update(pageNum);
} else {
return Index.update();
}
} else { } else {
onload = function(e) { onload = function(e) {
return Navigate.load(e, hash); return Navigate.load(e);
}; };
Navigate.req = $.ajax("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", { Navigate.req = $.ajax("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", {
onabort: onload, onabort: onload,
@ -15956,7 +15963,8 @@
Main.callbackNodes(Thread, [thread]); Main.callbackNodes(Thread, [thread]);
Main.callbackNodes(Post, posts); Main.callbackNodes(Post, posts);
Navigate.ready('Quote Threading', QuoteThreading.force, Conf['Quote Threading']); Navigate.ready('Quote Threading', QuoteThreading.force, Conf['Quote Threading']);
return Navigate.buildThread(); Navigate.buildThread();
return Header.hashScroll.call(window);
}, },
buildThread: function() { buildThread: function() {
var board; var board;
@ -15971,6 +15979,9 @@
}, },
popstate: function() { popstate: function() {
var a; var a;
if (window.location.pathname === Navigate.path) {
return;
}
a = $.el('a', { a = $.el('a', {
href: window.location, href: window.location,
id: 'popState' id: 'popState'

View File

@ -15629,14 +15629,13 @@
}; };
Navigate = { Navigate = {
path: window.location.pathname,
init: function() { init: function() {
if (g.VIEW === 'catalog' || g.BOARD.ID === 'f') { if (g.VIEW === 'catalog' || g.BOARD.ID === 'f') {
return; return;
} }
({ $.ready(function() {
ready: function() { return $.on(window, 'popstate', Navigate.popstate);
return $.on(window, 'popstate', Navigate.popstate);
}
}); });
Thread.callbacks.push({ Thread.callbacks.push({
name: 'Navigate', name: 'Navigate',
@ -15656,12 +15655,20 @@
return $.on(replyLink, 'click', Navigate.navigate); return $.on(replyLink, 'click', Navigate.navigate);
}, },
post: function() { post: function() {
var postLink; var hashlink, postlink, _i, _len, _ref;
if (g.VIEW === 'thread' && this.thread.ID === g.THREADID) { if (g.VIEW === 'thread' && this.thread.ID === g.THREADID) {
return; return;
} }
postLink = $('a[title="Highlight this post"]', this.nodes.info); postlink = $('a[title="Highlight this post"]', this.nodes.info);
return $.on(postLink, 'click', Navigate.navigate); $.on(postlink, 'click', Navigate.navigate);
if (!Conf['Quote Hash Navigation']) {
return;
}
_ref = $$('.hashlink', this.nodes.comment);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
hashlink = _ref[_i];
$.on(hashlink, 'click', Navigate.navigate);
}
}, },
clean: function() { clean: function() {
var posts, threads; var posts, threads;
@ -15829,13 +15836,12 @@
return $('.boardTitle').textContent = d.title = "/" + board + "/ - " + title; return $('.boardTitle').textContent = d.title = "/" + board + "/ - " + title;
}, },
navigate: function(e) { navigate: function(e) {
var boardID, hash, onload, pageNum, path, threadID, view; var boardID, onload, pageNum, path, threadID, view;
if (this.hostname !== 'boards.4chan.org' || window.location.hostname === 'rs.4chan.org' || (e && (e.shiftKey || (e.type === 'click' && e.button !== 0)))) { if (this.hostname !== 'boards.4chan.org' || window.location.hostname === 'rs.4chan.org' || (e && (e.shiftKey || (e.type === 'click' && e.button !== 0)))) {
return; return;
} }
$.addClass(Index.button, 'fa-spin'); $.addClass(Index.button, 'fa-spin');
path = this.pathname.split('/'); path = this.pathname.split('/');
hash = this.hash;
if (path[0] === '') { if (path[0] === '') {
path.shift(); path.shift();
} }
@ -15843,12 +15849,17 @@
if (view === 'catalog' || ('f' === boardID || 'f' === g.BOARD.ID)) { if (view === 'catalog' || ('f' === boardID || 'f' === g.BOARD.ID)) {
return; return;
} }
path = this.pathname;
if (this.hash) {
path += this.hash;
}
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
if (this.id !== 'popState') { if (this.id !== 'popState') {
history.pushState(null, '', this.pathname); history.pushState(null, '', path);
} }
Navigate.path = this.pathname;
if (threadID) { if (threadID) {
view = 'thread'; view = 'thread';
} else { } else {
@ -15867,14 +15878,10 @@
} else { } else {
Navigate.updateBoard(boardID); Navigate.updateBoard(boardID);
} }
if (Conf['Index Mode'] === 'paged' && pageNum) { return Index.update(pageNum);
return Index.update(pageNum);
} else {
return Index.update();
}
} else { } else {
onload = function(e) { onload = function(e) {
return Navigate.load(e, hash); return Navigate.load(e);
}; };
Navigate.req = $.ajax("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", { Navigate.req = $.ajax("//a.4cdn.org/" + boardID + "/res/" + threadID + ".json", {
onabort: onload, onabort: onload,
@ -15952,7 +15959,8 @@
Main.callbackNodes(Thread, [thread]); Main.callbackNodes(Thread, [thread]);
Main.callbackNodes(Post, posts); Main.callbackNodes(Post, posts);
Navigate.ready('Quote Threading', QuoteThreading.force, Conf['Quote Threading']); Navigate.ready('Quote Threading', QuoteThreading.force, Conf['Quote Threading']);
return Navigate.buildThread(); Navigate.buildThread();
return Header.hashScroll.call(window);
}, },
buildThread: function() { buildThread: function() {
var board; var board;
@ -15967,6 +15975,9 @@
}, },
popstate: function() { popstate: function() {
var a; var a;
if (window.location.pathname === Navigate.path) {
return;
}
a = $.el('a', { a = $.el('a', {
href: window.location, href: window.location,
id: 'popState' id: 'popState'

View File

@ -1,9 +1,10 @@
Navigate = Navigate =
path: window.location.pathname
init: -> init: ->
return if g.VIEW is 'catalog' or g.BOARD.ID is 'f' return if g.VIEW is 'catalog' or g.BOARD.ID is 'f'
# blink/webkit throw a popstate on page load. Not what we want. # blink/webkit throw a popstate on page load. Not what we want.
ready: -> $.ready ->
$.on window, 'popstate', Navigate.popstate $.on window, 'popstate', Navigate.popstate
Thread.callbacks.push Thread.callbacks.push
@ -22,8 +23,15 @@ Navigate =
post: -> post: ->
# We don't need to reload the thread inside the thread # We don't need to reload the thread inside the thread
return if g.VIEW is 'thread' and @thread.ID is g.THREADID return if g.VIEW is 'thread' and @thread.ID is g.THREADID
postLink = $ 'a[title="Highlight this post"]', @nodes.info postlink = $ 'a[title="Highlight this post"]', @nodes.info
$.on postLink, 'click', Navigate.navigate $.on postlink, 'click', Navigate.navigate
return unless Conf['Quote Hash Navigation']
for hashlink in $$ '.hashlink', @nodes.comment
$.on hashlink, 'click', Navigate.navigate
return
clean: -> clean: ->
{posts, threads} = g {posts, threads} = g
@ -125,7 +133,7 @@ Navigate =
error: err error: err
] ]
return false return false
return unless board return unless board
Navigate.updateTitle board Navigate.updateTitle board
@ -139,7 +147,7 @@ Navigate =
['ws', 'Yotsuba B New'] ['ws', 'Yotsuba B New']
else else
['nws', 'Yotsuba New'] ['nws', 'Yotsuba New']
$.globalEval "var style_group = '#{style[1]}'" $.globalEval "var style_group = '#{style[1]}'"
mainStyleSheet = $ 'link[title=switch]', d.head mainStyleSheet = $ 'link[title=switch]', d.head
@ -174,14 +182,17 @@ Navigate =
$.addClass Index.button, 'fa-spin' $.addClass Index.button, 'fa-spin'
path = @pathname.split '/' path = @pathname.split '/'
hash = @hash
path.shift() if path[0] is '' path.shift() if path[0] is ''
[boardID, view, threadID] = path [boardID, view, threadID] = path
return if view is 'catalog' or 'f' in [boardID, g.BOARD.ID] return if view is 'catalog' or 'f' in [boardID, g.BOARD.ID]
path = @pathname
path += @hash if @hash
e.preventDefault() if e e.preventDefault() if e
history.pushState null, '', @pathname unless @id is 'popState' history.pushState null, '', path unless @id is 'popState'
Navigate.path = @pathname
if threadID if threadID
view = 'thread' view = 'thread'
@ -201,14 +212,11 @@ Navigate =
else else
Navigate.updateBoard boardID Navigate.updateBoard boardID
if Conf['Index Mode'] is 'paged' and pageNum Index.update pageNum
Index.update pageNum
else
Index.update()
# Moving from index to thread or thread to thread # Moving from index to thread or thread to thread
else else
onload = (e) -> Navigate.load e, hash onload = (e) -> Navigate.load e
Navigate.req = $.ajax "//a.4cdn.org/#{boardID}/res/#{threadID}.json", Navigate.req = $.ajax "//a.4cdn.org/#{boardID}/res/#{threadID}.json",
onabort: onload onabort: onload
onloadend: onload onloadend: onload
@ -277,6 +285,7 @@ Navigate =
Navigate.ready 'Quote Threading', QuoteThreading.force, Conf['Quote Threading'] Navigate.ready 'Quote Threading', QuoteThreading.force, Conf['Quote Threading']
Navigate.buildThread() Navigate.buildThread()
Header.hashScroll.call window
buildThread: -> buildThread: ->
board = $ '.board' board = $ '.board'
@ -288,7 +297,8 @@ Navigate =
Unread.read() Unread.read()
Unread.update() Unread.update()
popstate: -> popstate: ->
return if window.location.pathname is Navigate.path
a = $.el 'a', a = $.el 'a',
href: window.location href: window.location
id: 'popState' id: 'popState'