diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/index.html | 2 | ||||
-rw-r--r-- | www/js/map-OpenLayers.js | 2 | ||||
-rw-r--r-- | www/js/router.js | 5 | ||||
-rw-r--r-- | www/js/views/around.js | 44 | ||||
-rw-r--r-- | www/js/views/fms.js | 4 | ||||
-rw-r--r-- | www/js/views/home.js | 1 |
6 files changed, 48 insertions, 10 deletions
diff --git a/www/index.html b/www/index.html index 11b334d..5ab85d7 100644 --- a/www/index.html +++ b/www/index.html @@ -31,6 +31,8 @@ <script type="text/javascript" src="js/map-OpenLayers.js"></script> <script type="text/javascript" src="js/map-bing-ol.js"></script> + <script type="text/javascript" src="js/locate.js"></script> + <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> diff --git a/www/js/map-OpenLayers.js b/www/js/map-OpenLayers.js index ed6af9a..c4a6d68 100644 --- a/www/js/map-OpenLayers.js +++ b/www/js/map-OpenLayers.js @@ -317,7 +317,7 @@ function show_map(event) { //if ( localStorage.currentReport ) { //mark_here(); //} else { - //fixmystreet.nav.activate(); + fixmystreet.nav.activate(); $('#mark-here').show(); //} } diff --git a/www/js/router.js b/www/js/router.js index 2217c9b..5327a1c 100644 --- a/www/js/router.js +++ b/www/js/router.js @@ -29,13 +29,14 @@ }, changeView: function(view) { + console.log( 'change View to ' + view.id ); $(view.el).attr('data-role', 'page'); view.render(); $('body').append($(view.el)); $.mobile.changePage($(view.el), { changeHash: false }); + if(!_.isNull(this.currentView)) { - var oldView = this.currentView; - oldView.destroy(); + this.currentView.destroy(); } view.afterDisplay(); this.currentView = view; diff --git a/www/js/views/around.js b/www/js/views/around.js index ba0e62e..02f7cc0 100644 --- a/www/js/views/around.js +++ b/www/js/views/around.js @@ -6,13 +6,45 @@ id: 'around-page', afterDisplay: function() { - console.log( 'around after display'); - fixmystreet.latitude = 56.33182; - fixmystreet.longitude = -2.79483; + this.locate(); + }, - show_map(); - console.log('map shown'); - } + locate: function() { + var that = this; + var l = new Locate(); + _.extend(l, Backbone.Events); + l.on('located', this.showMap, this ); + l.on('failed', this.noMap, this ); + + l.geolocate(); + }, + + showMap: function( info ) { + var coords = info.coordinates; + fixmystreet.latitude = coords.latitude; + fixmystreet.longitude = coords.longitude; + if ( !fixmystreet.map ) { + show_map(); + } else { + var centre = new OpenLayers.LonLat( coords.longitude, coords.latitude ); + centre.transform( + new OpenLayers.Projection("EPSG:4326"), + fixmystreet.map.getProjectionObject() + ); + fixmystreet.map.panTo(centre); + } + }, + + noMap: function( details ) { + $('#ajaxOverlay').hide(); + if ( details.msg ) { + this.displayError( details.msg ); + } else if ( details.locs ) { + this.displayError( STRINGS.multiple_locations ); + } else { + this.displayError( STRINGS.location_problem ); + } + }, }) }); })(FMS, Backbone, _, $); diff --git a/www/js/views/fms.js b/www/js/views/fms.js index d827445..384d125 100644 --- a/www/js/views/fms.js +++ b/www/js/views/fms.js @@ -29,6 +29,10 @@ this.navigate( this.next, 'left' ); }, + displayError: function(msg) { + alert(msg); + }, + destroy: function() { console.log('destory for ' + this.id); this.remove(); } }) }); diff --git a/www/js/views/home.js b/www/js/views/home.js index cfa6167..e29534e 100644 --- a/www/js/views/home.js +++ b/www/js/views/home.js @@ -29,7 +29,6 @@ localStorage.offline = 1; FMS.router.navigate( 'no_connection' ); } else { - alert('pause'); FMS.router.navigate( 'around', { trigger: true } ); } } |