-
Jason
-
-
Offline
-
Fresh Boarder
-
-
Posts: 9
-
Thank you received: 0
-
-
|
Hi Daniel,
I tried to change the code as above so the menu slides away after a set time but the menu does not slide away at all, please check the code of hotspots.js I've attached.
var Hscord = null;
var Zoomlevel = null;
var was = null;
var bounds = new GLatLngBounds();
var costcenter = null;
var costzoom = null;
var progressBar = null;
var num = null;
var maxNum = null;
var highlightCircle = null;
var currentMarker = null;
var markers = [];
var polys = [];
var editingNow = false;
var catfirstLetter = null;
var supopup = false;
var Position = null;
var centertype = 0;
var mapOverlaySlide = null;
var slideroute = null;
var map_overlay_div = 0;
var map_highlight_currentmarker = 0;
var addhs_map = 0;
function setstartpos(){
setCenter(map_startposition, map_startzoom);
}
function slideOut(slidemenu) {
slidemenu.slideIn();
}
function effects() {
if(MooTools.version > "1.12") {
var slidemenu = new Fx.Slide('slide_menu', {
mode: 'horizontal',
hideOverflow: false,
transition: 'bounce:out'
});
} else {
var slidemenu = new Fx.Slide('slide_menu', {
mode: 'horizontal'
});
}
/**
* this is a needed hack for mootools 1.2
* without it the menu is positioned wrong on the left
*/
$('slide_menu').setStyle('position', 'absolute');
$('slide_menu_out').addEvent('click', function(e){
e = new Event(e);
slidemenu.slideIn();
e.stop();
});
$('slide_menu').addEvent('mouseover', function(e){
e = new Event(e);
slidemenu.slideOut();
if(typeof slideTimeout != 'undefined') {
window.clearTimeout(slideTimeout);
}
e.stop();
});
$('slide_menu').addEvent('mouseout', function(e){
e = new Event(e);
slideTimeout = setTimeout(slideOut, 3000, slidemenu);
e.stop();
});
if(MooTools.version > "1.12") {
mapOverlaySlide = new Fx.Slide('map_overlay_cont', {
hideOverflow: false,
transition: 'bounce:out'
});
} else {
mapOverlaySlide = new Fx.Slide('map_overlay_cont');
}
/**
* same bug as above
*/
$('map_overlay_cont').setStyle('position', 'absolute');
$('close_mapoverlay').addEvent('click', function(e){
e = new Event(e);
mapOverlaySlide.slideIn();
e.stop();
});
if(hotspots_routenplaner) {
// Slide Route
if(MooTools.version > "1.12") {
slideroute = new Fx.Slide('routepop', {
duration: 1000,
hideOverflow: false,
transition: 'bounce:out'
}).hide();
} else {
slideroute = new Fx.Slide('routepop').hide();
}
$('btn_close_route').addEvent('click', function(e){
e = new Event(e);
slideroute.slideOut();
e.stop();
});
$('btn_open_route').addEvent('click', function(e){
e = new Event(e);
slideroute.toggle();
e.stop();
});
}
// footer_slide = new Fx.Slide('hs_foot_menu');
if(show_footer_menu == 1) {
slide_address = new Fx.Slide('hs_foot_info').hide();
}
}
function setVariables() {
geocoder = new GClientGeocoder();
map = new GMap2(document.getElementById("map_canvas"));
map.enableScrollWheelZoom();
if(hotspots_routenplaner) {
directionsPanel = $("routenplaner");
directions = new GDirections(map, directionsPanel);
}
}
function gmcontrols() {
mapControl = new GMapTypeControl();
if(gm_control_pos == "topLeft") {
gm_control_pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,10));
}
if (gm_control_pos == "topRigth") {
gm_control_pos = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
}
if(gm_control_pos == "bottomLeft") {
gm_control_pos = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(10,10));
}
if(gm_control_pos == "bottomRigth") {
gm_control_pos = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(10,10));
}
if(template != 'default') {
map.addControl(mapControl);
}
if (gm_control == "1") {
map.addControl(new GLargeMapControl(), gm_control_pos );
}
if (gm_control == "2") {
map.addControl(new GSmallMapControl(), gm_control_pos );
}
if (gm_control == "3") {
map.addControl(new GSmallZoomControl(), gm_control_pos);
}
if (gm_control == "4") {
map.addControl(new GOverviewMapControl(), gm_control_pos );
}
if(map_progressbar) {
progressBar = new ProgressbarControl(map, {
width:150
});
}
}
function maptype() {
if (map_type == "1") {
map.removeMapType(G_HYBRID_MAP);
map.removeMapType(G_SATELLITE_MAP);
} else if (map_type == "2") {
map.removeMapType(G_NORMAL_MAP);
map.removeMapType(G_HYBRID_MAP);
} else if (map_type == "3") {
map.removeMapType(G_NORMAL_MAP);
map.removeMapType(G_SATELLITE_MAP);
} else if (map_type == "4") {
map.removeMapType(G_HYBRID_MAP);
} else if (map_type == "5" ) {
map.removeMapType(G_SATELLITE_MAP);
} else if (map_type == "6") {
map.removeMapType(G_NORMAL_MAP);
}
}
function setCenter(address, zoom) {
var geocoder = new GClientGeocoder();
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " " + "not_found");
} else {
map.setCenter(point, zoom);
}
}
);
};
function hsload(was){
markers = [];
currentMarker = null;
if (was == null) {
was = hs_startcat;
}
catid = was;
document.getElementById('hsloading').style.visibility = "visible";
if(hotspots_routenplaner) {
directionsPanel.innerHTML = '';
}
// hotspotsUtils::fontweight();
// if (show_footer_menu) {
// document.getElementById('cat_new_'+was).style.display = "inline-block";
// }
var _cat = document.getElementById('cat' + was);
_cat.style.fontWeight = "bold";
if(typeof footer_opened != 'undefined' && footer_opened == 1) {
getLatestHotspots();
}
if(show_footer_menu == 1) {
var cat_element = new Element(_cat);
$('newestSpotId').innerHTML = (cat_element.getElement('a').innerHTML).replace(/\(\d+\)/g,'');
}
client = window.XMLHttpRequest ? new XMLHttpRequest()
: new ActiveXObject("Microsoft.XMLHTTP");
client.onreadystatechange = callback;
client.open("get",hotspots_route+"index.php?option=com_hotspots&task=gethotspots&format=raw&cat="+was+"&level="+Zoomlevel+"&position="+Position,true);
client.send(null);
}
function callback(){
if (client.readyState == 4) {
if (client.status == 200) {
eval(client.responseText);
} else {
alert("Response Error:" + client.statusText);
}
}
}
function saveCord(cord, id){
client = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
client.onreadystatechange = callback;
client.open("get",hotspots_route+"index.php?option=com_hotspots&task=getCords&cord="+cord+"&id="+id+'&format=raw',true);
client.send(null);
}
function addspot() {
var client = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
client.onreadystatechange = function () {
if (client.readyState == 4) {
if (client.status == 200) {
eval(client.responseText);
} else {
alert('Response Error:' + client.statusText);
}
}
};
client.open('get',hotspots_route+'index.php?option=com_hotspots&task=showaddhotspot&format=raw',true);
client.send(null);
}
function adsearch() {
strasse = document.getElementById('address_strasse').value;
plztown = document.getElementById('address_zip').value;
setCenter(strasse + ' ' + plztown, search_zoom);
}
function showCord(address, id, html) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " " + "not_found");
} else {
if(map_overlay_div == 0) {
map.addOverlay(createMarker(point, id, html, markerOptions));
} else {
map.addOverlay(createMarkerDiv(point, id, html, markerOptions));
}
saveCord(point, id)
}
}
);
}
function createMarker(point, number, myhtml, markerOptions) {
num++;
if (typeof(markerOptions.icon) !== "undefined" && typeof (markerOptions.icon.shadow) !== 'undefined' ) {
var marker = new GMarker(point, markerOptions);
} else {
var marker = new GMarker(point);
}
progressBar.updateLoader(1);
GEvent.addListener(marker, "click", function() {
map.openInfoWindowHtml(point, myhtml);
if(map_highlight_currentmarker) {
currentMarker = marker;
highlightCurrentMarker();
}
});
if (num < maxNum) {
} else {
progressBar.remove();
num = 0;
}
if(map_highlight_currentmarker) {
GEvent.addListener(marker, "mouseover", function() {
currentMarker = marker;
highlightCurrentMarker();
});
}
bounds.extend(point);
markers.push(marker);
return marker;
}
function createMarkerDiv(point, number, myhtml, markerOptions) {
maxNum = 12;
num++;
if (typeof(markerOptions.icon) != "undefined") {
var marker = new GMarker(point, markerOptions);
} else {
var marker = new GMarker(point);
}
progressBar.updateLoader(1);
GEvent.addListener(marker, "click", function() {
document.getElementById('map_overlay_cont').style.display = 'inline';
mapOverlaySlide.slideOut();
document.getElementById('map_overlay').innerHTML = myhtml;
if(map_highlight_currentmarker) {
currentMarker = marker;
highlightCurrentMarker();
}
});
if (num < maxNum) {
} else {
progressBar.remove();
num = 0;
}
if(map_highlight_currentmarker) {
GEvent.addListener(marker, "mouseover", function() {
currentMarker = marker;
highlightCurrentMarker();
});
}
bounds.extend(point);
markers.push(marker);
return marker;
}
function routeplan() {
routestr = $('route_street').value;
routezip = $('route_zip').value;
if (currentMarker != null) {
slideroute.slideOut();
directionsPanel.innerHTML = '';
directionsPanel.style.display = "block";
directions.load("from: " + routestr + " " + routezip + " to: " + currentMarker.getLatLng() );
} else {
alert("Please select a Hotspot Marker (mouse-over it)");
}
}
function routeplan_close() {
$('routenplaner').style.display = "none";
}
function setCatCenter() {
var newZoom = map.getBoundsZoomLevel(bounds);
map.setZoom(map.getBoundsZoomLevel(bounds));
map.setCenter(bounds.getCenter(),newZoom);
}
function showNew(lat, lng) {
map.setCenter(new GLatLng(lat, lng), 13);
}
function savePosition() {
costcenter = map.getCenter();
costzoom = map.getZoom();
document.getElementById('button_loadposition').style.display = "block";
}
function goSavedPosition() {
map.setZoom(costzoom);
map.panTo(costcenter);
}
function smallmenu() {
document.getElementById('hs_cont').style.height = "33px";
document.getElementById('hs_topmenu').style.display = "none";
document.getElementById('cat_info_' + catid).style.display = "none";
document.getElementById('small_menu').style.display = "inline-block";
document.getElementById('button_catinfo').style.display = "block";
document.getElementById('button_cat_view').style.display = "block";
document.getElementById('button_miniview').style.display = "none";
}
function bigmenu() {
document.getElementById('hs_cont').style.height = catheight + "px";
document.getElementById('hs_topmenu').style.display = "inline-block";
document.getElementById('cat_info_' + catid).style.display = "none";
document.getElementById('small_menu').style.display = "none";
document.getElementById('button_catinfo').style.display = "block";
document.getElementById('button_miniview').style.display = "block";
document.getElementById('button_cat_view').style.display = "none";
}
function showcatinfo() {
document.getElementById('hs_cont').style.height = catheight + "px";
document.getElementById('hs_topmenu').style.display = "none";
document.getElementById('small_menu').style.display = "none";
document.getElementById('cat_info_' + catid).style.display = "inline-block";
document.getElementById('button_catinfo').style.display = "none";
document.getElementById('button_cat_view').style.display = "block";
document.getElementById('button_miniview').style.display = "block";
}
function hswelcomeClose() {
document.getElementById('hswelcome').style.visibility = "hidden";
}
function hotspotsAjax(params) {
if(MooTools.version > "1.12") {
var hostspotsRequest = new Request({
url: params.url,
method: params.method,
update: params.update,
onComplete: function(response) {
$(params.update).set('html', response);
}
});
hostspotsRequest.send();
} else {
hostspotsRequest = new Ajax(params.url, {
method: params.method,
update: params.update
});
hostspotsRequest.request();
}
}
function getLatestHotspots(){
params = new Object();
params.url = hotspots_route+"index.php?option=com_hotspots&task=getLatestHotspots&cat="+catid+'&format=raw';
params.method = 'get';
params.update = 'newestSpots';
hotspotsAjax(params);
}
function expandfootmenu() {
if(typeof footer_opened == 'undefined' || footer_opened == 0) {
slide_address.toggle();
getLatestHotspots();
footer_opened = 1;
} else if(footer_opened == 1) {
slide_address.slideOut();
footer_opened = 0;
}
}
function satView() {
map.setMapType(G_SATELLITE_MAP);
document.getElementById('button_map').style.display = "block";
document.getElementById('button_hybmap').style.display = "block";
document.getElementById('button_phymap').style.display = "block";
document.getElementById('button_satmap').style.display = "none";
}
function hybView() {
map.setMapType(G_HYBRID_MAP);
document.getElementById('button_map').style.display = "block";
document.getElementById('button_hybmap').style.display = "none";
document.getElementById('button_satmap').style.display = "block";
document.getElementById('button_phymap').style.display = "block";
}
function norView() {
map.setMapType(G_NORMAL_MAP);
document.getElementById('button_map').style.display = "none";
document.getElementById('button_hybmap').style.display = "block";
document.getElementById('button_satmap').style.display = "block";
document.getElementById('button_phymap').style.display = "block";
}
function phyView() {
map.setMapType(G_PHYSICAL_MAP);
document.getElementById('button_phymap').style.display = "none";
document.getElementById('button_hybmap').style.display = "block";
document.getElementById('button_satmap').style.display = "block";
document.getElementById('button_map').style.display = "block";
}
function highlightCurrentMarker(){
if (currentMarker != null)
{
var markerPoint = currentMarker.getPoint();
var polyPoints = Array();
if (highlightCircle) {
map.removeOverlay(highlightCircle);
}
var mapNormalProj = G_NORMAL_MAP.getProjection();
var mapZoom = map.getZoom();
var clickedPixel = mapNormalProj.fromLatLngToPixel(markerPoint, mapZoom);
var polySmallRadius = 20;
var polyNumSides = 20;
var polySideLength = 18;
for (var a = 0; a<(polyNumSides+1); a++) {
var aRad = polySideLength*a*(Math.PI/180);
var polyRadius = polySmallRadius;
var pixelX = clickedPixel.x + 5 + polyRadius * Math.cos(aRad);
var pixelY = clickedPixel.y - 10 + polyRadius * Math.sin(aRad);
var polyPixel = new GPoint(pixelX,pixelY);
var polyPoint = mapNormalProj.fromPixelToLatLng(polyPixel,mapZoom);
polyPoints.push(polyPoint);
}
// Using GPolygon(points, strokeColor?, strokeWeight?, strokeOpacity?, fillColor?, fillOpacity?)
highlightCircle = new GPolygon(polyPoints,"#000000",2,0.0,"#FF0000",.5);
map.addOverlay(highlightCircle);
}
}
function spopup(url, img) {
x = screen.availWidth/2-600/2;
y = screen.availHeight/2-800/2;
supopup = window.open("","_supopup",'width=600,height=800,left='+x+',top='+y+',screenX='+x+',screenY='+y+',scrollbars=1,resizeable');
if (supopup != null){
with (supopup.document){
open()
write(" <script language='javascript' type='text/javascript'> ")
write("<!-- ")
write(" function submitbutton(pressbutton) { ")
write(" var form = document.mailtoForm; ")
write(" // do field validation ")
write(" if (form.mailto.value == '' || form.from.value == '') { ")
write(" alert( 'Please enter your Name and E-Mail address' ); ")
write(" return false; ")
write(" } ")
write(" form.submit(); ")
write(" } ")
write("--> ")
write("</script> ")
write("<form action='index.php' name='mailtoForm' method='post'>")
write("<div style='padding: 10px;'>")
write("<div style='text-align:right'>")
write("<a href='javascript: void window.close()'> Close Window <img src='components/com_mailto/assets/close-x.png' border='0' alt='' title='' /></a>")
write("</div>")
write("<div class='componentheading'>")
write("E-Mail this link to a friend")
write("</div>")
write("<p>")
write("Mailto:")
write(" <br />")
write(" <input type='text' name='mailto' class='inputbox' size='25' value=''/>")
write(" </p>")
write(" <p>")
write(" Sender:")
write(" <br />")
write(" <input type='text' name='sender' class='inputbox' value='' size='25' />")
write(" </p>")
write(" <p>")
write(" Your name:")
write(" <br />")
write(" <input type='text' name='from' class='inputbox' value='' size='25' />")
write(" </p>")
write(" <p>")
write(" Subject:")
write(" <br />")
write(" <input type='text' name='subject' id='subject' class='inputbox' value='' size='25' />")
write(" </p>")
write("<p>")
write("<div id='mailimg' name='mailimg'>")
write("<img src='" + img + "'>")
write("</div>")
write(" Message:")
write(" <br />")
write(" <textarea type='text_area' name='bodytext' id='bodytext' class='text_area' value='' rows='4' cols='40'/></textarea>")
write(" </p>")
write(" <p>")
write(" <button class='button' onclick='return submitbutton('send');'>")
write(" Send")
write(" </button>")
write("<button class='button' onclick='window.close();return false;'>")
write(" Cancel ")
write(" </button>")
write(" </p>")
write("</div>")
write(" <input type='hidden' name='option' value='com_hotspots' />")
write(" <input type='hidden' name='view' value='all' />")
write(" <input type='hidden' name='task' value='sendmail' />")
write(" <input type='hidden' name='imglink' id='imglink' value='" + img + "' />")
write(" </form>")
close()
}
}
}
function htmlpopup(w,h,site) {
x = screen.availWidth/2-w/2;
y = screen.availHeight/2-h/2;
var popupWindow = window.open(
'','','width='+w+',height='+h+',left='+x+',top='+y+',screenX='+x+',screenY='+y);
popupWindow.document.write(site);
}
function updateImage(todo) {
var baseUrl = "http://maps.google.com/maps/api/staticmap?";
var params = [];
params.push("center=" + map.getCenter().lat().toFixed(6) + "," + map.getCenter().lng().toFixed(6));
params.push("zoom=" + map.getZoom());
var markerSize = "";
var markerColor = "";
var markerLetter = "label:" + catfirstLetter;
var markerParams = [];
if (markerSize != "") markerParams.push(markerSize);
if (markerColor != "") markerParams.push(markerColor);
if (markerLetter != "") markerParams.push(markerLetter);
var markersArray = [];
for (var i = 0; i < markers.length; i++) {
markersArray.push(markers[i].getLatLng().lat().toFixed(6) + "," + markers[i].getLatLng().lng().toFixed(6));
}
if (markersArray.length) {
var markersString = markerParams.join("|");
if (markerParams.length) markersString += "|";
markersString += markersArray.join("|");
params.push("markers=" + markersString);
}
var polyColor = "color:0x" + "0000FF" + 80;
var polyWeight = "weight:" + 5;
var polyParams = polyColor + "|" + polyWeight;
for (var i = 0; i < polys.length; i++) {
var poly = polys[i];
var polyLatLngs = [];
for (var j = 0; j < poly.getVertexCount(); j++) {
polyLatLngs.push(poly.getVertex(j).lat().toFixed(5) + "," + poly.getVertex(j).lng().toFixed(5));
}
params.push("path=" + polyParams + "|" + polyLatLngs.join("|"));
}
if (map.getCurrentMapType() == G_SATELLITE_MAP) {
params.push("maptype=satellite");
}
if (map.getCurrentMapType() == G_HYBRID_MAP) {
params.push("maptype=hybrid");
}
if (map.getCurrentMapType() == G_PHYSICAL_MAP) {
params.push("maptype=terrain");
}
params.push("size=" + static_mapwidth + "x" + static_mapheight);
var img = document.createElement("img");
img.src = baseUrl + params.join("&") + "&sensor=false&key=" + api_key ;
/* document.getElementById("staticMapIMG").innerHTML = "";
document.getElementById("staticMapIMG").appendChild(img);
document.getElementById("staticMapURL").innerHTML = baseUrl + params.join("&") + "&sensor=false&key=" + api_key;*/
if (todo == 'print')
{
//var popupheight2 = (static_mapheight + 100);
var popupheight2 = 500;
htmlpopup(static_mapwidth, popupheight2, '<html><head><title>Print</title></head><body Onload="window.print();"><img src="' + baseUrl + params.join("&") + "&sensor=false&key=" + api_key + '"><br /><p align="right"><img src="components/com_hotspots/images/utils/print.png"><a href="javascript:print();"><font face="Verdana" size="2pt">Print</a></p></body></html>');
} else {
spopup('index2.php?option=com_hotspots&view=popupmail', baseUrl + params.join("&") + "&sensor=false&key=" + api_key);
}
}
function handleErrors(){
if(routenplaner) {
if (directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + directions.getStatus().code);
else if (directions.getStatus().code == G_GEO_SERVER_ERROR)
alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + directions.getStatus().code);
else if (directions.getStatus().code == G_GEO_MISSING_QUERY)
alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + directions.getStatus().code);
else if (directions.getStatus().code == G_GEO_BAD_KEY)
alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + directions.getStatus().code);
else if (directions.getStatus().code == G_GEO_BAD_REQUEST)
alert("A directions request could not be successfully parsed.\n Error code: " + directions.getStatus().code);
else alert("An unknown error occurred.");
}
}
|