=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js 2011-04-06 11:44:07 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/global.js 2011-04-06 13:34:20 +0000 @@ -160,18 +160,19 @@ }, labels: { - getActivatedOpenLayersStyleMap: function(fsize, fweight, fstyle) { + getActivatedOpenLayersStyleMap: function(fsize, fweight, fstyle, fcolor) { return new OpenLayers.StyleMap({ 'default' : new OpenLayers.Style( OpenLayers.Util.applyDefaults({ 'fillOpacity': 1, - 'strokeColor': '#222222', 'strokeWidth': 1, + 'strokeColor': '#222222', 'label': '${labelString}', 'fontFamily': 'arial,lucida sans unicode', 'fontSize': fsize ? fsize : 13, 'fontWeight': fweight ? 'bold' : 'normal', - 'fontStyle': fstyle ? 'italic' : 'normal' + 'fontStyle': fstyle ? 'italic' : 'normal', + 'fontColor': fcolor ? fcolor : '#000000' }, OpenLayers.Feature.Vector.style['default']) ), @@ -199,9 +200,9 @@ }) }); }, - toggleFeatureLabels: function(widget, fsize, fweight, fstyle) { + toggleFeatureLabels: function(widget, fsize, fweight, fstyle, fcolor) { function activateLabels() { - widget.layer.styleMap = this.getActivatedOpenLayersStyleMap(fsize, fweight, fstyle); + widget.layer.styleMap = this.getActivatedOpenLayersStyleMap(fsize, fweight, fstyle, fcolor); widget.labels = true; } function deactivateLabels(scope) { === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js 2011-04-06 12:01:31 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/javascript/index.js 2011-04-06 13:34:20 +0000 @@ -2124,106 +2124,129 @@ }, showLabelWindow: function(item) { - if (item.labelWindow) { - item.labelWindow.show(); + var layer = G.vars.map.getLayersByName(item.parentMenu.contextNode.attributes.layer)[0]; + if (layer.features.length) { + if (item.labelWindow) { + item.labelWindow.show(); + } + else { + item.labelWindow = new Ext.Window({ + title: 'Labels', + layout: 'fit', + closeAction: 'hide', + width: G.conf.window_width, + height: 200, + items: [ + { + xtype: 'form', + bodyStyle: 'padding:8px', + labelWidth: G.conf.label_width, + items: [ + {html: '
Show/hide feature labels
'}, + { + xtype: 'numberfield', + id: 'labelfontsize_nf', + fieldLabel: 'Font size', + labelSeparator: G.conf.labelseparator, + width: G.conf.combo_number_width_small, + enableKeyEvents: true, + allowDecimals: false, + allowNegative: false, + value: 13, + emptyText: 13, + listeners: { + 'keyup': function(nf) { + if (layer.widget.labels) { + layer.widget.labels = false; + G.util.labels.toggleFeatureLabels(layer.widget, nf.getValue(), Ext.getCmp('labelstrong_chb').getValue(), + Ext.getCmp('labelitalic_chb').getValue(), Ext.getCmp('labelcolor_cf').getValue()); + } + } + } + }, + { + xtype: 'checkbox', + id: 'labelstrong_chb', + fieldLabel: 'Bold', + labelSeparator: G.conf.labelseparator, + listeners: { + 'check': function(chb, checked) { + if (layer.widget.labels) { + layer.widget.labels = false; + G.util.labels.toggleFeatureLabels(layer.widget, Ext.getCmp('labelfontsize_nf').getValue(), + checked, Ext.getCmp('labelitalic_chb').getValue(), Ext.getCmp('labelcolor_cf').getValue()); + } + } + } + }, + { + xtype: 'checkbox', + id: 'labelitalic_chb', + fieldLabel: 'Italic', + labelSeparator: G.conf.labelseparator, + listeners: { + 'check': function(chb, checked) { + if (layer.widget.labels) { + layer.widget.labels = false; + G.util.labels.toggleFeatureLabels(layer.widget, Ext.getCmp('labelfontsize_nf').getValue(), + Ext.getCmp('labelstrong_chb').getValue(), checked, Ext.getCmp('labelcolor_cf').getValue()); + } + } + } + }, + { + xtype: 'colorfield', + id: 'labelcolor_cf', + fieldLabel: G.i18n.color, + labelSeparator: G.conf.labelseparator, + allowBlank: false, + width: G.conf.combo_width_fieldset, + value: "#000000", + listeners: { + 'select': { + scope: this, + fn: function(cf) { + if (layer.widget.labels) { + layer.widget.labels = false; + G.util.labels.toggleFeatureLabels(layer.widget, Ext.getCmp('labelfontsize_nf').getValue(), + Ext.getCmp('labelstrong_chb').getValue(), Ext.getCmp('labelitalic_chb').getValue(), cf.getValue()); + } + } + } + } + } + ] + } + ], + bbar: [ + '->', + { + xtype: 'button', + id: 'labelshow_b', + iconCls: 'icon-assign', + hideLabel: true, + text: G.i18n.toggle, + handler: function() { + var layer = G.vars.map.getLayersByName(item.parentMenu.contextNode.attributes.layer)[0]; + if (layer.features.length) { + G.util.labels.toggleFeatureLabels(layer.widget, Ext.getCmp('labelfontsize_nf').getValue(), + Ext.getCmp('labelstrong_chb').getValue(), Ext.getCmp('labelitalic_chb').getValue(), Ext.getCmp('labelcolor_cf').getValue()); + } + else { + Ext.message.msg(false, '' + layer.name + ': No features rendered'); + } + } + } + ] + }); + + item.labelWindow.setPagePosition(Ext.getCmp('east').x - (G.conf.window_width + 15 + 5), Ext.getCmp('center').y + 41); + item.labelWindow.show(); + } } else { - var labelWindow = new Ext.Window({ - title: 'Labels', - layout: 'fit', - closeAction: 'hide', - width: G.conf.window_width, - height: 170, - items: [ - { - xtype: 'form', - bodyStyle: 'padding:8px', - labelWidth: G.conf.label_width, - items: [ - {html: '
Show/hide feature labels
'}, - { - xtype: 'numberfield', - id: 'labelfontsize_nf', - fieldLabel: 'Font size', - labelSeparator: G.conf.labelseparator, - width: G.conf.combo_number_width_small, - enableKeyEvents: true, - allowDecimals: false, - allowNegative: false, - value: 13, - emptyText: 13, - listeners: { - 'keyup': function(nf) { - var layer = G.vars.map.getLayersByName(item.parentMenu.contextNode.attributes.layer)[0]; - if (layer.widget.labels) { - layer.widget.labels = false; - G.util.labels.toggleFeatureLabels(layer.widget, nf.getValue(), - Ext.getCmp('labelstrong_chb').getValue(), Ext.getCmp('labelitalic_chb').getValue()); - } - } - } - }, - { - xtype: 'checkbox', - id: 'labelstrong_chb', - fieldLabel: 'Bold', - labelSeparator: G.conf.labelseparator, - listeners: { - 'check': function(chb, checked) { - var layer = G.vars.map.getLayersByName(item.parentMenu.contextNode.attributes.layer)[0]; - if (layer.widget.labels) { - layer.widget.labels = false; - G.util.labels.toggleFeatureLabels(layer.widget, Ext.getCmp('labelfontsize_nf').getValue(), - checked, Ext.getCmp('labelitalic_chb').getValue()); - } - } - } - }, - { - xtype: 'checkbox', - id: 'labelitalic_chb', - fieldLabel: 'Italic', - labelSeparator: G.conf.labelseparator, - listeners: { - 'check': function(chb, checked) { - var layer = G.vars.map.getLayersByName(item.parentMenu.contextNode.attributes.layer)[0]; - if (layer.widget.labels) { - layer.widget.labels = false; - G.util.labels.toggleFeatureLabels(layer.widget, Ext.getCmp('labelfontsize_nf').getValue(), - Ext.getCmp('labelstrong_chb').getValue(), checked); - } - } - } - } - ] - } - ], - bbar: [ - '->', - { - xtype: 'button', - id: 'labelshow_b', - iconCls: 'icon-assign', - hideLabel: true, - text: G.i18n.toggle, - handler: function() { - var layer = G.vars.map.getLayersByName(item.parentMenu.contextNode.attributes.layer)[0]; - if (layer.features.length) { - G.util.labels.toggleFeatureLabels(layer.widget, Ext.getCmp('labelfontsize_nf').getValue(), - Ext.getCmp('labelstrong_chb').getValue(), Ext.getCmp('labelitalic_chb').getValue()); - } - else { - Ext.message.msg(false, '' + layer.name + ': No features rendered'); - } - } - } - ] - }); - - item.labelWindow = labelWindow; - item.labelWindow.setPagePosition(Ext.getCmp('east').x - (G.conf.window_width + 15 + 5), Ext.getCmp('center').y + 41); - item.labelWindow.show(); - } + Ext.message.msg(false, '' + layer.name + ': No features rendered'); + } }, items: [ {