]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/application.js
Remove unused osmarender key data
[rails.git] / app / assets / javascripts / application.js
index e40465f06e0d814607ffaeec433553a5b6327635..747c6d9afe5d45544717c7f24c759ee5f8bfd77a 100644 (file)
@@ -2,30 +2,40 @@
 //= require jquery_ujs
 //= require jquery.autogrowtextarea
 //= require jquery.timers
+//= require augment
 //= require openlayers
 //= require i18n/translations
 //= require globals
 //= require browse
 //= require export
 //= require map
+//= require key
 //= require menu
+//= require sidebar
+
+function zoomPrecision(zoom) {
+    var decimals = Math.pow(10, Math.floor(zoom/3));
+    return function(x) {
+         return Math.round(x * decimals) / decimals;
+    };
+}
 
 /*
  * Called as the user scrolls/zooms around to aniplate hrefs of the
  * view tab and various other links
  */
 function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,objid) {
-  var decimals = Math.pow(10, Math.floor(zoom/3));
+  var toPrecision = zoomPrecision(zoom);
   var node;
 
-  lat = Math.round(lat * decimals) / decimals;
-  lon = Math.round(lon * decimals) / decimals;
+  lat = toPrecision(lat);
+  lon = toPrecision(lon);
 
   if (minlon) {
-    minlon = Math.round(minlon * decimals) / decimals;
-    minlat = Math.round(minlat * decimals) / decimals;
-    maxlon = Math.round(maxlon * decimals) / decimals;
-    maxlat = Math.round(maxlat * decimals) / decimals;
+    minlon = toPrecision(minlon);
+    minlat = toPrecision(minlat);
+    maxlon = toPrecision(maxlon);
+    maxlat = toPrecision(maxlat);
   }
 
   $(".geolink").each(function (index, link) {
@@ -254,3 +264,20 @@ $(document).ready(function () {
   $(".richtext_doedit").click(editRichtext);
   $(".richtext_dopreview").click(previewRichtext);
 });
+
+/*
+ * Forms which have been cached by rails may have he wrong
+ * authenticity token, so patch up any forms with the correct
+ * token taken from the page header.
+ */
+$(document).ready(function () {
+  var auth_token = $("meta[name=csrf-token]").attr("content");
+  $("form input[name=authenticity_token]").val(auth_token);
+});
+
+/*
+ * Enable auto expansion for all text areas
+ */
+$(document).ready(function () {
+  $("textarea").autoGrow();
+});