From 1bbd1a94bb248ef50d4e1463b08a1b67246e3fb7 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 13 Dec 2013 13:43:20 -0500 Subject: [PATCH] Cold/Hot classes in Topic Map --- .../discourse/helpers/application_helpers.js | 29 ++++++++++--------- .../components/topic-map.js.handlebars | 4 +-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/discourse/helpers/application_helpers.js b/app/assets/javascripts/discourse/helpers/application_helpers.js index 132fbbff305..adbd09d7908 100644 --- a/app/assets/javascripts/discourse/helpers/application_helpers.js +++ b/app/assets/javascripts/discourse/helpers/application_helpers.js @@ -267,30 +267,32 @@ Ember.Handlebars.registerHelper('float', function(property, options) { @for Handlebars **/ Handlebars.registerHelper('number', function(property, options) { - var n, orig, title, result; - orig = parseInt(Ember.Handlebars.get(this, property, options), 10); - if (isNaN(orig)) { - orig = 0; - } - title = orig; + + var orig = parseInt(Ember.Handlebars.get(this, property, options), 10); + if (isNaN(orig)) { orig = 0; } + + var title = orig; if (options.hash.numberKey) { - title = I18n.t(options.hash.numberKey, { - number: orig - }); + title = I18n.t(options.hash.numberKey, { number: orig }); } + // Round off the thousands to one decimal place - n = orig; + var n = orig; if (orig > 999 && !options.hash.noTitle) { n = (orig / 1000).toFixed(1) + "K"; } - result = ""; + return new Handlebars.SafeString(result); }); @@ -310,6 +312,7 @@ Handlebars.registerHelper('date', function(property, options) { property = property.hash.path; } } + var val = Ember.Handlebars.get(this, property, options); if (val) { var date = new Date(val); diff --git a/app/assets/javascripts/discourse/templates/components/topic-map.js.handlebars b/app/assets/javascripts/discourse/templates/components/topic-map.js.handlebars index 634307d113b..d9a415ef146 100644 --- a/app/assets/javascripts/discourse/templates/components/topic-map.js.handlebars +++ b/app/assets/javascripts/discourse/templates/components/topic-map.js.handlebars @@ -7,7 +7,7 @@