diff options
author | Struan Donald <struan@exo.org.uk> | 2013-07-12 09:47:56 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-07-12 11:00:11 +0100 |
commit | 25e3a0c94551b0faac3f16e0598e6f4bdffcf7d8 (patch) | |
tree | f78f68ba8ed39e5b5004e41435aac3e9bbe9c044 /www/js/views/offline.js | |
parent | 4c2206c97250b7f72eb04d13ae886a7fb4f4086a (diff) |
instead of using js to inject the correct cordova js file in to
index.html restructure things so that the common files are a level down
and the platofrm specific ones are directly placed in the relevant
project. This both makes for less fuss and also avoids the error with
Android < v3 instantiating cordova twice.
Note that the iOS common assets are included by a build script rather
than a symlink as symlinking doesn't seem to agree with Xcode
Diffstat (limited to 'www/js/views/offline.js')
-rw-r--r-- | www/js/views/offline.js | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/www/js/views/offline.js b/www/js/views/offline.js deleted file mode 100644 index 117c67e..0000000 --- a/www/js/views/offline.js +++ /dev/null @@ -1,140 +0,0 @@ -(function (FMS, Backbone, _, $) { - _.extend( FMS, { - OfflineView: FMS.LocatorView.extend({ - template: 'offline', - id: 'offline', - prev: 'home', - next: 'reports', - skipLocationCheck: true, - - events: { - 'pagehide': 'destroy', - 'pagebeforeshow': 'toggleNextButton', - 'pageshow': 'afterDisplay', - 'vclick .ui-btn-left': 'onClickButtonPrev', - 'vclick .ui-btn-right': 'onClickButtonNext', - 'vclick #id_photo_button': 'takePhoto', - 'vclick #id_existing': 'addPhoto', - 'vclick #id_del_photo_button': 'deletePhoto', - 'vclick #locate': 'locate', - 'vclick #locate_cancel': 'onClickCancel', - 'blur input': 'toggleNextButton', - 'blur textarea': 'toggleNextButton' - }, - - draftHasContent: function() { - var hasContent = false; - - if ( $('#form_title').val() || $('#form_detail').val() || - this.model.get('lat') || this.model.get('file') ) { - hasContent = true; - } - - return hasContent; - }, - - toggleNextButton: function() { - if ( this.draftHasContent() ) { - $('#offline-next-btn .ui-btn-text').text('Save'); - } else { - $('#offline-next-btn .ui-btn-text').text('Skip'); - } - }, - - failedLocation: function(details) { - this.finishedLocating(); - this.locateCount = 21; - - $('#locate_result').html('Could not get position'); - }, - - gotLocation: function(info) { - this.finishedLocating(); - - this.model.set('lat', info.coordinates.latitude); - this.model.set('lon', info.coordinates.longitude); - - $('#locate_result').html('Got position (' + info.coordinates.latitude.toFixed(2) + ', ' + info.coordinates.longitude.toFixed(2) + ')'); - }, - - 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) { - 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() { - if ( message != 'no image selected' && - message != 'Selection cancelled.' && - message != 'Camera cancelled.' ) { - this.displayError(FMS.strings.photo_failed); - } - }, - - deletePhoto: function() { - 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(); - }); - }, - - onClickCancel: function() { - this.finishedLocating(); - }, - - onClickButtonNext: function() { - this.updateCurrentReport(); - if ( !this.draftHasContent() && this.model.id ) { - var del = FMS.removeDraft( this.model.id ); - - var that = this; - del.done( function() { that.draftDeleted(); } ); - del.fail( function() { that.draftDeleted(); } ); - } else { - FMS.clearCurrentDraft(); - this.navigate( this.next, 'left' ); - } - }, - - draftDeleted: function() { - FMS.clearCurrentDraft(); - this.navigate( this.next, 'left' ); - }, - - updateCurrentReport: function() { - this.model.set('title', $('#form_title').val()); - this.model.set('details', $('#form_detail').val()); - FMS.saveCurrentDraft(); - } - }) - }); -})(FMS, Backbone, _, $); |