]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Switch to using js-cookie to manage cookies from javascript
[rails.git] / app / assets / javascripts / index.js
index 68beefeb6a7f4fa5122c2629c4254a8d01cc8f04..9305a541595e321cdae3a2040f5b3f29902b17b2 100644 (file)
@@ -108,9 +108,9 @@ $(document).ready(function () {
     iconLoading: "icon geolocate",
     strings: {
       title: I18n.t("javascripts.map.locate.title"),
-      metersUnit: I18n.t("javascripts.map.locate.metersUnit"),
-      feetUnit: I18n.t("javascripts.map.locate.feetUnit"),
-      popup: I18n.t("javascripts.map.locate.popup")
+      popup: function (options) {
+        return I18n.t("javascripts.map.locate." + options.unit + "Popup", { count: options.distance });
+      }
     }
   }).addTo(map);
 
@@ -188,17 +188,17 @@ $(document).ready(function () {
       map.getLayersCode(),
       map._object);
 
-    $.removeCookie("_osm_location");
-    $.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" });
+    Cookies.remove("_osm_location");
+    Cookies.set("_osm_location", OSM.locationCookie(map), { secure: true, expires: expiry, path: "/" });
   });
 
-  if ($.cookie("_osm_welcome") !== "hide") {
+  if (Cookies.get("_osm_welcome") !== "hide") {
     $(".welcome").addClass("visible");
   }
 
   $(".welcome .close").on("click", function () {
     $(".welcome").removeClass("visible");
-    $.cookie("_osm_welcome", "hide", { expires: expiry, path: "/" });
+    Cookies.set("_osm_welcome", "hide", { secure: true, expires: expiry, path: "/" });
   });
 
   var bannerExpiry = new Date();
@@ -209,7 +209,7 @@ $(document).ready(function () {
     $("#banner").hide();
     e.preventDefault();
     if (cookieId) {
-      $.cookie(cookieId, "hide", { expires: bannerExpiry, path: "/" });
+      Cookies.set(cookieId, "hide", { secure: true, expires: bannerExpiry, path: "/" });
     }
   });