Header.headerBar -> Header.bar
This commit is contained in:
parent
75858153c8
commit
9e03194f7d
@ -1024,12 +1024,12 @@
|
|||||||
id: 'header',
|
id: 'header',
|
||||||
innerHTML: "<div id=header-bar class=dialog>\n <span class='menu-button brackets-wrap'><a href=javascript:;><i></i></a></span>\n <span class=brackets-wrap hidden>top secret</span>\n <span id=board-list>\n <span id=custom-board-list></span>\n <span id=full-board-list hidden></span>\n </span>\n <div id=toggle-header-bar title=\"Toggle the header auto-hiding.\"></div>\n</div>\n<div id=notifications></div>".replace(/>\s+</g, '><')
|
innerHTML: "<div id=header-bar class=dialog>\n <span class='menu-button brackets-wrap'><a href=javascript:;><i></i></a></span>\n <span class=brackets-wrap hidden>top secret</span>\n <span id=board-list>\n <span id=custom-board-list></span>\n <span id=full-board-list hidden></span>\n </span>\n <div id=toggle-header-bar title=\"Toggle the header auto-hiding.\"></div>\n</div>\n<div id=notifications></div>".replace(/>\s+</g, '><')
|
||||||
});
|
});
|
||||||
this.headerBar = $('#header-bar', headerEl);
|
this.bar = $('#header-bar', headerEl);
|
||||||
this.setBarVisibility(Conf['Header auto-hide']);
|
this.setBarVisibility(Conf['Header auto-hide']);
|
||||||
$.sync('Header auto-hide', this.setBarVisibility);
|
$.sync('Header auto-hide', this.setBarVisibility);
|
||||||
this.menu = new UI.Menu('header');
|
this.menu = new UI.Menu('header');
|
||||||
$.on($('.menu-button', this.headerBar), 'click', this.menuToggle);
|
$.on($('.menu-button', this.bar), 'click', this.menuToggle);
|
||||||
$.on($('#toggle-header-bar', this.headerBar), 'click', this.toggleBarVisibility);
|
$.on($('#toggle-header-bar', this.bar), 'click', this.toggleBarVisibility);
|
||||||
catalogToggler = $.el('label', {
|
catalogToggler = $.el('label', {
|
||||||
innerHTML: "<input type=checkbox " + (Conf['Header catalog links'] ? 'checked' : '') + "> Use catalog board links"
|
innerHTML: "<input type=checkbox " + (Conf['Header catalog links'] ? 'checked' : '') + "> Use catalog board links"
|
||||||
});
|
});
|
||||||
@ -1058,7 +1058,7 @@
|
|||||||
if (a = $("a[href*='/" + g.BOARD + "/']", nav)) {
|
if (a = $("a[href*='/" + g.BOARD + "/']", nav)) {
|
||||||
a.className = 'current';
|
a.className = 'current';
|
||||||
}
|
}
|
||||||
fullBoardList = $('#full-board-list', Header.headerBar);
|
fullBoardList = $('#full-board-list', Header.bar);
|
||||||
$.add(fullBoardList, __slice.call(nav.childNodes));
|
$.add(fullBoardList, __slice.call(nav.childNodes));
|
||||||
if (Conf['Custom Board Navigation']) {
|
if (Conf['Custom Board Navigation']) {
|
||||||
Header.generateBoardList(Conf['boardnav']);
|
Header.generateBoardList(Conf['boardnav']);
|
||||||
@ -1070,14 +1070,14 @@
|
|||||||
$.on(btn, 'click', Header.toggleBoardList);
|
$.on(btn, 'click', Header.toggleBoardList);
|
||||||
$.prepend(fullBoardList, btn);
|
$.prepend(fullBoardList, btn);
|
||||||
} else {
|
} else {
|
||||||
$.rm($('#custom-board-list', Header.headerBar));
|
$.rm($('#custom-board-list', Header.bar));
|
||||||
fullBoardList.hidden = false;
|
fullBoardList.hidden = false;
|
||||||
}
|
}
|
||||||
return Header.setCatalogLinks(Conf['Header catalog links']);
|
return Header.setCatalogLinks(Conf['Header catalog links']);
|
||||||
},
|
},
|
||||||
generateBoardList: function(text) {
|
generateBoardList: function(text) {
|
||||||
var as, list, nodes;
|
var as, list, nodes;
|
||||||
as = $$('#full-board-list a', Header.headerBar).slice(0, -2);
|
as = $$('#full-board-list a', Header.bar).slice(0, -2);
|
||||||
nodes = text.match(/[\w@]+(-(all|title|full|text:"[^"]+"))?|[^\w@]+/g).map(function(t) {
|
nodes = text.match(/[\w@]+(-(all|title|full|text:"[^"]+"))?|[^\w@]+/g).map(function(t) {
|
||||||
var a, board, m, _i, _len;
|
var a, board, m, _i, _len;
|
||||||
if (/^[^\w@]/.test(t)) {
|
if (/^[^\w@]/.test(t)) {
|
||||||
@ -1112,20 +1112,20 @@
|
|||||||
}
|
}
|
||||||
return $.tn(t);
|
return $.tn(t);
|
||||||
});
|
});
|
||||||
list = $('#custom-board-list', Header.headerBar);
|
list = $('#custom-board-list', Header.bar);
|
||||||
list.innerHTML = null;
|
list.innerHTML = null;
|
||||||
return $.add(list, nodes);
|
return $.add(list, nodes);
|
||||||
},
|
},
|
||||||
toggleBoardList: function() {
|
toggleBoardList: function() {
|
||||||
var headerBar, showBoardList;
|
var bar, showBoardList;
|
||||||
showBoardList = $.hasClass(this, 'show-board-list-button');
|
showBoardList = $.hasClass(this, 'show-board-list-button');
|
||||||
headerBar = Header.headerBar;
|
bar = Header.bar;
|
||||||
$('#custom-board-list', headerBar).hidden = showBoardList;
|
$('#custom-board-list', bar).hidden = showBoardList;
|
||||||
return $('#full-board-list', headerBar).hidden = !showBoardList;
|
return $('#full-board-list', bar).hidden = !showBoardList;
|
||||||
},
|
},
|
||||||
setCatalogLinks: function(useCatalog) {
|
setCatalogLinks: function(useCatalog) {
|
||||||
var a, as, str, _i, _len;
|
var a, as, str, _i, _len;
|
||||||
as = $$('#board-list a[href*="boards.4chan.org"]', Header.headerBar);
|
as = $$('#board-list a[href*="boards.4chan.org"]', Header.bar);
|
||||||
str = useCatalog ? 'catalog' : '';
|
str = useCatalog ? 'catalog' : '';
|
||||||
for (_i = 0, _len = as.length; _i < _len; _i++) {
|
for (_i = 0, _len = as.length; _i < _len; _i++) {
|
||||||
a = as[_i];
|
a = as[_i];
|
||||||
@ -1137,11 +1137,11 @@
|
|||||||
return $.set('Header catalog links', this.checked);
|
return $.set('Header catalog links', this.checked);
|
||||||
},
|
},
|
||||||
setBarVisibility: function(hide) {
|
setBarVisibility: function(hide) {
|
||||||
return (hide ? $.addClass : $.rmClass)(Header.headerBar, 'autohide');
|
return (hide ? $.addClass : $.rmClass)(Header.bar, 'autohide');
|
||||||
},
|
},
|
||||||
toggleBarVisibility: function() {
|
toggleBarVisibility: function() {
|
||||||
var hide, message;
|
var hide, message;
|
||||||
hide = !$.hasClass(Header.headerBar, 'autohide');
|
hide = !$.hasClass(Header.bar, 'autohide');
|
||||||
Header.setBarVisibility(hide);
|
Header.setBarVisibility(hide);
|
||||||
message = hide ? 'The header bar will automatically hide itself.' : 'The header bar will remain visible.';
|
message = hide ? 'The header bar will automatically hide itself.' : 'The header bar will remain visible.';
|
||||||
new Notification('info', message, 2);
|
new Notification('info', message, 2);
|
||||||
@ -3087,7 +3087,7 @@
|
|||||||
},
|
},
|
||||||
hl: function(delta, thread) {
|
hl: function(delta, thread) {
|
||||||
var headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len;
|
var headRect, next, postEl, rect, replies, reply, root, topMargin, _i, _len;
|
||||||
headRect = Header.headerBar.getBoundingClientRect();
|
headRect = Header.bar.getBoundingClientRect();
|
||||||
topMargin = headRect.top + headRect.height;
|
topMargin = headRect.top + headRect.height;
|
||||||
if (postEl = $('.reply.highlight', thread)) {
|
if (postEl = $('.reply.highlight', thread)) {
|
||||||
$.rmClass(postEl, 'highlight');
|
$.rmClass(postEl, 'highlight');
|
||||||
@ -3165,7 +3165,7 @@
|
|||||||
},
|
},
|
||||||
getThread: function(full) {
|
getThread: function(full) {
|
||||||
var headRect, i, rect, thread, threads, topMargin, _i, _len;
|
var headRect, i, rect, thread, threads, topMargin, _i, _len;
|
||||||
headRect = Header.headerBar.getBoundingClientRect();
|
headRect = Header.bar.getBoundingClientRect();
|
||||||
topMargin = headRect.top + headRect.height;
|
topMargin = headRect.top + headRect.height;
|
||||||
threads = $$('.thread:not([hidden])');
|
threads = $$('.thread:not([hidden])');
|
||||||
for (i = _i = 0, _len = threads.length; _i < _len; i = ++_i) {
|
for (i = _i = 0, _len = threads.length; _i < _len; i = ++_i) {
|
||||||
@ -4651,7 +4651,7 @@
|
|||||||
rect = thumb.parentNode.getBoundingClientRect();
|
rect = thumb.parentNode.getBoundingClientRect();
|
||||||
if (rect.bottom > 0) {
|
if (rect.bottom > 0) {
|
||||||
postRect = post.nodes.root.getBoundingClientRect();
|
postRect = post.nodes.root.getBoundingClientRect();
|
||||||
headRect = Header.headerBar.getBoundingClientRect();
|
headRect = Header.bar.getBoundingClientRect();
|
||||||
top = postRect.top - headRect.top - headRect.height - 2;
|
top = postRect.top - headRect.top - headRect.height - 2;
|
||||||
root = $.engine === 'webkit' ? d.body : doc;
|
root = $.engine === 'webkit' ? d.body : doc;
|
||||||
if (rect.top < 0) {
|
if (rect.top < 0) {
|
||||||
|
|||||||
@ -15,13 +15,13 @@ Header =
|
|||||||
<div id=notifications></div>
|
<div id=notifications></div>
|
||||||
""".replace />\s+</g, '><' # get rid of spaces between elements
|
""".replace />\s+</g, '><' # get rid of spaces between elements
|
||||||
|
|
||||||
@headerBar = $ '#header-bar', headerEl
|
@bar = $ '#header-bar', headerEl
|
||||||
@setBarVisibility Conf['Header auto-hide']
|
@setBarVisibility Conf['Header auto-hide']
|
||||||
$.sync 'Header auto-hide', @setBarVisibility
|
$.sync 'Header auto-hide', @setBarVisibility
|
||||||
|
|
||||||
@menu = new UI.Menu 'header'
|
@menu = new UI.Menu 'header'
|
||||||
$.on $('.menu-button', @headerBar), 'click', @menuToggle
|
$.on $('.menu-button', @bar), 'click', @menuToggle
|
||||||
$.on $('#toggle-header-bar', @headerBar), 'click', @toggleBarVisibility
|
$.on $('#toggle-header-bar', @bar), 'click', @toggleBarVisibility
|
||||||
|
|
||||||
catalogToggler = $.el 'label',
|
catalogToggler = $.el 'label',
|
||||||
innerHTML: "<input type=checkbox #{if Conf['Header catalog links'] then 'checked' else ''}> Use catalog board links"
|
innerHTML: "<input type=checkbox #{if Conf['Header catalog links'] then 'checked' else ''}> Use catalog board links"
|
||||||
@ -41,7 +41,7 @@ Header =
|
|||||||
nav = $.id 'boardNavDesktop'
|
nav = $.id 'boardNavDesktop'
|
||||||
if a = $ "a[href*='/#{g.BOARD}/']", nav
|
if a = $ "a[href*='/#{g.BOARD}/']", nav
|
||||||
a.className = 'current'
|
a.className = 'current'
|
||||||
fullBoardList = $ '#full-board-list', Header.headerBar
|
fullBoardList = $ '#full-board-list', Header.bar
|
||||||
$.add fullBoardList, [nav.childNodes...]
|
$.add fullBoardList, [nav.childNodes...]
|
||||||
|
|
||||||
if Conf['Custom Board Navigation']
|
if Conf['Custom Board Navigation']
|
||||||
@ -53,13 +53,13 @@ Header =
|
|||||||
$.on btn, 'click', Header.toggleBoardList
|
$.on btn, 'click', Header.toggleBoardList
|
||||||
$.prepend fullBoardList, btn
|
$.prepend fullBoardList, btn
|
||||||
else
|
else
|
||||||
$.rm $ '#custom-board-list', Header.headerBar
|
$.rm $ '#custom-board-list', Header.bar
|
||||||
fullBoardList.hidden = false
|
fullBoardList.hidden = false
|
||||||
|
|
||||||
Header.setCatalogLinks Conf['Header catalog links']
|
Header.setCatalogLinks Conf['Header catalog links']
|
||||||
|
|
||||||
generateBoardList: (text) ->
|
generateBoardList: (text) ->
|
||||||
as = $$('#full-board-list a', Header.headerBar)[0...-2] # ignore the Settings and Home links
|
as = $$('#full-board-list a', Header.bar)[0...-2] # ignore the Settings and Home links
|
||||||
nodes = text.match(/[\w@]+(-(all|title|full|text:"[^"]+"))?|[^\w@]+/g).map (t) ->
|
nodes = text.match(/[\w@]+(-(all|title|full|text:"[^"]+"))?|[^\w@]+/g).map (t) ->
|
||||||
if /^[^\w@]/.test t
|
if /^[^\w@]/.test t
|
||||||
return $.tn t
|
return $.tn t
|
||||||
@ -87,18 +87,18 @@ Header =
|
|||||||
$.log t, t.match /-text:"(.+)"$/
|
$.log t, t.match /-text:"(.+)"$/
|
||||||
return a
|
return a
|
||||||
$.tn t
|
$.tn t
|
||||||
list = $ '#custom-board-list', Header.headerBar
|
list = $ '#custom-board-list', Header.bar
|
||||||
list.innerHTML = null
|
list.innerHTML = null
|
||||||
$.add list, nodes
|
$.add list, nodes
|
||||||
|
|
||||||
toggleBoardList: ->
|
toggleBoardList: ->
|
||||||
showBoardList = $.hasClass @, 'show-board-list-button'
|
showBoardList = $.hasClass @, 'show-board-list-button'
|
||||||
{headerBar} = Header
|
{bar} = Header
|
||||||
$('#custom-board-list', headerBar).hidden = showBoardList
|
$('#custom-board-list', bar).hidden = showBoardList
|
||||||
$('#full-board-list', headerBar).hidden = !showBoardList
|
$('#full-board-list', bar).hidden = !showBoardList
|
||||||
|
|
||||||
setCatalogLinks: (useCatalog) ->
|
setCatalogLinks: (useCatalog) ->
|
||||||
as = $$ '#board-list a[href*="boards.4chan.org"]', Header.headerBar
|
as = $$ '#board-list a[href*="boards.4chan.org"]', Header.bar
|
||||||
str = if useCatalog then 'catalog' else ''
|
str = if useCatalog then 'catalog' else ''
|
||||||
for a in as
|
for a in as
|
||||||
a.pathname = "/#{a.pathname.split('/')[1]}/#{str}"
|
a.pathname = "/#{a.pathname.split('/')[1]}/#{str}"
|
||||||
@ -108,9 +108,9 @@ Header =
|
|||||||
$.set 'Header catalog links', @checked
|
$.set 'Header catalog links', @checked
|
||||||
|
|
||||||
setBarVisibility: (hide) ->
|
setBarVisibility: (hide) ->
|
||||||
(if hide then $.addClass else $.rmClass) Header.headerBar, 'autohide'
|
(if hide then $.addClass else $.rmClass) Header.bar, 'autohide'
|
||||||
toggleBarVisibility: ->
|
toggleBarVisibility: ->
|
||||||
hide = !$.hasClass Header.headerBar, 'autohide'
|
hide = !$.hasClass Header.bar, 'autohide'
|
||||||
Header.setBarVisibility hide
|
Header.setBarVisibility hide
|
||||||
message = if hide
|
message = if hide
|
||||||
'The header bar will automatically hide itself.'
|
'The header bar will automatically hide itself.'
|
||||||
@ -1756,7 +1756,7 @@ Keybinds =
|
|||||||
location.href = url
|
location.href = url
|
||||||
|
|
||||||
hl: (delta, thread) ->
|
hl: (delta, thread) ->
|
||||||
headRect = Header.headerBar.getBoundingClientRect()
|
headRect = Header.bar.getBoundingClientRect()
|
||||||
topMargin = headRect.top + headRect.height
|
topMargin = headRect.top + headRect.height
|
||||||
if postEl = $ '.reply.highlight', thread
|
if postEl = $ '.reply.highlight', thread
|
||||||
$.rmClass postEl, 'highlight'
|
$.rmClass postEl, 'highlight'
|
||||||
@ -1816,7 +1816,7 @@ Nav =
|
|||||||
Nav.scroll +1
|
Nav.scroll +1
|
||||||
|
|
||||||
getThread: (full) ->
|
getThread: (full) ->
|
||||||
headRect = Header.headerBar.getBoundingClientRect()
|
headRect = Header.bar.getBoundingClientRect()
|
||||||
topMargin = headRect.top + headRect.height
|
topMargin = headRect.top + headRect.height
|
||||||
threads = $$ '.thread:not([hidden])'
|
threads = $$ '.thread:not([hidden])'
|
||||||
for thread, i in threads
|
for thread, i in threads
|
||||||
@ -3117,7 +3117,7 @@ ImageExpand =
|
|||||||
# Scroll back to the thumbnail when contracting the image
|
# Scroll back to the thumbnail when contracting the image
|
||||||
# to avoid being left miles away from the relevant post.
|
# to avoid being left miles away from the relevant post.
|
||||||
postRect = post.nodes.root.getBoundingClientRect()
|
postRect = post.nodes.root.getBoundingClientRect()
|
||||||
headRect = Header.headerBar.getBoundingClientRect()
|
headRect = Header.bar.getBoundingClientRect()
|
||||||
top = postRect.top - headRect.top - headRect.height - 2
|
top = postRect.top - headRect.top - headRect.height - 2
|
||||||
root = if $.engine is 'webkit'
|
root = if $.engine is 'webkit'
|
||||||
d.body
|
d.body
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user