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
|
@ -96,7 +96,7 @@ class Index extends App.Controller
|
||||||
replaceAvatar.text(activeAvatar.text())
|
replaceAvatar.text(activeAvatar.text())
|
||||||
replaceAvatar.addClass('unique')
|
replaceAvatar.addClass('unique')
|
||||||
else
|
else
|
||||||
replaceAvatar.text( '' )
|
replaceAvatar.text('')
|
||||||
replaceAvatar.removeClass('unique')
|
replaceAvatar.removeClass('unique')
|
||||||
)
|
)
|
||||||
avatar
|
avatar
|
||||||
|
@ -122,7 +122,7 @@ class Index extends App.Controller
|
||||||
)
|
)
|
||||||
processData: true
|
processData: true
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
avatarHolder = $(App.view('profile/avatar-holder')( src: src, avatar: data.avatar ) )
|
avatarHolder = $(App.view('profile/avatar-holder')(src: src, avatar: data.avatar))
|
||||||
@avatarGallery.append(avatarHolder)
|
@avatarGallery.append(avatarHolder)
|
||||||
@pick avatarHolder.find('.avatar')
|
@pick avatarHolder.find('.avatar')
|
||||||
)
|
)
|
||||||
|
@ -143,8 +143,7 @@ class Index extends App.Controller
|
||||||
|
|
||||||
reader.readAsDataURL(@)
|
reader.readAsDataURL(@)
|
||||||
|
|
||||||
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
|
||||||
|
@ -173,13 +172,17 @@ class ImageCropper extends App.ControllerModal
|
||||||
if @angle == undefined
|
if @angle == undefined
|
||||||
@angle = 0
|
@angle = 0
|
||||||
|
|
||||||
if @angle != 0
|
show = (dataUrl) =>
|
||||||
@isOrientating = true
|
if @angle != 0
|
||||||
image = new Image()
|
@isOrientating = true
|
||||||
image.addEventListener 'load', @orientateImage
|
image = new Image()
|
||||||
image.src = @imageSource
|
image.addEventListener 'load', @orientateImage
|
||||||
else
|
image.src = dataUrl
|
||||||
@image.attr src: @imageSource
|
else
|
||||||
|
@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