Merge from Appchan X: src/General/Header.coffee
This commit is contained in:
parent
e1b63d4a99
commit
8c17090b3d
@ -6,14 +6,16 @@ Header =
|
|||||||
className: 'menu-button'
|
className: 'menu-button'
|
||||||
$.extend menuButton, <%= html('<i></i>') %>
|
$.extend menuButton, <%= html('<i></i>') %>
|
||||||
|
|
||||||
barFixedToggler = UI.checkbox 'Fixed Header', 'Fixed Header'
|
box = UI.checkbox
|
||||||
headerToggler = UI.checkbox 'Header auto-hide', 'Auto-hide header'
|
|
||||||
scrollHeaderToggler = UI.checkbox 'Header auto-hide on scroll', 'Auto-hide header on scroll'
|
barFixedToggler = box 'Fixed Header', 'Fixed Header'
|
||||||
barPositionToggler = UI.checkbox 'Bottom Header', 'Bottom header'
|
headerToggler = box 'Header auto-hide', 'Auto-hide header'
|
||||||
linkJustifyToggler = UI.checkbox 'Centered links', 'Centered links'
|
scrollHeaderToggler = box 'Header auto-hide on scroll', 'Auto-hide header on scroll'
|
||||||
customNavToggler = UI.checkbox 'Custom Board Navigation', 'Custom board navigation'
|
barPositionToggler = box 'Bottom Header', 'Bottom header'
|
||||||
footerToggler = UI.checkbox 'Bottom Board List', 'Hide bottom board list'
|
linkJustifyToggler = box 'Centered links', 'Centered links'
|
||||||
shortcutToggler = UI.checkbox 'Shortcut Icons', 'Shortcut Icons'
|
customNavToggler = box 'Custom Board Navigation', 'Custom board navigation'
|
||||||
|
footerToggler = box 'Bottom Board List', 'Hide bottom board list'
|
||||||
|
shortcutToggler = box 'Shortcut Icons', 'Shortcut Icons'
|
||||||
editCustomNav = $.el 'a',
|
editCustomNav = $.el 'a',
|
||||||
textContent: 'Edit custom board navigation'
|
textContent: 'Edit custom board navigation'
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
@ -33,7 +35,6 @@ Header =
|
|||||||
$.on @barPositionToggler, 'change', @toggleBarPosition
|
$.on @barPositionToggler, 'change', @toggleBarPosition
|
||||||
$.on @scrollHeaderToggler, 'change', @toggleHideBarOnScroll
|
$.on @scrollHeaderToggler, 'change', @toggleHideBarOnScroll
|
||||||
$.on @linkJustifyToggler, 'change', @toggleLinkJustify
|
$.on @linkJustifyToggler, 'change', @toggleLinkJustify
|
||||||
$.on @headerToggler, 'change', @toggleBarVisibility
|
|
||||||
$.on @footerToggler, 'change', @toggleFooterVisibility
|
$.on @footerToggler, 'change', @toggleFooterVisibility
|
||||||
$.on @shortcutToggler, 'change', @toggleShortcutIcons
|
$.on @shortcutToggler, 'change', @toggleShortcutIcons
|
||||||
$.on @customNavToggler, 'change', @toggleCustomNav
|
$.on @customNavToggler, 'change', @toggleCustomNav
|
||||||
@ -185,79 +186,78 @@ Header =
|
|||||||
return unless boardnav
|
return unless boardnav
|
||||||
boardnav = boardnav.replace /(\r\n|\n|\r)/g, ' '
|
boardnav = boardnav.replace /(\r\n|\n|\r)/g, ' '
|
||||||
as = $$ '#full-board-list a[title]', Header.boardList
|
as = $$ '#full-board-list a[title]', Header.boardList
|
||||||
nodes = boardnav.match(/[\w@]+(-(all|title|replace|full|index|catalog|archive|expired|text:"[^"]+"(,"[^"]+")?))*|[^\w@]+/g).map (t) ->
|
re = /[\w@]+(-(all|title|replace|full|index|catalog|archive|expired|text:"[^"]+"(,"[^"]+")?))*|[^\w@]+/g
|
||||||
if /^[^\w@]/.test t
|
nodes = (Header.mapCustomNavigation t, as for t in boardnav.match re)
|
||||||
return $.tn t
|
|
||||||
|
|
||||||
text = url = null
|
|
||||||
t = t.replace /-text:"([^"]+)"(?:,"([^"]+)")?/g, (m0, m1, m2) ->
|
|
||||||
text = m1
|
|
||||||
url = m2
|
|
||||||
''
|
|
||||||
|
|
||||||
if /^toggle-all/.test t
|
|
||||||
a = $.el 'a',
|
|
||||||
className: 'show-board-list-button'
|
|
||||||
textContent: text or '+'
|
|
||||||
href: 'javascript:;'
|
|
||||||
$.on a, 'click', Header.toggleBoardList
|
|
||||||
return a
|
|
||||||
|
|
||||||
if /^external/.test t
|
|
||||||
a = $.el 'a',
|
|
||||||
href: url or 'javascript:;'
|
|
||||||
textContent: text or '+'
|
|
||||||
className: 'external'
|
|
||||||
return a
|
|
||||||
|
|
||||||
boardID = if /^current/.test t
|
|
||||||
g.BOARD.ID
|
|
||||||
else
|
|
||||||
t.match(/^[^-]+/)[0]
|
|
||||||
|
|
||||||
for aOrig in as
|
|
||||||
if aOrig.textContent is boardID
|
|
||||||
a = aOrig.cloneNode true
|
|
||||||
if !a
|
|
||||||
if /^current/.test t
|
|
||||||
a = $.el 'a',
|
|
||||||
href: "/#{boardID}/"
|
|
||||||
textContent: boardID
|
|
||||||
else
|
|
||||||
return $.tn t
|
|
||||||
|
|
||||||
a.textContent = if /-title/.test(t) or /-replace/.test(t) and $.hasClass a, 'current'
|
|
||||||
a.title or a.textContent
|
|
||||||
else if /-full/.test t
|
|
||||||
"/#{boardID}/" + (if a.title then " - #{a.title}" else '')
|
|
||||||
else if text
|
|
||||||
text
|
|
||||||
else
|
|
||||||
a.textContent
|
|
||||||
|
|
||||||
if m = t.match /-(index|catalog)/
|
|
||||||
a.dataset.only = m[1]
|
|
||||||
a.href = CatalogLinks[m[1]] boardID
|
|
||||||
$.addClass a, 'catalog' if m[1] is 'catalog'
|
|
||||||
|
|
||||||
if /-archive/.test t
|
|
||||||
if href = Redirect.to 'board', {boardID}
|
|
||||||
a.href = href
|
|
||||||
else
|
|
||||||
return $.tn a.textContent
|
|
||||||
|
|
||||||
if /-expired/.test t
|
|
||||||
if boardID not in ['b', 'f']
|
|
||||||
a.href = "/#{boardID}/archive"
|
|
||||||
else
|
|
||||||
return $.tn a.textContent
|
|
||||||
|
|
||||||
$.addClass a, 'navSmall' if boardID is '@'
|
|
||||||
return a
|
|
||||||
|
|
||||||
$.add list, nodes
|
$.add list, nodes
|
||||||
$.ready CatalogLinks.initBoardList
|
$.ready CatalogLinks.initBoardList
|
||||||
|
|
||||||
|
mapCustomNavigation: (t, as) ->
|
||||||
|
if /^[^\w@]/.test t
|
||||||
|
return $.tn t
|
||||||
|
|
||||||
|
text = url = null
|
||||||
|
t = t.replace /-text:"([^"]+)"(?:,"([^"]+)")?/g, (m0, m1, m2) ->
|
||||||
|
text = m1
|
||||||
|
url = m2
|
||||||
|
''
|
||||||
|
|
||||||
|
if /^toggle-all/.test t
|
||||||
|
a = $.el 'a',
|
||||||
|
className: 'show-board-list-button'
|
||||||
|
textContent: text or '+'
|
||||||
|
href: 'javascript:;'
|
||||||
|
$.on a, 'click', Header.toggleBoardList
|
||||||
|
return a
|
||||||
|
|
||||||
|
if /^external/.test t
|
||||||
|
a = $.el 'a',
|
||||||
|
href: url or 'javascript:;'
|
||||||
|
textContent: text or '+'
|
||||||
|
className: 'external'
|
||||||
|
return a
|
||||||
|
|
||||||
|
boardID = t.split('-')[0]
|
||||||
|
boardID = g.BOARD.ID if boardID is 'current'
|
||||||
|
|
||||||
|
for aOrig in as
|
||||||
|
if aOrig.textContent is boardID
|
||||||
|
a = aOrig.cloneNode true
|
||||||
|
if !a
|
||||||
|
if /^current/.test t
|
||||||
|
a = $.el 'a',
|
||||||
|
href: "/#{boardID}/"
|
||||||
|
textContent: boardID
|
||||||
|
else
|
||||||
|
return $.tn t
|
||||||
|
|
||||||
|
a.textContent = if /-title/.test(t) or /-replace/.test(t) and boardID is g.BOARD.ID
|
||||||
|
a.title or a.textContent
|
||||||
|
else if /-full/.test t
|
||||||
|
"/#{boardID}/" + (if a.title then " - #{a.title}" else '')
|
||||||
|
else
|
||||||
|
text or boardID
|
||||||
|
|
||||||
|
if m = t.match /-(index|catalog)/
|
||||||
|
a.dataset.only = m[1]
|
||||||
|
a.href = CatalogLinks[m[1]] boardID
|
||||||
|
$.addClass a, 'catalog' if m[1] is 'catalog'
|
||||||
|
|
||||||
|
if /-archive/.test t
|
||||||
|
if href = Redirect.to 'board', {boardID}
|
||||||
|
a.href = href
|
||||||
|
else
|
||||||
|
return a.firstChild # Its text node.
|
||||||
|
|
||||||
|
if /-expired/.test t
|
||||||
|
if boardID not in ['b', 'f']
|
||||||
|
a.href = "/#{boardID}/archive"
|
||||||
|
else
|
||||||
|
return a.firstChild # Its text node.
|
||||||
|
|
||||||
|
$.addClass a, 'navSmall' if boardID is '@'
|
||||||
|
a
|
||||||
|
|
||||||
toggleBoardList: ->
|
toggleBoardList: ->
|
||||||
{bar} = Header
|
{bar} = Header
|
||||||
custom = $ '#custom-board-list', bar
|
custom = $ '#custom-board-list', bar
|
||||||
@ -323,10 +323,9 @@ Header =
|
|||||||
@checked
|
@checked
|
||||||
else
|
else
|
||||||
!$.hasClass Header.bar, 'autohide'
|
!$.hasClass Header.bar, 'autohide'
|
||||||
# set checked status if called from keybind
|
|
||||||
@checked = hide
|
|
||||||
|
|
||||||
$.set 'Header auto-hide', Conf['Header auto-hide'] = hide
|
Conf['Header auto-hide'] = hide
|
||||||
|
$.set 'Header auto-hide', hide
|
||||||
Header.setBarVisibility hide
|
Header.setBarVisibility hide
|
||||||
message = "The header bar will #{if hide
|
message = "The header bar will #{if hide
|
||||||
'automatically hide itself.'
|
'automatically hide itself.'
|
||||||
@ -412,7 +411,7 @@ Header =
|
|||||||
editCustomNav: ->
|
editCustomNav: ->
|
||||||
Settings.open 'Advanced'
|
Settings.open 'Advanced'
|
||||||
settings = $.id 'fourchanx-settings'
|
settings = $.id 'fourchanx-settings'
|
||||||
$('textarea[name=boardnav]', settings).focus()
|
$('[name=boardnav]', settings).focus()
|
||||||
|
|
||||||
hashScroll: ->
|
hashScroll: ->
|
||||||
hash = @location.hash[1..]
|
hash = @location.hash[1..]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user