diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index b30564a1ae6..3abebf5cfb9 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -238,11 +238,37 @@ $(document).ready(function () { L.marker(center, {icon: OSM.getUserIcon()}).addTo(map); }); + var isMobile = { + Windows: function() { + return /IEMobile/i.test(navigator.userAgent); + }, + Android: function() { + return /Android/i.test(navigator.userAgent); + }, + BlackBerry: function() { + return /BlackBerry/i.test(navigator.userAgent); + }, + iOS: function() { + return /iPhone|iPad|iPod/i.test(navigator.userAgent); + }, + any: function() { + return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows()); + } + }; + + var url = { + if (isMobile.Android()) { + return "intent:/load_and_zoom?"; + } else { + return document.location.protocol === "https:" ? + "https://127.0.0.1:8112/load_and_zoom?" : + "http://127.0.0.1:8111/load_and_zoom?"; + } + }; + 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?", + android = isMobile.Android(), query = { left: bbox.getWest() - 0.0001, top: bbox.getNorth() + 0.0001, @@ -255,17 +281,18 @@ $(document).ready(function () { var iframe = $('