lib/suricate/generator/assets/javascript/widgets/counter-widget.js in suricate-0.0.2 vs lib/suricate/generator/assets/javascript/widgets/counter-widget.js in suricate-0.0.3
- old
+ new
@@ -6,18 +6,18 @@
Suricate.Widget.call(this, id, container, configuration, application);
};
Suricate.CounterWidget.prototype = new Suricate.Widget();
- /*
- *
- */
-
Suricate.CounterWidget.prototype.setData = function(data) {
- var precision = data.value % 1 === 0 ? 0 : 2;
+ var value = this.formatNumber(data.value);
+ this.view.setPlaceholder('value', value);
+ };
+
+ Suricate.CounterWidget.prototype.formatNumber = function(number) {
+ var precision = number % 1 === 0 ? 0 : 2;
// From http://stackoverflow.com/a/14428340/610531
- var value = data.value.toFixed(precision).replace(/./g, function(c, i, a) {
+ return number.toFixed(precision).replace(/./g, function(c, i, a) {
return i && c !== "." && ((a.length - i) % 3 === 0) ? ',' + c : c;
});
- this.view.setPlaceholder('value', value);
};
}());