aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js')
-rw-r--r--www/js/models/report.js3
-rw-r--r--www/js/views/photo.js55
2 files changed, 57 insertions, 1 deletions
diff --git a/www/js/models/report.js b/www/js/models/report.js
index 6fd48f9..063165a 100644
--- a/www/js/models/report.js
+++ b/www/js/models/report.js
@@ -11,7 +11,8 @@
may_show_name: '',
category: '',
phone: '',
- pc: ''
+ pc: '',
+ file: ''
},
sync: function(method, model, options) {
diff --git a/www/js/views/photo.js b/www/js/views/photo.js
new file mode 100644
index 0000000..1634cc0
--- /dev/null
+++ b/www/js/views/photo.js
@@ -0,0 +1,55 @@
+;(function (FMS, Backbone, _, $) {
+ _.extend( FMS, {
+ PhotoView: FMS.FMSView.extend({
+ template: 'photo',
+ id: 'photo-page',
+ prev: 'around',
+ next: 'details',
+
+ events: {
+ 'pagehide': 'destroy',
+ 'pageshow': 'afterDisplay',
+ 'click .ui-btn-left': 'onClickButtonPrev',
+ 'click .ui-btn-right': 'onClickButtonNext',
+ 'click #id_photo_button': 'takePhoto',
+ 'click #id_existing': 'addPhoto',
+ 'click #id_del_photo_button': 'deletePhoto'
+ },
+
+ takePhoto: function() {
+ var that = this;
+ navigator.camera.getPicture( function(imgURI) { that.addPhotoSuccess(imgURI); }, function(error) { that.addPhotoFail(error); }, { saveToPhotoAlbum: true, quality: 49, destinationType: Camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.CAMERA, correctOrientation: true });
+ },
+
+ addPhoto: function() {
+ var that = this;
+ navigator.camera.getPicture( function(imgURI) { that.addPhotoSuccess(imgURI); }, function(error) { that.addPhotoFail(error); }, { saveToPhotoAlbum: false, quality: 49, destinationType: Camera.DestinationType.FILE_URI, sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY, correctOrientation: true });
+ },
+
+ addPhotoSuccess: function(imgURI) {
+ $('#photo').attr('src', imgURI );
+ this.model.set('file', imgURI);
+
+ $('#display_photo').show();
+ $('#add_photo').hide();
+ },
+
+ addPhotoFail: function() {
+ if ( message != 'no image selected' &&
+ message != 'Selection cancelled.' &&
+ message != 'Camera cancelled.'
+ ) {
+ this.displayError(FMS.strings.photo_failed);
+ }
+ },
+
+ deletePhoto: function() {
+ this.model.set('file', '');
+ $('#photo').attr('src', '');
+
+ $('#display_photo').hide();
+ $('#add_photo').show();
+ }
+ })
+ });
+})(FMS, Backbone, _, $);