Resize huge uploaded images to 1600x1600 before starting image cropper. Fixed @stream.stop() is not a function error message on chrome 50. Disabled save buttons after submit.
This commit is contained in:
parent
bee011d030
commit
7d35186ab7
1 changed files with 28 additions and 16 deletions
|
@ -145,7 +145,6 @@ class Index extends App.Controller
|
||||||
|
|
||||||
App.Config.set('Avatar', { prio: 1100, name: 'Avatar', parent: '#profile', target: '#profile/avatar', controller: Index }, 'NavBarProfile')
|
App.Config.set('Avatar', { prio: 1100, name: 'Avatar', parent: '#profile', target: '#profile/avatar', controller: Index }, 'NavBarProfile')
|
||||||
|
|
||||||
|
|
||||||
class ImageCropper extends App.ControllerModal
|
class ImageCropper extends App.ControllerModal
|
||||||
buttonClose: true
|
buttonClose: true
|
||||||
buttonCancel: true
|
buttonCancel: true
|
||||||
|
@ -173,13 +172,17 @@ class ImageCropper extends App.ControllerModal
|
||||||
if @angle == undefined
|
if @angle == undefined
|
||||||
@angle = 0
|
@angle = 0
|
||||||
|
|
||||||
|
show = (dataUrl) =>
|
||||||
if @angle != 0
|
if @angle != 0
|
||||||
@isOrientating = true
|
@isOrientating = true
|
||||||
image = new Image()
|
image = new Image()
|
||||||
image.addEventListener 'load', @orientateImage
|
image.addEventListener 'load', @orientateImage
|
||||||
image.src = @imageSource
|
image.src = dataUrl
|
||||||
else
|
else
|
||||||
@image.attr src: @imageSource
|
@image.attr src: dataUrl
|
||||||
|
|
||||||
|
# resize if to big
|
||||||
|
App.ImageService.resize(@imageSource, 800, 'auto', 2, 'image/jpeg', 0.9, show)
|
||||||
|
|
||||||
orientateImage: (e) =>
|
orientateImage: (e) =>
|
||||||
image = e.currentTarget
|
image = e.currentTarget
|
||||||
|
@ -215,12 +218,12 @@ class ImageCropper extends App.ControllerModal
|
||||||
minContainerHeight: 300
|
minContainerHeight: 300
|
||||||
preview: '.imageCropper-preview'
|
preview: '.imageCropper-preview'
|
||||||
|
|
||||||
onSubmit: =>
|
onSubmit: (e) =>
|
||||||
|
@formDisable(e)
|
||||||
@callback( @image.cropper('getCroppedCanvas').toDataURL() )
|
@callback( @image.cropper('getCroppedCanvas').toDataURL() )
|
||||||
@image.cropper('destroy')
|
@image.cropper('destroy')
|
||||||
@close()
|
@close()
|
||||||
|
|
||||||
|
|
||||||
class Camera extends App.ControllerModal
|
class Camera extends App.ControllerModal
|
||||||
buttonClose: true
|
buttonClose: true
|
||||||
buttonCancel: true
|
buttonCancel: true
|
||||||
|
@ -283,7 +286,7 @@ class Camera extends App.ControllerModal
|
||||||
# in case the modal is closed before the
|
# in case the modal is closed before the
|
||||||
# request was fullfilled
|
# request was fullfilled
|
||||||
if @hidden
|
if @hidden
|
||||||
@stream.stop()
|
@stopStream()
|
||||||
return
|
return
|
||||||
|
|
||||||
# cache stream so that we can later turn it off
|
# cache stream so that we can later turn it off
|
||||||
|
@ -401,11 +404,20 @@ class Camera extends App.ControllerModal
|
||||||
@video.attr height: @size
|
@video.attr height: @size
|
||||||
|
|
||||||
onClose: =>
|
onClose: =>
|
||||||
@stream.stop() if @stream
|
@stopStream()
|
||||||
@hidden = true
|
@hidden = true
|
||||||
|
|
||||||
onSubmit: =>
|
onSubmit: (e) =>
|
||||||
|
@formDisable(e)
|
||||||
|
|
||||||
# send picture to the callback
|
# send picture to the callback
|
||||||
window.file = @cache.get(0).toDataURL()
|
window.file = @cache.get(0).toDataURL()
|
||||||
@callback @cache.get(0).toDataURL()
|
@callback @cache.get(0).toDataURL()
|
||||||
@close()
|
@close()
|
||||||
|
|
||||||
|
stopStream: =>
|
||||||
|
return if !@stream
|
||||||
|
if @stream.getTracks
|
||||||
|
@stream.getTracks().forEach( (track) -> track.stop() )
|
||||||
|
if @stream.stop
|
||||||
|
@stream.stop()
|
||||||
|
|
Loading…
Reference in a new issue