mirror of https://github.com/zulip/zulip.git
Render recent dates as weekdays, part 1.
This commit just moves time rendering logic to its own file, and does not make any functionality changes. (imported from commit d111d03c6abc8d9550fcf65e4f89eab8056d1ed4)
This commit is contained in:
parent
5d79bb6a20
commit
59dab21fcd
|
@ -225,6 +225,7 @@ PIPELINE_JS = {
|
||||||
'js/zephyr.js',
|
'js/zephyr.js',
|
||||||
'js/activity.js',
|
'js/activity.js',
|
||||||
'js/colorspace.js',
|
'js/colorspace.js',
|
||||||
|
'js/timerender.js',
|
||||||
),
|
),
|
||||||
'output_filename': 'min/app.js'
|
'output_filename': 'min/app.js'
|
||||||
},
|
},
|
||||||
|
|
|
@ -54,6 +54,9 @@ var globals =
|
||||||
// invite.js
|
// invite.js
|
||||||
+ ' invite'
|
+ ' invite'
|
||||||
|
|
||||||
|
// timerender.js
|
||||||
|
+ ' timerender'
|
||||||
|
|
||||||
// ui.js
|
// ui.js
|
||||||
+ ' ui'
|
+ ' ui'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
var timerender = (function () {
|
||||||
|
|
||||||
|
var exports = {};
|
||||||
|
|
||||||
|
// Given an XDate object 'time', return a DOM node that initially
|
||||||
|
// displays the human-formatted time, and is updated automatically as
|
||||||
|
// necessary (e.g. changing "Mon 11:21" to "Jan 14 11:21" after a week
|
||||||
|
// or so).
|
||||||
|
|
||||||
|
// (But for now it just returns a static node.)
|
||||||
|
exports.render_time = function(time) {
|
||||||
|
// Wrap the text in a span because (oddly) a text node has no outerHTML attribute.
|
||||||
|
return $("<span />").text(time.toString("MMM dd") + "\xa0\xa0" + time.toString("HH:mm"));
|
||||||
|
};
|
||||||
|
|
||||||
|
return exports;
|
||||||
|
}());
|
|
@ -349,8 +349,7 @@ function add_display_time(message, prev) {
|
||||||
|
|
||||||
// NB: timestr is HTML, inserted into the document without escaping.
|
// NB: timestr is HTML, inserted into the document without escaping.
|
||||||
if (include_date) {
|
if (include_date) {
|
||||||
message.timestr = time.toString("MMM dd") + " " +
|
message.timestr = (timerender.render_time(time))[0].outerHTML;
|
||||||
time.toString("HH:mm");
|
|
||||||
} else {
|
} else {
|
||||||
message.timestr = time.toString("HH:mm");
|
message.timestr = time.toString("HH:mm");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue