diff options
-rw-r--r-- | www/index.html | 1 | ||||
-rw-r--r-- | www/js/app.js | 2 | ||||
-rw-r--r-- | www/js/router.js | 6 | ||||
-rw-r--r-- | www/js/views/around.js | 20 | ||||
-rw-r--r-- | www/js/views/search.js | 42 | ||||
-rw-r--r-- | www/templates/en/address_search.html | 35 | ||||
-rw-r--r-- | www/templates/en/around.html | 1 |
7 files changed, 105 insertions, 2 deletions
diff --git a/www/index.html b/www/index.html index d7bab77..1f1f77e 100644 --- a/www/index.html +++ b/www/index.html @@ -38,6 +38,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/search.js"></script> <script type="text/javascript" src="js/views/photo.js"></script> <script type="text/javascript" src="js/views/details.js"></script> <script type="text/javascript" src="js/views/submit.js"></script> diff --git a/www/js/app.js b/www/js/app.js index 63d38d2..00c178c 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', 'photo', 'details', 'submit', 'submit_email', 'submit_name', 'submit_password', 'sent' + 'home', 'around', 'address_search', 'photo', 'details', 'submit', 'submit_email', 'submit_name', 'submit_password', 'sent' ], initialized: 0, diff --git a/www/js/router.js b/www/js/router.js index 29a5d64..e9bce54 100644 --- a/www/js/router.js +++ b/www/js/router.js @@ -7,6 +7,7 @@ '': 'home', 'home': 'home', 'around': 'around', + 'search': 'search', 'photo': 'photo', 'details': 'details', 'submit': 'submit', @@ -30,6 +31,11 @@ this.changeView(aroundView); }, + search: function(){ + var searchView = new FMS.SearchView({ model: FMS.currentReport }); + this.changeView(searchView); + }, + home: function(){ var homeView = new FMS.HomeView({ model: FMS.currentReport }); this.changeView(homeView); diff --git a/www/js/views/around.js b/www/js/views/around.js index 8720ccc..49b65da 100644 --- a/www/js/views/around.js +++ b/www/js/views/around.js @@ -7,12 +7,20 @@ events: { 'pagehide': 'destroy', 'pageshow': 'afterDisplay', + 'click #search': 'goSearch', 'click #relocate': 'centerMapOnPosition', 'click #mark-here': 'onClickReport' }, afterDisplay: function() { - this.locate(); + if ( FMS.currentLocation ) { + var info = { coordinates: FMS.currentLocation }; + FMS.currentLocation = null; + FMS.locator.on('gps_current_position', this.positionUpdate, this); + this.showMap(info); + } else { + this.locate(); + } }, locate: function() { @@ -150,6 +158,16 @@ this.navigate( 'photo' ); }, + goSearch: function(e) { + e.preventDefault(); + FMS.locator.off('gps_located'); + FMS.locator.off('gps_failed'); + FMS.locator.off('gps_locating'); + FMS.locator.off('gps_current_position'); + FMS.locator.stopUpdating(); + this.navigate( 'search' ); + }, + getCrossHairPosition: function() { var cross = fixmystreet.map.getControlsByClass( "OpenLayers.Control.Crosshairs"); diff --git a/www/js/views/search.js b/www/js/views/search.js new file mode 100644 index 0000000..8e2bfd2 --- /dev/null +++ b/www/js/views/search.js @@ -0,0 +1,42 @@ +(function (FMS, Backbone, _, $) { + _.extend( FMS, { + SearchView: FMS.FMSView.extend({ + template: 'address_search', + id: 'search-page', + + events: { + 'click #submit': 'search', + 'pagehide': 'destroy', + 'pageshow': 'afterDisplay' + }, + + search: function() { + var pc = this.$('#pc').val(); + FMS.locator.on('search_located', this.searchSuccess, this ); + FMS.locator.on('search_failed', this.searchFail, this ); + + $('#ajaxOverlay').show(); + FMS.locator.lookup(pc); + }, + + + searchSuccess: function( info ) { + var coords = info.coordinates; + FMS.currentLocation = coords; + this.navigate('around'); + }, + + + searchFail: function( details ) { + $('#ajaxOverlay').hide(); + if ( details.msg ) { + this.displayError( details.msg ); + } else if ( details.locs ) { + this.displayError( FMS.strings.multiple_locations ); + } else { + this.displayError( FMS.strings.location_problem ); + } + } + }) + }); +})(FMS, Backbone, _, $); diff --git a/www/templates/en/address_search.html b/www/templates/en/address_search.html new file mode 100644 index 0000000..f3674bd --- /dev/null +++ b/www/templates/en/address_search.html @@ -0,0 +1,35 @@ +<div data-id="locate" id="search-header" data-role="header" data-position="fixed"> + <a href="index.html" data-transition="slidedown" class="ui-btn-left">Locate</a> + <h1>Locate</h1> + <a href="settings.html" data-transition="slideup" class="ui-btn-right" data-icon="gear" data-iconpos="notext"></a> +</div> +<div class="table-cell"> + <div class="container"> + <div class="content" role="main"> + <div id="front-main"> + <div id="front-main-container" data-enhance="false"> + <form name="postcodeForm" id="postcodeForm"> + <label for="pc">Enter a nearby GB postcode, or street name and area:</label> + <div> + <input type="text" name="pc" value="" id="pc" size="10" maxlength="200" placeholder="e.g. ‘B2 4QA’ or ‘Tib St, Manchester’"> + <input type="button" value="Go" id="submit"> + </div> + </form> + </div> + </div> + + <div class="tablewrapper"> + <div id="front-howto"> + <h2>How to report a problem</h2> + + <ol class="big-numbers"> + <li>Enter a nearby GB postcode, or street name and area</li> + <li>Locate the problem on a map of the area</li> + <li>Enter details of the problem</li> + <li>We send it to the council on your behalf</li> + </ol> + </div> + </div> + </div> + </div> +</div> diff --git a/www/templates/en/around.html b/www/templates/en/around.html index 812efba..20425e1 100644 --- a/www/templates/en/around.html +++ b/www/templates/en/around.html @@ -61,6 +61,7 @@ <a id="hide_pins_link" rel="nofollow" href="">Hide pins</a> <a id="all_pins_link" rel="nofollow" href="">Show old</a> <a id="relocate" rel="nofollow" href="">Recenter</a> + <a id="search" rel="nofollow" href="">Search</a> </p> </div> </form> |