-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Display early polling locations in sidebar, via ejs template - Create new early voting module to separate early voting out - introduce ejs for templating and moment for date formatting
- Loading branch information
Showing
10 changed files
with
168 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
define( | ||
[ | ||
'jquery', 'moment', 'ejs', 'geojson', | ||
'json!vendor/EARLY_VOTING_AddressPoints.geojson', | ||
'text!templates/early_voting_sidebar.ejs', 'moment_range' | ||
], | ||
function($, moment, ejs, GeoJSON, earlyVotingJSON, earlyVotingSidebarTmpl) { | ||
'use strict'; | ||
|
||
var earlyVotingLocations = new GeoJSON(earlyVotingJSON); | ||
|
||
var $el = $('#early-voting-sidebar'); | ||
|
||
function getDirections(destination) { | ||
var url; | ||
if (navigator.userAgent.match(/iPhone|iPad|iPod/)) { | ||
url = "http://maps.apple.com/?saddr=Current+Location&daddr="; | ||
} else { | ||
url = "https://maps.google.com/maps?daddr="; | ||
} | ||
return encodeURI(url + destination); | ||
} | ||
|
||
return { | ||
init: function() { | ||
$el.html(ejs.render(earlyVotingSidebarTmpl, { | ||
moment: moment, | ||
locations: earlyVotingLocations, | ||
getDirections: getDirections | ||
})); | ||
} | ||
} | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<% locations.forEach(function(location, i) { %> | ||
<div class="early-voting-location" id="location<%= i %>"> | ||
<h4><%= location.geojsonProperties.LOCATION %></h4> | ||
<div> | ||
<a href="<%= getDirections(location.geojsonProperties.Full_Addr + ', Cambridge, MA') %>" target="_blank">Directions</a> | ||
</div> | ||
<ul> | ||
<% location.geojsonProperties.hours.forEach(function(interval) { %> | ||
<% | ||
var dates = moment.range(interval).toDate(); | ||
var startDate = moment(dates[0]); | ||
var endDate = moment(dates[1]); | ||
%> | ||
<li><%= startDate.format('MMM Do, h:mma') %> - <%= endDate.format('h:mma') %></li> | ||
<% }) %> | ||
</ul> | ||
</div> | ||
<% }) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.