diff options
author | blackle <isabelle@blackle-mori.com> | 2017-01-12 23:54:26 -0500 |
---|---|---|
committer | blackle <isabelle@blackle-mori.com> | 2017-01-23 21:07:40 -0500 |
commit | bf0f6eb62d0f5bd1f0d8e4e2a6e9e8fd3b297b6c (patch) | |
tree | c06ebcba34c5971d564beb98aa81d5d9784ec2c7 /app/assets/javascripts/extras.jsx | |
parent | 1761d3f9c33f3e2e98a09906fae1a03783b54b10 (diff) |
Implement a click-to-view spoiler system
Diffstat (limited to 'app/assets/javascripts/extras.jsx')
-rw-r--r-- | app/assets/javascripts/extras.jsx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/assets/javascripts/extras.jsx b/app/assets/javascripts/extras.jsx index 5738863dd..5784d17c2 100644 --- a/app/assets/javascripts/extras.jsx +++ b/app/assets/javascripts/extras.jsx @@ -14,6 +14,16 @@ $(() => { } }); + $.each($('.spoiler'), (_, content) => { + $(content).on('click', e => { + var hasClass = $(content).hasClass('spoiler-on'); + if (hasClass || e.target === content) { + e.preventDefault(); + $(content).siblings(".spoiler").andSelf().toggleClass('spoiler-on', !hasClass); + } + }); + }); + $('.media-spoiler').on('click', e => { $(e.target).hide(); }); |