Mercurial > pub > ImplabJs
diff src/djol/LayerCheckBox.js @ 8:f0035923ff3e
добавлена библиотека для работы с openlayers 3+
author | cin |
---|---|
date | Mon, 21 Aug 2017 17:47:00 +0300 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/djol/LayerCheckBox.js Mon Aug 21 17:47:00 2017 +0300 @@ -0,0 +1,49 @@ +define([ + "dojo/_base/declare", + "dijit/_WidgetBase", + "dijit/_TemplatedMixin", + "dijit/_WidgetsInTemplateMixin", + "dojo/text!./resources/LayerCheckBoxTemplate.html", + "dijit/form/CheckBox" ], function(declare, _WidgetBase, _TemplatedMixin, + _WidgetsInTemplateMixin, templateString) { + return declare([ _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin ], { + templateString : templateString, + labelNode : null, + checkBox : null, + + label : "", + _setLabelAttr : { + node : "labelNode", + type : "innerHTML" + }, + + name : "layer", + + _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.checkBox.set('name', me.name); + me.checkBox.set('value', me._layer.getVisible()); + this.checkBox.on("change", function(value) { + me._changed(value); + }); + }, + + _changed : function(visible) { + this._layer.setVisible(visible); + } + }); +}); \ No newline at end of file