X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/a89d75d3d8824c2a4c2c3567083afc986c3b18a6..778659a78cdbdbf03014943b9ce85b990daa8cb1:/app/assets/javascripts/leaflet.share.js diff --git a/app/assets/javascripts/leaflet.share.js b/app/assets/javascripts/leaflet.share.js index 441acfd74..a6b10821e 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( $('

') @@ -121,6 +120,21 @@ L.OSM.share = function (options) { .text(I18n.t('javascripts.share.paste_html')) .appendTo($linkSection)); + // Geo URI + + var $geoUriSection = $('
') + .attr('class', 'section share-geo-uri') + .appendTo($ui); + + $('

') + .text(I18n.t('javascripts.share.geo_uri')) + .appendTo($geoUriSection); + + $('
') + .appendTo($geoUriSection) + .append($('') + .attr('id', 'geo_uri')); + // Image var $imageSection = $('
') @@ -131,7 +145,14 @@ L.OSM.share = function (options) { .text(I18n.t('javascripts.share.image')) .appendTo($imageSection); + $('
') + .attr('id', 'export-warning') + .attr('class', 'deemphasize') + .text(I18n.t('javascripts.share.only_standard_layer')) + .appendTo($imageSection); + $form = $('
') + .attr('id', 'export-image') .attr('class', 'standard-form') .attr('action', '/export/finish') .attr('method', 'post') @@ -231,6 +252,7 @@ L.OSM.share = function (options) { update(); options.sidebar.togglePane($ui, button); + $('.leaflet-control .control-button').tooltip('hide'); } function toggleMarker() { @@ -274,6 +296,19 @@ L.OSM.share = function (options) { update(); } + function escapeHTML(string) { + var htmlEscapes = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) { + return htmlEscapes[match]; + }); + } + function update() { var bounds = map.getBounds(); @@ -296,14 +331,22 @@ 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')) + ''); + + // Geo URI + + $('#geo_uri') + .attr('href', map.getGeoUri(marker)) + .html(map.getGeoUri(marker)); // Image @@ -328,6 +371,14 @@ L.OSM.share = function (options) { $("#mapnik_image_width").text(Math.round(size.x / scale / 0.00028)); $("#mapnik_image_height").text(Math.round(size.y / scale / 0.00028)); + + if (map.getMapBaseLayerId() === 'mapnik') { + $('#export-image').show(); + $('#export-warning').hide(); + } else { + $('#export-image').hide(); + $('#export-warning').show(); + } } function select() {