Cold/Hot classes in Topic Map

This commit is contained in:
Robin Ward 2013-12-13 13:43:20 -05:00
parent 06e9cbc6cb
commit 1bbd1a94bb
2 changed files with 18 additions and 15 deletions

View File

@ -267,30 +267,32 @@ Ember.Handlebars.registerHelper('float', function(property, options) {
@for Handlebars @for Handlebars
**/ **/
Handlebars.registerHelper('number', function(property, options) { Handlebars.registerHelper('number', function(property, options) {
var n, orig, title, result;
orig = parseInt(Ember.Handlebars.get(this, property, options), 10); var orig = parseInt(Ember.Handlebars.get(this, property, options), 10);
if (isNaN(orig)) { if (isNaN(orig)) { orig = 0; }
orig = 0;
} var title = orig;
title = orig;
if (options.hash.numberKey) { if (options.hash.numberKey) {
title = I18n.t(options.hash.numberKey, { title = I18n.t(options.hash.numberKey, { number: orig });
number: orig
});
} }
// Round off the thousands to one decimal place // Round off the thousands to one decimal place
n = orig; var n = orig;
if (orig > 999 && !options.hash.noTitle) { if (orig > 999 && !options.hash.noTitle) {
n = (orig / 1000).toFixed(1) + "K"; n = (orig / 1000).toFixed(1) + "K";
} }
result = "<span class='number'"; var classNames = 'number';
if (options.hash['class']) {
classNames += ' ' + Ember.Handlebars.get(this, options.hash['class'], options);
}
var result = "<span class='" + classNames + "'";
if(n !== title) { if (n !== title) {
result += " title='" + title + "'"; result += " title='" + title + "'";
} }
result += ">" + n + "</span>"; result += ">" + n + "</span>";
return new Handlebars.SafeString(result); return new Handlebars.SafeString(result);
}); });
@ -310,6 +312,7 @@ Handlebars.registerHelper('date', function(property, options) {
property = property.hash.path; property = property.hash.path;
} }
} }
var val = Ember.Handlebars.get(this, property, options); var val = Ember.Handlebars.get(this, property, options);
if (val) { if (val) {
var date = new Date(val); var date = new Date(val);

View File

@ -7,7 +7,7 @@
<section {{bindAttr class=":map mapCollapsed"}}> <section {{bindAttr class=":map mapCollapsed"}}>
<ul class="clearfix"> <ul class="clearfix">
<li> <li>
<a href='{{unbound topic.url}}'> <a href='{{unbound topic.url}}' {{bindAttr class=topic.ageCold}}>
<h4>{{i18n created}}</h4> <h4>{{i18n created}}</h4>
{{avatar details.created_by imageSize="tiny"}} {{avatar details.created_by imageSize="tiny"}}
{{date topic.created_at}} {{date topic.created_at}}
@ -26,7 +26,7 @@
</li> </li>
<li class='secondary'> <li class='secondary'>
<h4>{{i18n views}}</h4> <h4>{{i18n views}}</h4>
{{number topic.views}} {{number topic.views class=topic.viewsHeat}}
</li> </li>
<li class='secondary'> <li class='secondary'>
<h4>{{i18n users}}</h4> <h4>{{i18n users}}</h4>