aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/views/search.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-07-12 09:47:56 +0100
committerStruan Donald <struan@exo.org.uk>2013-07-12 11:00:11 +0100
commit25e3a0c94551b0faac3f16e0598e6f4bdffcf7d8 (patch)
treef78f68ba8ed39e5b5004e41435aac3e9bbe9c044 /www/js/views/search.js
parent4c2206c97250b7f72eb04d13ae886a7fb4f4086a (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/search.js')
-rw-r--r--www/js/views/search.js81
1 files changed, 0 insertions, 81 deletions
diff --git a/www/js/views/search.js b/www/js/views/search.js
deleted file mode 100644
index 6930e2a..0000000
--- a/www/js/views/search.js
+++ /dev/null
@@ -1,81 +0,0 @@
-(function (FMS, Backbone, _, $) {
- _.extend( FMS, {
- SearchView: FMS.FMSView.extend({
- template: 'address_search',
- id: 'search-page',
-
- events: {
- 'vclick a.address': 'goAddress',
- 'vclick #submit': 'search',
- 'vclick #locate': 'goLocate',
- 'pagehide': 'destroy',
- 'pagebeforeshow': 'beforeDisplay',
- 'pageshow': 'afterDisplay',
- 'submit #postcodeForm': 'search'
- },
-
- afterDisplay: function() {
- if ( FMS.isOffline ) {
- this.navigate('offline');
- }
- },
-
- search: function(e) {
- // this is to stop form submission
- e.preventDefault();
- this.clearValidationErrors();
- var pc = this.$('#pc').val();
- this.listenTo(FMS.locator, 'search_located', this.searchSuccess );
- this.listenTo(FMS.locator, 'search_failed', this.searchFail);
-
- FMS.locator.lookup(pc);
- },
-
- searchSuccess: function( info ) {
- this.stopListening(FMS.locator);
- var coords = info.coordinates;
- FMS.currentPosition = coords;
- this.navigate('around');
- },
-
- goAddress: function(e) {
- var t = $(e.target);
- var lat = t.attr('data-lat');
- var long = t.attr('data-long');
-
- FMS.currentPosition = { latitude: lat, longitude: long };
- this.navigate('around');
- },
-
- searchFail: function( details ) {
- // this makes sure any onscreen keyboard is dismissed
- $('#submit').focus();
- this.stopListening(FMS.locator);
- if ( details.msg ) {
- this.validationError( 'pc', details.msg );
- } else if ( details.locations ) {
- var multiple = '';
- for ( var i = 0; i < details.locations.length; i++ ) {
- var loc = details.locations[i];
- var li = '<li><a class="address" id="location_' + i + '" data-lat="' + loc.lat + '" data-long="' + loc.long + '">' + loc.address + '</a></li>';
- multiple = multiple + li;
- }
- $('#front-howto').html('<p>Multiple matches found</p><ul data-role="listview" data-inset="true">' + multiple + '</ul>');
- $('.ui-page').trigger('create');
- } else {
- this.validationError( 'pc', FMS.strings.location_problem );
- }
- },
-
- goLocate: function(e) {
- e.preventDefault();
- this.navigate( 'around' );
- },
-
- _destroy: function() {
- delete FMS.searchMessage;
- this.stopListening(FMS.locator);
- }
- })
- });
-})(FMS, Backbone, _, $);