Merge some appchan x flavor.

This commit is contained in:
Zixaphir 2013-04-16 10:42:43 -07:00
parent 0e103f0526
commit f66240b860
7 changed files with 388 additions and 228 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -94,15 +94,25 @@ a[href="javascript:;"] {
.fixed #boardNavDesktop { .fixed #boardNavDesktop {
z-index: 10; z-index: 10;
} }
/* Header */ /* Header */
.fourchan-x body { .fourchan-x body {
-moz-box-sizing: border-box; -moz-box-sizing: border-box;
box-sizing: border-box; box-sizing: border-box;
} }
.fixed.top body {
padding-top: 2em;
}
.fixed.bottom body {
padding-bottom: 2em;
}
#boardNavDesktop {
float: left;
}
.fixed #boardNavDesktop { .fixed #boardNavDesktop {
float: none;
right: 0; right: 0;
left: 0; left: 0;
padding: 3px 4px 4px;
} }
.fixed.top #boardNavDesktop { .fixed.top #boardNavDesktop {
top: 0; top: 0;
@ -112,8 +122,6 @@ a[href="javascript:;"] {
} }
#boardNavDesktop { #boardNavDesktop {
border-width: 0; border-width: 0;
padding: 3px 4px 4px;
position: relative;
transition: all .1s .05s ease-in-out; transition: all .1s .05s ease-in-out;
} }
.fixed.top #boardNavDesktop { .fixed.top #boardNavDesktop {

View File

@ -75,6 +75,10 @@ Config =
true true
'Embed supported services.' 'Embed supported services.'
] ]
'Auto-embed': [
false
'Auto-embed Linkify Embeds.'
]
'Link Title': [ 'Link Title': [
true true
'Replace the link of a supported site with its actual title. Currently Supported: YouTube, Vimeo, SoundCloud' 'Replace the link of a supported site with its actual title. Currently Supported: YouTube, Vimeo, SoundCloud'
@ -374,7 +378,7 @@ http://iqdb.org/?url=%TURL
'Custom CSS': false 'Custom CSS': false
'Bottom header': false 'Boards Navigation': 'sticky top'
'Header auto-hide': false 'Header auto-hide': false

View File

@ -1,13 +1,5 @@
Header = Header =
init: -> init: ->
@bar = $.el 'div',
id: 'notifications'
@shortcuts = $.el 'span',
id: 'shortcuts'
@hover = $.el 'div',
id: 'hoverUI'
@toggle = $.el 'div',
id: 'toggle-header-bar'
@menuButton = $.el 'span', @menuButton = $.el 'span',
className: 'menu-button' className: 'menu-button'
innerHTML: '<a class=brackets-wrap href=javascript:;><i></i></a>' innerHTML: '<a class=brackets-wrap href=javascript:;><i></i></a>'
@ -17,14 +9,20 @@ Header =
$.on @toggle, 'mousedown', @toggleBarVisibility $.on @toggle, 'mousedown', @toggleBarVisibility
$.on window, 'load hashchange', Header.hashScroll $.on window, 'load hashchange', Header.hashScroll
@positionToggler = $.el 'label', @positionToggler = $.el 'span',
innerHTML: "<input type=checkbox #{if Conf['Bottom header'] then 'checked' else ''}> Bottom header" textContent: 'Header Position'
$.on @positionToggler.firstElementChild, 'change', @toggleBarPosition className: 'header-position-link'
{createSubEntry} = Header
subEntries = []
for setting in ['sticky top', 'sticky bottom', 'top']
subEntries.push createSubEntry setting
$.event 'AddMenuEntry', $.event 'AddMenuEntry',
type: 'header' type: 'header'
el: @positionToggler el: @positionToggler
order: 108 order: 108
subEntries: subEntries
@headerToggler = $.el 'label', @headerToggler = $.el 'label',
innerHTML: "<input type=checkbox #{if Conf['Header auto-hide'] then 'checked' else ''}> Auto-hide header" innerHTML: "<input type=checkbox #{if Conf['Header auto-hide'] then 'checked' else ''}> Auto-hide header"
@ -46,6 +44,26 @@ Header =
$.ready -> $.ready ->
$.add d.body, Header.hover $.add d.body, Header.hover
bar: $.el 'div',
id: 'notifications'
shortcuts: $.el 'span',
id: 'shortcuts'
hover: $.el 'div',
id: 'hoverUI'
toggle: $.el 'div',
id: 'toggle-header-bar'
createSubEntry: (setting)->
label = $.el 'label',
textContent: "#{setting}"
$.on label, 'click', Header.setBarPosition
el: label
setBoardList: -> setBoardList: ->
Header.nav = nav = $.id 'boardNavDesktop' Header.nav = nav = $.id 'boardNavDesktop'
if a = $ "a[href*='/#{g.BOARD}/']", nav if a = $ "a[href*='/#{g.BOARD}/']", nav
@ -58,34 +76,29 @@ Header =
customBoardList = $.el 'span', customBoardList = $.el 'span',
id: 'custom-board-list' id: 'custom-board-list'
Header.fixedHeader nav if Conf['Fixed Header'] Header.setBarPosition.call textContent: "#{Conf['Boards Navigation']}"
$.sync 'Boards Navigation', Header.changeBarPosition
Header.setBarVisibility Conf['Header auto-hide']
$.sync 'Header auto-hide', Header.setBarVisibility
$.after nav, $.id 'navtopright'
$.add fullBoardList, [nav.childNodes...] $.add fullBoardList, [nav.childNodes...]
$.add nav, [Header.menuButton, customBoardList, fullBoardList, Header.shortcuts, $('#navtopright', fullBoardList), Header.toggle] $.add nav, [Header.menuButton, customBoardList, fullBoardList, Header.shortcuts, Header.bar, Header.toggle]
$.add d.body, Header.bar
if Conf['Custom Board Navigation'] if Conf['Custom Board Navigation']
Header.generateBoardList Conf['boardnav'] Header.generateBoardList Conf['boardnav']
$.sync 'boardnav', Header.generateBoardList $.sync 'boardnav', Header.generateBoardList
btn = $.el 'span', btn = $.el 'span',
className: 'hide-board-list-button brackets-wrap' className: 'hide-board-list-button'
innerHTML: '<a href=javascript:;> - </a>' innerHTML: '[<a href=javascript:;> - </a>]\u00A0'
$.on btn, 'click', Header.toggleBoardList $.on btn, 'click', Header.toggleBoardList
$.prepend fullBoardList, btn $.prepend fullBoardList, btn
else else
$.rm $ '#custom-board-list', nav $.rm $ '#custom-board-list', nav
fullBoardList.hidden = false fullBoardList.hidden = false
fixedHeader: (nav) ->
$.addClass doc, 'fixed'
$.addClass nav, 'dialog'
@setBarPosition Conf['Bottom header']
$.sync 'Bottom header', @setBarPosition
@setBarVisibility Conf['Header auto-hide']
$.sync 'Header auto-hide', @setBarVisibility
generateBoardList: (text) -> generateBoardList: (text) ->
list = $ '#custom-board-list', Header.nav list = $ '#custom-board-list', Header.nav
$.rmAll list $.rmAll list
@ -133,21 +146,30 @@ Header =
custom.hidden = !showBoardList custom.hidden = !showBoardList
full.hidden = showBoardList full.hidden = showBoardList
setBarPosition: (bottom) -> setBarPosition: ->
$.event 'CloseMenu' $.event 'CloseMenu'
Header.positionToggler.firstElementChild.checked = bottom
if bottom
$.addClass doc, 'bottom'
$.rmClass doc, 'top'
else
$.addClass doc, 'top'
$.rmClass doc, 'bottom'
toggleBarPosition: -> Header.changeBarPosition @textContent
bottom = @checked
Header.setBarPosition bottom Conf['Boards Navigation'] = @textContent
Conf['Bottom header'] = bottom $.set 'Boards Navigation', @textContent
$.set 'Bottom header', bottom
changeBarPosition: (setting) ->
$.rmClass doc, 'top'
$.rmClass doc, 'fixed'
$.rmClass doc, 'bottom'
$.rmClass Header.nav, 'dialog'
switch setting
when 'sticky top'
$.addClass doc, 'top'
$.addClass doc, 'fixed'
$.addClass Header.nav, 'dialog'
when 'sticky bottom'
$.addClass doc, 'fixed'
$.addClass doc, 'bottom'
$.addClass Header.nav, 'dialog'
when 'top'
$.addClass doc, 'top'
setBarVisibility: (hide) -> setBarVisibility: (hide) ->
Header.headerToggler.firstElementChild.checked = hide Header.headerToggler.firstElementChild.checked = hide
@ -160,10 +182,10 @@ Header =
scrollToPost: (post) -> scrollToPost: (post) ->
{top} = post.getBoundingClientRect() {top} = post.getBoundingClientRect()
unless Conf['Bottom header'] if Conf['Boards Navigation'] is 'sticky top'
headRect = Header.bar.getBoundingClientRect() headRect = Header.bar.getBoundingClientRect()
top += - headRect.top - headRect.height top += - headRect.top - headRect.height
<% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop += top (if $.engine is 'webkit' then d.body else doc).scrollTop += top
toggleBarVisibility: (e) -> toggleBarVisibility: (e) ->
return if e.type is 'mousedown' and e.button isnt 0 # not LMB return if e.type is 'mousedown' and e.button isnt 0 # not LMB
@ -4454,6 +4476,7 @@ ThreadWatcher =
ThreadWatcher.refresh watched ThreadWatcher.refresh watched
$.set 'WatchedThreads', watched $.set 'WatchedThreads', watched
Linkify = Linkify =
init: -> init: ->
return if g.VIEW is 'catalog' or not Conf['Linkify'] return if g.VIEW is 'catalog' or not Conf['Linkify']
@ -4560,6 +4583,12 @@ Linkify =
$.replace node, nodes $.replace node, nodes
if Conf['Auto-embed']
embeds = $$ '.embedder', @nodes.comment
for embed in embeds
embed.click()
return
toggle: -> toggle: ->
# We setup the link to be replaced by the embedded video # We setup the link to be replaced by the embedded video
embed = @previousElementSibling embed = @previousElementSibling
@ -4582,10 +4611,14 @@ Linkify =
el = (type = Linkify.types[@getAttribute("data-service")]).el.call @ el = (type = Linkify.types[@getAttribute("data-service")]).el.call @
# Set style values. # Set style values.
el.style.cssText = if style = type.style if style = type.style
style el.style.cssText = style
else else
"border: 0; width: #{$.get 'embedWidth', Config['embedWidth']}px; height: #{$.get 'embedHeight', Config['embedHeight']}px" items =
'embedWidth': Config['embedWidth']
'embedHeight': Config['embedHeight']
$.get items, (items) ->
el.style.cssText = "border: 0; width: #{items['embedWidth']}px; height: #{items['embedHeight']}px"
@textContent = '(unembed)' @textContent = '(unembed)'
@ -4653,6 +4686,7 @@ Linkify =
embedder: (a) -> embedder: (a) ->
return [a] unless Conf['Embedding'] return [a] unless Conf['Embedding']
titles = {}
callbacks = -> callbacks = ->
a.textContent = switch @status a.textContent = switch @status