gluon-config-mode-geo-location-with-map: load map asyncron to don't block the formular

This commit is contained in:
Jan-Tarek Butt 2018-07-27 21:38:55 +02:00
parent cc5e447c03
commit f1dd0c5f71

View File

@ -67,18 +67,22 @@ return function(form, uci)
<script type="text/javascript" src="/static/osm.js"></script> <script type="text/javascript" src="/static/osm.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var latitude=]] .. show_lon() .. ",longitude=" .. show_lat() .. ",zoom=" .. site_zoom() .. [[; var latitude=]] .. show_lon() .. ",longitude=" .. show_lat() .. ",zoom=" .. site_zoom() .. [[;
function loadedContent() { var openLayerSrc = document.createElement("script");
document.addEventListener("DOMContentLoaded", showMap, false); openLayerSrc.type = 'text/javascript';
openLayerSrc.src = "]] .. show_olurl() .. [[?noCache=]] .. os.time() .. [[";
openLayerSrc.onload = openLayerSrc.onreadystatechange = function () {
window.addEventListener("load", showMap, false);
var lpm=document.getElementById("locationPickerMap");
setInterval(function() { setInterval(function() {
if(false !== findObj("longitude")) { if(false !== findObj("longitude")) {
document.getElementById("locationPickerMap").style.display="block"; lpm.style.display="block";
}else{ }else{
document.getElementById("locationPickerMap").style.display="none"; lpm.style.display="none";
}
}, 10);
} }
}, 100);
};
document.head.appendChild(openLayerSrc);
</script> </script>
<script onload="loadedContent();" type="text/javascript" src="]] .. show_olurl() .. [[?noCache=]] .. os.time() .. [["></script>
<div> <div>
]] ]]