diff options
Diffstat (limited to 'www/js/views/photo.js')
-rw-r--r-- | www/js/views/photo.js | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/www/js/views/photo.js b/www/js/views/photo.js index 4171e6a..8d4b20e 100644 --- a/www/js/views/photo.js +++ b/www/js/views/photo.js @@ -27,15 +27,20 @@ }, addPhotoSuccess: function(imgURI) { - //TODO move this file somewhere permanent rather than temp - // storage so it doesn't get randomly cleaned up by the OS - $('#photo').attr('src', imgURI ); - this.model.set('file', imgURI); - FMS.saveCurrentDraft(); - - $('#photo-next-btn .ui-btn-text').text('Next'); - $('#display_photo').show(); - $('#add_photo').hide(); + var move = FMS.files.moveURI( imgURI ); + + var that = this; + move.done( function( file ) { + $('#photo').attr('src', file.toURL()); + that.model.set('file', file.toURL()); + FMS.saveCurrentDraft(); + + $('#photo-next-btn .ui-btn-text').text('Next'); + $('#display_photo').show(); + $('#add_photo').hide(); + }); + + move.fail( function() { that.addPhotoFail(); } ); }, addPhotoFail: function() { @@ -47,13 +52,19 @@ }, deletePhoto: function() { - this.model.set('file', ''); - FMS.saveCurrentDraft(); - $('#photo').attr('src', ''); + var that = this; + var del = FMS.files.deleteURI( this.model.get('file') ); + + del.done( function() { + that.model.set('file', ''); + FMS.saveCurrentDraft(); + $('#photo').attr('src', ''); + + $('#photo-next-btn .ui-btn-text').text('Skip'); + $('#display_photo').hide(); + $('#add_photo').show(); + }); - $('#photo-next-btn .ui-btn-text').text('Skip'); - $('#display_photo').hide(); - $('#add_photo').show(); } }) }); |