/**
* @namespace WPGMZA
* @module InfoWindow
* @requires WPGMZA.EventDispatcher
*/
(function($) {
WPGMZA.InfoWindow = function(mapObject)
{
var self = this;
WPGMZA.EventDispatcher.call(this);
WPGMZA.assertInstanceOf(this, "InfoWindow");
if(!mapObject)
return;
this.mapObject = mapObject;
if(mapObject.map)
{
// This has to be slightly delayed so the map initialization won't overwrite the infowindow element
setTimeout(function() {
self.onMapObjectAdded(event);
}, 100);
}
else
mapObject.addEventListener("added", function(event) {
self.onMapObjectAdded(event);
});
}
WPGMZA.InfoWindow.prototype = Object.create(WPGMZA.EventDispatcher.prototype);
WPGMZA.InfoWindow.prototype.constructor = WPGMZA.InfoWindow;
WPGMZA.InfoWindow.OPEN_BY_CLICK = 1;
WPGMZA.InfoWindow.OPEN_BY_HOVER = 2;
WPGMZA.InfoWindow.getConstructor = function()
{
switch(WPGMZA.settings.engine)
{
case "google-maps":
if(WPGMZA.isProVersion())
return WPGMZA.GoogleProInfoWindow;
return WPGMZA.GoogleInfoWindow;
break;
default:
if(WPGMZA.isProVersion())
return WPGMZA.OLProInfoWindow;
return WPGMZA.OLInfoWindow;
break;
}
}
WPGMZA.InfoWindow.createInstance = function(mapObject)
{
var constructor = this.getConstructor();
return new constructor(mapObject);
}
/**
* Gets the content for the info window and passes it to the specified callback - this allows for delayed loading (eg AJAX) as well as instant content
* @return void
*/
WPGMZA.InfoWindow.prototype.getContent = function(callback)
{
var html = "";
if(this.mapObject instanceof WPGMZA.Marker)
html = this.mapObject.address;
callback(html);
}
/**
* Opens the info window
* @return boolean FALSE if the info window should not & will not open, TRUE if it will
*/
WPGMZA.InfoWindow.prototype.open = function(map, mapObject)
{
var self = this;
this.mapObject = mapObject;
if(WPGMZA.settings.disable_infowindows)
return false;
return true;
}
WPGMZA.InfoWindow.prototype.close = function()
{
}
/**
* Event listener for when the map object is added. This will cause the info window to open if the map object has infoopen set
* @return void
*/
WPGMZA.InfoWindow.prototype.onMapObjectAdded = function()
{
if(this.mapObject.settings.infoopen == 1)
this.open();
}
})(jQuery);