2012-01-06 10:09:53 +01:00
|
|
|
componentconstructors['link'] = function(dynmap, configuration) {
|
|
|
|
|
|
|
|
var dynmapLink = L.Class.extend({
|
2012-01-08 18:40:40 +01:00
|
|
|
options: { position: L.Control.Position.BOTTOM_LEFT },
|
2012-01-06 10:09:53 +01:00
|
|
|
|
|
|
|
onAdd: function(map) {
|
|
|
|
this._map = map;
|
|
|
|
this._container = L.DomUtil.create('div', 'dynmap-link');
|
|
|
|
|
|
|
|
this._linkButton = this._createButton(
|
|
|
|
'Link', 'dynmap-link-button', this._follow, this);
|
|
|
|
|
|
|
|
this._container.appendChild(this._linkButton);
|
|
|
|
},
|
|
|
|
|
|
|
|
getContainer: function() {
|
|
|
|
return this._container;
|
|
|
|
},
|
|
|
|
|
|
|
|
getPosition: function() {
|
|
|
|
return this.options.position;
|
|
|
|
},
|
|
|
|
|
|
|
|
_createButton: function(title, className, fn, context) {
|
|
|
|
var link = document.createElement('a');
|
|
|
|
link.href = '#';
|
|
|
|
link.title = title;
|
|
|
|
link.className = className;
|
|
|
|
link.onmouseover = function() {
|
|
|
|
link.href = dynmap.getLink();
|
|
|
|
};
|
|
|
|
|
|
|
|
L.DomEvent.disableClickPropagation(link);
|
|
|
|
L.DomEvent.addListener(link, 'click', L.DomEvent.preventDefault);
|
|
|
|
L.DomEvent.addListener(link, 'click', fn, context);
|
|
|
|
|
|
|
|
return link;
|
|
|
|
},
|
|
|
|
|
|
|
|
_follow: function() {
|
|
|
|
var url = dynmap.getLink();
|
|
|
|
window.location = url;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var link = new dynmapLink();
|
|
|
|
dynmap.map.addControl(link);
|
|
|
|
};
|