Skip to content

Commit

Permalink
Show full dates with smaller font in topic lists
Browse files Browse the repository at this point in the history
  • Loading branch information
nlalonde committed Jan 10, 2014
1 parent d16b448 commit 845c2b6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
18 changes: 16 additions & 2 deletions app/assets/javascripts/discourse/lib/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Discourse.Formatter = (function(){

var updateRelativeAge, autoUpdatingRelativeAge, relativeAge, relativeAgeTiny,
relativeAgeMedium, relativeAgeMediumSpan, longDate, toTitleCase,
shortDate, shortDateNoYear, tinyDateYear, breakUp;
shortDate, shortDateNoYear, tinyDateYear, breakUp, relativeAgeTinyShowsYear;

/*
* memoize.js
Expand Down Expand Up @@ -143,11 +143,17 @@ Discourse.Formatter = (function(){
options.wrapInSpan = false;
}

var relAge = relativeAge(date, options);

if (format === 'tiny' && relativeAgeTinyShowsYear(relAge)) {
append += " with-year";
}

if (options.title) {
append += "' title='" + longDate(date);
}

return "<span class='relative-date" + append + "' data-time='" + date.getTime() + "' data-format='" + format + "'>" + relativeAge(date, options) + "</span>";
return "<span class='relative-date" + append + "' data-time='" + date.getTime() + "' data-format='" + format + "'>" + relAge + "</span>";
};


Expand Down Expand Up @@ -196,6 +202,14 @@ Discourse.Formatter = (function(){
return formatted;
};

/*
* Returns true if the given tiny date string includes the year.
* Useful for checking if the string isn't so tiny.
*/
relativeAgeTinyShowsYear = function(relativeAgeString) {
return relativeAgeString.match(/'[\d]{2}$/);
};

relativeAgeMediumSpan = function(distance, leaveAgo) {
var formatted, distanceInMinutes;

Expand Down
6 changes: 5 additions & 1 deletion app/assets/stylesheets/desktop/topic-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,15 @@
width: 65px;
}
.activity {
width: 50px;
width: 60px;
}
.age {
width: 60px;
}
.with-year {
font-size: 85%;
white-space: nowrap;
}
}


Expand Down
6 changes: 6 additions & 0 deletions app/assets/stylesheets/mobile/topic-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@
color: inherit;
}
}
.age {
white-space: nowrap;
.with-year {
font-size: 85%;
}
}
}

// Category list
Expand Down

0 comments on commit 845c2b6

Please sign in to comment.