comparison src/djol/LayerCheckBox.js @ 34:27e8e9e38e07 default tip

Слияние
author nickolay
date Wed, 05 Jun 2019 20:44:15 +0300
parents 8af8e840dd49 1dc2fd263b90
children
comparison
equal deleted inserted replaced
33:8af8e840dd49 34:27e8e9e38e07
1 define([
2 "dojo/_base/declare",
3 "dijit/_WidgetBase",
4 "dijit/_TemplatedMixin",
5 "dijit/_WidgetsInTemplateMixin",
6 "dojo/text!./resources/LayerCheckBoxTemplate.html",
7 "dijit/form/CheckBox" ], function(declare, _WidgetBase, _TemplatedMixin,
8 _WidgetsInTemplateMixin, templateString) {
9 return declare([ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], {
10 templateString : templateString,
11 labelNode : null,
12 checkBox : null,
13
14 label : "",
15 _setLabelAttr : {
16 node : "labelNode",
17 type : "innerHTML"
18 },
19
20 name : "layer",
21
22 _layer : null,
23
24 constructor : function(options) {
25 options = options || {};
26
27 if (!options.layer)
28 throw new Error("The layer is required");
29
30 this._layer = options.layer;
31 this.label = options.layer.get("label") || "unnamed";
32 },
33
34 postCreate : function() {
35 var me = this;
36 me.inherited(arguments);
37
38 me.checkBox.set('name', me.name);
39 me.checkBox.set('value', me._layer.getVisible());
40 this.checkBox.on("change", function(value) {
41 me._changed(value);
42 });
43 },
44
45 _changed : function(visible) {
46 this._layer.setVisible(visible);
47 }
48 });
49 });