Bonus: now you can edit directly the coordinates without opening an annoying new window every time
you click in the GPS coodinates box. After closing the goolge maps window it can be opened agais just clicking
again in the GPS coordinates box.
<?php use_javascripts_for_form($form) ?>
<script type="text/javascript">
+ var alreadyOpened = false;
$(document).ready(function(){
- var longitude = document.getElementById('ad_longitude');
- var latitude = document.getElementById('ad_latitude');
- var adMapURL = 'http://localhost/companyfront_dev.php/admap/admap?latitude='+latitude.value+'&longitude='+longitude.value;
$('#ad_longitude').click(function() {
- newwindow=window.open(adMapURL, '', 'menubar=no,height=600,width=600');
- if (window.focus) {
- newwindow.focus()
+ if (!window.alreadyOpened) {
+ window.alreadyOpened = true;
+ var longitude = document.getElementById('ad_longitude');
+ var latitude = document.getElementById('ad_latitude');
+ var adMapURL = 'http://localhost/companyfront_dev.php/admap/admap?latitude='+latitude.value+'&longitude='+longitude.value;
+ newwindow=window.open(adMapURL, '', 'menubar=no,height=600,width=600');
+ if (window.focus) {
+ newwindow.focus()
+ }
}
- return false;
});
});
$(document).ready(function(){
- var longitude = document.getElementById('ad_longitude');
- var latitude = document.getElementById('ad_latitude');
- var adMapURL = 'http://localhost/companyfront_dev.php/admap/admap?latitude='+latitude.value+'&longitude='+longitude.value;
$('#ad_latitude').click(function() {
- newwindow=window.open(adMapURL, '', 'menubar=no,height=600,width=600');
- if (window.focus) {
- newwindow.focus()
+ if (!window.alreadyOpened) {
+ window.alreadyOpened = true;
+ var longitude = document.getElementById('ad_longitude');
+ var latitude = document.getElementById('ad_latitude');
+ var adMapURL = 'http://localhost/companyfront_dev.php/admap/admap?latitude='+latitude.value+'&longitude='+longitude.value;
+ newwindow=window.open(adMapURL, '', 'menubar=no,height=600,width=600');
+ if (window.focus) {
+ newwindow.focus()
+ }
}
- return false;
});
});
document.body.appendChild(script);
}
+ function taskOnExit() {
+ self.opener.alreadyOpened = false;
+ }
+
window.onload = loadScript;
- google.maps.event.addDomListener(window, 'load', initialize);
+ window.onbeforeunload = taskOnExit;
</script>
</head>
document.body.appendChild(script);
}
+ function taskOnExit() {
+ self.opener.alreadyOpened = false;
+ }
+
window.onload = loadScript;
- google.maps.event.addDomListener(window, 'load', initialize);
+ window.onbeforeunload = taskOnExit;
+
</script>
</head>
</script>
<script type="text/javascript">
+ var alreadyOpened = false;
$(document).ready(function(){
- var longitude = document.getElementById('office_longitude');
- var latitude = document.getElementById('office_latitude');
- var adMapURL = 'http://localhost/companyfront_dev.php/admap/officemap?latitude='+latitude.value+'&longitude='+longitude.value;
$('#office_longitude').click(function() {
- newwindow=window.open(adMapURL, '', 'menubar=no,height=600,width=600');
- if (window.focus) {
- newwindow.focus()
+ if (!window.alreadyOpened) {
+ window.alreadyOpened = true;
+ var longitude = document.getElementById('office_longitude');
+ var latitude = document.getElementById('office_latitude');
+ var adMapURL = 'http://localhost/companyfront_dev.php/admap/officemap?latitude='+latitude.value+'&longitude='+longitude.value;
+ newwindow=window.open(adMapURL, '', 'menubar=no,height=600,width=600');
+ if (window.focus) {
+ newwindow.focus()
+ }
}
});
});
$(document).ready(function(){
- var longitude = document.getElementById('office_longitude');
- var latitude = document.getElementById('office_latitude');
- var adMapURL = 'http://localhost/companyfront.php/admap/officemap?latitude='+latitude.value+'&longitude='+longitude.value;
$('#office_latitude').click(function() {
- newwindow=window.open(adMapURL, '', 'menubar=no,height=600,width=600');
- if (window.focus) {
- newwindow.focus()
+ if (!window.alreadyOpened) {
+ window.alreadyOpened = true;
+ var longitude = document.getElementById('office_longitude');
+ var latitude = document.getElementById('office_latitude');
+ var adMapURL = 'http://localhost/companyfront_dev.php/admap/officemap?latitude='+latitude.value+'&longitude='+longitude.value;
+ newwindow=window.open(adMapURL, '', 'menubar=no,height=600,width=600');
+ if (window.focus) {
+ newwindow.focus()
+ }
}
});
});