diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/index.html | 5 | ||||
-rw-r--r-- | www/js/app.js | 2 | ||||
-rw-r--r-- | www/js/map-OpenLayers.js | 14 | ||||
-rw-r--r-- | www/js/router.js | 11 | ||||
-rw-r--r-- | www/js/views/around.js | 18 | ||||
-rw-r--r-- | www/js/views/fms.js | 4 | ||||
-rw-r--r-- | www/js/views/home.js | 31 |
7 files changed, 76 insertions, 9 deletions
diff --git a/www/index.html b/www/index.html index 72a9418..11b334d 100644 --- a/www/index.html +++ b/www/index.html @@ -27,8 +27,13 @@ <script type="text/javascript" src="jslib/json2.js"></script> <script type="text/javascript" src="jslib/jquery.validate.min.js"></script> + <script type="text/javascript" src="js/OpenLayers.fixmystreet.js"></script> + <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/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/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 16efe3a..01c8f03 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -38,7 +38,7 @@ var tpl = { ;(function (FMS, Backbone, _, $) { _.extend(FMS, { templates: [ - 'home' + 'home', 'around' ], initialized: 0, diff --git a/www/js/map-OpenLayers.js b/www/js/map-OpenLayers.js index da0b414..ed6af9a 100644 --- a/www/js/map-OpenLayers.js +++ b/www/js/map-OpenLayers.js @@ -314,17 +314,17 @@ function show_map(event) { if ( fixmystreet.page == 'around' ) { - if ( localStorage.currentReport ) { - mark_here(); - } else { - fixmystreet.nav.activate(); + //if ( localStorage.currentReport ) { + //mark_here(); + //} else { + //fixmystreet.nav.activate(); $('#mark-here').show(); - } + //} } } -$(document).delegate('#around-page', 'pageshow', show_map ); -$(document).delegate('#report-page', 'pageshow', show_map ); +//$(document).delegate('#around-page', 'pageshow', show_map ); +//$(document).delegate('#report-page', 'pageshow', show_map ); OpenLayers.Control.Crosshairs = OpenLayers.Class.create(); diff --git a/www/js/router.js b/www/js/router.js index 777acd9..2217c9b 100644 --- a/www/js/router.js +++ b/www/js/router.js @@ -6,6 +6,7 @@ routes: { '': 'home', 'home': 'home', + 'around': 'around' }, initialize: function() { @@ -17,6 +18,11 @@ } }, + around: function(){ + var aroundView = new FMS.AroundView(); + this.changeView(aroundView); + }, + home: function(){ var homeView = new FMS.HomeView(); this.changeView(homeView); @@ -27,6 +33,11 @@ view.render(); $('body').append($(view.el)); $.mobile.changePage($(view.el), { changeHash: false }); + if(!_.isNull(this.currentView)) { + var oldView = this.currentView; + oldView.destroy(); + } + view.afterDisplay(); this.currentView = view; } }) diff --git a/www/js/views/around.js b/www/js/views/around.js new file mode 100644 index 0000000..ba0e62e --- /dev/null +++ b/www/js/views/around.js @@ -0,0 +1,18 @@ +;(function (FMS, Backbone, _, $) { + _.extend( FMS, { + AroundView: FMS.FMSView.extend({ + template: 'around', + tag: 'div', + id: 'around-page', + + afterDisplay: function() { + console.log( 'around after display'); + fixmystreet.latitude = 56.33182; + fixmystreet.longitude = -2.79483; + + show_map(); + console.log('map shown'); + } + }) + }); +})(FMS, Backbone, _, $); diff --git a/www/js/views/fms.js b/www/js/views/fms.js index 45eeabf..d827445 100644 --- a/www/js/views/fms.js +++ b/www/js/views/fms.js @@ -19,6 +19,8 @@ afterRender: function() {}, + afterDisplay: function() {}, + onClickButtonPrev: function() { this.navigate( this.prev, 'right' ); }, @@ -26,6 +28,8 @@ onClickButtonNext: function() { this.navigate( this.next, 'left' ); }, + + destroy: function() { console.log('destory for ' + this.id); this.remove(); } }) }); })(FMS, Backbone, _, $); diff --git a/www/js/views/home.js b/www/js/views/home.js index 644754d..cfa6167 100644 --- a/www/js/views/home.js +++ b/www/js/views/home.js @@ -3,7 +3,36 @@ HomeView: FMS.FMSView.extend({ template: 'home', tag: 'div', - id: 'front-page' + id: 'front-page', + + afterRender: function() { + /* + if ( !can_geolocate && ( !navigator.network || !navigator.network.connection ) ) { + geocheck_count++; + window.setTimeout( decide_front_page, 1000 ); + return; + } + + // sometime onDeviceReady does not fire so set this here to be sure + can_geolocate = true; + + geocheck_count = 0; + */ + + $('#locating').show(); + + }, + + afterDisplay: function() { + if ( navigator && navigator.network && ( navigator.network.connection.type == Connection.NONE || + navigator.network.connection.type == Connection.UNKNOWN ) ) { + localStorage.offline = 1; + FMS.router.navigate( 'no_connection' ); + } else { + alert('pause'); + FMS.router.navigate( 'around', { trigger: true } ); + } + } }) }); })(FMS, Backbone, _, $); |