mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 08:03:36 +08:00
UX: Tweak logic for showing times in topic entrance popup
This commit is contained in:
parent
13891292d3
commit
14c765ef11
|
@ -1,29 +1,46 @@
|
|||
function entranceDate(dt) {
|
||||
var bumpedAt = new Date(dt),
|
||||
today = new Date();
|
||||
function entranceDate(bumpedAt, showTime) {
|
||||
var today = new Date();
|
||||
|
||||
if (bumpedAt.getDate() === today.getDate()) {
|
||||
return moment(bumpedAt).format(I18n.t("dates.time"));
|
||||
}
|
||||
|
||||
if (bumpedAt.getYear() === today.getYear()) {
|
||||
return moment(bumpedAt).format(I18n.t("dates.long_no_year"));
|
||||
// No year
|
||||
return moment(bumpedAt).format(
|
||||
showTime ? I18n.t("dates.long_no_year") : I18n.t("dates.long_no_year_no_time")
|
||||
);
|
||||
}
|
||||
|
||||
return moment(bumpedAt).format(I18n.t('dates.long_with_year'));
|
||||
return moment(bumpedAt).format(
|
||||
showTime ? I18n.t('dates.long_with_year') : I18n.t('dates.long_with_year_no_time')
|
||||
);
|
||||
}
|
||||
|
||||
export default Ember.ObjectController.extend({
|
||||
position: null,
|
||||
|
||||
topDate: function() {
|
||||
return entranceDate(this.get('created_at'));
|
||||
createdDate: function() {
|
||||
return new Date(this.get('model.created_at'));
|
||||
}.property('model.created_at'),
|
||||
|
||||
bottomDate: function() {
|
||||
return entranceDate(this.get('bumped_at'));
|
||||
bumpedDate: function() {
|
||||
return new Date(this.get('model.bumped_at'));
|
||||
}.property('model.bumped_at'),
|
||||
|
||||
showTime: function() {
|
||||
var diffMs = this.get('bumpedDate').getTime() - this.get('createdDate').getTime();
|
||||
return diffMs < (1000 * 60 * 60 * 24 * 2);
|
||||
}.property('createdDate', 'bumpedDate'),
|
||||
|
||||
topDate: function() {
|
||||
return entranceDate(this.get('createdDate'), this.get('showTime'));
|
||||
}.property('createdDate'),
|
||||
|
||||
bottomDate: function() {
|
||||
return entranceDate(this.get('bumpedDate'), this.get('showTime'));
|
||||
}.property('bumpedDate'),
|
||||
|
||||
actions: {
|
||||
show: function(data) {
|
||||
// Show the chooser but only if the model changes
|
||||
|
|
|
@ -32,7 +32,9 @@ en:
|
|||
dates:
|
||||
time: "h:mm a"
|
||||
long_no_year: "MMM DD h:mm a"
|
||||
long_no_year_no_time: "MMM DD"
|
||||
long_with_year: "MMM DD, YYYY h:mm a"
|
||||
long_with_year_no_time: "MMM DD, YYYY"
|
||||
tiny:
|
||||
half_a_minute: "< 1m"
|
||||
less_than_x_seconds:
|
||||
|
|
Loading…
Reference in New Issue
Block a user