]> git.openstreetmap.org Git - rails.git/blobdiff - app/assets/javascripts/index.js
Enable some more eslint rules from iD rules
[rails.git] / app / assets / javascripts / index.js
index b30564a1ae64b12ee3c7a98aff01b1c131da8c26..2678ba2824e3ad7edd05560a1a6bdd80324251d8 100644 (file)
 //= require index/changeset
 //= require index/query
 //= require router
+//= require bowser
 
 $(document).ready(function () {
   var loaderTimeout;
 
+  var map = new L.OSM.Map("map", {
+    zoomControl: false,
+    layerControl: false,
+    contextmenu: true
+  });
+
   OSM.loadSidebarContent = function(path, callback) {
     map.setSidebarOverlaid(false);
 
@@ -77,12 +84,6 @@ $(document).ready(function () {
 
   var params = OSM.mapParams();
 
-  var map = new L.OSM.Map("map", {
-    zoomControl: false,
-    layerControl: false,
-    contextmenu: true
-  });
-
   map.attributionControl.setPrefix('');
 
   map.updateLayers(params.layers);
@@ -114,6 +115,7 @@ $(document).ready(function () {
     .removeClass('leaflet-control-locate leaflet-bar')
     .addClass('control-locate')
     .children("a")
+    .attr('href', '#')
     .removeClass('leaflet-bar-part leaflet-bar-part-single')
     .addClass('control-button');
 
@@ -185,12 +187,12 @@ $(document).ready(function () {
     $.cookie('_osm_location', OSM.locationCookie(map), { expires: expiry, path: '/' });
   });
 
-  if ($.cookie('_osm_welcome') === 'hide') {
-    $('.welcome').hide();
+  if ($.cookie('_osm_welcome') !== 'hide') {
+    $('.welcome').addClass('visible');
   }
 
   $('.welcome .close-wrap').on('click', function() {
-    $('.welcome').hide();
+    $('.welcome').removeClass('visible');
     $.cookie('_osm_welcome', 'hide', { expires: expiry, path: '/' });
   });
 
@@ -240,9 +242,7 @@ $(document).ready(function () {
 
   function remoteEditHandler(bbox, object) {
     var loaded = false,
-        url = document.location.protocol === "https:" ?
-        "https://127.0.0.1:8112/load_and_zoom?" :
-        "http://127.0.0.1:8111/load_and_zoom?",
+        url,
         query = {
           left: bbox.getWest() - 0.0001,
           top: bbox.getNorth() + 0.0001,
@@ -250,6 +250,13 @@ $(document).ready(function () {
           bottom: bbox.getSouth() - 0.0001
         };
 
+    if (location.protocol === 'http' ||
+        bowser.check({chrome: "53", firefox: "55"})) {
+      url = "http://127.0.0.1:8111/load_and_zoom?";
+    } else {
+      url = "https://127.0.0.1:8112/load_and_zoom?";
+    }
+
     if (object) query.select = object.type + object.id;
 
     var iframe = $('<iframe>')
@@ -327,7 +334,7 @@ $(document).ready(function () {
     };
 
     function addObject(type, id, center) {
-      map.addObject({type: type, id: parseInt(id)}, function(bounds) {
+      map.addObject({type: type, id: parseInt(id, 10)}, function(bounds) {
         if (!window.location.hash && bounds.isValid() &&
             (center || !map.getBounds().contains(bounds))) {
           OSM.router.withoutMoveListener(function () {