Move edit menu item stuff into QR.oekaki.menu.
This commit is contained in:
parent
dbf2911891
commit
0a49c5a0eb
@ -406,7 +406,7 @@ Main =
|
|||||||
['Reply Hiding (Menu)', PostHiding.menu]
|
['Reply Hiding (Menu)', PostHiding.menu]
|
||||||
['Delete Link', DeleteLink]
|
['Delete Link', DeleteLink]
|
||||||
['Filter (Menu)', Filter.menu]
|
['Filter (Menu)', Filter.menu]
|
||||||
['Edit Link', QR.oekaki]
|
['Edit Link', QR.oekaki.menu]
|
||||||
['Download Link', DownloadLink]
|
['Download Link', DownloadLink]
|
||||||
['Archive Link', ArchiveLink]
|
['Archive Link', ArchiveLink]
|
||||||
['Quote Inlining', QuoteInline]
|
['Quote Inlining', QuoteInline]
|
||||||
|
|||||||
@ -1,48 +1,49 @@
|
|||||||
QR.oekaki =
|
QR.oekaki =
|
||||||
init: ->
|
menu:
|
||||||
return unless Conf['Quick Reply'] and Conf['Edit Link']
|
init: ->
|
||||||
|
return unless Conf['Quick Reply'] and Conf['Edit Link']
|
||||||
|
|
||||||
a = $.el 'a',
|
a = $.el 'a',
|
||||||
className: 'edit-link'
|
className: 'edit-link'
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
textContent: 'Edit image'
|
textContent: 'Edit image'
|
||||||
$.on a, 'click', @editFile
|
$.on a, 'click', @editFile
|
||||||
|
|
||||||
Menu.menu.addEntry
|
Menu.menu.addEntry
|
||||||
el: a
|
el: a
|
||||||
order: 95
|
order: 95
|
||||||
open: (post) ->
|
open: (post) ->
|
||||||
QR.oekaki.post = post
|
QR.oekaki.menu.post = post
|
||||||
{file} = post
|
{file} = post
|
||||||
!!file and (file.isImage or file.isVideo)
|
!!file and (file.isImage or file.isVideo)
|
||||||
|
|
||||||
editFile: ->
|
editFile: ->
|
||||||
return unless QR.postingIsEnabled
|
return unless QR.postingIsEnabled
|
||||||
{post} = QR.oekaki
|
{post} = QR.oekaki.menu
|
||||||
QR.quote.call post.nodes.root
|
QR.quote.call post.nodes.root
|
||||||
{isVideo} = post.file
|
{isVideo} = post.file
|
||||||
currentTime = post.file.fullImage?.currentTime or 0
|
currentTime = post.file.fullImage?.currentTime or 0
|
||||||
CrossOrigin.file post.file.url, (blob) ->
|
CrossOrigin.file post.file.url, (blob) ->
|
||||||
if !blob
|
if !blob
|
||||||
QR.error "Can't load file."
|
QR.error "Can't load file."
|
||||||
else if isVideo
|
else if isVideo
|
||||||
video = $.el 'video'
|
video = $.el 'video'
|
||||||
$.on video, 'loadedmetadata', ->
|
$.on video, 'loadedmetadata', ->
|
||||||
$.on video, 'seeked', ->
|
$.on video, 'seeked', ->
|
||||||
canvas = $.el 'canvas',
|
canvas = $.el 'canvas',
|
||||||
width: video.videoWidth
|
width: video.videoWidth
|
||||||
height: video.videoHeight
|
height: video.videoHeight
|
||||||
canvas.getContext('2d').drawImage(video, 0, 0)
|
canvas.getContext('2d').drawImage(video, 0, 0)
|
||||||
canvas.toBlob (snapshot) ->
|
canvas.toBlob (snapshot) ->
|
||||||
snapshot.name = post.file.name.replace(/\.\w+$/, '') + '.png'
|
snapshot.name = post.file.name.replace(/\.\w+$/, '') + '.png'
|
||||||
QR.handleFiles [snapshot]
|
QR.handleFiles [snapshot]
|
||||||
QR.oekaki.edit()
|
QR.oekaki.edit()
|
||||||
video.currentTime = currentTime
|
video.currentTime = currentTime
|
||||||
video.src = URL.createObjectURL blob
|
video.src = URL.createObjectURL blob
|
||||||
else
|
else
|
||||||
blob.name = post.file.name
|
blob.name = post.file.name
|
||||||
QR.handleFiles [blob]
|
QR.handleFiles [blob]
|
||||||
QR.oekaki.edit()
|
QR.oekaki.edit()
|
||||||
|
|
||||||
setup: ->
|
setup: ->
|
||||||
$.global ->
|
$.global ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user