diff --git a/src/General/Main.coffee b/src/General/Main.coffee index a6a33eb77..c5102b5bb 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -95,7 +95,9 @@ Main = initFeatures: -> if location.hostname in ['boards.4chan.org', 'sys.4chan.org', 'www.4chan.org'] - $.globalEval 'document.documentElement.classList.add("js-enabled");' + $.global -> + document.documentElement.classList.add 'js-enabled' + window.FCX = {} switch location.hostname when 'www.4chan.org' diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 434333e66..b28e8138a 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -584,6 +584,7 @@ QR = new QR.post true QR.status() QR.cooldown.setup() + QR.oekaki.setup() QR.captcha.init() $.add d.body, dialog diff --git a/src/Posting/QR.oekaki.coffee b/src/Posting/QR.oekaki.coffee index 536da4c1e..63ee38c10 100644 --- a/src/Posting/QR.oekaki.coffee +++ b/src/Posting/QR.oekaki.coffee @@ -32,6 +32,15 @@ QR.oekaki = else QR.error "Can't load image." + setup: -> + $.global -> + {FCX} = window + FCX.oekakiCB = -> + window.Tegaki.flatten().toBlob (file) -> + document.dispatchEvent new CustomEvent 'QRSetFile', + bubbles: true + detail: {file, name: FCX.oekakiName} + load: (cb) -> if $ 'script[src^="//s.4cdn.org/js/painter"]', d.head cb() @@ -50,21 +59,18 @@ QR.oekaki = draw: -> $.global -> - {Tegaki} = window + {Tegaki, FCX} = window Tegaki.destroy() if Tegaki.bg + FCX.oekakiName = 'tegaki.png' Tegaki.open - onDone: -> - Tegaki.flatten().toBlob (file) -> - document.dispatchEvent new CustomEvent 'QRSetFile', - bubbles: true - detail: {file, name: 'tegaki.png'} + onDone: FCX.oekakiCB onCancel: -> width: +document.querySelector('#qr [name=oekaki-width]').value height: +document.querySelector('#qr [name=oekaki-height]').value edit: -> QR.oekaki.load -> $.global -> - {Tegaki} = window + {Tegaki, FCX} = window name = document.getElementById('qr-filename').value.replace(/\.\w+$/, '') + '.png' error = (content) -> document.dispatchEvent new CustomEvent 'CreateNotification', @@ -78,12 +84,9 @@ QR.oekaki = img.onerror = -> error 'Could not open image.' img.onload = -> Tegaki.destroy() if Tegaki.bg + FCX.oekakiName = name Tegaki.open - onDone: -> - Tegaki.flatten().toBlob (file) -> - document.dispatchEvent new CustomEvent 'QRSetFile', - bubbles: true - detail: {file, name} + onDone: FCX.oekakiCB onCancel: -> width: img.naturalWidth height: img.naturalHeight