/* ImageMapper Wordpress frontend script */ var Image; var Canvas, Ctx; jQuery(function($) { $('img[usemap]').each(function() { var areas = []; $('map[name="' + $(this).attr('usemap').substr(1) + '"]').find('area').each(function() { areas.push({ 'key': $(this).attr('data-mapkey'), 'toolTip': $(this).attr('data-tooltip'), 'isSelectable': false, 'render_highlight': { 'fillColor': $(this).attr('data-fill-color'), 'fillOpacity': $(this).attr('data-fill-opacity'), 'strokeColor': $(this).attr('data-stroke-color'), 'strokeOpacity': $(this).attr('data-stroke-opacity'), 'stroke': $(this).attr('data-stroke-width') > 0, 'strokeWidth': $(this).attr('data-stroke-width'), 'fade': true, 'fadeDuration': 300 } }); }); var map = this; $(this).mapster({ clickNavigate: true, showToolTip: true, toolTipContainer: $('
'), toolTipClose: ['area-click'], mapKey: 'data-mapkey', onClick: AreaClicked, onMouseover: function(m) { if(!m.options.toolTip.length) $(map).mapster('tooltip', false); clearTimeout($(map).data('mapster-highlight-timeout')); $(map).mapster('highlight', false); $(map).mapster('highlight', m.key); }, singleSelect: true, render_select: { fillOpacity: 0 }, areas: areas }); // If pulse option is set, initialize it. if(imgmap.pulseOption && imgmap.pulseOption != 'never') { $(this).mouseenter(function(e) { //Prevent pulse from happening when mouse moves on the image map from tooltip or area. (Prevent mouseenter from "inner" elements) if($(e.fromElement).hasClass('imagemapper-tooltip') || $(e.fromElement).is('area')) return; //If this is set true, the pulse has been done already and Wordpress doesn't want to do it again. if(!$(this).attr('data-first-mouseenter')) { //Mark image map as "pulsed" if the first_time pulse option is set. if(imgmap.pulseOption == 'first_time') $(this).attr('data-first-mouseenter', true); //Prevent duplicate highlights $(this).mapster('highlight', false); //Highlight all areas for(var area in areas) { $(this).mapster('highlight', areas[area].key); } var map = this; // Stop highlighting after a short delay // Also fade highlighted areas out rather than hide them instantly clearTimeout($(this).data('mapster-highlight-timeout')); $(this).data('mapster-highlight-timeout', setTimeout(function() { $(map).closest('.imgmap-frontend-image').find('canvas').each(function() { $(this).stop().animate({ opacity: 0 }, 300, function() { $(map).mapster('highlight', false); }); }); }, 500)); } }); } //Close tooltips when clicking outside the tooltip. $('body').click(function(e) { if(!$(e.target).is('.imagemapper-tooltip') && !$(e.target).closest('.imagemapper-tooltip').length && $(e.target).attr('data-type') != 'tooltip') $(map).mapster('tooltip', false); if(!$(e.target).is('.imgmap-dialog-alt') && !$(e.target).closest('.imgmap-dialog-alt').length) $('.imgmap-dialog-alt').hide(200); }); }); if(!imgmap.alt_dialog) { if($().dialog) { $('.imgmap-dialog-wrapper').dialog({ autoOpen: false, zIndex: 10000, maxWidth: 700, width: 'auto', show: 300, dialogClass: 'imgmap-dialog', position: { of: $(parent) } }); $('body').click(function(e) { if(!$(e.target).is('.ui-dialog, a') && !$(e.target).closest('.ui-dialog').length) $('.imgmap-dialog-wrapper').each(function(e) { $(this).dialog('close'); }); }); } else { if($('area[data-type="popup"]').length) { if(imgmap.admin_logged) { var close = $(''); close.text('Close').css( { cursor: 'pointer', float: 'right', fontSize: '0.9em' }); close.click(function() { $('.imgmap-dialog-wrapper').text(''); }); $('.imgmap-dialog-wrapper'). html("There was a problem loading jQuery UI Dialog widget. A plugin or a theme you're using might be including its own copy of jQuery library which causes conflict with the copy included in Wordpress. Because of this ImageMapper isn't able to use jQuery UI Dialog widget causing the popup window function incorrectly or not at all.