diff options
-rw-r--r-- | www/index.html | 1 | ||||
-rw-r--r-- | www/js/app.js | 2 | ||||
-rw-r--r-- | www/js/router.js | 16 | ||||
-rw-r--r-- | www/js/views/around.js | 41 | ||||
-rw-r--r-- | www/js/views/fms.js | 13 | ||||
-rw-r--r-- | www/js/views/home.js | 9 | ||||
-rw-r--r-- | www/templates/en/photo.html | 27 |
7 files changed, 100 insertions, 9 deletions
diff --git a/www/index.html b/www/index.html index 5ab85d7..20e2db6 100644 --- a/www/index.html +++ b/www/index.html @@ -36,6 +36,7 @@ <script type="text/javascript" src="js/views/fms.js"></script> <script type="text/javascript" src="js/views/home.js"></script> <script type="text/javascript" src="js/views/around.js"></script> + <script type="text/javascript" src="js/views/photo.js"></script> <script type="text/javascript" src="js/router.js"></script> <script type="text/javascript" src="js/app.js"></script> diff --git a/www/js/app.js b/www/js/app.js index 01c8f03..94ed26a 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -38,7 +38,7 @@ var tpl = { ;(function (FMS, Backbone, _, $) { _.extend(FMS, { templates: [ - 'home', 'around' + 'home', 'around', 'photo' ], initialized: 0, diff --git a/www/js/router.js b/www/js/router.js index 5327a1c..4c7430c 100644 --- a/www/js/router.js +++ b/www/js/router.js @@ -6,7 +6,8 @@ routes: { '': 'home', 'home': 'home', - 'around': 'around' + 'around': 'around', + 'photo': 'photo' }, initialize: function() { @@ -28,17 +29,22 @@ this.changeView(homeView); }, + photo: function(){ + var photoView = new FMS.PhotoView(); + this.changeView(photoView); + }, + changeView: function(view) { console.log( 'change View to ' + view.id ); $(view.el).attr('data-role', 'page'); + if ( view.prev ) { + $(view.el).attr('data-add-back-btn', 'true'); + } view.render(); $('body').append($(view.el)); $.mobile.changePage($(view.el), { changeHash: false }); - if(!_.isNull(this.currentView)) { - this.currentView.destroy(); - } - view.afterDisplay(); + console.log('changed View to ' + view.id); this.currentView = view; } }) diff --git a/www/js/views/around.js b/www/js/views/around.js index 02f7cc0..53c2889 100644 --- a/www/js/views/around.js +++ b/www/js/views/around.js @@ -5,6 +5,12 @@ tag: 'div', id: 'around-page', + events: { + 'pagehide': 'destroy', + 'pageshow': 'afterDisplay', + 'click #mark-here': 'onClickReport' + }, + afterDisplay: function() { this.locate(); }, @@ -45,6 +51,41 @@ this.displayError( STRINGS.location_problem ); } }, + + onClickReport: function() { + var position = this.getCrossHairPosition(); + + var l = new Locate(); + _.extend(l, Backbone.Events); + l.on('failed', this.noMap, this ); + l.on('located', this.goPhoto, this ); + l.check_location( { latitude: position.lat, longitude: position.lon } ); + }, + + goPhoto: function(info) { + //this.model.set('lat', info.coordinates.latitude ); + //this.model.set('lon', info.coordinates.longitude ); + //this.model.set('categories', info.details.category ); + + this.navigate( 'photo' ); + }, + + getCrossHairPosition: function() { + var cross = fixmystreet.map.getControlsByClass( + "OpenLayers.Control.Crosshairs"); + + var position = cross[0].getMapPosition(); + position.transform( + fixmystreet.map.getProjectionObject(), + new OpenLayers.Projection("EPSG:4326") + ); + + return position; + }, + + _destroy: function() { + delete fixmystreet; + } }) }); })(FMS, Backbone, _, $); diff --git a/www/js/views/fms.js b/www/js/views/fms.js index 384d125..848690d 100644 --- a/www/js/views/fms.js +++ b/www/js/views/fms.js @@ -21,6 +21,14 @@ afterDisplay: function() {}, + navigate: function( route, direction ) { + if ( !direction ) { + direction == 'left'; + } + + FMS.router.navigate( route, { trigger: true } ); + }, + onClickButtonPrev: function() { this.navigate( this.prev, 'right' ); }, @@ -33,7 +41,10 @@ alert(msg); }, - destroy: function() { console.log('destory for ' + this.id); this.remove(); } + destroy: function() { console.log('destory for ' + this.id); this._destroy(); this.remove(); }, + + _destroy: function() {} }) }); + _.extend( FMS.FMSView, Backbone.Events ); })(FMS, Backbone, _, $); diff --git a/www/js/views/home.js b/www/js/views/home.js index e29534e..2fc07e6 100644 --- a/www/js/views/home.js +++ b/www/js/views/home.js @@ -5,6 +5,11 @@ tag: 'div', id: 'front-page', + events: { + 'pagehide': 'destroy', + 'pageshow': 'afterDisplay' + }, + afterRender: function() { /* if ( !can_geolocate && ( !navigator.network || !navigator.network.connection ) ) { @@ -27,9 +32,9 @@ if ( navigator && navigator.network && ( navigator.network.connection.type == Connection.NONE || navigator.network.connection.type == Connection.UNKNOWN ) ) { localStorage.offline = 1; - FMS.router.navigate( 'no_connection' ); + this.navigate( 'no_connection' ); } else { - FMS.router.navigate( 'around', { trigger: true } ); + this.navigate( 'around' ); } } }) diff --git a/www/templates/en/photo.html b/www/templates/en/photo.html new file mode 100644 index 0000000..ed27929 --- /dev/null +++ b/www/templates/en/photo.html @@ -0,0 +1,27 @@ +<div data-role="header" data-position="fixed" > + <h1>Add Photo</h1> + <a href="details.html" id="photo-next-btn" data-icon="arrow-r" data-iconpos="right" class="ui-btn-right">Skip</a> +</div> +<div class="container" data-enhance="false"> + <div class="content" role="main"> + <div id="side-form"> + <fieldset> + <div id="problem_form"> + <div id="add_photo"> + <label>Optionally Add a Photo</label> + <input value="Take Photo" type="button" name="photo_button" id="id_photo_button" class="green-btn"> Or + <input value="Choose" type="button" name="existing" id="id_existing" class="green-btn"> + </div> + + <div id="display_photo" style="display: none"> + <label>Your Photo</label> + <img id="photo" src="" width="200" /> + <input value="Remove Photo" type="button" name="del_photo_button" id="id_del_photo_button" class="green-btn"> + </div> + + <input type="hidden" name="photo" id="form_photo" value=""> + </div> + </fieldset> + </div> + </div> +</div> |