mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-24 08:09:13 -05:00
UX: Tweak logic for showing times in topic entrance popup
This commit is contained in:
parent
13891292d3
commit
14c765ef11
2 changed files with 28 additions and 9 deletions
|
@ -1,29 +1,46 @@
|
||||||
function entranceDate(dt) {
|
function entranceDate(bumpedAt, showTime) {
|
||||||
var bumpedAt = new Date(dt),
|
var today = new Date();
|
||||||
today = new Date();
|
|
||||||
|
|
||||||
if (bumpedAt.getDate() === today.getDate()) {
|
if (bumpedAt.getDate() === today.getDate()) {
|
||||||
return moment(bumpedAt).format(I18n.t("dates.time"));
|
return moment(bumpedAt).format(I18n.t("dates.time"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bumpedAt.getYear() === today.getYear()) {
|
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({
|
export default Ember.ObjectController.extend({
|
||||||
position: null,
|
position: null,
|
||||||
|
|
||||||
topDate: function() {
|
createdDate: function() {
|
||||||
return entranceDate(this.get('created_at'));
|
return new Date(this.get('model.created_at'));
|
||||||
}.property('model.created_at'),
|
}.property('model.created_at'),
|
||||||
|
|
||||||
bottomDate: function() {
|
bumpedDate: function() {
|
||||||
return entranceDate(this.get('bumped_at'));
|
return new Date(this.get('model.bumped_at'));
|
||||||
}.property('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: {
|
actions: {
|
||||||
show: function(data) {
|
show: function(data) {
|
||||||
// Show the chooser but only if the model changes
|
// Show the chooser but only if the model changes
|
||||||
|
|
|
@ -32,7 +32,9 @@ en:
|
||||||
dates:
|
dates:
|
||||||
time: "h:mm a"
|
time: "h:mm a"
|
||||||
long_no_year: "MMM DD 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: "MMM DD, YYYY h:mm a"
|
||||||
|
long_with_year_no_time: "MMM DD, YYYY"
|
||||||
tiny:
|
tiny:
|
||||||
half_a_minute: "< 1m"
|
half_a_minute: "< 1m"
|
||||||
less_than_x_seconds:
|
less_than_x_seconds:
|
||||||
|
|
Loading…
Reference in a new issue