X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/48775da938fcfa29902b1d18fdde80aadc17c249..254aaaf5fb2135a9f3f1b343331b4d5b3d94fe74:/app/assets/javascripts/leaflet.share.js?ds=sidebyside
diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js
index d43bc8ad2..6a4491c2a 100644
--- a/app/assets/javascripts/leaflet.share.js
+++ b/app/assets/javascripts/leaflet.share.js
@@ -13,7 +13,7 @@ L.OSM.share = function (options) {
var button = $('')
.attr('class', 'control-button')
.attr('href', '#')
- .attr('title', 'Share')
+ .attr('title', I18n.t('javascripts.share.title'))
.html('')
.on('click', toggle)
.appendTo($container);
@@ -25,10 +25,9 @@ L.OSM.share = function (options) {
.attr('class', 'sidebar_heading')
.appendTo($ui)
.append(
- $('')
+ $('')
.text(I18n.t('javascripts.close'))
- .attr('class', 'sidebar_close')
- .attr('href', '#')
+ .attr('class', 'icon close')
.bind('click', toggle))
.append(
$('')
@@ -206,8 +205,9 @@ L.OSM.share = function (options) {
.on('change', update)
.addTo(map);
+ marker.on('dragend', movedMarker);
+ map.on('move', movedMap);
map.on('moveend layeradd layerremove', update);
- marker.on('dragend', update);
options.sidebar.addPane($ui);
@@ -216,6 +216,7 @@ L.OSM.share = function (options) {
function hidden() {
map.removeLayer(marker);
+ map.options.scrollWheelZoom = map.options.doubleClickZoom = true;
locationFilter.disable();
update();
}
@@ -235,18 +236,17 @@ L.OSM.share = function (options) {
if ($(this).is(':checked')) {
marker.setLatLng(map.getCenter());
map.addLayer(marker);
+ map.options.scrollWheelZoom = map.options.doubleClickZoom = 'center';
} else {
map.removeLayer(marker);
+ map.options.scrollWheelZoom = map.options.doubleClickZoom = true;
}
update();
}
function toggleFilter() {
if ($(this).is(':checked')) {
- if (!locationFilter.getBounds().isValid()) {
- locationFilter.setBounds(map.getBounds().pad(-0.2));
- }
-
+ locationFilter.setBounds(map.getBounds().pad(-0.2));
locationFilter.enable();
} else {
locationFilter.disable();
@@ -254,11 +254,26 @@ L.OSM.share = function (options) {
update();
}
- function update() {
+ function movedMap() {
+ marker.setLatLng(map.getCenter());
+ update();
+ }
+
+ function movedMarker() {
if (map.hasLayer(marker)) {
+ map.off('move', movedMap);
+ map.on('moveend', updateOnce);
map.panTo(marker.getLatLng());
}
+ }
+ function updateOnce() {
+ map.off('moveend', updateOnce);
+ map.on('move', movedMap);
+ update();
+ }
+
+ function update() {
var bounds = map.getBounds();
$('#link_marker')
@@ -280,14 +295,16 @@ L.OSM.share = function (options) {
};
if (map.hasLayer(marker)) {
- params.marker = marker.getLatLng().lat + ',' + marker.getLatLng().lng;
+ var latLng = marker.getLatLng().wrap();
+ params.marker = latLng.lat + ',' + latLng.lng;
}
$('#embed_html').val(
'
' +
- '' +
+ escapeHTML(I18n.t('javascripts.share.view_larger_map')) + '');
// Image