From 6cdb49d0e57ec9446d2ba87b2407dd4d8c92bb57 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 29 Jan 2016 01:54:09 -0800 Subject: [PATCH] Use boards.json data to detect enabled tags for QR and Keybinds. #525 --- src/Miscellaneous/Keybinds.coffee | 14 ++++++++------ src/Posting/QR.coffee | 20 +++++++++----------- src/css/style.css | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index dc62900d3..c4589e5e3 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -246,12 +246,14 @@ Keybinds = QR.nodes.com.focus() tags: (tag, ta) -> - supported = switch tag - when 'spoiler' then !!$ '.postForm input[name=spoiler]' - when 'code' then g.BOARD.ID is 'g' - when 'math', 'eqn' then g.BOARD.ID is 'sci' - when 'sjis' then g.BOARD.ID is 'jp' - new Notice 'warning', "[#{tag}] tags are not supported on /#{g.BOARD}/.", 20 unless supported + BoardConfig.ready -> + {config} = g.BOARD + supported = switch tag + when 'spoiler' then !!config.spoilers + when 'code' then !!config.code_tags + when 'math', 'eqn' then !!config.math_tags + when 'sjis' then !!config.sjis_tags + new Notice 'warning', "[#{tag}] tags are not supported on /#{g.BOARD}/.", 20 unless supported value = ta.value selStart = ta.selectionStart diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 47ca5f861..4ef6b85ff 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -31,7 +31,7 @@ QR = version = if Conf['Use Recaptcha v1'] and Main.jsEnabled then 'v1' else 'v2' @captcha = Captcha[version] - $.on d, '4chanXInitFinished', @initReady + $.on d, '4chanXInitFinished', -> BoardConfig.ready QR.initReady Post.callbacks.push name: 'Quick Reply' @@ -54,7 +54,6 @@ QR = Header.addShortcut sc initReady: -> - $.off d, '4chanXInitFinished', @initReady QR.postingIsEnabled = !!$.id 'postForm' return unless QR.postingIsEnabled @@ -494,16 +493,15 @@ QR = $.addClass QR.nodes.sub, 'force-show' QR.nodes.email.placeholder = 'E-mail' + {config} = g.BOARD + {classList} = QR.nodes.el QR.forcedAnon = !!$ 'form[name="post"] input[name="name"][type="hidden"]' - if QR.forcedAnon - $.addClass QR.nodes.el, 'forced-anon' - - QR.spoiler = !!$ '.postForm input[name=spoiler]' - if QR.spoiler - $.addClass QR.nodes.el, 'has-spoiler' - - if g.BOARD.ID is 'jp' and Conf['sjisPreview'] - $.addClass QR.nodes.el, 'sjis-preview' + QR.spoiler = !!config.spoilers + classList.toggle 'forced-anon', QR.forcedAnon + classList.toggle 'has-spoiler', QR.spoiler + classList.toggle 'has-sjis', !!config.sjis_tags + classList.toggle 'has-math', !!config.math_tags + classList.toggle 'sjis-preview', !!config.sjis_tags and Conf['sjisPreview'] if parseInt(Conf['customCooldown'], 10) > 0 $.addClass QR.nodes.fileSubmit, 'custom-cooldown' diff --git a/src/css/style.css b/src/css/style.css index 96ba04a98..78840ac39 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -1284,8 +1284,8 @@ input[name="Default Volume"] { #qr.reply-to-thread input[data-name="sub"]:not(.force-show), body:not(.board_f) #qr select[name="filetag"], #qr.reply-to-thread select[name="filetag"], -body:not(.board_jp) #sjis-toggle, -body:not(.board_sci) #tex-preview-button, +#qr:not(.has-sjis) #sjis-toggle, +#qr:not(.has-math) #tex-preview-button, #qr.tex-preview .textarea > :not(#tex-preview), #qr:not(.tex-preview) #tex-preview { display: none;