docbrown/app/assets/javascripts/initializers/initializeArticleDate.js
rhymes 4e591fea1c Show localized date/time on hover for articles/comments (#2722)
* Add article decorator published_timestamp

* Use time HTML5 element and refactor date in partial

* Add published_timestamp to Article

Adding `published_timestamp` to the homepage we can then use JS to render the full timestamp localized for the user.

We've also added the timestamp to the index and the API

* Display article published timestamp on hover

* Use time also in the article show page

* Add timestamp to bottom articles as well

* Remove published_timestamp from index because it is not used

* Fix broken specs

* Add more article dates specs

* Refactor date initializers
2019-05-09 11:05:17 -04:00

10 lines
336 B
JavaScript

/* Show article date/time according to user's locale */
/* global addLocalizedDateTimeToElementsTitles */
function initializeArticleDate() {
var articlesDates = document.querySelectorAll(
'.single-article time, article time, .single-other-article time',
);
addLocalizedDateTimeToElementsTitles(articlesDates, 'datetime');
}