if the title is the same as the value for a number, do not display it

This commit is contained in:
Sam 2013-06-27 16:29:31 +10:00
parent 5d1f5505af
commit 274d8cbc0b
1 changed files with 11 additions and 3 deletions

View File

@ -257,7 +257,7 @@ Ember.Handlebars.registerHelper('float', function(property, options) {
@for Handlebars
**/
Handlebars.registerHelper('number', function(property, options) {
var n, orig, title;
var n, orig, title, result;
orig = parseInt(Ember.Handlebars.get(this, property, options), 10);
if (isNaN(orig)) {
orig = 0;
@ -270,10 +270,18 @@ Handlebars.registerHelper('number', function(property, options) {
}
// Round off the thousands to one decimal place
n = orig;
if (orig > 999) {
if (orig > 999 && !options.hash.noTitle) {
n = (orig / 1000).toFixed(1) + "K";
}
return new Handlebars.SafeString("<span class='number' title='" + title + "'>" + n + "</span>");
result = "<span class='number'";
if(n != title) {
result += " title='" + title + "'";
}
result += ">" + n + "</span>";
return new Handlebars.SafeString(result);
});
/**