Sha256: eb27b4db0f727262d6b98f0a4890edbaa9f821641b24112567dd162bcf296522

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

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

    Suricate.WidgetView = function(content) {
        this.content = $(content);
    };

    /*
     * Public
     */

    Suricate.WidgetView.prototype.getBody = function() {
        return this.content.find(".body");
    };

    Suricate.WidgetView.prototype.appendTo = function(container) {
        container.append(this.content);
    };

    Suricate.WidgetView.prototype.setLastUpdateAt = function(time) {
        this.setPlaceholder("last-update-at", time.toLocaleTimeString());
    };

    Suricate.WidgetView.prototype.setName = function(name) {
        this.setPlaceholder("name", name);
    };

    Suricate.WidgetView.prototype.setPlaceholders = function(placeholders) {
        for(var name in placeholders) {
            var value = placeholders[name];
            this.setPlaceholder(name, value);
        }
    };

    Suricate.WidgetView.prototype.setPlaceholder = function(name, value) {
        this.getPlaceholder(name).html(value);
    };

    /*
     * Private
     */
    Suricate.WidgetView.prototype.getPlaceholder = function(name) {
        return this.content.find("[data-widget-binding='" + name + "']");
    };
}());

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
suricate-0.0.2 lib/suricate/generator/assets/javascript/widget-view.js