//= 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) {
$(".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();
+});