Skip to content

Instantly share code, notes, and snippets.

@DylanCodeCabin
Last active October 11, 2024 12:54
Show Gist options
  • Save DylanCodeCabin/8c7b2b3a3e1a71db40db092906cdd72f to your computer and use it in GitHub Desktop.
Save DylanCodeCabin/8c7b2b3a3e1a71db40db092906cdd72f to your computer and use it in GitHub Desktop.
jQuery(($) => {
let wpgmza_last_active = false;
WPGMZA.ProMarker.prototype.__onClick = WPGMZA.ProMarker.prototype.onClick;
WPGMZA.ProMarker.prototype.onClick = function(event){
this.__onClick(event);
if(wpgmza_last_active){
wpgmzaReleaseActiveMarker();
}
if(this.hoverIcon && this.hoverIcon instanceof Object){
if(this.hoverIcon.url){
/* We have a hover icon */
if(!this.restoreActiveIcon){
this.restoreActiveIcon = Object.assign({}, this.restoreIcon || this.icon);
}
this.icon = this.hoverIcon;
wpgmza_last_active = this;
}
}
}
WPGMZA.ProMarker.prototype.__openInfoWindow = WPGMZA.ProMarker.prototype.openInfoWindow;
WPGMZA.ProMarker.prototype.openInfoWindow = function(autoOpen){
this.__openInfoWindow(autoOpen);
if(WPGMZA.getQueryParamValue("markerid") == this.id || this.map.shortcodeAttributes.marker == this.id ) {
if(wpgmza_last_active){
wpgmzaReleaseActiveMarker();
}
if(this.hoverIcon && this.hoverIcon instanceof Object){
if(this.hoverIcon.url){
/* We have a hover icon */
if(!this.restoreActiveIcon){
this.restoreActiveIcon = Object.assign({}, this.restoreIcon || this.icon);
}
this.icon = this.hoverIcon;
wpgmza_last_active = this;
}
}
}
}
WPGMZA.ProMarker.prototype.__onMouseOut = WPGMZA.ProMarker.prototype.onMouseOut;
WPGMZA.ProMarker.prototype.onMouseOut = function(event){
if(wpgmza_last_active && wpgmza_last_active.id === this.id){
return;
}
if(this.hoverIcon && this.restoreIcon){
if(this.restoreIcon instanceof Object){
this.icon = this.restoreIcon;
this.restoreIcon = false;
}
}
}
WPGMZA.ProInfoWindow.prototype.__close = WPGMZA.ProInfoWindow.prototype.close;
WPGMZA.ProInfoWindow.prototype.close = function() {
this.__close();
if(wpgmza_last_active){
wpgmzaReleaseActiveMarker();
}
}
WPGMZA.ProMap.prototype.__onClick = WPGMZA.ProMap.prototype.onClick;
WPGMZA.ProMap.prototype.onClick = function(event)
{
var self = this;
this.__onClick(event);
if(this.settings.close_infowindow_on_map_click){
if(event.target instanceof WPGMZA.Map){
if(wpgmza_last_active){
wpgmzaReleaseActiveMarker();
}
}
}
}
wpgmzaReleaseActiveMarker = function(){
if(wpgmza_last_active.restoreActiveIcon){
if(wpgmza_last_active.restoreActiveIcon instanceof Object){
wpgmza_last_active.icon = wpgmza_last_active.restoreActiveIcon;
wpgmza_last_active.restoreActiveIcon = false;
wpgmza_last_active = false;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment