mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 02:55:28 +08:00
Fix title attributes on post info
This commit is contained in:
parent
a0031f2a0d
commit
6b58713fa6
@ -43,13 +43,17 @@ Discourse.Formatter = (function(){
|
||||
var append = "";
|
||||
|
||||
if(format === 'medium') {
|
||||
append = " date' title='" + longDate(date);
|
||||
append = " date";
|
||||
if(options.leaveAgo) {
|
||||
format = 'medium-with-ago';
|
||||
}
|
||||
options.wrapInSpan = false;
|
||||
}
|
||||
|
||||
if (options.title) {
|
||||
append += "' title='" + longDate(date);
|
||||
}
|
||||
|
||||
return "<span class='relative-date" + append + "' data-time='" + date.getTime() + "' data-format='" + format + "'>" + relativeAge(date, options) + "</span>";
|
||||
};
|
||||
|
||||
|
@ -203,6 +203,17 @@ Handlebars.registerHelper('unboundAge', function(property, options) {
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(dt));
|
||||
});
|
||||
|
||||
/**
|
||||
Live refreshing age helper, with a tooltip showing the date and time
|
||||
|
||||
@method unboundAgeWithTooltip
|
||||
@for Handlebars
|
||||
**/
|
||||
Handlebars.registerHelper('unboundAgeWithTooltip', function(property, options) {
|
||||
var dt = new Date(Ember.Handlebars.get(this, property, options));
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(dt, {title: true}));
|
||||
});
|
||||
|
||||
/**
|
||||
Display a date related to an edit of a post
|
||||
|
||||
@ -212,7 +223,7 @@ Handlebars.registerHelper('unboundAge', function(property, options) {
|
||||
Handlebars.registerHelper('editDate', function(property, options) {
|
||||
// autoupdating this is going to be painful
|
||||
var date = new Date(Ember.Handlebars.get(this, property, options));
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: 'medium', leaveAgo: true, wrapInSpan: false}));
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: 'medium', title: true, leaveAgo: true, wrapInSpan: false}));
|
||||
});
|
||||
|
||||
/**
|
||||
@ -284,7 +295,7 @@ Handlebars.registerHelper('date', function(property, options) {
|
||||
var val = Ember.Handlebars.get(this, property, options);
|
||||
if (val) {
|
||||
var date = new Date(val);
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: 'medium', leaveAgo: leaveAgo}));
|
||||
return new Handlebars.SafeString(Discourse.Formatter.autoUpdatingRelativeAge(date, {format: 'medium', title: true, leaveAgo: leaveAgo}));
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -39,14 +39,14 @@
|
||||
<div class='topic-meta-data-inside'>
|
||||
{{#if hasHistory}}
|
||||
<div class='post-info edits'>
|
||||
<a href='#' class="{{unbound historyHeat}}" {{action showHistory this}} title="{{editDate updated_at}}">
|
||||
<a href='#' class="{{unbound historyHeat}}" {{action showHistory this}} title="{{unboundDate updated_at}}">
|
||||
{{editCount}}
|
||||
<i class='icon-pencil'></i>
|
||||
</a>
|
||||
</div>
|
||||
{{/if}}
|
||||
<div class='post-info'>
|
||||
<a href='#' class='post-date' {{bindAttr data-share-url="shareUrl"}}>{{unboundAge created_at}}</a>
|
||||
<a href='#' class='post-date' {{bindAttr data-share-url="shareUrl"}}>{{unboundAgeWithTooltip created_at}}</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/unless}}
|
||||
|
@ -86,8 +86,12 @@ test("autoUpdatingRelativeAge", function() {
|
||||
var $elem = $(Discourse.Formatter.autoUpdatingRelativeAge(d));
|
||||
equal($elem.data('format'), "tiny");
|
||||
equal($elem.data('time'), d.getTime());
|
||||
equal($elem.attr('title'), undefined);
|
||||
|
||||
$elem = $(Discourse.Formatter.autoUpdatingRelativeAge(d,{format: 'medium', leaveAgo: true}));
|
||||
$elem = $(Discourse.Formatter.autoUpdatingRelativeAge(d, {title: true}));
|
||||
equal($elem.attr('title'), moment(d).longDate());
|
||||
|
||||
$elem = $(Discourse.Formatter.autoUpdatingRelativeAge(d,{format: 'medium', title: true, leaveAgo: true}));
|
||||
equal($elem.data('format'), "medium-with-ago");
|
||||
equal($elem.data('time'), d.getTime());
|
||||
equal($elem.attr('title'), moment(d).longDate());
|
||||
@ -96,6 +100,7 @@ test("autoUpdatingRelativeAge", function() {
|
||||
$elem = $(Discourse.Formatter.autoUpdatingRelativeAge(d,{format: 'medium'}));
|
||||
equal($elem.data('format'), "medium");
|
||||
equal($elem.data('time'), d.getTime());
|
||||
equal($elem.attr('title'), undefined);
|
||||
equal($elem.html(), '1 day');
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user