Move the show announcement button to the header's menu. #1059
This commit is contained in:
parent
e6d54c0560
commit
c6d3a99f72
@ -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 `board-replace` setting to Custom Board Navigation ricing.
|
||||||
- Added the option `Cooldown Prediction`, enabled by default.
|
- Added the option `Cooldown Prediction`, enabled by default.
|
||||||
- Added the option `Hide Unread Count at (0)`, disabled by default.
|
- Added the option `Hide Unread Count at (0)`, disabled by default.
|
||||||
|
|||||||
@ -790,6 +790,20 @@ PSAHiding =
|
|||||||
|
|
||||||
$.addClass doc, 'hide-announcement'
|
$.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
|
$.on d, '4chanXInitFinished', @setup
|
||||||
setup: ->
|
setup: ->
|
||||||
$.off d, '4chanXInitFinished', PSAHiding.setup
|
$.off d, '4chanXInitFinished', PSAHiding.setup
|
||||||
@ -799,12 +813,12 @@ PSAHiding =
|
|||||||
return
|
return
|
||||||
|
|
||||||
PSAHiding.btn = btn = $.el 'a',
|
PSAHiding.btn = btn = $.el 'a',
|
||||||
title: 'Toggle announcement.'
|
innerHTML: '<span>[ - ]</span>'
|
||||||
innerHTML: '<span></span>'
|
title: 'Hide announcement.'
|
||||||
|
className: 'hide-announcement'
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
$.on btn, 'click', PSAHiding.toggle
|
$.on btn, 'click', PSAHiding.toggle
|
||||||
|
|
||||||
text = PSAHiding.trim psa
|
|
||||||
$.get 'hiddenPSAs', [], (item) ->
|
$.get 'hiddenPSAs', [], (item) ->
|
||||||
PSAHiding.sync item['hiddenPSAs']
|
PSAHiding.sync item['hiddenPSAs']
|
||||||
$.before psa, btn
|
$.before psa, btn
|
||||||
@ -817,19 +831,19 @@ PSAHiding =
|
|||||||
$.get 'hiddenPSAs', [], ({hiddenPSAs}) ->
|
$.get 'hiddenPSAs', [], ({hiddenPSAs}) ->
|
||||||
if hide
|
if hide
|
||||||
hiddenPSAs.push text
|
hiddenPSAs.push text
|
||||||
|
hiddenPSAs = hiddenPSAs[-5..]
|
||||||
else
|
else
|
||||||
|
$.event 'CloseMenu'
|
||||||
i = hiddenPSAs.indexOf text
|
i = hiddenPSAs.indexOf text
|
||||||
hiddenPSAs.splice i, 1
|
hiddenPSAs.splice i, 1
|
||||||
hiddenPSAs = hiddenPSAs[-5..]
|
|
||||||
PSAHiding.sync hiddenPSAs
|
PSAHiding.sync hiddenPSAs
|
||||||
$.set 'hiddenPSAs', hiddenPSAs
|
$.set 'hiddenPSAs', hiddenPSAs
|
||||||
sync: (hiddenPSAs) ->
|
sync: (hiddenPSAs) ->
|
||||||
{btn} = PSAHiding
|
psa = $.id 'globalMessage'
|
||||||
psa = $.id 'globalMessage'
|
psa.hidden = PSAHiding.btn.hidden = if PSAHiding.trim(psa) in hiddenPSAs
|
||||||
[psa.hidden, btn.firstChild.textContent, btn.className] = if PSAHiding.trim(psa) in hiddenPSAs
|
true
|
||||||
[true, '[\u00A0+\u00A0]', 'show-announcement']
|
|
||||||
else
|
else
|
||||||
[false, '[\u00A0-\u00A0]', 'hide-announcement']
|
false
|
||||||
trim: (psa) ->
|
trim: (psa) ->
|
||||||
psa.textContent.replace(/\W+/g, '').toLowerCase()
|
psa.textContent.replace(/\W+/g, '').toLowerCase()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user