4chan-x/src/Theming/Banner.coffee
Zixaphir 77433f5da8 Merge branch 'v3' into Av2
Conflicts:
	builds/4chan-X.js
	builds/4chan-X.meta.js
	builds/4chan-X.user.js
	builds/crx.crx
	builds/crx/manifest.json
	builds/crx/script.js
	package.json
	src/General/Config.coffee
	src/General/Main.coffee
	src/General/Settings.coffee
	src/General/css/burichan.css
	src/General/css/futaba.css
	src/General/css/photon.css
	src/General/css/style.css
	src/General/css/tomorrow.css
	src/General/css/yotsuba-b.css
	src/General/css/yotsuba.css
	src/General/img/favicons/Original/unreadDead.gif
	src/General/img/favicons/Original/unreadNSFW.gif
	src/General/img/favicons/Original/unreadSFW.gif
	src/General/img/favicons/dead.gif
	src/General/img/favicons/empty.gif
	src/General/img/favicons/ferongr/unreadDead.gif
	src/General/img/favicons/ferongr/unreadNSFW.gif
	src/General/img/favicons/ferongr/unreadSFW.gif
	src/General/meta/metadata.js
	src/Miscellaneous/AnnouncementHiding.coffee
	src/Miscellaneous/Keybinds.coffee
	src/Monitoring/ThreadStats.coffee
	src/Monitoring/ThreadUpdater.coffee
	src/Posting/QuickReply.coffee
	src/features/misc/header.coffee
	src/features/monitoring/favicon.coffee
2013-04-28 21:20:22 -07:00

71 lines
1.9 KiB
CoffeeScript

Banner =
init: ->
$.asap (-> d.body), ->
$.asap (-> $ '.abovePostForm'), Banner.ready
ready: ->
banner = $ ".boardBanner"
title = $.el "div",
id: "boardTitle"
children = banner.children
i = children.length
nodes = []
while i--
child = children[i]
if child.tagName.toLowerCase() is "img"
child.id = "Banner"
continue
if Conf['Custom Board Titles']
Banner.custom child
nodes.push child
$.add title, nodes.reverse()
$.after banner, title
return
cb:
click: (e) ->
if e.shiftKey
@contentEditable = true
keydown: (e) ->
e.stopPropagation()
focus: ->
string = "#{g.BOARD}.#{@className}"
items =
title: @innerHTML
items["#{string}"] = ''
items["#{string}.orig"] = false
$.get items, (items) ->
unless items["#{string}.orig"] and items.title is items["#{string}"]
$.set "#{string}.orig", items.title
@textContent = @innerHTML
blur: ->
$.set "#{g.BOARD}.#{@className}", @textContent
@innerHTML = @textContent
@contentEditable = false
custom: (child) ->
cachedTest = child.innerHTML
$.get "#{g.BOARD}.#{child.className}", cachedTest, (item) ->
return unless title = item["#{g.BOARD}.#{child.className}"]
if Conf['Persistent Custom Board Titles']
child.innerHTML = title
else
$.get "#{g.BOARD}.#{child.className}.orig", cachedTest, (itemb) ->
if cachedTest is itemb["#{g.BOARD}.#{child.className}.orig"]
child.innerHTML = title
else
$.set "#{g.BOARD}.#{child.className}", cachedTest
$.set "#{g.BOARD}.#{child.className}.orig", cachedTest
$.on child, 'click', Banner.cb.click
$.on child, 'keydown', Banner.cb.keydown
$.on child, 'focus', Banner.cb.focus
$.on child, 'blur', Banner.cb.blur