Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 #55

Merged
merged 38 commits into from
Aug 7, 2017
Merged

2.0 #55

merged 38 commits into from
Aug 7, 2017

Conversation

javan
Copy link
Contributor

@javan javan commented Mar 17, 2016

  • Adds i18n support (branched from I18n #53)
  • Uses MutationObserver instead of listening for various Turbolinks and jQuery events
  • Allows updating a single element with LocalTime.process(element)
  • Refactors code into multiple files, logical pieces

Todo:

  • Update README
  • Drop coffee-rails dependency, bundle compiled local-time.js instead
  • Publish npm package

Fixes #54
Fixes #56
Fixes #60
Fixes #63
Fixes #66
Fixes #70
Fixes #71
Closes #49
Closes #50
Closes #53

This was referenced Mar 17, 2016
Closed
@grk
Copy link

grk commented May 18, 2016

I was testing this branch because we need I18n support, and I ran into an issue with PageObserver. It's observing on document.body, but turbolinks throws out the body and replaces it with a new one, so no callbacks were being fired. A quick fix would be to observe on document.body.parentElement (so <html>), but I'm not sure if that's the right way.

Do you have any suggestions how to work around that? Or am I doing something wrong?

@javan
Copy link
Contributor Author

javan commented May 29, 2016

@grk Fixed in 9fae425. Mind giving it a try?

@grk
Copy link

grk commented May 31, 2016

@javan yes, this fixes the problem. Thanks!

@brandonhilkert
Copy link

Hi there! Thanks so much for this gem. We're using with Rails 5 and it's not working with the new Turbolinks b/c of the page:change. This looks like it'll do the trick. Was curious if you're going to release soon or if there was something I could do to help the cause. Thanks again 👍

@javan
Copy link
Contributor Author

javan commented Jul 14, 2016

Hey @brandonhilkert, thanks!

I'd like to explore using Date#toLocaleString (and Date#toLocaleDateString, Date#toLocaleTimeString) to localize timestamp formats natively, and to avoid the need for defining translations client side where possible. I'm not sure it will pan out, but it's worth an investigation.

Other than that, I think this branch is stable for use and could be shipped soon. Just need to polish the docs.

@brandonhilkert
Copy link

@javan Sounds good! Branch worked well locally, I'll go with that for now. Curious was Basecamp 3 is using for local time display if it's not this...

@javan
Copy link
Contributor Author

javan commented Jul 14, 2016

Basecamp 3 is running on #49 and using its own MutationObserver wrapper to process elements:

BC.observe 'time[datetime]', (element) ->
  LocalTime.updateElement(element)

This branch obviates it by incorporating a MutationObserver. We could switch over and just haven't gotten around to it.

djch added a commit to djch/daybook that referenced this pull request Sep 5, 2016
Using this fantastic gem:
https://github.com/basecamp/local_time

⚠️ Using a pre-release version (which seems quite stable):
basecamp/local_time#55
@javan javan mentioned this pull request Oct 10, 2016
@akashagarwal7
Copy link

akashagarwal7 commented Nov 5, 2016

Uncaught TypeError: LocalTime.relativeTimeAgo is not a function
This error didn't show up in the master branch. I use this function on the client side to render data.

@javan javan merged commit 124ece3 into master Aug 7, 2017
@javan javan deleted the 2-0 branch August 7, 2017 14:54
@javan
Copy link
Contributor Author

javan commented Aug 7, 2017

@akashaggarwal7, you can create LocalTime.RelativeTime instances directly now. See relative_time.coffee for its full API.

screen shot 2017-08-07 at 11 34 26 am

@brandonhilkert
Copy link

Thanks for this! ☮️

benoittgt pushed a commit to benoittgt/codetriage that referenced this pull request Aug 9, 2017
The branche 2_0 has been deleted and merged
basecamp/local_time#55 (comment)
It was not possible to build the projet with the gemfile like before.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants