| 26 | | this.panel = new Ext.Panel(config); |
|---|
| 27 | | var layerRecord = config.layerRecord; |
|---|
| | 34 | // create panel to be adapted as menu item |
|---|
| | 35 | var panel = new Ext.Panel(Ext.applyIf(config.panelConfig || {}, { |
|---|
| | 36 | layout: "column", |
|---|
| | 37 | cls: "gx-layer-menu-item", |
|---|
| | 38 | defautls: { |
|---|
| | 39 | border: false |
|---|
| | 40 | }, |
|---|
| | 41 | items: [{ |
|---|
| | 42 | xtype: record.get("background") ? "radio" : "checkbox", |
|---|
| | 43 | checked: layer.getVisibility(), |
|---|
| | 44 | handler: function(el, checked) { |
|---|
| | 45 | layer.setVisibility(checked); |
|---|
| | 46 | } |
|---|
| | 47 | }, { |
|---|
| | 48 | html: record.get("title") |
|---|
| | 49 | }] |
|---|
| | 50 | })); |
|---|
| 29 | | //var queryRadio = null; |
|---|
| 30 | | //if (layerRecord.get("queryable")){ |
|---|
| 31 | | // queryRadio = new Ext.form.Radio({checked: false, name: 'query'}); |
|---|
| 32 | | //} else { |
|---|
| 33 | | // queryRadio = new Ext.Panel(); |
|---|
| 34 | | //} |
|---|
| 35 | | |
|---|
| 36 | | var visibilityField = null; |
|---|
| 37 | | |
|---|
| 38 | | if (layerRecord.get("background")) { |
|---|
| 39 | | visibilityField = new Ext.form.Radio({ |
|---|
| 40 | | checked: layerRecord.get("layer").getVisibility(), |
|---|
| 41 | | handler: function(radio, checked) { |
|---|
| 42 | | layerRecord.get('layer').setVisibility(checked); |
|---|
| 43 | | } |
|---|
| 44 | | }); |
|---|
| 45 | | //need to adjust the checkboxes according to layer visiblity |
|---|
| 46 | | } else { |
|---|
| 47 | | visibilityField = new Ext.form.Checkbox({ |
|---|
| 48 | | checked: layerRecord.get("layer").getVisibility(), |
|---|
| 49 | | handler: function (checkbox, checked) { |
|---|
| 50 | | layerRecord.get("layer").setVisibility(checked); |
|---|
| 51 | | } |
|---|
| 52 | | }); |
|---|
| 53 | | } |
|---|
| 54 | | |
|---|
| 55 | | this.panel.add(visibilityField); |
|---|
| 56 | | //this.panel.add(queryRadio); |
|---|
| 57 | | this.panel.add({html: layerRecord.get("title"), border: false}); |
|---|
| 58 | | this.panel.addClass("gx-layer-menu-item"); |
|---|
| 59 | | |
|---|
| 60 | | this.panel.on("render", function(panel){ |
|---|
| 61 | | panel.getEl().swallowEvent("click"); |
|---|
| | 52 | delete config.panelConfig; |
|---|
| | 53 | |
|---|
| | 54 | // set default config for menu item |
|---|
| | 55 | Ext.applyIf(config, { |
|---|
| | 56 | handler: function(item) { |
|---|
| | 57 | layer.setVisibility(!layer.getVisibility()); |
|---|
| | 58 | panel.getEl().swallowEvent("click"); |
|---|
| | 59 | } |
|---|