Add workaround for pasting images to the Quick Reply in Firefox.
This commit is contained in:
parent
9556c493db
commit
a6a9d31733
@ -1332,9 +1332,9 @@ input#qr-filename {
|
||||
flex: none;
|
||||
margin: 0;
|
||||
margin-right: 3px;
|
||||
font: 13px sans-serif;
|
||||
}
|
||||
#qr.has-spoiler #file-n-submit:not(.has-file) #qr-spoiler-label,
|
||||
.has-file #paste-area,
|
||||
.has-file #url-button,
|
||||
#file-n-submit:not(.custom-cooldown) #custom-cooldown-button {
|
||||
display: none;
|
||||
@ -1342,9 +1342,15 @@ input#qr-filename {
|
||||
#qr-file-spoiler {
|
||||
margin: 0;
|
||||
}
|
||||
#url-button, #custom-cooldown-button, #dump-button {
|
||||
#paste-area, #url-button, #custom-cooldown-button, #dump-button {
|
||||
opacity: 0.6;
|
||||
}
|
||||
#paste-area {
|
||||
font-size: 0;
|
||||
}
|
||||
#paste-area:focus {
|
||||
opacity: 1;
|
||||
}
|
||||
#custom-cooldown-button.disabled {
|
||||
opacity: 0.27;
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
<input type="checkbox" id="qr-file-spoiler" title="Spoiler image">
|
||||
</label>
|
||||
<a href="javascript:;" id="qr-filerm" title="Remove file"><i class="fa fa-times-circle"></i></a>
|
||||
<a hidden id="paste-area" title="Paste image" class="fa fa-clipboard" tabindex="-1" contentEditable="true"></a>
|
||||
<a id="url-button" title="Post from url"><i class="fa fa-link"></i></a>
|
||||
<a id="custom-cooldown-button" title="Toggle custom cooldown" class="disabled"><i class="fa fa-clock-o"></i></a>
|
||||
<a id="dump-button" title="Dump list"><i class="fa fa-plus-square"></i></a>
|
||||
|
||||
@ -317,13 +317,32 @@ QR =
|
||||
QR.handleFiles files
|
||||
$.addClass QR.nodes.el, 'dump'
|
||||
|
||||
handleUrl: ->
|
||||
url = prompt 'Enter a URL:'
|
||||
pasteFF: ->
|
||||
{pasteArea} = QR.nodes
|
||||
return unless pasteArea.childNodes.length
|
||||
images = $$ 'img', pasteArea
|
||||
$.rmAll pasteArea
|
||||
for img in images
|
||||
{src} = img
|
||||
if m = src.match /data:(image\/(\w+));base64,(.+)/
|
||||
bstr = atob m[3]
|
||||
arr = new Uint8Array(bstr.length)
|
||||
for i in [0...bstr.length]
|
||||
arr[i] = bstr.charCodeAt(i)
|
||||
blob = new Blob [arr], {type: m[1]}
|
||||
blob.name = "image.#{m[2]}"
|
||||
QR.handleFiles [blob]
|
||||
else if /^https?:\/\//.test src
|
||||
QR.handleUrl src
|
||||
return
|
||||
|
||||
handleUrl: (urlDefault) ->
|
||||
url = prompt 'Enter a URL:', urlDefault
|
||||
return if url is null
|
||||
QR.nodes.fileButton.focus()
|
||||
CrossOrigin.file url, (blob) ->
|
||||
if blob
|
||||
QR.handleFiles([blob])
|
||||
QR.handleFiles [blob]
|
||||
else
|
||||
QR.error "Can't load image."
|
||||
|
||||
@ -389,6 +408,7 @@ QR =
|
||||
setNode 'close', '.close'
|
||||
setNode 'form', 'form'
|
||||
setNode 'dumpButton', '#dump-button'
|
||||
setNode 'pasteArea', '#paste-area'
|
||||
setNode 'urlButton', '#url-button'
|
||||
setNode 'name', '[data-name=name]'
|
||||
setNode 'email', '[data-name=email]'
|
||||
@ -474,7 +494,7 @@ QR =
|
||||
$.on nodes.autohide, 'change', QR.toggleHide
|
||||
$.on nodes.close, 'click', QR.close
|
||||
$.on nodes.dumpButton, 'click', -> nodes.el.classList.toggle 'dump'
|
||||
$.on nodes.urlButton, 'click', QR.handleUrl
|
||||
$.on nodes.urlButton, 'click', -> QR.handleUrl ''
|
||||
$.on nodes.addPost, 'click', -> new QR.post true
|
||||
$.on nodes.form, 'submit', QR.submit
|
||||
$.on nodes.fileRM, 'click', -> QR.selected.rmFile()
|
||||
@ -487,6 +507,10 @@ QR =
|
||||
# We don't receive blur events from captcha iframe.
|
||||
$.on d, 'click', QR.focus
|
||||
|
||||
unless chrome?
|
||||
nodes.pasteArea.hidden = false
|
||||
new MutationObserver(QR.pasteFF).observe nodes.pasteArea, {childList: true}
|
||||
|
||||
# save selected post's data
|
||||
items = ['thread', 'name', 'email', 'sub', 'com', 'filename']
|
||||
i = 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user