Skip to content

Commit

Permalink
Merge pull request #143 from openplans/startpage-bug
Browse files Browse the repository at this point in the history
Make the condition for show the start page handle the map location routes.
  • Loading branch information
atogle committed Sep 9, 2014
2 parents f676cec + 4dc50b0 commit 54bd5a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/flavors/default/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ pages:
- title: _(About)
slug: about
name: overview
# start_page: true
start_page: true

- title: _(Why Shareabouts?)
slug: why
Expand Down
12 changes: 11 additions & 1 deletion src/sa_web/static/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var Shareabouts = Shareabouts || {};
Backbone.history.start(historyOptions);

// Load the default page only if there is no page already in the url
if (Backbone.history.getFragment() === '') {
if (this.isMapRoute(Backbone.history.getFragment())) {
startPageConfig = _.find(options.pagesConfig, function(pageConfig) {
return pageConfig.start_page === true;
});
Expand Down Expand Up @@ -110,6 +110,16 @@ var Shareabouts = Shareabouts || {};

showList: function() {
this.appView.showListView();
},

isMapRoute: function(fragment) {
// This is a little hacky. I attempted to use Backbone.history.handlers,
// but there is currently no way to map the route, at this point
// transformed into a regex, back to the route name. This may change
// in the future.
return (fragment === '' || (fragment.indexOf('place') === -1 &&
fragment.indexOf('page') === -1 &&
fragment.indexOf('list') === -1));
}
});

Expand Down
5 changes: 0 additions & 5 deletions src/sa_web/static/js/views/app-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,6 @@ var Shareabouts = Shareabouts || {};
_.defer(function() {
self.mapView.map.setView(ll, parseInt(zoom, 10));
});
} else {
// If not, set it to the current map location but don't trigger the route
zoom = this.mapView.map.getZoom();
ll = this.mapView.map.getCenter();
this.setLocationRoute(zoom, ll.lat, ll.lng);
}

this.hidePanel();
Expand Down

0 comments on commit 54bd5a8

Please sign in to comment.