Move the show announcement button to the header's menu. #1059

This commit is contained in:
Nicolas Stepien 2013-04-23 19:45:13 +02:00
parent e6d54c0560
commit c6d3a99f72
2 changed files with 24 additions and 9 deletions

View File

@ -1,3 +1,4 @@
- The button to show a hidden announcement is now inside the header's menu.
- Added the `board-replace` setting to Custom Board Navigation ricing.
- Added the option `Cooldown Prediction`, enabled by default.
- Added the option `Hide Unread Count at (0)`, disabled by default.

View File

@ -790,6 +790,20 @@ PSAHiding =
$.addClass doc, 'hide-announcement'
entry =
type: 'header'
el: $.el 'a',
textContent: 'Show announcement.'
className: 'show-announcement'
href: 'javascript:;'
order: 50
open: ->
if $.id('globalMessage')?.hidden
return true
false
$.event 'AddMenuEntry', entry
$.on entry.el, 'click', PSAHiding.toggle
$.on d, '4chanXInitFinished', @setup
setup: ->
$.off d, '4chanXInitFinished', PSAHiding.setup
@ -799,12 +813,12 @@ PSAHiding =
return
PSAHiding.btn = btn = $.el 'a',
title: 'Toggle announcement.'
innerHTML: '<span></span>'
innerHTML: '<span>[&nbsp;-&nbsp;]</span>'
title: 'Hide announcement.'
className: 'hide-announcement'
href: 'javascript:;'
$.on btn, 'click', PSAHiding.toggle
text = PSAHiding.trim psa
$.get 'hiddenPSAs', [], (item) ->
PSAHiding.sync item['hiddenPSAs']
$.before psa, btn
@ -817,19 +831,19 @@ PSAHiding =
$.get 'hiddenPSAs', [], ({hiddenPSAs}) ->
if hide
hiddenPSAs.push text
hiddenPSAs = hiddenPSAs[-5..]
else
$.event 'CloseMenu'
i = hiddenPSAs.indexOf text
hiddenPSAs.splice i, 1
hiddenPSAs = hiddenPSAs[-5..]
PSAHiding.sync hiddenPSAs
$.set 'hiddenPSAs', hiddenPSAs
sync: (hiddenPSAs) ->
{btn} = PSAHiding
psa = $.id 'globalMessage'
[psa.hidden, btn.firstChild.textContent, btn.className] = if PSAHiding.trim(psa) in hiddenPSAs
[true, '[\u00A0+\u00A0]', 'show-announcement']
psa = $.id 'globalMessage'
psa.hidden = PSAHiding.btn.hidden = if PSAHiding.trim(psa) in hiddenPSAs
true
else
[false, '[\u00A0-\u00A0]', 'hide-announcement']
false
trim: (psa) ->
psa.textContent.replace(/\W+/g, '').toLowerCase()