view src/djol/LayerRadioButton.js @ 25:c2a7d21175ce

Added css injection plugin, implab/dom/css!<css-path>
author cin
date Fri, 08 Dec 2017 04:31:43 +0300
parents f0035923ff3e
children
line wrap: on
line source

define([
    "dojo/_base/declare",
    "dijit/_WidgetBase",
    "dijit/_TemplatedMixin",
    "dijit/_WidgetsInTemplateMixin",
    "dojo/text!./resources/LayerRadioButtonTemplate.html",
    "dijit/form/RadioButton" ], function(declare, _WidgetBase, _TemplatedMixin,
    _WidgetsInTemplateMixin, templateString) {
    return declare([ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], {
        templateString : templateString,

        labelNode : null,
        radioButton : null,

        label : "",
        _setLabelAttr : {
            node : "labelNode",
            type : "innerHTML"
        },

        name : "layers",

        _layer : null,

        constructor : function(options) {
            options = options || {};

            if (!options.layer)
                throw new Error("The layer is required");

            this._layer = options.layer;
            this.label = options.layer.get("label") || "unnamed";
        },

        postCreate : function() {
            var me = this;
            me.inherited(arguments);

            me.radioButton.set('name', me.name);
            me.radioButton.set('value', me._layer.getVisible());
            this.radioButton.on("change", function(value) {
                me._changed(value);
            });
        },

        _changed : function(visible) {
            this._layer.setVisible(visible);
        }
    });
});