]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/leaflet.share.js
Remove inline property of secondary links on diary page
[rails.git] / app / assets / javascripts / leaflet.share.js
index 6a4491c2a7e57fcbf6158603bf8779dfd8990f70..b991210dfad5a063fcc48d76181c0deb5e72a2c6 100644 (file)
@@ -120,6 +120,21 @@ L.OSM.share = function (options) {
           .text(I18n.t('javascripts.share.paste_html'))
           .appendTo($linkSection));
 
+    // Geo URI
+
+    var $geoUriSection = $('<div>')
+      .attr('class', 'section share-geo-uri')
+      .appendTo($ui);
+
+    $('<h4>')
+      .text(I18n.t('javascripts.share.geo_uri'))
+      .appendTo($geoUriSection);
+
+    $('<div>')
+      .appendTo($geoUriSection)
+      .append($('<a>')
+        .attr('id', 'geo_uri'));
+
     // Image
 
     var $imageSection = $('<div>')
@@ -230,6 +245,7 @@ L.OSM.share = function (options) {
 
       update();
       options.sidebar.togglePane($ui, button);
+      $('.leaflet-control .control-button').tooltip('hide');
     }
 
     function toggleMarker() {
@@ -273,6 +289,19 @@ L.OSM.share = function (options) {
       update();
     }
 
+    function escapeHTML(string) {
+      var htmlEscapes = {
+        '&': '&amp;',
+        '<': '&lt;',
+        '>': '&gt;',
+        '"': '&quot;',
+        "'": '&#x27;'
+      };
+      return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
+        return htmlEscapes[match];
+      });
+    }
+
     function update() {
       var bounds = map.getBounds();
 
@@ -306,6 +335,12 @@ L.OSM.share = function (options) {
           '<small><a href="' + escapeHTML(map.getUrl(marker)) + '">' +
           escapeHTML(I18n.t('javascripts.share.view_larger_map')) + '</a></small>');
 
+      // Geo URI
+
+      $('#geo_uri')
+        .attr('href', map.getGeoUri(marker))
+        .html(map.getGeoUri(marker));
+
       // Image
 
       if (locationFilter.isEnabled()) {