1/* ImageMapper Wordpress frontend script 2*/ 3var Image; 4var Canvas, Ctx; 5 6jQuery(function($) { 7 8 $('img[usemap]').each(function() { 9 var areas = []; 10 $('map[name="' + $(this).attr('usemap').substr(1) + '"]').find('area').each(function() { 11 areas.push({ 12 'key': $(this).attr('data-mapkey'), 13 'toolTip': $(this).attr('data-tooltip'), 14 'isSelectable': false, 15 'render_highlight': { 16 'fillColor': $(this).attr('data-fill-color'), 17 'fillOpacity': $(this).attr('data-fill-opacity'), 18 'strokeColor': $(this).attr('data-stroke-color'), 19 'strokeOpacity': $(this).attr('data-stroke-opacity'), 20 'stroke': $(this).attr('data-stroke-width') > 0, 21 'strokeWidth': $(this).attr('data-stroke-width'), 22 'fade': true, 23 'fadeDuration': 300 24 } 25 }); 26 }); 27 28 var map = this; 29 $(this).mapster({ 30 clickNavigate: true, 31 showToolTip: true, 32 toolTipContainer: $('<div class="imagemapper-tooltip"></div>'), 33 toolTipClose: ['area-click'], 34 mapKey: 'data-mapkey', 35 onClick: AreaClicked, 36 onMouseover: function(m) { 37 if(!m.options.toolTip.length) 38 $(map).mapster('tooltip', false); 39 40 clearTimeout($(map).data('mapster-highlight-timeout')); 41 $(map).mapster('highlight', false); 42 $(map).mapster('highlight', m.key); 43 }, 44 singleSelect: true, 45 render_select: { 46 fillOpacity: 0 47 }, 48 areas: areas 49 }); 50 51 // If pulse option is set, initialize it. 52 if(imgmap.pulseOption && imgmap.pulseOption != 'never') { 53 $(this).mouseenter(function(e) { 54 55 //Prevent pulse from happening when mouse moves on the image map from tooltip or area. (Prevent mouseenter from "inner" elements) 56 if($(e.fromElement).hasClass('imagemapper-tooltip') || $(e.fromElement).is('area')) 57 return; 58 59 //If this is set true, the pulse has been done already and Wordpress doesn't want to do it again. 60 if(!$(this).attr('data-first-mouseenter')) { 61 62 //Mark image map as "pulsed" if the first_time pulse option is set. 63 if(imgmap.pulseOption == 'first_time') 64 $(this).attr('data-first-mouseenter', true); 65 66 //Prevent duplicate highlights 67 $(this).mapster('highlight', false); 68 //Highlight all areas 69 for(var area in areas) { 70 $(this).mapster('highlight', areas[area].key); 71 } 72 73 var map = this; 74 75 // Stop highlighting after a short delay 76 // Also fade highlighted areas out rather than hide them instantly 77 clearTimeout($(this).data('mapster-highlight-timeout')); 78 $(this).data('mapster-highlight-timeout', setTimeout(function() { 79 $(map).closest('.imgmap-frontend-image').find('canvas').each(function() { 80 $(this).stop().animate({ opacity: 0 }, 300, function() { $(map).mapster('highlight', false); }); 81 }); 82 }, 500)); 83 } 84 }); 85 } 86 //Close tooltips when clicking outside the tooltip. 87 $('body').click(function(e) { 88 if(!$(e.target).is('.imagemapper-tooltip') && !$(e.target).closest('.imagemapper-tooltip').length && $(e.target).attr('data-type') != 'tooltip') 89 $(map).mapster('tooltip', false); 90 91 if(!$(e.target).is('.imgmap-dialog-alt') && !$(e.target).closest('.imgmap-dialog-alt').length) 92 $('.imgmap-dialog-alt').hide(200); 93 }); 94 }); 95 if(!imgmap.alt_dialog) { 96 if($().dialog) { 97 $('.imgmap-dialog-wrapper').dialog({ 98 autoOpen: false, 99 zIndex: 10000, 100 maxWidth: 700, 101 width: 'auto', 102 show: 300, 103 dialogClass: 'imgmap-dialog', 104 position: { 105 of: $(parent) 106 } 107 }); 108 $('body').click(function(e) { 109 if(!$(e.target).is('.ui-dialog, a') && !$(e.target).closest('.ui-dialog').length) 110 $('.imgmap-dialog-wrapper').each(function(e) { $(this).dialog('close'); }); 111 }); 112 } 113 else { 114 if($('area[data-type="popup"]').length) { 115 116 if(imgmap.admin_logged) { 117 var close = $('<a>'); 118 close.text('Close').css( { cursor: 'pointer', float: 'right', fontSize: '0.9em' }); 119 close.click(function() { $('.imgmap-dialog-wrapper').text(''); }); 120 121 $('.imgmap-dialog-wrapper'). 122 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.<br />This message is shown only to an admin. This message is shown because some of the image map areas on this page are using the popup functionality and thus not working properly."). 123 css({ color: 'red', padding: '5px', fontSize: '0.8em' }).append(close); 124 } 125 } 126 } 127 } 128 129 130 131 $('.alternative-links-imagemap'). 132 click(AlternativeLinkClicked). 133 mouseenter(function () { 134 var mapster = $($(this).attr('data-parent').replace('imgmap', '#imagemap')).get(0); 135 jQuery(mapster).mapster('highlight', false); 136 jQuery(mapster).mapster('highlight', $(this).attr('data-key')); 137 }). 138 mouseleave(function () { 139 var mapster = $($(this).attr('data-parent').replace('imgmap', '#imagemap')).get(0); 140 jQuery(mapster).mapster('highlight', false); 141 }); 142 143 $('.altlinks-toggle').click(function() { 144 $('#altlinks-container-' + $(this).attr('data-parent')).toggle(200); 145 }); 146 147}); 148 149 150 151function AlternativeLinkClicked() { 152 var key = jQuery(this).attr('data-key'); 153 var type = jQuery(this).attr('data-type'); 154 var parent = jQuery(this).attr('data-parent'); 155 AlternativeLinkAction(key, type, parent); 156} 157 158function AlternativeLinkAction(areaKey, areaType, imagemap) { 159 switch(areaType) { 160 case 'popup': 161 OpenImgmapDialog(areaKey, jQuery('map[name="' + imagemap + '"]').get(0)); 162 break; 163 164 case 'tooltip': 165 imagemap = jQuery('img[usemap="#' + imagemap + '"]').get(0); 166 jQuery(imagemap).mapster('tooltip', areaKey); 167 break; 168 } 169} 170 171function AreaClicked(data) { 172 var type = jQuery('area[data-mapKey='+data.key+']').attr('data-type'); 173 if(type == 'popup' || type == '' ) { 174 OpenImgmapDialog(data.key, jQuery(this).parent()[0]); 175 } 176} 177 178function OpenImgmapDialog(key, parent) { 179 var image = jQuery('#' + parent.name.replace('imgmap', 'imagemap')); 180 var dialog = parent.name.replace('imgmap', '#imgmap-dialog'); 181 182 jQuery.post(imgmap.ajaxurl, { 183 action: 'imgmap_load_dialog_post', 184 id: key.replace('area-', '') 185 }, function(response) { 186 if(response.length <= 0) return; 187 if(!imgmap.alt_dialog) { 188 jQuery(dialog).dialog('option', 'title', jQuery('area[data-mapkey='+key+']').attr('title'));
189 jQuery(dialog).html(response).dialog('open'); 190 } else { 191 192 // Some ugly quick bug-fixing code 193 // Sometimes it's needed since everything does not always make sense. Or at least seem to do. 194 195 // Resets the element 196 // Without this centering the element doesn't work well 197 jQuery(dialog).replaceWith('<div class="imgmap-dialog-wrapper" id="' + dialog.replace('#','') + '" style="visibility:hidden"></div>').hide(0); 198 199 jQuery(dialog).addClass('imgmap-dialog-alt').html(response); 200 setTimeout(function() { 201 jQuery(dialog).position({ 202 my: 'center', 203 at: 'center', 204 of: image 205 }). 206 hide(). 207 css({visibility:'visible'}). 208 show(200); 209 }, 0); 210 211 212 } 213 }); 214} 215
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.