I want to preface by saying that my fundamentals of javascript are exceedingly poor. This is basically the first complex problem I've tried to solve, so if my issue here is glaring syntactical ignorance, I will not be surprised, but please be gentle.
So I'm using Imagemapster to do some hover effects in an imagemap. I also want a click in the various regions of the imagemap to open a popup, and I'm trying to do this with Fancybox-2 after giving up with Highslide.
I'm aware that normally Imagemapster inhibits the action of clicking on region from utlizing it as a link and that to disable this you need to manually insert something to the effect of:
image.mapster({
fillOpacity: 0.0,
isSelectable: true,
singleSelect: true,
mapKey: 'data-name',
showToolTip: true,
onClick: go
});
And I have seen code snippets of people using this for condtionals like:
function go (data) {
if (this.href && this.href !== '#') {
window.open(this.href);
}
}
So through a process of breaking this in meaningful ways I've been trying to insert the call for fancybox into this "go" function, thinking perhaps this is the key to my problem. Currently however, none of my breaking has yielded much insight, and like I said, I don't really know enough about javascript to understand where my problem lies.
Here's my code currently:
(implicit are all the includes for jquery, fancybox, and imagemapster)
<script>
$(document).ready(function () {
$('#leoweb').mapster({
singleSelect: true,
render_highlight: {altImage: 'img/open.jpg'},
mapKey:'hex',
fill: true,
altImage: 'img/open.jpg',
fillOpacity : 1,
onClick: go
});
});
function go (data) {
$(".fancybox").fancybox();
};
</script>
<map name="leoweb" id="leoweb">
<area hex="1" class="fancybox" rel="image" title="hex" href="img/hex1.png" shape="poly" coords=" 463,73, 363,74, 305,160, 363,258, 462,255, 513,168, 465,76" />
<area hex="2" href="#" shape="poly" coords=" 579,196, 521,292, 578,384, 675,388, 733,294, 683,200, 585,198" />
<area hex="3" href="#" shape="poly" coords=" 243,202, 138,202, 86,293, 133,379, 245,382, 295,293, 251,206, 245,206" />
<area hex="4" href="#" shape="poly" coords=" 353,330, 304,419, 361,513, 461,508, 513,413, 461,324, 354,328" />
<area hex="5" href="#" shape="poly" coords=" 229,450, 142,451, 83,542, 133,638, 239,636, 296,538, 245,452, 239,450, 235,450, 233,450" />
<area hex="6" href="#" shape="poly" coords=" 453,575, 355,574, 303,664, 351,764, 460,765, 515,672, 459,577, 457,576" />
<area hex="7" href="#" shape="poly" coords=" 573,453, 521,550, 574,638, 681,638, 737,550, 685,450, 577,452" />
</map>
That one class="fancybox" business is my test region, the intent being that when I click on that region the image designated by the href opens in a fancybox popup.
If I omit everything from onClick on in the javascript, Imagemapster works fine. Currently, imagemapster does not work and the link functions, but just opens the image as if it were a regular link, no popup.
Any clues?