Change announcement hiding link to FontAwesome minus button and make it work on Tinyboard/vichan sites. #2171
This commit is contained in:
parent
5af268c602
commit
bbccf5e1b8
@ -1,15 +1,17 @@
|
|||||||
PSAHiding =
|
PSAHiding =
|
||||||
init: ->
|
init: ->
|
||||||
return unless Conf['Announcement Hiding']
|
return unless Conf['Announcement Hiding'] and g.SITE.selectors.psa
|
||||||
$.addClass doc, 'hide-announcement'
|
$.addClass doc, 'hide-announcement'
|
||||||
$.one d, '4chanXInitFinished', @setup
|
$.onExists doc, g.SITE.selectors.psa, @setup
|
||||||
|
$.ready ->
|
||||||
|
$.rmClass doc, 'hide-announcement' if !$(g.SITE.selectors.psa)
|
||||||
|
|
||||||
setup: ->
|
setup: (psa) ->
|
||||||
if not (psa = PSAHiding.psa = $.id 'globalMessage')
|
PSAHiding.psa = psa
|
||||||
$.rmClass doc, 'hide-announcement'
|
PSAHiding.text = psa.dataset.utc ? psa.innerHTML
|
||||||
return
|
if g.SITE.selectors.psaTop and (hr = $(g.SITE.selectors.psaTop)?.previousElementSibling) and hr.nodeName is 'HR'
|
||||||
if (hr = $.id('globalToggle')?.previousElementSibling) and hr.nodeName is 'HR'
|
|
||||||
PSAHiding.hr = hr
|
PSAHiding.hr = hr
|
||||||
|
PSAHiding.content = $.el 'div'
|
||||||
|
|
||||||
entry =
|
entry =
|
||||||
el: $.el 'a',
|
el: $.el 'a',
|
||||||
@ -17,40 +19,44 @@ PSAHiding =
|
|||||||
className: 'show-announcement'
|
className: 'show-announcement'
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
order: 50
|
order: 50
|
||||||
open: -> PSAHiding.hidden
|
open: -> psa.hidden
|
||||||
Header.menu.addEntry entry
|
Header.menu.addEntry entry
|
||||||
$.on entry.el, 'click', PSAHiding.toggle
|
$.on entry.el, 'click', PSAHiding.toggle
|
||||||
|
|
||||||
PSAHiding.btn = btn = $.el 'span',
|
PSAHiding.btn = btn = $.el 'a',
|
||||||
title: 'Mark announcement as read and hide.'
|
title: 'Mark announcement as read and hide.'
|
||||||
className: 'hide-announcement'
|
className: 'hide-announcement-button fa fa-minus-square'
|
||||||
|
href: 'javascript:;'
|
||||||
$.extend btn, <%= html('[<a href="javascript:;">Dismiss</a>]') %>
|
|
||||||
|
|
||||||
$.on btn, 'click', PSAHiding.toggle
|
$.on btn, 'click', PSAHiding.toggle
|
||||||
|
if psa.firstChild?.tagName is 'HR'
|
||||||
|
$.after psa.firstChild, btn
|
||||||
|
else
|
||||||
|
$.prepend psa, btn
|
||||||
|
|
||||||
$.get 'hiddenPSA', 0, ({hiddenPSA}) ->
|
PSAHiding.sync Conf['hiddenPSAList']
|
||||||
PSAHiding.sync hiddenPSA
|
$.rmClass doc, 'hide-announcement'
|
||||||
$.add psa, btn
|
|
||||||
$.rmClass doc, 'hide-announcement'
|
|
||||||
|
|
||||||
$.sync 'hiddenPSA', PSAHiding.sync
|
$.sync 'hiddenPSAList', PSAHiding.sync
|
||||||
|
|
||||||
toggle: ->
|
toggle: ->
|
||||||
if $.hasClass @, 'hide-announcement'
|
hide = $.hasClass @, 'hide-announcement-button'
|
||||||
UTC = +$.id('globalMessage').dataset.utc
|
set = (hiddenPSAList) ->
|
||||||
$.set 'hiddenPSA', UTC
|
if hide
|
||||||
else
|
hiddenPSAList[g.SITE.ID] = PSAHiding.text
|
||||||
$.event 'CloseMenu'
|
else
|
||||||
$.delete 'hiddenPSA'
|
delete hiddenPSAList[g.SITE.ID]
|
||||||
PSAHiding.sync UTC
|
set Conf['hiddenPSAList']
|
||||||
|
PSAHiding.sync Conf['hiddenPSAList']
|
||||||
|
$.get 'hiddenPSAList', Conf['hiddenPSAList'], ({hiddenPSAList}) ->
|
||||||
|
set hiddenPSAList
|
||||||
|
$.set 'hiddenPSAList', hiddenPSAList
|
||||||
|
|
||||||
sync: (UTC) ->
|
sync: (hiddenPSAList) ->
|
||||||
{psa} = PSAHiding
|
{psa, content} = PSAHiding
|
||||||
PSAHiding.hidden = PSAHiding.btn.hidden = UTC? and UTC >= +psa.dataset.utc
|
psa.hidden = (hiddenPSAList[g.SITE.ID] is PSAHiding.text)
|
||||||
if PSAHiding.hidden
|
# Remove content to prevent autoplaying sounds from hidden announcements
|
||||||
$.rm psa
|
if psa.hidden
|
||||||
|
$.add content, [psa.childNodes...]
|
||||||
else
|
else
|
||||||
$.after $.id('globalToggle'), psa
|
$.add psa, [content.childNodes...]
|
||||||
PSAHiding.hr?.hidden = PSAHiding.hidden
|
PSAHiding.hr?.hidden = psa.hidden
|
||||||
return
|
|
||||||
|
|||||||
@ -1162,3 +1162,5 @@ Config =
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
fourchanImageHost: 'i.4cdn.org'
|
fourchanImageHost: 'i.4cdn.org'
|
||||||
|
|
||||||
|
hiddenPSAList: [{}]
|
||||||
|
|||||||
@ -1056,18 +1056,12 @@ textarea.copy-text-element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Announcement Hiding */
|
/* Announcement Hiding */
|
||||||
:root.hide-announcement #globalMessage {
|
:root.hide-announcement $site$psa {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
span.hide-announcement {
|
.hide-announcement-button {
|
||||||
font-size: 11px;
|
opacity: 0.4;
|
||||||
position: relative;
|
float: left;
|
||||||
bottom: 5px;
|
|
||||||
}
|
|
||||||
.globalMessage, h2, h3 {
|
|
||||||
color: inherit !important;
|
|
||||||
font-size: 13px;
|
|
||||||
font-weight: 100;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unread */
|
/* Unread */
|
||||||
|
|||||||
@ -664,7 +664,7 @@ if GM?.deleteValue? and window.BroadcastChannel and not GM_addValueChangeListene
|
|||||||
GM.listValues().then((keys) ->
|
GM.listValues().then((keys) ->
|
||||||
$.delete keys.map((key) -> key.replace g.NAMESPACE, ''), cb
|
$.delete keys.map((key) -> key.replace g.NAMESPACE, ''), cb
|
||||||
).catch( ->
|
).catch( ->
|
||||||
$.delete Object.keys(Conf).concat(['previousversion', 'QR Size', 'QR.persona', 'hiddenPSA']), cb
|
$.delete Object.keys(Conf).concat(['previousversion', 'QR Size', 'QR.persona']), cb
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -778,7 +778,7 @@ else
|
|||||||
# XXX https://github.com/greasemonkey/greasemonkey/issues/2033
|
# XXX https://github.com/greasemonkey/greasemonkey/issues/2033
|
||||||
# Also support case where GM_listValues is not defined.
|
# Also support case where GM_listValues is not defined.
|
||||||
$.delete Object.keys(Conf)
|
$.delete Object.keys(Conf)
|
||||||
$.delete ['previousversion', 'QR Size', 'QR.persona', 'hiddenPSA']
|
$.delete ['previousversion', 'QR Size', 'QR.persona']
|
||||||
try
|
try
|
||||||
$.delete $.listValues().map (key) -> key.replace g.NAMESPACE, ''
|
$.delete $.listValues().map (key) -> key.replace g.NAMESPACE, ''
|
||||||
cb?()
|
cb?()
|
||||||
|
|||||||
@ -4,7 +4,6 @@ SW.tinyboard =
|
|||||||
|
|
||||||
disabledFeatures: [
|
disabledFeatures: [
|
||||||
'Index Generator'
|
'Index Generator'
|
||||||
'Announcement Hiding'
|
|
||||||
'Resurrect Quotes'
|
'Resurrect Quotes'
|
||||||
'Quick Reply Personas'
|
'Quick Reply Personas'
|
||||||
'Quick Reply'
|
'Quick Reply'
|
||||||
@ -96,6 +95,7 @@ SW.tinyboard =
|
|||||||
boardList: '.boardlist'
|
boardList: '.boardlist'
|
||||||
boardListBottom: '.boardlist.bottom'
|
boardListBottom: '.boardlist.bottom'
|
||||||
styleSheet: '#stylesheet'
|
styleSheet: '#stylesheet'
|
||||||
|
psa: '.blotter'
|
||||||
|
|
||||||
xpath:
|
xpath:
|
||||||
thread: 'div[starts-with(@id,"thread_")]'
|
thread: 'div[starts-with(@id,"thread_")]'
|
||||||
|
|||||||
@ -52,6 +52,8 @@ SW.yotsuba =
|
|||||||
boardList: '#boardNavDesktop > .boardList'
|
boardList: '#boardNavDesktop > .boardList'
|
||||||
boardListBottom: '#boardNavDesktopFoot > .boardList'
|
boardListBottom: '#boardNavDesktopFoot > .boardList'
|
||||||
styleSheet: 'link[title=switch]'
|
styleSheet: 'link[title=switch]'
|
||||||
|
psa: '#globalMessage'
|
||||||
|
psaTop: '#globalToggle'
|
||||||
|
|
||||||
xpath:
|
xpath:
|
||||||
thread: 'div[contains(concat(" ",@class," ")," thread ")]'
|
thread: 'div[contains(concat(" ",@class," ")," thread ")]'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user