From 82318346c20b11c5b9e74fc7538e9f76f4591a0e Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sat, 3 Dec 2011 04:31:05 +0800 Subject: [PATCH] Add 'hidey' option to 'coord' component - option to show just X,Z --- src/main/resources/configuration.txt | 1 + web/css/dynmap_style.css | 4 ++++ web/js/coord.js | 15 ++++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index 799126b7..f4988cdf 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -101,6 +101,7 @@ components: - class: org.dynmap.ClientComponent type: coord label: "Location" + hidey: false #- class: org.dynmap.ClientComponent # type: logo diff --git a/web/css/dynmap_style.css b/web/css/dynmap_style.css index 3713bfb4..98e7382c 100644 --- a/web/css/dynmap_style.css +++ b/web/css/dynmap_style.css @@ -877,6 +877,10 @@ border-radius: 5px; } +.dynmap .coord-control-noy { + width: 60px; +} + .dynmap .coord-control .coord-control-label { } diff --git a/web/js/coord.js b/web/js/coord.js index 7441be9f..a329f85d 100644 --- a/web/js/coord.js +++ b/web/js/coord.js @@ -4,7 +4,10 @@ componentconstructors['coord'] = function(dynmap, configuration) { valfield: $(''), onAdd: function(map) { - this._container = L.DomUtil.create('div', 'coord-control'); + if(configuration.hidey) + this._container = L.DomUtil.create('div', 'coord-control coord-control-noy'); + else + this._container = L.DomUtil.create('div', 'coord-control'); this._map = map; $('').addClass('coord-control-label').text((configuration.label || 'x,y,z') + ': ').appendTo(this._container); $('
').appendTo(this._container); @@ -31,10 +34,16 @@ componentconstructors['coord'] = function(dynmap, configuration) { dynmap.map.on('mousemove', function(mevent) { if(!dynmap.map) return; var loc = dynmap.getProjection().fromLatLngToLocation(mevent.latlng, 64); - coord.valfield.text(Math.round(loc.x) + ',' + loc.y + ',' + Math.round(loc.z)); + if(configuration.hidey) + coord.valfield.text(Math.round(loc.x) + ',' + Math.round(loc.z)); + else + coord.valfield.text(Math.round(loc.x) + ',' + loc.y + ',' + Math.round(loc.z)); }); dynmap.map.on('mouseout', function(mevent) { if(!dynmap.map) return; - coord.valfield.text('---,---,---'); + if(configuration.hidey) + coord.valfield.text('---,---'); + else + coord.valfield.text('---,---,---'); }); }; \ No newline at end of file