Sha256: 126ffc100d50f502361f123a89f2624e5fb0f04a87b56b0227487ec621030159

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

(function() {
    "use strict";
    window.Suricate = window.Suricate || {};

    Suricate.CounterWidget = function(id, container, configuration, application) {
        Suricate.Widget.call(this, id, container, configuration, application);
    };

    Suricate.CounterWidget.prototype = new Suricate.Widget();

    Suricate.CounterWidget.prototype.setData = function(data) {
        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
        return number.toFixed(precision).replace(/./g, function(c, i, a) {
            return i && c !== "." && ((a.length - i) % 3 === 0) ? ',' + c : c;
        });
    };
}());

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
suricate-0.0.4 lib/suricate/generator/assets/javascript/widgets/counter-widget.js
suricate-0.0.3 lib/suricate/generator/assets/javascript/widgets/counter-widget.js