]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Add support triggering a piwik goal when a map layer is selected
[rails.git] / app / assets / javascripts / index.js
index 5190277c98c6927a040be94f64d6b6c17e5ef335..d577e0cf731be9086e673ee4e63e883951c09570 100644 (file)
@@ -75,7 +75,10 @@ $(document).ready(function () {
 
   L.control.locate({
     position: position,
-    title: I18n.t('javascripts.map.locate.title')
+    strings: {
+      title: I18n.t('javascripts.map.locate.title'),
+      popup: I18n.t('javascripts.map.locate.popup')
+    }
   }).addTo(map);
 
   var sidebar = L.OSM.sidebar('#map-ui')
@@ -110,6 +113,18 @@ $(document).ready(function () {
 
   map.on('moveend layeradd layerremove', updateLocation);
 
+  if (OSM.PIWIK) {
+    map.on('layeradd', function (e) {
+      if (e.layer.options) {
+        var goal = OSM.PIWIK.goals[e.layer.options.keyid];
+
+        if (goal) {
+          $('body').trigger('piwikgoal', goal);
+        }
+      }
+    });
+  }
+
   var marker = L.marker([0, 0], {icon: getUserIcon()});
 
   if (!params.object_zoom) {
@@ -155,6 +170,20 @@ $(document).ready(function () {
     remoteEditHandler(map.getBounds());
   }
 
+  if (OSM.params().edit_help) {
+    $('#editanchor')
+      .removeAttr('title')
+      .tooltip({
+        placement: 'bottom',
+        title: I18n.t('javascripts.edit_help')
+      })
+      .tooltip('show');
+
+    $('body').one('click', function() {
+      $('#editanchor').tooltip('hide');
+    });
+  }
+
   initializeSearch(map);
   initializeExport(map);
   initializeBrowse(map, params);