Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ A meteor.js package that allows you to detect client-side timezones and gives yo

Just run

```
```sh
meteor add joshowens:timezone-picker
```

### Add the timezone picker calls

Now we just have to add a startup block on the client to detect timezones:

```
```js
// set the user's timezone
Deps.autorun(function() {
Tracker.autorun(function() {
if (!Meteor.user().profile.timezone) {
Meteor.users.update(Meteor.userId(), {$set: {
'profile.timezone': TimezonePicker.detectedZone()
Expand All @@ -33,5 +33,16 @@ Then we can add a quick form field to a profile settings form:
{{> timezonePicker class="form-group" selected=timezone}}
```

With this example helper:
```js
Template.profile.helpers({
// ...
timezone() {
return Meteor.user().profile.timezone;
}
// ...
});
```

This will inject a select element with all the available moment-timezone timezones as options.
If the user's profile is the context for this template, it should pick up the timezone string we set on loading the page.
10 changes: 6 additions & 4 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
Package.describe({
summary: "Nicely formatted dropdown list of timezones, based on moment. Also timezone detection.",
version: '0.1.2',
version: '0.1.3',
name: "joshowens:timezone-picker",
git: 'https://github.com/MeteorClub/timezone-picker'
});

Package.onUse(function(api, where) {
api.versionsFrom("[email protected]");

// Client side only packages
api.use(['blaze', 'templating', 'jquery'], 'client');
api.use(['underscore'], 'client');
api.use(['mrt:[email protected]', 'mrt:[email protected]'], 'client');
// Isomorphic packages (exposed on Client and Server)
var sharedDeps = ['momentjs:[email protected]', 'aldeed:[email protected]'];
api.use(sharedDeps);
api.imply(sharedDeps);

api.addFiles([
'mapping.js',
Expand All @@ -21,5 +25,3 @@ Package.onUse(function(api, where) {

api.export(['TimezonePicker']);
});