]> git.openstreetmap.org Git - rails.git/commitdiff
Use $(document).ready() to initialise browse JS
authorJohn Firebaugh <john.firebaugh@gmail.com>
Sat, 29 Sep 2012 21:49:16 +0000 (14:49 -0700)
committerTom Hughes <tom@compton.nu>
Sun, 30 Sep 2012 11:15:49 +0000 (12:15 +0100)
app/assets/javascripts/browse.js

index 424940130069b31a43755efff6b9c7f7591e04b3..1db89ad0ad08ffe5ca7ad2c360b264fabba14467 100644 (file)
@@ -1,26 +1,26 @@
-function remoteEditHandler(event, bbox, select) {
-  var left = bbox.left - 0.0001;
-  var top = bbox.top + 0.0001;
-  var right = bbox.right + 0.0001;
-  var bottom = bbox.bottom - 0.0001;
-  var loaded = false;
+$(document).ready(function () {
+  function remoteEditHandler(event, bbox, select) {
+    var left = bbox.left - 0.0001;
+    var top = bbox.top + 0.0001;
+    var right = bbox.right + 0.0001;
+    var bottom = bbox.bottom - 0.0001;
+    var loaded = false;
+
+    $("#linkloader").load(function () { loaded = true; });
+
+    if (select) {
+      $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom + "&select=" + select);
+    } else {
+      $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom);
+    }
 
-  $("#linkloader").load(function () { loaded = true; });
+    setTimeout(function () {
+      if (!loaded) alert(I18n.t('site.index.remote_failed'));
+    }, 1000);
 
-  if (select) {
-    $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom + "&select=" + select);
-  } else {
-    $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + left + "&top=" + top + "&right=" + right + "&bottom=" + bottom);
+    return false;
   }
 
-  setTimeout(function () {
-    if (!loaded) alert(I18n.t('site.index.remote_failed'));
-  }, 1000);
-
-  return false;
-}
-
-function init() {
   var map = createMap("small_map", {
     controls: [ new OpenLayers.Control.Navigation() ]
   });
@@ -83,6 +83,4 @@ function init() {
 
   createMenu("area_edit", "area_edit_menu", "right");
   createMenu("object_edit", "object_edit_menu", "right");
-}
-
-window.onload = init;
+});