From 0abc944c6e56a45f3409fcc9bbfc995220a46e5e Mon Sep 17 00:00:00 2001 From: FrozenCow Date: Wed, 27 Jul 2011 18:51:26 +0200 Subject: [PATCH] Added logo-component. --- src/main/resources/configuration.txt | 4 +++ web/css/dynmap_style.css | 6 +++++ web/js/logo.js | 39 ++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 web/js/logo.js diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index 18cc1ee8..2781a75a 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -61,6 +61,10 @@ components: type: timeofdayclock showdigitalclock: true #showweather: true + #- class: org.dynmap.ClientComponent + # type: logo + # text: "Dynmap" + # linkurl: "http://forums.bukkit.org/threads/dynmap.489/" #- class: org.dynmap.regions.RegionsComponent # type: regions # name: WorldGuard diff --git a/web/css/dynmap_style.css b/web/css/dynmap_style.css index e5e8b58c..02533cfb 100644 --- a/web/css/dynmap_style.css +++ b/web/css/dynmap_style.css @@ -4,6 +4,12 @@ border: 1px solid red; }*/ +/******************* + * Attribution placement + */ +.leaflet-control-attribution { + margin-right: 20px !important; +} /******************* * Page setup diff --git a/web/js/logo.js b/web/js/logo.js new file mode 100644 index 00000000..8ffeb311 --- /dev/null +++ b/web/js/logo.js @@ -0,0 +1,39 @@ +componentconstructors['logo'] = function(dynmap, configuration) { + + var Logo = L.Class.extend({ + onAdd: function(map) { + this._container = L.DomUtil.create('div', 'leaflet-control-attribution'); + this._map = map; + this._update(); + }, + + getPosition: function() { + return L.Control.Position.BOTTOM_RIGHT; + }, + + getContainer: function() { + return this._container; + }, + + _update: function() { + if (!this._map) return; + var c = this._container; + if (configuration.linkurl) { + c = $('').attr('href', configuration.linkurl).appendTo(c)[0]; + } + if (configuration.logourl) { + $(c).append($('').attr('src', configuration.logourl).attr('alt', configuration.text).appendTo(c)[0]); + } else { + $(c).text(configuration.text); + } + } + }); + + dynmap.map.options.attributionControl = false; + if (dynmap.map.attributionControl) { + dynmap.map.removeControl(dynmap.map.attributionControl); + dynmap.map.attributionControl = null; + } + var l = new Logo(); + dynmap.map.addControl(l); +}; \ No newline at end of file