1 //= require templates/map/share
3 L.Control.Share = L.Control.extend({
12 onAdd: function (map) {
13 var className = 'leaflet-control-locate',
14 classNames = className + ' leaflet-control-zoom leaflet-bar leaflet-control',
15 container = L.DomUtil.create('div', classNames);
17 var link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single', container);
19 link.title = this.options.title;
21 this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container);
24 .on(this._uiPane, 'click', L.DomEvent.stopPropagation)
25 .on(this._uiPane, 'click', L.DomEvent.preventDefault)
26 .on(this._uiPane, 'dblclick', L.DomEvent.preventDefault);
28 var h2 = L.DomUtil.create('h2', '', this._uiPane);
29 h2.innerHTML = I18n.t('javascripts.share.title');
31 this._linkInput = L.DomUtil.create('input', '', this._uiPane);
34 .on(link, 'click', L.DomEvent.stopPropagation)
35 .on(link, 'click', L.DomEvent.preventDefault)
36 .on(link, 'click', this._toggle, this)
37 .on(link, 'dblclick', L.DomEvent.stopPropagation);
39 map.on('moveend layeradd layerremove', this._update, this);
44 _update: function (e) {
45 var center = map.getCenter().wrap();
46 var layers = getMapLayers();
47 this._linkInput.value = this.options.getUrl(map);
51 var controlContainer = $('.leaflet-control-container .leaflet-top.leaflet-right');
53 if ($(this._uiPane).is(':visible')) {
54 $(this._uiPane).hide();
55 controlContainer.css({paddingRight: '0'});
57 $(this._uiPane).show();
58 controlContainer.css({paddingRight: '200px'});
63 L.control.share = function(options) {
64 return new L.Control.Share(options);