Skip to content

Commit

Permalink
Add infowindows containing store information
Browse files Browse the repository at this point in the history
This commit takes the infopane div from previous versions and
displays it in an infowindow pointing to the relevant store
when the store is selected. There are also minor fixes to
disable the "find me" button when AJAX is being processed.
  • Loading branch information
wetmore committed Apr 5, 2012
1 parent d62c2a8 commit fce2f28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions app/app.js
Expand Up @@ -79,6 +79,7 @@ $(function() {
timeInt: null,
timeInfo: 'empty',
initialize: function() {
$(this.el).hide();
var self = this;
// every 20 seconds, check if the store is near closing or opening.
var checkCriticalTimes = function() {
Expand All @@ -96,12 +97,16 @@ $(function() {
};
var minsToClose = mins(closeHr, closeMin) - mins(curHr, curMin);
if (self.model.get('open') && minsToClose < 8 * 60) {
self.timeInfo = 'closes in ' + Math.floor(minsToClose / 60) + ':' + minsToClose % 60;
var hours = Math.floor(minsToClose / 60);
var min = minsToClose % 60;
self.timeInfo = 'Closes in ' + hours + ':' + ((min < 10) ? '0' : '') + min;
self.render(self);
}
var minsToOpen = mins(curHr, curMin) - mins(openHr, openMin);
if (!self.model.get('open') && minsToOpen < 1 * 60) {
self.timeInfo = 'opens in ' + Math.floor(minsToOpen / 60) + ':' + minsToOpen % 60;
var hours = Math.floor(minsToOpen / 60);
var min = minsToOpen % 60;
self.timeInfo = 'Opens in ' + hours + ':' + ((min < 10) ? '0' : '') + min;
self.render(self);
}
}(); // execute immediately
Expand All @@ -123,6 +128,7 @@ $(function() {
//Map view
window.MapView = Backbone.View.extend({
el: $('#map'),
infoWindow: new google.maps.InfoWindow({}),
view: null,
markers: {},
locMarker: null,
Expand Down Expand Up @@ -178,7 +184,12 @@ $(function() {
if (this.view !== null) {
clearInterval(this.view.timeInt);
}
if (this.infoWindow !== null) {
this.infoWindow.close();
}
this.view = new StoreInfo({model: store, el: $('#infopane')});
this.infoWindow.setContent($('#infopane').html());
this.infoWindow.open(this.map, this.markers[store.id]);
}
});

Expand Down Expand Up @@ -247,6 +258,7 @@ $(function() {
this.input.val('');
},
create: function(text) {
$('#find').attr('disabled', true);
this.clear();
var self = this;
console.log('requesting address: '+text);
Expand Down
4 changes: 2 additions & 2 deletions app/index.html
Expand Up @@ -72,8 +72,8 @@ <h1>SAQ Finder</h1>
<div class="infopane">
<span class="title">SAQ <%= storeType %></span>
<div class="info-body">
Phone: <%= storePhone %>
<%= storeTimeInfo %>
<p>Phone: <%= storePhone %></p>
<p><%= storeTimeInfo %></p>
<div class="times">

</div>
Expand Down

0 comments on commit fce2f28

Please sign in to comment.