diff --git a/CHANGELOG.md b/CHANGELOG.md index e8c65ee..c3882ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,19 @@ - Make callback data structures consistent - Improve docs +## Version 1.7.0 - 2024.04.28 + +- [Issue 138](https://github.com/jamietre/ImageMapster/issues/138) 📘 Docs incorrectly state that highlighting will be disabled when staticState option is specified +- [Issue 228](https://github.com/jamietre/ImageMapster/issues/228) 📘 onClick event will not fire if `clickNavigate` is set to `true` +- [Issue 322](https://github.com/jamietre/ImageMapster/issues/322) 📘 Migrate website to github +- [Issue 382](https://github.com/jamietre/ImageMapster/issues/382) 📘 rebind docs are not correct regarding preserving selected state +- [Issue 408](https://github.com/jamietre/ImageMapster/issues/408) 🐞 navigate example pages are unresponsive +- [Issue 410](https://github.com/jamietre/ImageMapster/issues/410) 🐞 grunt docco task failing with Fatal error: marked is not a function +- [Issue 412](https://github.com/jamietre/ImageMapster/issues/412) ✨ Improve ability to run tests with all supported libraries & versions +- [Issue 414](https://github.com/jamietre/ImageMapster/issues/414) 🐞 configTimeout not respected for value specified +- [Issue 415](https://github.com/jamietre/ImageMapster/issues/415) ✨ Add ESM support +- [Issue 418](https://github.com/jamietre/ImageMapster/issues/418) 🐞 fadeDuration specified in area options is not honored for tooltips + ## Version 1.6.0 - 2024.03.12 - [Issue 394](https://github.com/jamietre/ImageMapster/issues/394) \[TouchScreen only] Weird highlight glitch when touch on the other area beside the map. diff --git a/README.md b/README.md index 43d2f99..d3e62e9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ImageMapster activates the areas in HTML image maps so you can highlight and sel ## Documentation -Available on the [ImageMapster Website](https://jamietre.github.io/ImageMapster). +See the [ImageMapster website](https://jamietre.github.io/ImageMapster) for full documentation including [how to get started](https://jamietre.github.io/ImageMapster/overview/getting-started/), [demos](https://jamietre.github.io/ImageMapster/overview/demos/), and [live examples](https://jamietre.github.io/ImageMapster/resources/live-examples/). ## Release Information diff --git a/bower.json b/bower.json index 4684a85..8d4347c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ImageMapster", - "version": "1.6.0", + "version": "1.7.0", "homepage": "https://jamietre.github.io/ImageMapster", "description": "jQuery plugin that activates areas in HTML image maps with support for highlighting, selecting, tooltips, resizing and more", "main": "dist/jquery.imagemapster.min.js", diff --git a/dist/jquery.imagemapster.js b/dist/jquery.imagemapster.js index 2a5043e..ebe02b4 100644 --- a/dist/jquery.imagemapster.js +++ b/dist/jquery.imagemapster.js @@ -1,6 +1,6 @@ /*! -* imagemapster - v1.6.0 - 2024-04-05 -* https://github.com/jamietre/ImageMapster/ +* imagemapster - v1.7.0 - 2024-04-29 +* https://jamietre.github.io/ImageMapster * Copyright (c) 2011 - 2024 James Treworgy * License: MIT */ @@ -106,7 +106,7 @@ (function ($) { 'use strict'; - var mapster_version = '1.6.0'; + var mapster_version = '1.7.0'; // all public functions in $.mapster.impl are methods $.fn.mapster = function (method) { @@ -139,7 +139,8 @@ includeKeys: '', altImage: null, altImageId: null, // used internally - altImages: {} + altImages: {}, + altImageOpacity: null }, defaults: { clickNavigate: false, @@ -148,7 +149,7 @@ wrapCss: null, onGetList: null, sortList: false, - listenToList: false, + // listenToList: false, // not used - see mapdata.js line 1002 mapKey: '', mapValue: '', singleSelect: false, @@ -170,7 +171,6 @@ autoResizeDelay: 0, autoResizeDuration: 0, onAutoResize: null, - safeLoad: false, areas: [] }, shared_defaults: { @@ -357,6 +357,9 @@ isFunction: function (obj) { return typeof obj === 'function'; }, + isNumeric: function (obj) { + return !isNaN(parseFloat(obj)); + }, // evaluates "obj", if function, calls it with args // (todo - update this to handle variable lenght/more than one arg) ifFunction: function (obj, that, args) { @@ -571,7 +574,7 @@ * invoked on an image, or an area; then queues the command if the MapData is in an active state. * * @param {[jQuery]} that The target of the invocation - * @param {[function]} func_map The callback if the target is an imagemap + * @param {[function]} func_map The callback if the target is an image map * @param {[function]} func_area The callback if the target is an area * @param {[object]} opt Options: { key: a map key if passed explicitly * name: the command name, if it can be queued, @@ -1203,11 +1206,11 @@ }; return me; })(); - + console.log('foo3456'); $.mapster.impl.init(); })(jQuery); -/* +/* graphics.js Graphics object handles all rendering. */ @@ -1758,9 +1761,9 @@ ); })(jQuery); -/* +/* mapimage.js - The MapImage object, repesents an instance of a single bound imagemap + The MapImage object, repesents an instance of a single bound image map */ (function ($) { @@ -1768,7 +1771,8 @@ var m = $.mapster, u = m.utils, - ap = []; + ap = [], + configCheckInterval = 50; /** * An object encapsulating all the images used by a MapData. */ @@ -1927,7 +1931,7 @@ bind: function () { var me = this, promise, - triesLeft = me.owner.options.configTimeout / 200, + triesLeft = me.owner.options.configTimeout / configCheckInterval, /* A recursive function to continue checking that the images have been loaded until a timeout has elapsed */ @@ -1953,7 +1957,7 @@ if (triesLeft-- > 0) { me.imgTimeout = window.setTimeout(function () { check.call(me, true); - }, 50); + }, configCheckInterval); } else { me.imageLoadError.call(me); } @@ -2039,7 +2043,7 @@ /* mapdata.js - The MapData object, repesents an instance of a single bound imagemap + The MapData object, repesents an instance of a single bound image map */ (function ($) { @@ -2809,7 +2813,7 @@ me.wrapper = wrap; // me.images[1] is the copy of the original image. It should be loaded & at its native size now so we can obtain the true - // width & height. This is needed to scale the imagemap if not being shown at its native size. It is also needed purely + // width & height. This is needed to scale the image map if not being shown at its native size. It is also needed purely // to finish binding in case the original image was not visible. It can be impossible in some browsers to obtain the // native size of a hidden image. @@ -2900,7 +2904,7 @@ $img = $(me.image), opts = me.options; - if (opts.onConfigured && typeof opts.onConfigured === 'function') { + if (u.isFunction(opts.onConfigured)) { opts.onConfigured.call($img, true); } }, @@ -3505,7 +3509,7 @@ /** * Compute positions that will place a target with dimensions [width,height] outside - * but near the boundaries of the elements "elements". When an imagemap is passed, the + * but near the boundaries of the elements "elements". When an image map is passed, the * * @param {Element|Element[]} elements An element or an array of elements (such as a jQuery object) * @param {Element} image The image to which area elements are bound, if this is an image map. @@ -3682,7 +3686,7 @@ }; })(jQuery); -/* +/* scale.js Resize and zoom functionality Requires areacorners.js @@ -3737,7 +3741,7 @@ /** * Resize the image map. Only one of newWidth and newHeight should be passed to preserve scale * - * @param {int} width The new width OR an object containing named parameters matching this function sig + * @param {int} width The new width * @param {int} height The new height * @param {int} effectDuration Time in ms for the resize animation, or zero for no animation * @param {function} callback A function to invoke when the operation finishes @@ -4073,7 +4077,7 @@ */ })(jQuery); -/* +/* tooltip.js Tooltip functionality Requires areacorners.js @@ -4348,7 +4352,7 @@ options.fadeDuration = options.fadeDuration || (md.options.toolTipFade - ? md.options.fadeDuration || areaOpts.fadeDuration + ? u.isNumeric(areaOpts.fadeDuration) ? areaOpts.fadeDuration : md.options.fadeDuration : 0); target = ad.area diff --git a/dist/jquery.imagemapster.min.js b/dist/jquery.imagemapster.min.js index 320217e..c57c05f 100644 --- a/dist/jquery.imagemapster.min.js +++ b/dist/jquery.imagemapster.min.js @@ -1,8 +1,8 @@ /*! -* imagemapster - v1.6.0 - 2024-04-05 -* https://github.com/jamietre/ImageMapster/ +* imagemapster - v1.7.0 - 2024-04-29 +* https://jamietre.github.io/ImageMapster * Copyright (c) 2011 - 2024 James Treworgy * License: MIT */ -!function(i){"function"==typeof define&&define.amd?define(["jquery"],i):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),i(t),t}:i(jQuery)}(function(jQuery){!function(e){"use strict";if(e.event&&e.event.special){var a,t=!1;try{var i=Object.defineProperty({},"passive",{get:function(){return t=!0}});window.addEventListener("testPassive.mapster",function(){},i),window.removeEventListener("testPassive.mapster",function(){},i)}catch(e){}t&&(a=function(e,t,i){if(!e.includes("mapster")||!e.includes("noPreventDefault"))return!1;this.addEventListener(t,i,{passive:!0})},e.event.special.touchstart={setup:function(e,t,i){return a.call(this,t,"touchstart",i)}},e.event.special.touchend={setup:function(e,t,i){return a.call(this,t,"touchend",i)}})}}(jQuery),!function($){"use strict";var mapster_version="1.6.0",m=($.fn.mapster=function(e){var t=$.mapster.impl;return $.mapster.utils.isFunction(t[e])?t[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?void $.error("Method "+e+" does not exist on jQuery.mapster"):t.bind.apply(this,arguments)},$.mapster={version:mapster_version,render_defaults:{isSelectable:!0,isDeselectable:!0,fade:!1,fadeDuration:150,fill:!0,fillColor:"000000",fillColorMask:"FFFFFF",fillOpacity:.7,highlight:!0,stroke:!1,strokeColor:"ff0000",strokeOpacity:1,strokeWidth:1,includeKeys:"",altImage:null,altImageId:null,altImages:{}},defaults:{clickNavigate:!1,navigateMode:"location",wrapClass:null,wrapCss:null,onGetList:null,sortList:!1,listenToList:!1,mapKey:"",mapValue:"",singleSelect:!1,listKey:"value",listSelectedAttribute:"selected",listSelectedClass:null,onClick:null,onMouseover:null,onMouseout:null,mouseoutDelay:0,onStateChange:null,boundList:null,onConfigured:null,configTimeout:3e4,noHrefIsMask:!0,scaleMap:!0,enableAutoResizeSupport:!1,autoResize:!1,autoResizeDelay:0,autoResizeDuration:0,onAutoResize:null,safeLoad:!1,areas:[]},shared_defaults:{render_highlight:{fade:!0},render_select:{fade:!1},staticState:null,selected:null},area_defaults:{includeKeys:"",isMask:!1},canvas_style:{position:"absolute",left:0,top:0,padding:0,border:0},hasCanvas:null,map_cache:[],hooks:{},addHook:function(e,t){this.hooks[e]=(this.hooks[e]||[]).push(t)},callHooks:function(e,i){$.each(this.hooks[e]||[],function(e,t){t.apply(i)})},utils:{when:{all:function(e){return Promise.all(e)},defer:function(){return new function(){this.promise=new Promise(function(e,t){this.resolve=e,this.reject=t}.bind(this)),this.then=this.promise.then.bind(this.promise),this.catch=this.promise.catch.bind(this.promise)}}},defer:function(){return this.when.defer()},subclass:function(i,a){function e(){var e=this,t=Array.prototype.slice.call(arguments,0);e.base=i.prototype,e.base.init=function(){i.prototype.constructor.apply(e,t)},a.apply(e,t)}return(e.prototype=new i).constructor=e},asArray:function(e){return e.constructor===Array?e:this.split(e)},split:function(e,t){for(var i,a=e.split(","),n=0;n=e.index;t--)m.map_cache[t].index--};function hasVml(){var e=$("
").appendTo("body"),t=(e.html(''),e[0].firstChild),t=(t.style.behavior="url(#default#VML)",!t||"object"==typeof t.adj);return e.remove(),t}function namespaces(){return"object"==typeof document.namespaces?document.namespaces:null}function hasCanvas(){var e=namespaces();return!(e&&e.g_vml_||!$("")[0].getContext)}function merge_areas(i,e){var a,n=i.options.areas;e&&$.each(e,function(e,t){t&&t.key&&(0<=(a=u.indexOfProp(n,"key",t.key))?$.extend(n[a],t):n.push(t),a=i.getDataForKey(t.key))&&$.extend(a.options,t)})}function merge_options(e,t){var i=u.updateProps({},t);delete i.areas,u.updateProps(e.options,i),merge_areas(e,t.areas),u.updateProps(e.area_options,e.options)}return me.get=function(e){var t=m.getMapData(this);if(t&&t.complete)return new m.Method(this,function(){return this.getSelected()},function(){return this.isSelected()},{name:"get",args:arguments,key:e,first:!0,allowAsync:!0,defaultReturn:""}).go();throw"Can't access data until binding complete."},me.data=function(e){return new m.Method(this,null,function(){return this},{name:"data",args:arguments,key:e}).go()},me.highlight=function(t){return new m.Method(this,function(){var e;if(!1!==t)return 0<=(e=this.highlightId)?this.data[e].key:null;this.ensureNoHighlight()},function(){this.highlight()},{name:"highlight",args:arguments,key:t,first:!0}).go()},me.keys=function(e,a){var n=[],i=m.getMapData(this);if(i&&i.complete)return i&&i.complete?("string"==typeof e?a?o(i.getDataForKey(e)):n=[i.getKeysForGroup(e)]:(a=e,this.each(function(e,t){"AREA"===t.nodeName&&o(i.getDataForArea(t))})),n.join(",")):"";throw"Can't access data until binding complete.";function o(e){var t,i=[];a?(t=e.areas(),$.each(t,function(e,t){i=i.concat(t.keys)})):i.push(e.key),$.each(i,function(e,t){$.inArray(t,n)<0&&n.push(t)})}},me.select=function(){me.set.call(this,!0)},me.deselect=function(){me.set.call(this,!1)},me.set=function(a,n,e){var o,s,r,c,l=e;function h(e){e&&$.inArray(e,c)<0&&(c.push(e),r+=(""===r?"":",")+e.key)}function p(e){$.each(c,function(e,t){var i=t;if(i)switch(a){case!0:i.select(l);break;case!1:i.deselect(!0);break;default:i.toggle(l)}}),a||e.removeSelectionFinish()}return this.filter("img,area").each(function(e,t){var i;(s=m.getMapData(t))!==o&&(o&&p(o),c=[],r=""),s&&(i="","IMG"===t.nodeName.toUpperCase()?m.queueCommand(s,$(t),"set",[a,n,l])||(n instanceof Array?n.length&&(i=n.join(",")):i=n,i&&$.each(u.split(i),function(e,t){h(s.getDataForKey(t.toString())),o=s})):(l=n,m.queueCommand(s,$(t),"set",[a,l])||(h(s.getDataForArea(t)),o=s)))}),s&&p(s),this},me.unbind=function(e){return new m.Method(this,function(){this.clearEvents(),this.clearMapData(e),removeMap(this)},null,{name:"unbind",args:arguments}).go()},me.rebind=function(t){return new m.Method(this,function(){var e=this;e.complete=!1,e.configureOptions(t),e.bindImages().then(function(){e.buildDataset(!0),e.complete=!0,e.onConfigured()})},null,{name:"rebind",args:arguments}).go()},me.get_options=function(e,t){var i=u.isBool(e)?e:t;return new m.Method(this,function(){var e=$.extend({},this.options);return i&&(e.render_select=u.updateProps({},m.render_defaults,e,e.render_select),e.render_highlight=u.updateProps({},m.render_defaults,e,e.render_highlight)),e},function(){return i?this.effectiveOptions():this.options},{name:"get_options",args:arguments,first:!0,allowAsync:!0,key:e}).go()},me.set_options=function(e){return new m.Method(this,function(){merge_options(this,e)},null,{name:"set_options",args:arguments}).go()},me.unload=function(){for(var e=m.map_cache.length-1;0<=e;e--)m.map_cache[e]&&me.unbind.call($(m.map_cache[e].image));me.graphics=null},me.snapshot=function(){return new m.Method(this,function(){$.each(this.data,function(e,t){t.selected=!1}),this.base_canvas=this.graphics.createVisibleCanvas(this),$(this.image).before(this.base_canvas)},null,{name:"snapshot"}).go()},me.state=function(){var i,a=null;return $(this).each(function(e,t){if("IMG"===t.nodeName)return(i=m.getMapData(t))&&(a=i.state()),!1}),a},me.bind=function(o){return this.each(function(e,t){var i,a=$(t),n=m.getMapData(t);if(n){if(me.unbind.apply(a),!n.complete)return!0;n=null}if(i=(t=this.getAttribute("usemap"))&&$('map[name="'+t.substr(1)+'"]'),!(a.is("img")&&t&&0')[0]},clearHighlight:function(){var e=this.map_data.overlay_canvas;e.getContext("2d").clearRect(0,0,e.width,e.height)},refreshSelections:function(){var e=this.map_data,t=e.base_canvas;e.base_canvas=this.createVisibleCanvas(e),h(e.base_canvas).hide(),h(t).before(e.base_canvas),e.redrawSelections(),h(e.base_canvas).show(),h(t).remove()}},o={renderShape:function(e,t,i){var a,n=this,o=e.coords(),s=n.elementName?'name="'+n.elementName+'" ':"",r=i?'class="'+i+'" ':"",c='',l=t.stroke?" strokeweight="+t.strokeWidth+' stroked="t" strokecolor="#'+t.strokeColor+'"':' stroked="f"',u=t.fill?' filled="t"':' filled="f"';switch(e.shape){case"rect":case"rectangle":a="'+c+"";break;case"poly":case"polygon":a="'+c+"";break;case"circ":case"circle":a="'+c+""}return i=h(a),h(n.canvas).append(i),i},render:function(){var i,a=this;return h.each(this.shapes,function(e,t){a.renderShape(t.mapArea,t.options)}),this.masks.length&&h.each(this.masks,function(e,t){i=c.updateProps({},t.options,{fillOpacity:1,fillColor:t.options.fillColorMask}),a.renderShape(t.mapArea,i,"mapster_mask")}),this.active=!1,this.canvas},createCanvasFor:function(e){var t=e.scaleInfo.width,e=e.scaleInfo.height;return h('')[0]},clearHighlight:function(){h(this.map_data.overlay_canvas).children().remove()},removeSelections:function(e){(0<=e?h(this.map_data.base_canvas).find('[name="static_'+e.toString()+'"]'):h(this.map_data.base_canvas).children()).remove()}},h.each(["renderShape","addAltImage","render","createCanvasFor","clearHighlight","removeSelections","refreshSelections"],function(e,t){var i;a[t]=(i=t,function(){return a[i]=(r.hasCanvas()?n:o)[i]||s,a[i].apply(this,arguments)})})}(jQuery),!function(o){"use strict";var e=o.mapster,n=e.utils,t=[];e.MapImages=function(e){this.owner=e,this.clear()},e.MapImages.prototype={constructor:e.MapImages,slice:function(){return t.slice.apply(this,arguments)},splice:function(){return t.slice.apply(this.status,arguments),t.slice.apply(this,arguments)},complete:function(){return o.inArray(!1,this.status)<0},_add:function(e){e=t.push.call(this,e)-1;return this.status[e]=!1,e},indexOf:function(e){return n.indexOf(this,e)},clear:function(){var i=this;i.ids&&0").addClass("mapster_el").hide(),i=n._add(e[0]),e.on("load.mapster",function(e){n.imageLoaded.call(n,e)}).on("error.mapster",function(e){n.imageLoadError.call(n,e)}),e.attr("src",a)}else i=n._add(o(e)[0]);if(t){if(this[t])throw t+" is already used or is not available as an altImage alias.";n.ids.push(t),n[t]=n[i]}return i}},bind:function(){var t=this,i=t.owner.options.configTimeout/200,a=function(){for(var e=t.length;0
'),l.wrapClass&&(!0===l.wrapClass?i.addClass(s[0].className):i.addClass(l.wrapClass))),c.wrapper=i,c.scaleInfo=r=d.scaleMap(c.images[0],c.images[1],l.scaleMap),c.base_canvas=e=c.graphics.createVisibleCanvas(c),c.overlay_canvas=t=c.graphics.createVisibleCanvas(c),a=y(c.images[1]).addClass("mapster_el "+c.images[0].className).attr({id:null,usemap:null}),(o=d.size(c.images[0])).complete&&a.css({width:o.width,height:o.height}),c.buildDataset(),a=y.extend({display:"block",position:"relative",padding:0},!0===l.enableAutoResizeSupport?{}:{width:r.width,height:r.height}),l.wrapCss&&y.extend(a,l.wrapCss),s.parent()[0]!==c.wrapper[0]&&s.before(c.wrapper),i.css(a),y(c.images.slice(2)).hide(),n=1;nw&&t[1]>b)return v=t,!(s=!0)}),s||(v=[l,u])),v}}(jQuery),!function(d){"use strict";var f=d.mapster,m=f.utils,e=f.MapArea.prototype;f.utils.getScaleInfo=function(e,t){var i;return t?.98<(i=e.width/t.width||e.height/t.height)&&i<1.02&&(i=1):(i=1,t=e),{scale:1!==i,scalePct:i,realWidth:t.width,realHeight:t.height,width:e.width,height:e.height,ratio:e.width/e.height}},f.utils.scaleMap=function(e,t,i){e=m.size(e),t=m.size(t,!0);if(t.complete())return e.complete()||(e=t),this.getScaleInfo(e,i?t:null);throw"Another script, such as an extension, appears to be interfering with image loading. Please let us know about this."},f.MapData.prototype.resize=function(t,i,a,n){var o,s,r,c,e,l=this;function u(e,t,i){f.hasCanvas()?(e.width=t,e.height=i):(d(e).width(t),d(e).height(i))}function h(){var e;u(l.overlay_canvas,t,i),0<=c&&((e=l.data[c]).tempOptions={fade:!1},l.getDataForKey(e.key).highlight(),e.tempOptions=null),u(l.base_canvas,t,i),l.redrawSelections(),l.currentAction="",m.isFunction(n)&&n(),l.processCommandQueue()}function p(){d(l.image).css(r),l.scaleInfo=m.getScaleInfo({width:t,height:i},{width:l.scaleInfo.realWidth,height:l.scaleInfo.realHeight}),d.each(l.data,function(e,t){d.each(t.areas(),function(e,t){t.resize()})})}n=n||a,l.scaleInfo.width===t&&l.scaleInfo.height===i||(c=l.highlightId,t||(e=i/l.scaleInfo.realHeight,t=Math.round(l.scaleInfo.realWidth*e)),i||(e=t/l.scaleInfo.realWidth,i=Math.round(l.scaleInfo.realHeight*e)),r={width:String(t)+"px",height:String(i)+"px"},f.hasCanvas()||d(l.base_canvas).children().remove(),e=d(l.wrapper).find(".mapster_el"),!0!==l.options.enableAutoResizeSupport&&(e=e.add(l.wrapper)),a?(s=[],l.currentAction="resizing",e.filter(":visible").each(function(e,t){o=m.defer(),s.push(o),d(t).animate(r,{duration:a,complete:o.resolve,easing:"linear"})}),e.filter(":hidden").css(r),o=m.defer(),s.push(o),m.when.all(s).then(h),p(),o.resolve()):(e.css(r),p(),h()))},f.MapData.prototype.autoResize=function(e,t){this.resize(d(this.wrapper).width(),null,e,t)},f.MapData.prototype.configureAutoResize=function(){var e=this,t=e.instanceEventNamespace();function i(){!0===e.options.autoResize&&e.autoResize(e.options.autoResizeDuration,e.options.onAutoResize)}d(e.image).on("load"+t,i),d(window).on("focus"+t,i),d(window).on("resize"+t,function(){e.autoResizeTimer&&clearTimeout(e.autoResizeTimer),e.autoResizeTimer=setTimeout(i,e.options.autoResizeDelay)}),d(window).on("readystatechange"+t,i),d(window.document).on("fullscreenchange"+t,i),i()},f.MapArea=m.subclass(f.MapArea,function(){this.base.init(),this.owner.scaleInfo.scale&&this.resize()}),e.coords=function(e,t){var i,a=[],n=e||this.owner.scaleInfo.scalePct,o=t||0;if(1===n&&0===t)return this.originalCoords;for(i=0;i',showToolTip:!1,toolTip:null,toolTipFade:!0,toolTipClose:["area-mouseout","image-mouseout","generic-mouseout"],onShowToolTip:null,onHideToolTip:null}),c.extend(e.area_defaults,{toolTip:null,toolTipClose:null}),e.MapData.prototype.clearToolTip=function(){this.activeToolTip&&(this.activeToolTip.stop().remove(),this.activeToolTip=null,this.activeToolTipID=null,l.ifFunction(this.options.onHideToolTip,this))},e.AreaData.prototype.showToolTip=function(e,t){var i,a,n,o=this,s=o.owner,r=o.effectiveOptions();if(t=t?c.extend({},t):{},e=e||r.toolTip,i=t.closeEvents||r.toolTipClose||s.options.toolTipClose||"tooltip-click",n=void 0!==t.template?t.template:s.options.toolTipContainer,t.closeEvents="string"==typeof i?i=l.split(i):i,t.fadeDuration=t.fadeDuration||(s.options.toolTipFade?s.options.fadeDuration||r.fadeDuration:0),a=o.area||c.map(o.areas(),function(e){return e.area}),s.activeToolTipID!==o.areaId){s.clearToolTip();var e=l.isFunction(e)?e({key:this.key,target:a}):e;if(e)return s.activeToolTip=e=u(e,n,t.css),s.activeToolTipID=o.areaId,n=function(){s.clearToolTip()},h(i,"area-click","click",c(s.map),null,n),h(i,"tooltip-click","click",e,null,n),h(i,"image-mouseout","mouseout",c(s.image),function(e){return e.relatedTarget&&"AREA"!==e.relatedTarget.nodeName&&e.relatedTarget!==o.area},n),h(i,"image-click","click",c(s.image),null,n),p(e,a,s.image,t.container,t),l.ifFunction(s.options.onShowToolTip,o.area,{toolTip:e,options:{},areaOptions:r,key:o.key,selected:o.isSelected()}),e}},e.impl.tooltip=function(s,r){return new e.Method(this,function(){var e,t,i,a,n,o=this;s?(n=(e=c(s))&&0=e.index;t--)m.map_cache[t].index--};function hasVml(){var e=$("
").appendTo("body"),t=(e.html(''),e[0].firstChild),t=(t.style.behavior="url(#default#VML)",!t||"object"==typeof t.adj);return e.remove(),t}function namespaces(){return"object"==typeof document.namespaces?document.namespaces:null}function hasCanvas(){var e=namespaces();return!(e&&e.g_vml_||!$("")[0].getContext)}function merge_areas(i,e){var a,n=i.options.areas;e&&$.each(e,function(e,t){t&&t.key&&(0<=(a=u.indexOfProp(n,"key",t.key))?$.extend(n[a],t):n.push(t),a=i.getDataForKey(t.key))&&$.extend(a.options,t)})}function merge_options(e,t){var i=u.updateProps({},t);delete i.areas,u.updateProps(e.options,i),merge_areas(e,t.areas),u.updateProps(e.area_options,e.options)}return me.get=function(e){var t=m.getMapData(this);if(t&&t.complete)return new m.Method(this,function(){return this.getSelected()},function(){return this.isSelected()},{name:"get",args:arguments,key:e,first:!0,allowAsync:!0,defaultReturn:""}).go();throw"Can't access data until binding complete."},me.data=function(e){return new m.Method(this,null,function(){return this},{name:"data",args:arguments,key:e}).go()},me.highlight=function(t){return new m.Method(this,function(){var e;if(!1!==t)return 0<=(e=this.highlightId)?this.data[e].key:null;this.ensureNoHighlight()},function(){this.highlight()},{name:"highlight",args:arguments,key:t,first:!0}).go()},me.keys=function(e,a){var n=[],i=m.getMapData(this);if(i&&i.complete)return i&&i.complete?("string"==typeof e?a?o(i.getDataForKey(e)):n=[i.getKeysForGroup(e)]:(a=e,this.each(function(e,t){"AREA"===t.nodeName&&o(i.getDataForArea(t))})),n.join(",")):"";throw"Can't access data until binding complete.";function o(e){var t,i=[];a?(t=e.areas(),$.each(t,function(e,t){i=i.concat(t.keys)})):i.push(e.key),$.each(i,function(e,t){$.inArray(t,n)<0&&n.push(t)})}},me.select=function(){me.set.call(this,!0)},me.deselect=function(){me.set.call(this,!1)},me.set=function(a,n,e){var o,s,r,c,l=e;function h(e){e&&$.inArray(e,c)<0&&(c.push(e),r+=(""===r?"":",")+e.key)}function p(e){$.each(c,function(e,t){var i=t;if(i)switch(a){case!0:i.select(l);break;case!1:i.deselect(!0);break;default:i.toggle(l)}}),a||e.removeSelectionFinish()}return this.filter("img,area").each(function(e,t){var i;(s=m.getMapData(t))!==o&&(o&&p(o),c=[],r=""),s&&(i="","IMG"===t.nodeName.toUpperCase()?m.queueCommand(s,$(t),"set",[a,n,l])||(n instanceof Array?n.length&&(i=n.join(",")):i=n,i&&$.each(u.split(i),function(e,t){h(s.getDataForKey(t.toString())),o=s})):(l=n,m.queueCommand(s,$(t),"set",[a,l])||(h(s.getDataForArea(t)),o=s)))}),s&&p(s),this},me.unbind=function(e){return new m.Method(this,function(){this.clearEvents(),this.clearMapData(e),removeMap(this)},null,{name:"unbind",args:arguments}).go()},me.rebind=function(t){return new m.Method(this,function(){var e=this;e.complete=!1,e.configureOptions(t),e.bindImages().then(function(){e.buildDataset(!0),e.complete=!0,e.onConfigured()})},null,{name:"rebind",args:arguments}).go()},me.get_options=function(e,t){var i=u.isBool(e)?e:t;return new m.Method(this,function(){var e=$.extend({},this.options);return i&&(e.render_select=u.updateProps({},m.render_defaults,e,e.render_select),e.render_highlight=u.updateProps({},m.render_defaults,e,e.render_highlight)),e},function(){return i?this.effectiveOptions():this.options},{name:"get_options",args:arguments,first:!0,allowAsync:!0,key:e}).go()},me.set_options=function(e){return new m.Method(this,function(){merge_options(this,e)},null,{name:"set_options",args:arguments}).go()},me.unload=function(){for(var e=m.map_cache.length-1;0<=e;e--)m.map_cache[e]&&me.unbind.call($(m.map_cache[e].image));me.graphics=null},me.snapshot=function(){return new m.Method(this,function(){$.each(this.data,function(e,t){t.selected=!1}),this.base_canvas=this.graphics.createVisibleCanvas(this),$(this.image).before(this.base_canvas)},null,{name:"snapshot"}).go()},me.state=function(){var i,a=null;return $(this).each(function(e,t){if("IMG"===t.nodeName)return(i=m.getMapData(t))&&(a=i.state()),!1}),a},me.bind=function(o){return this.each(function(e,t){var i,a=$(t),n=m.getMapData(t);if(n){if(me.unbind.apply(a),!n.complete)return!0;n=null}if(i=(t=this.getAttribute("usemap"))&&$('map[name="'+t.substr(1)+'"]'),!(a.is("img")&&t&&0')[0]},clearHighlight:function(){var e=this.map_data.overlay_canvas;e.getContext("2d").clearRect(0,0,e.width,e.height)},refreshSelections:function(){var e=this.map_data,t=e.base_canvas;e.base_canvas=this.createVisibleCanvas(e),h(e.base_canvas).hide(),h(t).before(e.base_canvas),e.redrawSelections(),h(e.base_canvas).show(),h(t).remove()}},o={renderShape:function(e,t,i){var a,n=this,o=e.coords(),s=n.elementName?'name="'+n.elementName+'" ':"",r=i?'class="'+i+'" ':"",c='',l=t.stroke?" strokeweight="+t.strokeWidth+' stroked="t" strokecolor="#'+t.strokeColor+'"':' stroked="f"',u=t.fill?' filled="t"':' filled="f"';switch(e.shape){case"rect":case"rectangle":a="'+c+"";break;case"poly":case"polygon":a="'+c+"";break;case"circ":case"circle":a="'+c+""}return i=h(a),h(n.canvas).append(i),i},render:function(){var i,a=this;return h.each(this.shapes,function(e,t){a.renderShape(t.mapArea,t.options)}),this.masks.length&&h.each(this.masks,function(e,t){i=c.updateProps({},t.options,{fillOpacity:1,fillColor:t.options.fillColorMask}),a.renderShape(t.mapArea,i,"mapster_mask")}),this.active=!1,this.canvas},createCanvasFor:function(e){var t=e.scaleInfo.width,e=e.scaleInfo.height;return h('')[0]},clearHighlight:function(){h(this.map_data.overlay_canvas).children().remove()},removeSelections:function(e){(0<=e?h(this.map_data.base_canvas).find('[name="static_'+e.toString()+'"]'):h(this.map_data.base_canvas).children()).remove()}},h.each(["renderShape","addAltImage","render","createCanvasFor","clearHighlight","removeSelections","refreshSelections"],function(e,t){var i;a[t]=(i=t,function(){return a[i]=(r.hasCanvas()?n:o)[i]||s,a[i].apply(this,arguments)})})}(jQuery),!function(o){"use strict";var e=o.mapster,n=e.utils,t=[];e.MapImages=function(e){this.owner=e,this.clear()},e.MapImages.prototype={constructor:e.MapImages,slice:function(){return t.slice.apply(this,arguments)},splice:function(){return t.slice.apply(this.status,arguments),t.slice.apply(this,arguments)},complete:function(){return o.inArray(!1,this.status)<0},_add:function(e){e=t.push.call(this,e)-1;return this.status[e]=!1,e},indexOf:function(e){return n.indexOf(this,e)},clear:function(){var i=this;i.ids&&0").addClass("mapster_el").hide(),i=n._add(e[0]),e.on("load.mapster",function(e){n.imageLoaded.call(n,e)}).on("error.mapster",function(e){n.imageLoadError.call(n,e)}),e.attr("src",a)}else i=n._add(o(e)[0]);if(t){if(this[t])throw t+" is already used or is not available as an altImage alias.";n.ids.push(t),n[t]=n[i]}return i}},bind:function(){var t=this,i=t.owner.options.configTimeout/50,a=function(){for(var e=t.length;0
'),l.wrapClass&&(!0===l.wrapClass?i.addClass(s[0].className):i.addClass(l.wrapClass))),c.wrapper=i,c.scaleInfo=r=d.scaleMap(c.images[0],c.images[1],l.scaleMap),c.base_canvas=e=c.graphics.createVisibleCanvas(c),c.overlay_canvas=t=c.graphics.createVisibleCanvas(c),a=y(c.images[1]).addClass("mapster_el "+c.images[0].className).attr({id:null,usemap:null}),(o=d.size(c.images[0])).complete&&a.css({width:o.width,height:o.height}),c.buildDataset(),a=y.extend({display:"block",position:"relative",padding:0},!0===l.enableAutoResizeSupport?{}:{width:r.width,height:r.height}),l.wrapCss&&y.extend(a,l.wrapCss),s.parent()[0]!==c.wrapper[0]&&s.before(c.wrapper),i.css(a),y(c.images.slice(2)).hide(),n=1;nw&&t[1]>b)return v=t,!(s=!0)}),s||(v=[l,u])),v}}(jQuery),!function(d){"use strict";var f=d.mapster,m=f.utils,e=f.MapArea.prototype;f.utils.getScaleInfo=function(e,t){var i;return t?.98<(i=e.width/t.width||e.height/t.height)&&i<1.02&&(i=1):(i=1,t=e),{scale:1!==i,scalePct:i,realWidth:t.width,realHeight:t.height,width:e.width,height:e.height,ratio:e.width/e.height}},f.utils.scaleMap=function(e,t,i){e=m.size(e),t=m.size(t,!0);if(t.complete())return e.complete()||(e=t),this.getScaleInfo(e,i?t:null);throw"Another script, such as an extension, appears to be interfering with image loading. Please let us know about this."},f.MapData.prototype.resize=function(t,i,a,n){var o,s,r,c,e,l=this;function u(e,t,i){f.hasCanvas()?(e.width=t,e.height=i):(d(e).width(t),d(e).height(i))}function h(){var e;u(l.overlay_canvas,t,i),0<=c&&((e=l.data[c]).tempOptions={fade:!1},l.getDataForKey(e.key).highlight(),e.tempOptions=null),u(l.base_canvas,t,i),l.redrawSelections(),l.currentAction="",m.isFunction(n)&&n(),l.processCommandQueue()}function p(){d(l.image).css(r),l.scaleInfo=m.getScaleInfo({width:t,height:i},{width:l.scaleInfo.realWidth,height:l.scaleInfo.realHeight}),d.each(l.data,function(e,t){d.each(t.areas(),function(e,t){t.resize()})})}n=n||a,l.scaleInfo.width===t&&l.scaleInfo.height===i||(c=l.highlightId,t||(e=i/l.scaleInfo.realHeight,t=Math.round(l.scaleInfo.realWidth*e)),i||(e=t/l.scaleInfo.realWidth,i=Math.round(l.scaleInfo.realHeight*e)),r={width:String(t)+"px",height:String(i)+"px"},f.hasCanvas()||d(l.base_canvas).children().remove(),e=d(l.wrapper).find(".mapster_el"),!0!==l.options.enableAutoResizeSupport&&(e=e.add(l.wrapper)),a?(s=[],l.currentAction="resizing",e.filter(":visible").each(function(e,t){o=m.defer(),s.push(o),d(t).animate(r,{duration:a,complete:o.resolve,easing:"linear"})}),e.filter(":hidden").css(r),o=m.defer(),s.push(o),m.when.all(s).then(h),p(),o.resolve()):(e.css(r),p(),h()))},f.MapData.prototype.autoResize=function(e,t){this.resize(d(this.wrapper).width(),null,e,t)},f.MapData.prototype.configureAutoResize=function(){var e=this,t=e.instanceEventNamespace();function i(){!0===e.options.autoResize&&e.autoResize(e.options.autoResizeDuration,e.options.onAutoResize)}d(e.image).on("load"+t,i),d(window).on("focus"+t,i),d(window).on("resize"+t,function(){e.autoResizeTimer&&clearTimeout(e.autoResizeTimer),e.autoResizeTimer=setTimeout(i,e.options.autoResizeDelay)}),d(window).on("readystatechange"+t,i),d(window.document).on("fullscreenchange"+t,i),i()},f.MapArea=m.subclass(f.MapArea,function(){this.base.init(),this.owner.scaleInfo.scale&&this.resize()}),e.coords=function(e,t){var i,a=[],n=e||this.owner.scaleInfo.scalePct,o=t||0;if(1===n&&0===t)return this.originalCoords;for(i=0;i',showToolTip:!1,toolTip:null,toolTipFade:!0,toolTipClose:["area-mouseout","image-mouseout","generic-mouseout"],onShowToolTip:null,onHideToolTip:null}),c.extend(e.area_defaults,{toolTip:null,toolTipClose:null}),e.MapData.prototype.clearToolTip=function(){this.activeToolTip&&(this.activeToolTip.stop().remove(),this.activeToolTip=null,this.activeToolTipID=null,l.ifFunction(this.options.onHideToolTip,this))},e.AreaData.prototype.showToolTip=function(e,t){var i,a,n,o=this,s=o.owner,r=o.effectiveOptions();if(t=t?c.extend({},t):{},e=e||r.toolTip,i=t.closeEvents||r.toolTipClose||s.options.toolTipClose||"tooltip-click",n=void 0!==t.template?t.template:s.options.toolTipContainer,t.closeEvents="string"==typeof i?i=l.split(i):i,t.fadeDuration=t.fadeDuration||(s.options.toolTipFade?(l.isNumeric(r.fadeDuration)?r:s.options).fadeDuration:0),a=o.area||c.map(o.areas(),function(e){return e.area}),s.activeToolTipID!==o.areaId){s.clearToolTip();var e=l.isFunction(e)?e({key:this.key,target:a}):e;if(e)return s.activeToolTip=e=u(e,n,t.css),s.activeToolTipID=o.areaId,n=function(){s.clearToolTip()},h(i,"area-click","click",c(s.map),null,n),h(i,"tooltip-click","click",e,null,n),h(i,"image-mouseout","mouseout",c(s.image),function(e){return e.relatedTarget&&"AREA"!==e.relatedTarget.nodeName&&e.relatedTarget!==o.area},n),h(i,"image-click","click",c(s.image),null,n),p(e,a,s.image,t.container,t),l.ifFunction(s.options.onShowToolTip,o.area,{toolTip:e,options:{},areaOptions:r,key:o.key,selected:o.isSelected()}),e}},e.impl.tooltip=function(s,r){return new e.Method(this,function(){var e,t,i,a,n,o=this;s?(n=(e=c(s))&&0=e.index;t--)m.map_cache[t].index--};function hasVml(){var e=$("
").appendTo("body"),t=(e.html(''),e[0].firstChild),t=(t.style.behavior="url(#default#VML)",!t||"object"==typeof t.adj);return e.remove(),t}function namespaces(){return"object"==typeof document.namespaces?document.namespaces:null}function hasCanvas(){var e=namespaces();return!(e&&e.g_vml_||!$("")[0].getContext)}function merge_areas(a,e){var i,n=a.options.areas;e&&$.each(e,function(e,t){t&&t.key&&(0<=(i=u.indexOfProp(n,"key",t.key))?$.extend(n[i],t):n.push(t),i=a.getDataForKey(t.key))&&$.extend(i.options,t)})}function merge_options(e,t){var a=u.updateProps({},t);delete a.areas,u.updateProps(e.options,a),merge_areas(e,t.areas),u.updateProps(e.area_options,e.options)}return me.get=function(e){var t=m.getMapData(this);if(t&&t.complete)return new m.Method(this,function(){return this.getSelected()},function(){return this.isSelected()},{name:"get",args:arguments,key:e,first:!0,allowAsync:!0,defaultReturn:""}).go();throw"Can't access data until binding complete."},me.data=function(e){return new m.Method(this,null,function(){return this},{name:"data",args:arguments,key:e}).go()},me.highlight=function(t){return new m.Method(this,function(){var e;if(!1!==t)return 0<=(e=this.highlightId)?this.data[e].key:null;this.ensureNoHighlight()},function(){this.highlight()},{name:"highlight",args:arguments,key:t,first:!0}).go()},me.keys=function(e,i){var n=[],a=m.getMapData(this);if(a&&a.complete)return a&&a.complete?("string"==typeof e?i?s(a.getDataForKey(e)):n=[a.getKeysForGroup(e)]:(i=e,this.each(function(e,t){"AREA"===t.nodeName&&s(a.getDataForArea(t))})),n.join(",")):"";throw"Can't access data until binding complete.";function s(e){var t,a=[];i?(t=e.areas(),$.each(t,function(e,t){a=a.concat(t.keys)})):a.push(e.key),$.each(a,function(e,t){$.inArray(t,n)<0&&n.push(t)})}},me.select=function(){me.set.call(this,!0)},me.deselect=function(){me.set.call(this,!1)},me.set=function(i,n,e){var s,o,r,c,l=e;function h(e){e&&$.inArray(e,c)<0&&(c.push(e),r+=(""===r?"":",")+e.key)}function p(e){$.each(c,function(e,t){var a=t;if(a)switch(i){case!0:a.select(l);break;case!1:a.deselect(!0);break;default:a.toggle(l)}}),i||e.removeSelectionFinish()}return this.filter("img,area").each(function(e,t){var a;(o=m.getMapData(t))!==s&&(s&&p(s),c=[],r=""),o&&(a="","IMG"===t.nodeName.toUpperCase()?m.queueCommand(o,$(t),"set",[i,n,l])||(n instanceof Array?n.length&&(a=n.join(",")):a=n,a&&$.each(u.split(a),function(e,t){h(o.getDataForKey(t.toString())),s=o})):(l=n,m.queueCommand(o,$(t),"set",[i,l])||(h(o.getDataForArea(t)),s=o)))}),o&&p(o),this},me.unbind=function(e){return new m.Method(this,function(){this.clearEvents(),this.clearMapData(e),removeMap(this)},null,{name:"unbind",args:arguments}).go()},me.rebind=function(t){return new m.Method(this,function(){var e=this;e.complete=!1,e.configureOptions(t),e.bindImages().then(function(){e.buildDataset(!0),e.complete=!0,e.onConfigured()})},null,{name:"rebind",args:arguments}).go()},me.get_options=function(e,t){var a=u.isBool(e)?e:t;return new m.Method(this,function(){var e=$.extend({},this.options);return a&&(e.render_select=u.updateProps({},m.render_defaults,e,e.render_select),e.render_highlight=u.updateProps({},m.render_defaults,e,e.render_highlight)),e},function(){return a?this.effectiveOptions():this.options},{name:"get_options",args:arguments,first:!0,allowAsync:!0,key:e}).go()},me.set_options=function(e){return new m.Method(this,function(){merge_options(this,e)},null,{name:"set_options",args:arguments}).go()},me.unload=function(){for(var e=m.map_cache.length-1;0<=e;e--)m.map_cache[e]&&me.unbind.call($(m.map_cache[e].image));me.graphics=null},me.snapshot=function(){return new m.Method(this,function(){$.each(this.data,function(e,t){t.selected=!1}),this.base_canvas=this.graphics.createVisibleCanvas(this),$(this.image).before(this.base_canvas)},null,{name:"snapshot"}).go()},me.state=function(){var a,i=null;return $(this).each(function(e,t){if("IMG"===t.nodeName)return(a=m.getMapData(t))&&(i=a.state()),!1}),i},me.bind=function(s){return this.each(function(e,t){var a,i=$(t),n=m.getMapData(t);if(n){if(me.unbind.apply(i),!n.complete)return!0;n=null}if(a=(t=this.getAttribute("usemap"))&&$('map[name="'+t.substr(1)+'"]'),!(i.is("img")&&t&&0')[0]},clearHighlight:function(){var e=this.map_data.overlay_canvas;e.getContext("2d").clearRect(0,0,e.width,e.height)},refreshSelections:function(){var e=this.map_data,t=e.base_canvas;e.base_canvas=this.createVisibleCanvas(e),h(e.base_canvas).hide(),h(t).before(e.base_canvas),e.redrawSelections(),h(e.base_canvas).show(),h(t).remove()}},s={renderShape:function(e,t,a){var i,n=this,s=e.coords(),o=n.elementName?'name="'+n.elementName+'" ':"",r=a?'class="'+a+'" ':"",c='',l=t.stroke?" strokeweight="+t.strokeWidth+' stroked="t" strokecolor="#'+t.strokeColor+'"':' stroked="f"',u=t.fill?' filled="t"':' filled="f"';switch(e.shape){case"rect":case"rectangle":i="'+c+"";break;case"poly":case"polygon":i="'+c+"";break;case"circ":case"circle":i="'+c+""}return a=h(i),h(n.canvas).append(a),a},render:function(){var a,i=this;return h.each(this.shapes,function(e,t){i.renderShape(t.mapArea,t.options)}),this.masks.length&&h.each(this.masks,function(e,t){a=c.updateProps({},t.options,{fillOpacity:1,fillColor:t.options.fillColorMask}),i.renderShape(t.mapArea,a,"mapster_mask")}),this.active=!1,this.canvas},createCanvasFor:function(e){var t=e.scaleInfo.width,e=e.scaleInfo.height;return h('')[0]},clearHighlight:function(){h(this.map_data.overlay_canvas).children().remove()},removeSelections:function(e){(0<=e?h(this.map_data.base_canvas).find('[name="static_'+e.toString()+'"]'):h(this.map_data.base_canvas).children()).remove()}},h.each(["renderShape","addAltImage","render","createCanvasFor","clearHighlight","removeSelections","refreshSelections"],function(e,t){var a;i[t]=(a=t,function(){return i[a]=(r.hasCanvas()?n:s)[a]||o,i[a].apply(this,arguments)})})}(jQuery),!function(s){"use strict";var e=s.mapster,n=e.utils,t=[];e.MapImages=function(e){this.owner=e,this.clear()},e.MapImages.prototype={constructor:e.MapImages,slice:function(){return t.slice.apply(this,arguments)},splice:function(){return t.slice.apply(this.status,arguments),t.slice.apply(this,arguments)},complete:function(){return s.inArray(!1,this.status)<0},_add:function(e){e=t.push.call(this,e)-1;return this.status[e]=!1,e},indexOf:function(e){return n.indexOf(this,e)},clear:function(){var a=this;a.ids&&0").addClass("mapster_el").hide(),a=n._add(e[0]),e.on("load.mapster",function(e){n.imageLoaded.call(n,e)}).on("error.mapster",function(e){n.imageLoadError.call(n,e)}),e.attr("src",i)}else a=n._add(s(e)[0]);if(t){if(this[t])throw t+" is already used or is not available as an altImage alias.";n.ids.push(t),n[t]=n[a]}return a}},bind:function(){var t=this,a=t.owner.options.configTimeout/200,i=function(){for(var e=t.length;0
'),l.wrapClass&&(!0===l.wrapClass?a.addClass(o[0].className):a.addClass(l.wrapClass))),c.wrapper=a,c.scaleInfo=r=d.scaleMap(c.images[0],c.images[1],l.scaleMap),c.base_canvas=e=c.graphics.createVisibleCanvas(c),c.overlay_canvas=t=c.graphics.createVisibleCanvas(c),i=y(c.images[1]).addClass("mapster_el "+c.images[0].className).attr({id:null,usemap:null}),(s=d.size(c.images[0])).complete&&i.css({width:s.width,height:s.height}),c.buildDataset(),i=y.extend({display:"block",position:"relative",padding:0},!0===l.enableAutoResizeSupport?{}:{width:r.width,height:r.height}),l.wrapCss&&y.extend(i,l.wrapCss),o.parent()[0]!==c.wrapper[0]&&o.before(c.wrapper),a.css(i),y(c.images.slice(2)).hide(),n=1;nw&&t[1]>b)return v=t,!(o=!0)}),o||(v=[l,u])),v}}(jQuery),!function(d){"use strict";var f=d.mapster,m=f.utils,e=f.MapArea.prototype;f.utils.getScaleInfo=function(e,t){var a;return t?.98<(a=e.width/t.width||e.height/t.height)&&a<1.02&&(a=1):(a=1,t=e),{scale:1!==a,scalePct:a,realWidth:t.width,realHeight:t.height,width:e.width,height:e.height,ratio:e.width/e.height}},f.utils.scaleMap=function(e,t,a){e=m.size(e),t=m.size(t,!0);if(t.complete())return e.complete()||(e=t),this.getScaleInfo(e,a?t:null);throw"Another script, such as an extension, appears to be interfering with image loading. Please let us know about this."},f.MapData.prototype.resize=function(t,a,i,n){var s,o,r,c,e,l=this;function u(e,t,a){f.hasCanvas()?(e.width=t,e.height=a):(d(e).width(t),d(e).height(a))}function h(){var e;u(l.overlay_canvas,t,a),0<=c&&((e=l.data[c]).tempOptions={fade:!1},l.getDataForKey(e.key).highlight(),e.tempOptions=null),u(l.base_canvas,t,a),l.redrawSelections(),l.currentAction="",m.isFunction(n)&&n(),l.processCommandQueue()}function p(){d(l.image).css(r),l.scaleInfo=m.getScaleInfo({width:t,height:a},{width:l.scaleInfo.realWidth,height:l.scaleInfo.realHeight}),d.each(l.data,function(e,t){d.each(t.areas(),function(e,t){t.resize()})})}n=n||i,l.scaleInfo.width===t&&l.scaleInfo.height===a||(c=l.highlightId,t||(e=a/l.scaleInfo.realHeight,t=Math.round(l.scaleInfo.realWidth*e)),a||(e=t/l.scaleInfo.realWidth,a=Math.round(l.scaleInfo.realHeight*e)),r={width:String(t)+"px",height:String(a)+"px"},f.hasCanvas()||d(l.base_canvas).children().remove(),e=d(l.wrapper).find(".mapster_el"),!0!==l.options.enableAutoResizeSupport&&(e=e.add(l.wrapper)),i?(o=[],l.currentAction="resizing",e.filter(":visible").each(function(e,t){s=m.defer(),o.push(s),d(t).animate(r,{duration:i,complete:s.resolve,easing:"linear"})}),e.filter(":hidden").css(r),s=m.defer(),o.push(s),m.when.all(o).then(h),p(),s.resolve()):(e.css(r),p(),h()))},f.MapData.prototype.autoResize=function(e,t){this.resize(d(this.wrapper).width(),null,e,t)},f.MapData.prototype.configureAutoResize=function(){var e=this,t=e.instanceEventNamespace();function a(){!0===e.options.autoResize&&e.autoResize(e.options.autoResizeDuration,e.options.onAutoResize)}d(e.image).on("load"+t,a),d(window).on("focus"+t,a),d(window).on("resize"+t,function(){e.autoResizeTimer&&clearTimeout(e.autoResizeTimer),e.autoResizeTimer=setTimeout(a,e.options.autoResizeDelay)}),d(window).on("readystatechange"+t,a),d(window.document).on("fullscreenchange"+t,a),a()},f.MapArea=m.subclass(f.MapArea,function(){this.base.init(),this.owner.scaleInfo.scale&&this.resize()}),e.coords=function(e,t){var a,i=[],n=e||this.owner.scaleInfo.scalePct,s=t||0;if(1===n&&0===t)return this.originalCoords;for(a=0;a',showToolTip:!1,toolTip:null,toolTipFade:!0,toolTipClose:["area-mouseout","image-mouseout","generic-mouseout"],onShowToolTip:null,onHideToolTip:null}),c.extend(e.area_defaults,{toolTip:null,toolTipClose:null}),e.MapData.prototype.clearToolTip=function(){this.activeToolTip&&(this.activeToolTip.stop().remove(),this.activeToolTip=null,this.activeToolTipID=null,l.ifFunction(this.options.onHideToolTip,this))},e.AreaData.prototype.showToolTip=function(e,t){var a,i,n,s=this,o=s.owner,r=s.effectiveOptions();if(t=t?c.extend({},t):{},e=e||r.toolTip,a=t.closeEvents||r.toolTipClose||o.options.toolTipClose||"tooltip-click",n=void 0!==t.template?t.template:o.options.toolTipContainer,t.closeEvents="string"==typeof a?a=l.split(a):a,t.fadeDuration=t.fadeDuration||(o.options.toolTipFade?o.options.fadeDuration||r.fadeDuration:0),i=s.area||c.map(s.areas(),function(e){return e.area}),o.activeToolTipID!==s.areaId){o.clearToolTip();var e=l.isFunction(e)?e({key:this.key,target:i}):e;if(e)return o.activeToolTip=e=u(e,n,t.css),o.activeToolTipID=s.areaId,n=function(){o.clearToolTip()},h(a,"area-click","click",c(o.map),null,n),h(a,"tooltip-click","click",e,null,n),h(a,"image-mouseout","mouseout",c(o.image),function(e){return e.relatedTarget&&"AREA"!==e.relatedTarget.nodeName&&e.relatedTarget!==s.area},n),h(a,"image-click","click",c(o.image),null,n),p(e,i,o.image,t.container,t),l.ifFunction(o.options.onShowToolTip,s.area,{toolTip:e,options:{},areaOptions:r,key:s.key,selected:s.isSelected()}),e}},e.impl.tooltip=function(o,r){return new e.Method(this,function(){var e,t,a,i,n,s=this;o?(n=(e=c(o))&&0=e.index;t--)m.map_cache[t].index--};function hasVml(){var e=$("
").appendTo("body"),t=(e.html(''),e[0].firstChild),t=(t.style.behavior="url(#default#VML)",!t||"object"==typeof t.adj);return e.remove(),t}function namespaces(){return"object"==typeof document.namespaces?document.namespaces:null}function hasCanvas(){var e=namespaces();return!(e&&e.g_vml_||!$("")[0].getContext)}function merge_areas(a,e){var i,n=a.options.areas;e&&$.each(e,function(e,t){t&&t.key&&(0<=(i=u.indexOfProp(n,"key",t.key))?$.extend(n[i],t):n.push(t),i=a.getDataForKey(t.key))&&$.extend(i.options,t)})}function merge_options(e,t){var a=u.updateProps({},t);delete a.areas,u.updateProps(e.options,a),merge_areas(e,t.areas),u.updateProps(e.area_options,e.options)}return me.get=function(e){var t=m.getMapData(this);if(t&&t.complete)return new m.Method(this,function(){return this.getSelected()},function(){return this.isSelected()},{name:"get",args:arguments,key:e,first:!0,allowAsync:!0,defaultReturn:""}).go();throw"Can't access data until binding complete."},me.data=function(e){return new m.Method(this,null,function(){return this},{name:"data",args:arguments,key:e}).go()},me.highlight=function(t){return new m.Method(this,function(){var e;if(!1!==t)return 0<=(e=this.highlightId)?this.data[e].key:null;this.ensureNoHighlight()},function(){this.highlight()},{name:"highlight",args:arguments,key:t,first:!0}).go()},me.keys=function(e,i){var n=[],a=m.getMapData(this);if(a&&a.complete)return a&&a.complete?("string"==typeof e?i?s(a.getDataForKey(e)):n=[a.getKeysForGroup(e)]:(i=e,this.each(function(e,t){"AREA"===t.nodeName&&s(a.getDataForArea(t))})),n.join(",")):"";throw"Can't access data until binding complete.";function s(e){var t,a=[];i?(t=e.areas(),$.each(t,function(e,t){a=a.concat(t.keys)})):a.push(e.key),$.each(a,function(e,t){$.inArray(t,n)<0&&n.push(t)})}},me.select=function(){me.set.call(this,!0)},me.deselect=function(){me.set.call(this,!1)},me.set=function(i,n,e){var s,o,r,c,l=e;function h(e){e&&$.inArray(e,c)<0&&(c.push(e),r+=(""===r?"":",")+e.key)}function p(e){$.each(c,function(e,t){var a=t;if(a)switch(i){case!0:a.select(l);break;case!1:a.deselect(!0);break;default:a.toggle(l)}}),i||e.removeSelectionFinish()}return this.filter("img,area").each(function(e,t){var a;(o=m.getMapData(t))!==s&&(s&&p(s),c=[],r=""),o&&(a="","IMG"===t.nodeName.toUpperCase()?m.queueCommand(o,$(t),"set",[i,n,l])||(n instanceof Array?n.length&&(a=n.join(",")):a=n,a&&$.each(u.split(a),function(e,t){h(o.getDataForKey(t.toString())),s=o})):(l=n,m.queueCommand(o,$(t),"set",[i,l])||(h(o.getDataForArea(t)),s=o)))}),o&&p(o),this},me.unbind=function(e){return new m.Method(this,function(){this.clearEvents(),this.clearMapData(e),removeMap(this)},null,{name:"unbind",args:arguments}).go()},me.rebind=function(t){return new m.Method(this,function(){var e=this;e.complete=!1,e.configureOptions(t),e.bindImages().then(function(){e.buildDataset(!0),e.complete=!0,e.onConfigured()})},null,{name:"rebind",args:arguments}).go()},me.get_options=function(e,t){var a=u.isBool(e)?e:t;return new m.Method(this,function(){var e=$.extend({},this.options);return a&&(e.render_select=u.updateProps({},m.render_defaults,e,e.render_select),e.render_highlight=u.updateProps({},m.render_defaults,e,e.render_highlight)),e},function(){return a?this.effectiveOptions():this.options},{name:"get_options",args:arguments,first:!0,allowAsync:!0,key:e}).go()},me.set_options=function(e){return new m.Method(this,function(){merge_options(this,e)},null,{name:"set_options",args:arguments}).go()},me.unload=function(){for(var e=m.map_cache.length-1;0<=e;e--)m.map_cache[e]&&me.unbind.call($(m.map_cache[e].image));me.graphics=null},me.snapshot=function(){return new m.Method(this,function(){$.each(this.data,function(e,t){t.selected=!1}),this.base_canvas=this.graphics.createVisibleCanvas(this),$(this.image).before(this.base_canvas)},null,{name:"snapshot"}).go()},me.state=function(){var a,i=null;return $(this).each(function(e,t){if("IMG"===t.nodeName)return(a=m.getMapData(t))&&(i=a.state()),!1}),i},me.bind=function(s){return this.each(function(e,t){var a,i=$(t),n=m.getMapData(t);if(n){if(me.unbind.apply(i),!n.complete)return!0;n=null}if(a=(t=this.getAttribute("usemap"))&&$('map[name="'+t.substr(1)+'"]'),!(i.is("img")&&t&&0')[0]},clearHighlight:function(){var e=this.map_data.overlay_canvas;e.getContext("2d").clearRect(0,0,e.width,e.height)},refreshSelections:function(){var e=this.map_data,t=e.base_canvas;e.base_canvas=this.createVisibleCanvas(e),h(e.base_canvas).hide(),h(t).before(e.base_canvas),e.redrawSelections(),h(e.base_canvas).show(),h(t).remove()}},s={renderShape:function(e,t,a){var i,n=this,s=e.coords(),o=n.elementName?'name="'+n.elementName+'" ':"",r=a?'class="'+a+'" ':"",c='',l=t.stroke?" strokeweight="+t.strokeWidth+' stroked="t" strokecolor="#'+t.strokeColor+'"':' stroked="f"',u=t.fill?' filled="t"':' filled="f"';switch(e.shape){case"rect":case"rectangle":i="'+c+"";break;case"poly":case"polygon":i="'+c+"";break;case"circ":case"circle":i="'+c+""}return a=h(i),h(n.canvas).append(a),a},render:function(){var a,i=this;return h.each(this.shapes,function(e,t){i.renderShape(t.mapArea,t.options)}),this.masks.length&&h.each(this.masks,function(e,t){a=c.updateProps({},t.options,{fillOpacity:1,fillColor:t.options.fillColorMask}),i.renderShape(t.mapArea,a,"mapster_mask")}),this.active=!1,this.canvas},createCanvasFor:function(e){var t=e.scaleInfo.width,e=e.scaleInfo.height;return h('')[0]},clearHighlight:function(){h(this.map_data.overlay_canvas).children().remove()},removeSelections:function(e){(0<=e?h(this.map_data.base_canvas).find('[name="static_'+e.toString()+'"]'):h(this.map_data.base_canvas).children()).remove()}},h.each(["renderShape","addAltImage","render","createCanvasFor","clearHighlight","removeSelections","refreshSelections"],function(e,t){var a;i[t]=(a=t,function(){return i[a]=(r.hasCanvas()?n:s)[a]||o,i[a].apply(this,arguments)})})}(jQuery),!function(s){"use strict";var e=s.mapster,n=e.utils,t=[];e.MapImages=function(e){this.owner=e,this.clear()},e.MapImages.prototype={constructor:e.MapImages,slice:function(){return t.slice.apply(this,arguments)},splice:function(){return t.slice.apply(this.status,arguments),t.slice.apply(this,arguments)},complete:function(){return s.inArray(!1,this.status)<0},_add:function(e){e=t.push.call(this,e)-1;return this.status[e]=!1,e},indexOf:function(e){return n.indexOf(this,e)},clear:function(){var a=this;a.ids&&0").addClass("mapster_el").hide(),a=n._add(e[0]),e.on("load.mapster",function(e){n.imageLoaded.call(n,e)}).on("error.mapster",function(e){n.imageLoadError.call(n,e)}),e.attr("src",i)}else a=n._add(s(e)[0]);if(t){if(this[t])throw t+" is already used or is not available as an altImage alias.";n.ids.push(t),n[t]=n[a]}return a}},bind:function(){var t=this,a=t.owner.options.configTimeout/50,i=function(){for(var e=t.length;0
'),l.wrapClass&&(!0===l.wrapClass?a.addClass(o[0].className):a.addClass(l.wrapClass))),c.wrapper=a,c.scaleInfo=r=d.scaleMap(c.images[0],c.images[1],l.scaleMap),c.base_canvas=e=c.graphics.createVisibleCanvas(c),c.overlay_canvas=t=c.graphics.createVisibleCanvas(c),i=y(c.images[1]).addClass("mapster_el "+c.images[0].className).attr({id:null,usemap:null}),(s=d.size(c.images[0])).complete&&i.css({width:s.width,height:s.height}),c.buildDataset(),i=y.extend({display:"block",position:"relative",padding:0},!0===l.enableAutoResizeSupport?{}:{width:r.width,height:r.height}),l.wrapCss&&y.extend(i,l.wrapCss),o.parent()[0]!==c.wrapper[0]&&o.before(c.wrapper),a.css(i),y(c.images.slice(2)).hide(),n=1;nw&&t[1]>b)return v=t,!(o=!0)}),o||(v=[l,u])),v}}(jQuery),!function(d){"use strict";var f=d.mapster,m=f.utils,e=f.MapArea.prototype;f.utils.getScaleInfo=function(e,t){var a;return t?.98<(a=e.width/t.width||e.height/t.height)&&a<1.02&&(a=1):(a=1,t=e),{scale:1!==a,scalePct:a,realWidth:t.width,realHeight:t.height,width:e.width,height:e.height,ratio:e.width/e.height}},f.utils.scaleMap=function(e,t,a){e=m.size(e),t=m.size(t,!0);if(t.complete())return e.complete()||(e=t),this.getScaleInfo(e,a?t:null);throw"Another script, such as an extension, appears to be interfering with image loading. Please let us know about this."},f.MapData.prototype.resize=function(t,a,i,n){var s,o,r,c,e,l=this;function u(e,t,a){f.hasCanvas()?(e.width=t,e.height=a):(d(e).width(t),d(e).height(a))}function h(){var e;u(l.overlay_canvas,t,a),0<=c&&((e=l.data[c]).tempOptions={fade:!1},l.getDataForKey(e.key).highlight(),e.tempOptions=null),u(l.base_canvas,t,a),l.redrawSelections(),l.currentAction="",m.isFunction(n)&&n(),l.processCommandQueue()}function p(){d(l.image).css(r),l.scaleInfo=m.getScaleInfo({width:t,height:a},{width:l.scaleInfo.realWidth,height:l.scaleInfo.realHeight}),d.each(l.data,function(e,t){d.each(t.areas(),function(e,t){t.resize()})})}n=n||i,l.scaleInfo.width===t&&l.scaleInfo.height===a||(c=l.highlightId,t||(e=a/l.scaleInfo.realHeight,t=Math.round(l.scaleInfo.realWidth*e)),a||(e=t/l.scaleInfo.realWidth,a=Math.round(l.scaleInfo.realHeight*e)),r={width:String(t)+"px",height:String(a)+"px"},f.hasCanvas()||d(l.base_canvas).children().remove(),e=d(l.wrapper).find(".mapster_el"),!0!==l.options.enableAutoResizeSupport&&(e=e.add(l.wrapper)),i?(o=[],l.currentAction="resizing",e.filter(":visible").each(function(e,t){s=m.defer(),o.push(s),d(t).animate(r,{duration:i,complete:s.resolve,easing:"linear"})}),e.filter(":hidden").css(r),s=m.defer(),o.push(s),m.when.all(o).then(h),p(),s.resolve()):(e.css(r),p(),h()))},f.MapData.prototype.autoResize=function(e,t){this.resize(d(this.wrapper).width(),null,e,t)},f.MapData.prototype.configureAutoResize=function(){var e=this,t=e.instanceEventNamespace();function a(){!0===e.options.autoResize&&e.autoResize(e.options.autoResizeDuration,e.options.onAutoResize)}d(e.image).on("load"+t,a),d(window).on("focus"+t,a),d(window).on("resize"+t,function(){e.autoResizeTimer&&clearTimeout(e.autoResizeTimer),e.autoResizeTimer=setTimeout(a,e.options.autoResizeDelay)}),d(window).on("readystatechange"+t,a),d(window.document).on("fullscreenchange"+t,a),a()},f.MapArea=m.subclass(f.MapArea,function(){this.base.init(),this.owner.scaleInfo.scale&&this.resize()}),e.coords=function(e,t){var a,i=[],n=e||this.owner.scaleInfo.scalePct,s=t||0;if(1===n&&0===t)return this.originalCoords;for(a=0;a',showToolTip:!1,toolTip:null,toolTipFade:!0,toolTipClose:["area-mouseout","image-mouseout","generic-mouseout"],onShowToolTip:null,onHideToolTip:null}),c.extend(e.area_defaults,{toolTip:null,toolTipClose:null}),e.MapData.prototype.clearToolTip=function(){this.activeToolTip&&(this.activeToolTip.stop().remove(),this.activeToolTip=null,this.activeToolTipID=null,l.ifFunction(this.options.onHideToolTip,this))},e.AreaData.prototype.showToolTip=function(e,t){var a,i,n,s=this,o=s.owner,r=s.effectiveOptions();if(t=t?c.extend({},t):{},e=e||r.toolTip,a=t.closeEvents||r.toolTipClose||o.options.toolTipClose||"tooltip-click",n=void 0!==t.template?t.template:o.options.toolTipContainer,t.closeEvents="string"==typeof a?a=l.split(a):a,t.fadeDuration=t.fadeDuration||(o.options.toolTipFade?(l.isNumeric(r.fadeDuration)?r:o.options).fadeDuration:0),i=s.area||c.map(s.areas(),function(e){return e.area}),o.activeToolTipID!==s.areaId){o.clearToolTip();var e=l.isFunction(e)?e({key:this.key,target:i}):e;if(e)return o.activeToolTip=e=u(e,n,t.css),o.activeToolTipID=s.areaId,n=function(){o.clearToolTip()},h(a,"area-click","click",c(o.map),null,n),h(a,"tooltip-click","click",e,null,n),h(a,"image-mouseout","mouseout",c(o.image),function(e){return e.relatedTarget&&"AREA"!==e.relatedTarget.nodeName&&e.relatedTarget!==s.area},n),h(a,"image-click","click",c(o.image),null,n),p(e,i,o.image,t.container,t),l.ifFunction(o.options.onShowToolTip,s.area,{toolTip:e,options:{},areaOptions:r,key:s.key,selected:s.isSelected()}),e}},e.impl.tooltip=function(o,r){return new e.Method(this,function(){var e,t,a,i,n,s=this;o?(n=(e=c(o))&&0 0) { me.imgTimeout = window.setTimeout(function () { check.call(me, true); - }, 50); + }, configCheckInterval); } else { me.imageLoadError.call(me); } @@ -2015,7 +2019,7 @@ function imagemapsterFactory(jQuery) { /* mapdata.js - The MapData object, repesents an instance of a single bound imagemap + The MapData object, repesents an instance of a single bound image map */ (function ($) { @@ -2785,7 +2789,7 @@ function imagemapsterFactory(jQuery) { me.wrapper = wrap; // me.images[1] is the copy of the original image. It should be loaded & at its native size now so we can obtain the true - // width & height. This is needed to scale the imagemap if not being shown at its native size. It is also needed purely + // width & height. This is needed to scale the image map if not being shown at its native size. It is also needed purely // to finish binding in case the original image was not visible. It can be impossible in some browsers to obtain the // native size of a hidden image. @@ -2876,7 +2880,7 @@ function imagemapsterFactory(jQuery) { $img = $(me.image), opts = me.options; - if (opts.onConfigured && typeof opts.onConfigured === 'function') { + if (u.isFunction(opts.onConfigured)) { opts.onConfigured.call($img, true); } }, @@ -3481,7 +3485,7 @@ function imagemapsterFactory(jQuery) { /** * Compute positions that will place a target with dimensions [width,height] outside - * but near the boundaries of the elements "elements". When an imagemap is passed, the + * but near the boundaries of the elements "elements". When an image map is passed, the * * @param {Element|Element[]} elements An element or an array of elements (such as a jQuery object) * @param {Element} image The image to which area elements are bound, if this is an image map. @@ -3658,7 +3662,7 @@ function imagemapsterFactory(jQuery) { }; })(jQuery); -/* +/* scale.js Resize and zoom functionality Requires areacorners.js @@ -3713,7 +3717,7 @@ function imagemapsterFactory(jQuery) { /** * Resize the image map. Only one of newWidth and newHeight should be passed to preserve scale * - * @param {int} width The new width OR an object containing named parameters matching this function sig + * @param {int} width The new width * @param {int} height The new height * @param {int} effectDuration Time in ms for the resize animation, or zero for no animation * @param {function} callback A function to invoke when the operation finishes @@ -4049,7 +4053,7 @@ function imagemapsterFactory(jQuery) { */ })(jQuery); -/* +/* tooltip.js Tooltip functionality Requires areacorners.js @@ -4324,7 +4328,7 @@ function imagemapsterFactory(jQuery) { options.fadeDuration = options.fadeDuration || (md.options.toolTipFade - ? md.options.fadeDuration || areaOpts.fadeDuration + ? u.isNumeric(areaOpts.fadeDuration) ? areaOpts.fadeDuration : md.options.fadeDuration : 0); target = ad.area diff --git a/dist/jquery.imagemapster.zepto.js b/dist/jquery.imagemapster.zepto.js index 8a03ac4..c2d9b24 100644 --- a/dist/jquery.imagemapster.zepto.js +++ b/dist/jquery.imagemapster.zepto.js @@ -1,6 +1,6 @@ /*! -* imagemapster - v1.6.0 - 2024-04-05 -* https://github.com/jamietre/ImageMapster/ +* imagemapster - v1.7.0 - 2024-04-29 +* https://jamietre.github.io/ImageMapster * Copyright (c) 2011 - 2024 James Treworgy * License: MIT */ @@ -132,7 +132,7 @@ (function ($) { 'use strict'; - var mapster_version = '1.6.0'; + var mapster_version = '1.7.0'; // all public functions in $.mapster.impl are methods $.fn.mapster = function (method) { @@ -165,7 +165,8 @@ includeKeys: '', altImage: null, altImageId: null, // used internally - altImages: {} + altImages: {}, + altImageOpacity: null }, defaults: { clickNavigate: false, @@ -174,7 +175,7 @@ wrapCss: null, onGetList: null, sortList: false, - listenToList: false, + // listenToList: false, // not used - see mapdata.js line 1002 mapKey: '', mapValue: '', singleSelect: false, @@ -196,7 +197,6 @@ autoResizeDelay: 0, autoResizeDuration: 0, onAutoResize: null, - safeLoad: false, areas: [] }, shared_defaults: { @@ -383,6 +383,9 @@ isFunction: function (obj) { return typeof obj === 'function'; }, + isNumeric: function (obj) { + return !isNaN(parseFloat(obj)); + }, // evaluates "obj", if function, calls it with args // (todo - update this to handle variable lenght/more than one arg) ifFunction: function (obj, that, args) { @@ -597,7 +600,7 @@ * invoked on an image, or an area; then queues the command if the MapData is in an active state. * * @param {[jQuery]} that The target of the invocation - * @param {[function]} func_map The callback if the target is an imagemap + * @param {[function]} func_map The callback if the target is an image map * @param {[function]} func_area The callback if the target is an area * @param {[object]} opt Options: { key: a map key if passed explicitly * name: the command name, if it can be queued, @@ -1229,11 +1232,11 @@ }; return me; })(); - + console.log('foo3456'); $.mapster.impl.init(); })(jQuery); -/* +/* graphics.js Graphics object handles all rendering. */ @@ -1784,9 +1787,9 @@ ); })(jQuery); -/* +/* mapimage.js - The MapImage object, repesents an instance of a single bound imagemap + The MapImage object, repesents an instance of a single bound image map */ (function ($) { @@ -1794,7 +1797,8 @@ var m = $.mapster, u = m.utils, - ap = []; + ap = [], + configCheckInterval = 50; /** * An object encapsulating all the images used by a MapData. */ @@ -1953,7 +1957,7 @@ bind: function () { var me = this, promise, - triesLeft = me.owner.options.configTimeout / 200, + triesLeft = me.owner.options.configTimeout / configCheckInterval, /* A recursive function to continue checking that the images have been loaded until a timeout has elapsed */ @@ -1979,7 +1983,7 @@ if (triesLeft-- > 0) { me.imgTimeout = window.setTimeout(function () { check.call(me, true); - }, 50); + }, configCheckInterval); } else { me.imageLoadError.call(me); } @@ -2065,7 +2069,7 @@ /* mapdata.js - The MapData object, repesents an instance of a single bound imagemap + The MapData object, repesents an instance of a single bound image map */ (function ($) { @@ -2835,7 +2839,7 @@ me.wrapper = wrap; // me.images[1] is the copy of the original image. It should be loaded & at its native size now so we can obtain the true - // width & height. This is needed to scale the imagemap if not being shown at its native size. It is also needed purely + // width & height. This is needed to scale the image map if not being shown at its native size. It is also needed purely // to finish binding in case the original image was not visible. It can be impossible in some browsers to obtain the // native size of a hidden image. @@ -2926,7 +2930,7 @@ $img = $(me.image), opts = me.options; - if (opts.onConfigured && typeof opts.onConfigured === 'function') { + if (u.isFunction(opts.onConfigured)) { opts.onConfigured.call($img, true); } }, @@ -3531,7 +3535,7 @@ /** * Compute positions that will place a target with dimensions [width,height] outside - * but near the boundaries of the elements "elements". When an imagemap is passed, the + * but near the boundaries of the elements "elements". When an image map is passed, the * * @param {Element|Element[]} elements An element or an array of elements (such as a jQuery object) * @param {Element} image The image to which area elements are bound, if this is an image map. @@ -3708,7 +3712,7 @@ }; })(jQuery); -/* +/* scale.js Resize and zoom functionality Requires areacorners.js @@ -3763,7 +3767,7 @@ /** * Resize the image map. Only one of newWidth and newHeight should be passed to preserve scale * - * @param {int} width The new width OR an object containing named parameters matching this function sig + * @param {int} width The new width * @param {int} height The new height * @param {int} effectDuration Time in ms for the resize animation, or zero for no animation * @param {function} callback A function to invoke when the operation finishes @@ -4099,7 +4103,7 @@ */ })(jQuery); -/* +/* tooltip.js Tooltip functionality Requires areacorners.js @@ -4374,7 +4378,7 @@ options.fadeDuration = options.fadeDuration || (md.options.toolTipFade - ? md.options.fadeDuration || areaOpts.fadeDuration + ? u.isNumeric(areaOpts.fadeDuration) ? areaOpts.fadeDuration : md.options.fadeDuration : 0); target = ad.area diff --git a/dist/jquery.imagemapster.zepto.min.js b/dist/jquery.imagemapster.zepto.min.js index 670eccf..6d12773 100644 --- a/dist/jquery.imagemapster.zepto.min.js +++ b/dist/jquery.imagemapster.zepto.min.js @@ -1,8 +1,8 @@ /*! -* imagemapster - v1.6.0 - 2024-04-05 -* https://github.com/jamietre/ImageMapster/ +* imagemapster - v1.7.0 - 2024-04-29 +* https://jamietre.github.io/ImageMapster * Copyright (c) 2011 - 2024 James Treworgy * License: MIT */ -!function(e,i){"function"==typeof define&&define.amd?define(["jquery"],i):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),i(t),t}:i(e.jQuery||e.Zepto)}("undefined"!=typeof self?self:this,function(jQuery){!function(a){"use strict";a.fn.stop||(a.fn.stop=function(){return this}),a.each(["Height","Width"],function(e,t){var i="outer"+t;a.fn[i]||(a.fn[i]=function(){return this[t.toLowerCase()]()})})}(jQuery),!function(e){"use strict";if(e.event&&e.event.special){var a,t=!1;try{var i=Object.defineProperty({},"passive",{get:function(){return t=!0}});window.addEventListener("testPassive.mapster",function(){},i),window.removeEventListener("testPassive.mapster",function(){},i)}catch(e){}t&&(a=function(e,t,i){if(!e.includes("mapster")||!e.includes("noPreventDefault"))return!1;this.addEventListener(t,i,{passive:!0})},e.event.special.touchstart={setup:function(e,t,i){return a.call(this,t,"touchstart",i)}},e.event.special.touchend={setup:function(e,t,i){return a.call(this,t,"touchend",i)}})}}(jQuery),!function($){"use strict";var mapster_version="1.6.0",m=($.fn.mapster=function(e){var t=$.mapster.impl;return $.mapster.utils.isFunction(t[e])?t[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?void $.error("Method "+e+" does not exist on jQuery.mapster"):t.bind.apply(this,arguments)},$.mapster={version:mapster_version,render_defaults:{isSelectable:!0,isDeselectable:!0,fade:!1,fadeDuration:150,fill:!0,fillColor:"000000",fillColorMask:"FFFFFF",fillOpacity:.7,highlight:!0,stroke:!1,strokeColor:"ff0000",strokeOpacity:1,strokeWidth:1,includeKeys:"",altImage:null,altImageId:null,altImages:{}},defaults:{clickNavigate:!1,navigateMode:"location",wrapClass:null,wrapCss:null,onGetList:null,sortList:!1,listenToList:!1,mapKey:"",mapValue:"",singleSelect:!1,listKey:"value",listSelectedAttribute:"selected",listSelectedClass:null,onClick:null,onMouseover:null,onMouseout:null,mouseoutDelay:0,onStateChange:null,boundList:null,onConfigured:null,configTimeout:3e4,noHrefIsMask:!0,scaleMap:!0,enableAutoResizeSupport:!1,autoResize:!1,autoResizeDelay:0,autoResizeDuration:0,onAutoResize:null,safeLoad:!1,areas:[]},shared_defaults:{render_highlight:{fade:!0},render_select:{fade:!1},staticState:null,selected:null},area_defaults:{includeKeys:"",isMask:!1},canvas_style:{position:"absolute",left:0,top:0,padding:0,border:0},hasCanvas:null,map_cache:[],hooks:{},addHook:function(e,t){this.hooks[e]=(this.hooks[e]||[]).push(t)},callHooks:function(e,i){$.each(this.hooks[e]||[],function(e,t){t.apply(i)})},utils:{when:{all:function(e){return Promise.all(e)},defer:function(){return new function(){this.promise=new Promise(function(e,t){this.resolve=e,this.reject=t}.bind(this)),this.then=this.promise.then.bind(this.promise),this.catch=this.promise.catch.bind(this.promise)}}},defer:function(){return this.when.defer()},subclass:function(i,a){function e(){var e=this,t=Array.prototype.slice.call(arguments,0);e.base=i.prototype,e.base.init=function(){i.prototype.constructor.apply(e,t)},a.apply(e,t)}return(e.prototype=new i).constructor=e},asArray:function(e){return e.constructor===Array?e:this.split(e)},split:function(e,t){for(var i,a=e.split(","),n=0;n=e.index;t--)m.map_cache[t].index--};function hasVml(){var e=$("
").appendTo("body"),t=(e.html(''),e[0].firstChild),t=(t.style.behavior="url(#default#VML)",!t||"object"==typeof t.adj);return e.remove(),t}function namespaces(){return"object"==typeof document.namespaces?document.namespaces:null}function hasCanvas(){var e=namespaces();return!(e&&e.g_vml_||!$("")[0].getContext)}function merge_areas(i,e){var a,n=i.options.areas;e&&$.each(e,function(e,t){t&&t.key&&(0<=(a=u.indexOfProp(n,"key",t.key))?$.extend(n[a],t):n.push(t),a=i.getDataForKey(t.key))&&$.extend(a.options,t)})}function merge_options(e,t){var i=u.updateProps({},t);delete i.areas,u.updateProps(e.options,i),merge_areas(e,t.areas),u.updateProps(e.area_options,e.options)}return me.get=function(e){var t=m.getMapData(this);if(t&&t.complete)return new m.Method(this,function(){return this.getSelected()},function(){return this.isSelected()},{name:"get",args:arguments,key:e,first:!0,allowAsync:!0,defaultReturn:""}).go();throw"Can't access data until binding complete."},me.data=function(e){return new m.Method(this,null,function(){return this},{name:"data",args:arguments,key:e}).go()},me.highlight=function(t){return new m.Method(this,function(){var e;if(!1!==t)return 0<=(e=this.highlightId)?this.data[e].key:null;this.ensureNoHighlight()},function(){this.highlight()},{name:"highlight",args:arguments,key:t,first:!0}).go()},me.keys=function(e,a){var n=[],i=m.getMapData(this);if(i&&i.complete)return i&&i.complete?("string"==typeof e?a?o(i.getDataForKey(e)):n=[i.getKeysForGroup(e)]:(a=e,this.each(function(e,t){"AREA"===t.nodeName&&o(i.getDataForArea(t))})),n.join(",")):"";throw"Can't access data until binding complete.";function o(e){var t,i=[];a?(t=e.areas(),$.each(t,function(e,t){i=i.concat(t.keys)})):i.push(e.key),$.each(i,function(e,t){$.inArray(t,n)<0&&n.push(t)})}},me.select=function(){me.set.call(this,!0)},me.deselect=function(){me.set.call(this,!1)},me.set=function(a,n,e){var o,s,r,c,l=e;function h(e){e&&$.inArray(e,c)<0&&(c.push(e),r+=(""===r?"":",")+e.key)}function p(e){$.each(c,function(e,t){var i=t;if(i)switch(a){case!0:i.select(l);break;case!1:i.deselect(!0);break;default:i.toggle(l)}}),a||e.removeSelectionFinish()}return this.filter("img,area").each(function(e,t){var i;(s=m.getMapData(t))!==o&&(o&&p(o),c=[],r=""),s&&(i="","IMG"===t.nodeName.toUpperCase()?m.queueCommand(s,$(t),"set",[a,n,l])||(n instanceof Array?n.length&&(i=n.join(",")):i=n,i&&$.each(u.split(i),function(e,t){h(s.getDataForKey(t.toString())),o=s})):(l=n,m.queueCommand(s,$(t),"set",[a,l])||(h(s.getDataForArea(t)),o=s)))}),s&&p(s),this},me.unbind=function(e){return new m.Method(this,function(){this.clearEvents(),this.clearMapData(e),removeMap(this)},null,{name:"unbind",args:arguments}).go()},me.rebind=function(t){return new m.Method(this,function(){var e=this;e.complete=!1,e.configureOptions(t),e.bindImages().then(function(){e.buildDataset(!0),e.complete=!0,e.onConfigured()})},null,{name:"rebind",args:arguments}).go()},me.get_options=function(e,t){var i=u.isBool(e)?e:t;return new m.Method(this,function(){var e=$.extend({},this.options);return i&&(e.render_select=u.updateProps({},m.render_defaults,e,e.render_select),e.render_highlight=u.updateProps({},m.render_defaults,e,e.render_highlight)),e},function(){return i?this.effectiveOptions():this.options},{name:"get_options",args:arguments,first:!0,allowAsync:!0,key:e}).go()},me.set_options=function(e){return new m.Method(this,function(){merge_options(this,e)},null,{name:"set_options",args:arguments}).go()},me.unload=function(){for(var e=m.map_cache.length-1;0<=e;e--)m.map_cache[e]&&me.unbind.call($(m.map_cache[e].image));me.graphics=null},me.snapshot=function(){return new m.Method(this,function(){$.each(this.data,function(e,t){t.selected=!1}),this.base_canvas=this.graphics.createVisibleCanvas(this),$(this.image).before(this.base_canvas)},null,{name:"snapshot"}).go()},me.state=function(){var i,a=null;return $(this).each(function(e,t){if("IMG"===t.nodeName)return(i=m.getMapData(t))&&(a=i.state()),!1}),a},me.bind=function(o){return this.each(function(e,t){var i,a=$(t),n=m.getMapData(t);if(n){if(me.unbind.apply(a),!n.complete)return!0;n=null}if(i=(t=this.getAttribute("usemap"))&&$('map[name="'+t.substr(1)+'"]'),!(a.is("img")&&t&&0')[0]},clearHighlight:function(){var e=this.map_data.overlay_canvas;e.getContext("2d").clearRect(0,0,e.width,e.height)},refreshSelections:function(){var e=this.map_data,t=e.base_canvas;e.base_canvas=this.createVisibleCanvas(e),h(e.base_canvas).hide(),h(t).before(e.base_canvas),e.redrawSelections(),h(e.base_canvas).show(),h(t).remove()}},o={renderShape:function(e,t,i){var a,n=this,o=e.coords(),s=n.elementName?'name="'+n.elementName+'" ':"",r=i?'class="'+i+'" ':"",c='',l=t.stroke?" strokeweight="+t.strokeWidth+' stroked="t" strokecolor="#'+t.strokeColor+'"':' stroked="f"',u=t.fill?' filled="t"':' filled="f"';switch(e.shape){case"rect":case"rectangle":a="'+c+"";break;case"poly":case"polygon":a="'+c+"";break;case"circ":case"circle":a="'+c+""}return i=h(a),h(n.canvas).append(i),i},render:function(){var i,a=this;return h.each(this.shapes,function(e,t){a.renderShape(t.mapArea,t.options)}),this.masks.length&&h.each(this.masks,function(e,t){i=c.updateProps({},t.options,{fillOpacity:1,fillColor:t.options.fillColorMask}),a.renderShape(t.mapArea,i,"mapster_mask")}),this.active=!1,this.canvas},createCanvasFor:function(e){var t=e.scaleInfo.width,e=e.scaleInfo.height;return h('')[0]},clearHighlight:function(){h(this.map_data.overlay_canvas).children().remove()},removeSelections:function(e){(0<=e?h(this.map_data.base_canvas).find('[name="static_'+e.toString()+'"]'):h(this.map_data.base_canvas).children()).remove()}},h.each(["renderShape","addAltImage","render","createCanvasFor","clearHighlight","removeSelections","refreshSelections"],function(e,t){var i;a[t]=(i=t,function(){return a[i]=(r.hasCanvas()?n:o)[i]||s,a[i].apply(this,arguments)})})}(jQuery),!function(o){"use strict";var e=o.mapster,n=e.utils,t=[];e.MapImages=function(e){this.owner=e,this.clear()},e.MapImages.prototype={constructor:e.MapImages,slice:function(){return t.slice.apply(this,arguments)},splice:function(){return t.slice.apply(this.status,arguments),t.slice.apply(this,arguments)},complete:function(){return o.inArray(!1,this.status)<0},_add:function(e){e=t.push.call(this,e)-1;return this.status[e]=!1,e},indexOf:function(e){return n.indexOf(this,e)},clear:function(){var i=this;i.ids&&0").addClass("mapster_el").hide(),i=n._add(e[0]),e.on("load.mapster",function(e){n.imageLoaded.call(n,e)}).on("error.mapster",function(e){n.imageLoadError.call(n,e)}),e.attr("src",a)}else i=n._add(o(e)[0]);if(t){if(this[t])throw t+" is already used or is not available as an altImage alias.";n.ids.push(t),n[t]=n[i]}return i}},bind:function(){var t=this,i=t.owner.options.configTimeout/200,a=function(){for(var e=t.length;0
'),l.wrapClass&&(!0===l.wrapClass?i.addClass(s[0].className):i.addClass(l.wrapClass))),c.wrapper=i,c.scaleInfo=r=d.scaleMap(c.images[0],c.images[1],l.scaleMap),c.base_canvas=e=c.graphics.createVisibleCanvas(c),c.overlay_canvas=t=c.graphics.createVisibleCanvas(c),a=y(c.images[1]).addClass("mapster_el "+c.images[0].className).attr({id:null,usemap:null}),(o=d.size(c.images[0])).complete&&a.css({width:o.width,height:o.height}),c.buildDataset(),a=y.extend({display:"block",position:"relative",padding:0},!0===l.enableAutoResizeSupport?{}:{width:r.width,height:r.height}),l.wrapCss&&y.extend(a,l.wrapCss),s.parent()[0]!==c.wrapper[0]&&s.before(c.wrapper),i.css(a),y(c.images.slice(2)).hide(),n=1;nw&&t[1]>b)return v=t,!(s=!0)}),s||(v=[l,u])),v}}(jQuery),!function(d){"use strict";var f=d.mapster,m=f.utils,e=f.MapArea.prototype;f.utils.getScaleInfo=function(e,t){var i;return t?.98<(i=e.width/t.width||e.height/t.height)&&i<1.02&&(i=1):(i=1,t=e),{scale:1!==i,scalePct:i,realWidth:t.width,realHeight:t.height,width:e.width,height:e.height,ratio:e.width/e.height}},f.utils.scaleMap=function(e,t,i){e=m.size(e),t=m.size(t,!0);if(t.complete())return e.complete()||(e=t),this.getScaleInfo(e,i?t:null);throw"Another script, such as an extension, appears to be interfering with image loading. Please let us know about this."},f.MapData.prototype.resize=function(t,i,a,n){var o,s,r,c,e,l=this;function u(e,t,i){f.hasCanvas()?(e.width=t,e.height=i):(d(e).width(t),d(e).height(i))}function h(){var e;u(l.overlay_canvas,t,i),0<=c&&((e=l.data[c]).tempOptions={fade:!1},l.getDataForKey(e.key).highlight(),e.tempOptions=null),u(l.base_canvas,t,i),l.redrawSelections(),l.currentAction="",m.isFunction(n)&&n(),l.processCommandQueue()}function p(){d(l.image).css(r),l.scaleInfo=m.getScaleInfo({width:t,height:i},{width:l.scaleInfo.realWidth,height:l.scaleInfo.realHeight}),d.each(l.data,function(e,t){d.each(t.areas(),function(e,t){t.resize()})})}n=n||a,l.scaleInfo.width===t&&l.scaleInfo.height===i||(c=l.highlightId,t||(e=i/l.scaleInfo.realHeight,t=Math.round(l.scaleInfo.realWidth*e)),i||(e=t/l.scaleInfo.realWidth,i=Math.round(l.scaleInfo.realHeight*e)),r={width:String(t)+"px",height:String(i)+"px"},f.hasCanvas()||d(l.base_canvas).children().remove(),e=d(l.wrapper).find(".mapster_el"),!0!==l.options.enableAutoResizeSupport&&(e=e.add(l.wrapper)),a?(s=[],l.currentAction="resizing",e.filter(":visible").each(function(e,t){o=m.defer(),s.push(o),d(t).animate(r,{duration:a,complete:o.resolve,easing:"linear"})}),e.filter(":hidden").css(r),o=m.defer(),s.push(o),m.when.all(s).then(h),p(),o.resolve()):(e.css(r),p(),h()))},f.MapData.prototype.autoResize=function(e,t){this.resize(d(this.wrapper).width(),null,e,t)},f.MapData.prototype.configureAutoResize=function(){var e=this,t=e.instanceEventNamespace();function i(){!0===e.options.autoResize&&e.autoResize(e.options.autoResizeDuration,e.options.onAutoResize)}d(e.image).on("load"+t,i),d(window).on("focus"+t,i),d(window).on("resize"+t,function(){e.autoResizeTimer&&clearTimeout(e.autoResizeTimer),e.autoResizeTimer=setTimeout(i,e.options.autoResizeDelay)}),d(window).on("readystatechange"+t,i),d(window.document).on("fullscreenchange"+t,i),i()},f.MapArea=m.subclass(f.MapArea,function(){this.base.init(),this.owner.scaleInfo.scale&&this.resize()}),e.coords=function(e,t){var i,a=[],n=e||this.owner.scaleInfo.scalePct,o=t||0;if(1===n&&0===t)return this.originalCoords;for(i=0;i',showToolTip:!1,toolTip:null,toolTipFade:!0,toolTipClose:["area-mouseout","image-mouseout","generic-mouseout"],onShowToolTip:null,onHideToolTip:null}),c.extend(e.area_defaults,{toolTip:null,toolTipClose:null}),e.MapData.prototype.clearToolTip=function(){this.activeToolTip&&(this.activeToolTip.stop().remove(),this.activeToolTip=null,this.activeToolTipID=null,l.ifFunction(this.options.onHideToolTip,this))},e.AreaData.prototype.showToolTip=function(e,t){var i,a,n,o=this,s=o.owner,r=o.effectiveOptions();if(t=t?c.extend({},t):{},e=e||r.toolTip,i=t.closeEvents||r.toolTipClose||s.options.toolTipClose||"tooltip-click",n=void 0!==t.template?t.template:s.options.toolTipContainer,t.closeEvents="string"==typeof i?i=l.split(i):i,t.fadeDuration=t.fadeDuration||(s.options.toolTipFade?s.options.fadeDuration||r.fadeDuration:0),a=o.area||c.map(o.areas(),function(e){return e.area}),s.activeToolTipID!==o.areaId){s.clearToolTip();var e=l.isFunction(e)?e({key:this.key,target:a}):e;if(e)return s.activeToolTip=e=u(e,n,t.css),s.activeToolTipID=o.areaId,n=function(){s.clearToolTip()},h(i,"area-click","click",c(s.map),null,n),h(i,"tooltip-click","click",e,null,n),h(i,"image-mouseout","mouseout",c(s.image),function(e){return e.relatedTarget&&"AREA"!==e.relatedTarget.nodeName&&e.relatedTarget!==o.area},n),h(i,"image-click","click",c(s.image),null,n),p(e,a,s.image,t.container,t),l.ifFunction(s.options.onShowToolTip,o.area,{toolTip:e,options:{},areaOptions:r,key:o.key,selected:o.isSelected()}),e}},e.impl.tooltip=function(s,r){return new e.Method(this,function(){var e,t,i,a,n,o=this;s?(n=(e=c(s))&&0=e.index;t--)m.map_cache[t].index--};function hasVml(){var e=$("
").appendTo("body"),t=(e.html(''),e[0].firstChild),t=(t.style.behavior="url(#default#VML)",!t||"object"==typeof t.adj);return e.remove(),t}function namespaces(){return"object"==typeof document.namespaces?document.namespaces:null}function hasCanvas(){var e=namespaces();return!(e&&e.g_vml_||!$("")[0].getContext)}function merge_areas(i,e){var a,n=i.options.areas;e&&$.each(e,function(e,t){t&&t.key&&(0<=(a=u.indexOfProp(n,"key",t.key))?$.extend(n[a],t):n.push(t),a=i.getDataForKey(t.key))&&$.extend(a.options,t)})}function merge_options(e,t){var i=u.updateProps({},t);delete i.areas,u.updateProps(e.options,i),merge_areas(e,t.areas),u.updateProps(e.area_options,e.options)}return me.get=function(e){var t=m.getMapData(this);if(t&&t.complete)return new m.Method(this,function(){return this.getSelected()},function(){return this.isSelected()},{name:"get",args:arguments,key:e,first:!0,allowAsync:!0,defaultReturn:""}).go();throw"Can't access data until binding complete."},me.data=function(e){return new m.Method(this,null,function(){return this},{name:"data",args:arguments,key:e}).go()},me.highlight=function(t){return new m.Method(this,function(){var e;if(!1!==t)return 0<=(e=this.highlightId)?this.data[e].key:null;this.ensureNoHighlight()},function(){this.highlight()},{name:"highlight",args:arguments,key:t,first:!0}).go()},me.keys=function(e,a){var n=[],i=m.getMapData(this);if(i&&i.complete)return i&&i.complete?("string"==typeof e?a?o(i.getDataForKey(e)):n=[i.getKeysForGroup(e)]:(a=e,this.each(function(e,t){"AREA"===t.nodeName&&o(i.getDataForArea(t))})),n.join(",")):"";throw"Can't access data until binding complete.";function o(e){var t,i=[];a?(t=e.areas(),$.each(t,function(e,t){i=i.concat(t.keys)})):i.push(e.key),$.each(i,function(e,t){$.inArray(t,n)<0&&n.push(t)})}},me.select=function(){me.set.call(this,!0)},me.deselect=function(){me.set.call(this,!1)},me.set=function(a,n,e){var o,s,r,c,l=e;function h(e){e&&$.inArray(e,c)<0&&(c.push(e),r+=(""===r?"":",")+e.key)}function p(e){$.each(c,function(e,t){var i=t;if(i)switch(a){case!0:i.select(l);break;case!1:i.deselect(!0);break;default:i.toggle(l)}}),a||e.removeSelectionFinish()}return this.filter("img,area").each(function(e,t){var i;(s=m.getMapData(t))!==o&&(o&&p(o),c=[],r=""),s&&(i="","IMG"===t.nodeName.toUpperCase()?m.queueCommand(s,$(t),"set",[a,n,l])||(n instanceof Array?n.length&&(i=n.join(",")):i=n,i&&$.each(u.split(i),function(e,t){h(s.getDataForKey(t.toString())),o=s})):(l=n,m.queueCommand(s,$(t),"set",[a,l])||(h(s.getDataForArea(t)),o=s)))}),s&&p(s),this},me.unbind=function(e){return new m.Method(this,function(){this.clearEvents(),this.clearMapData(e),removeMap(this)},null,{name:"unbind",args:arguments}).go()},me.rebind=function(t){return new m.Method(this,function(){var e=this;e.complete=!1,e.configureOptions(t),e.bindImages().then(function(){e.buildDataset(!0),e.complete=!0,e.onConfigured()})},null,{name:"rebind",args:arguments}).go()},me.get_options=function(e,t){var i=u.isBool(e)?e:t;return new m.Method(this,function(){var e=$.extend({},this.options);return i&&(e.render_select=u.updateProps({},m.render_defaults,e,e.render_select),e.render_highlight=u.updateProps({},m.render_defaults,e,e.render_highlight)),e},function(){return i?this.effectiveOptions():this.options},{name:"get_options",args:arguments,first:!0,allowAsync:!0,key:e}).go()},me.set_options=function(e){return new m.Method(this,function(){merge_options(this,e)},null,{name:"set_options",args:arguments}).go()},me.unload=function(){for(var e=m.map_cache.length-1;0<=e;e--)m.map_cache[e]&&me.unbind.call($(m.map_cache[e].image));me.graphics=null},me.snapshot=function(){return new m.Method(this,function(){$.each(this.data,function(e,t){t.selected=!1}),this.base_canvas=this.graphics.createVisibleCanvas(this),$(this.image).before(this.base_canvas)},null,{name:"snapshot"}).go()},me.state=function(){var i,a=null;return $(this).each(function(e,t){if("IMG"===t.nodeName)return(i=m.getMapData(t))&&(a=i.state()),!1}),a},me.bind=function(o){return this.each(function(e,t){var i,a=$(t),n=m.getMapData(t);if(n){if(me.unbind.apply(a),!n.complete)return!0;n=null}if(i=(t=this.getAttribute("usemap"))&&$('map[name="'+t.substr(1)+'"]'),!(a.is("img")&&t&&0')[0]},clearHighlight:function(){var e=this.map_data.overlay_canvas;e.getContext("2d").clearRect(0,0,e.width,e.height)},refreshSelections:function(){var e=this.map_data,t=e.base_canvas;e.base_canvas=this.createVisibleCanvas(e),h(e.base_canvas).hide(),h(t).before(e.base_canvas),e.redrawSelections(),h(e.base_canvas).show(),h(t).remove()}},o={renderShape:function(e,t,i){var a,n=this,o=e.coords(),s=n.elementName?'name="'+n.elementName+'" ':"",r=i?'class="'+i+'" ':"",c='',l=t.stroke?" strokeweight="+t.strokeWidth+' stroked="t" strokecolor="#'+t.strokeColor+'"':' stroked="f"',u=t.fill?' filled="t"':' filled="f"';switch(e.shape){case"rect":case"rectangle":a="'+c+"";break;case"poly":case"polygon":a="'+c+"";break;case"circ":case"circle":a="'+c+""}return i=h(a),h(n.canvas).append(i),i},render:function(){var i,a=this;return h.each(this.shapes,function(e,t){a.renderShape(t.mapArea,t.options)}),this.masks.length&&h.each(this.masks,function(e,t){i=c.updateProps({},t.options,{fillOpacity:1,fillColor:t.options.fillColorMask}),a.renderShape(t.mapArea,i,"mapster_mask")}),this.active=!1,this.canvas},createCanvasFor:function(e){var t=e.scaleInfo.width,e=e.scaleInfo.height;return h('')[0]},clearHighlight:function(){h(this.map_data.overlay_canvas).children().remove()},removeSelections:function(e){(0<=e?h(this.map_data.base_canvas).find('[name="static_'+e.toString()+'"]'):h(this.map_data.base_canvas).children()).remove()}},h.each(["renderShape","addAltImage","render","createCanvasFor","clearHighlight","removeSelections","refreshSelections"],function(e,t){var i;a[t]=(i=t,function(){return a[i]=(r.hasCanvas()?n:o)[i]||s,a[i].apply(this,arguments)})})}(jQuery),!function(o){"use strict";var e=o.mapster,n=e.utils,t=[];e.MapImages=function(e){this.owner=e,this.clear()},e.MapImages.prototype={constructor:e.MapImages,slice:function(){return t.slice.apply(this,arguments)},splice:function(){return t.slice.apply(this.status,arguments),t.slice.apply(this,arguments)},complete:function(){return o.inArray(!1,this.status)<0},_add:function(e){e=t.push.call(this,e)-1;return this.status[e]=!1,e},indexOf:function(e){return n.indexOf(this,e)},clear:function(){var i=this;i.ids&&0").addClass("mapster_el").hide(),i=n._add(e[0]),e.on("load.mapster",function(e){n.imageLoaded.call(n,e)}).on("error.mapster",function(e){n.imageLoadError.call(n,e)}),e.attr("src",a)}else i=n._add(o(e)[0]);if(t){if(this[t])throw t+" is already used or is not available as an altImage alias.";n.ids.push(t),n[t]=n[i]}return i}},bind:function(){var t=this,i=t.owner.options.configTimeout/50,a=function(){for(var e=t.length;0
'),l.wrapClass&&(!0===l.wrapClass?i.addClass(s[0].className):i.addClass(l.wrapClass))),c.wrapper=i,c.scaleInfo=r=d.scaleMap(c.images[0],c.images[1],l.scaleMap),c.base_canvas=e=c.graphics.createVisibleCanvas(c),c.overlay_canvas=t=c.graphics.createVisibleCanvas(c),a=y(c.images[1]).addClass("mapster_el "+c.images[0].className).attr({id:null,usemap:null}),(o=d.size(c.images[0])).complete&&a.css({width:o.width,height:o.height}),c.buildDataset(),a=y.extend({display:"block",position:"relative",padding:0},!0===l.enableAutoResizeSupport?{}:{width:r.width,height:r.height}),l.wrapCss&&y.extend(a,l.wrapCss),s.parent()[0]!==c.wrapper[0]&&s.before(c.wrapper),i.css(a),y(c.images.slice(2)).hide(),n=1;nw&&t[1]>b)return v=t,!(s=!0)}),s||(v=[l,u])),v}}(jQuery),!function(d){"use strict";var f=d.mapster,m=f.utils,e=f.MapArea.prototype;f.utils.getScaleInfo=function(e,t){var i;return t?.98<(i=e.width/t.width||e.height/t.height)&&i<1.02&&(i=1):(i=1,t=e),{scale:1!==i,scalePct:i,realWidth:t.width,realHeight:t.height,width:e.width,height:e.height,ratio:e.width/e.height}},f.utils.scaleMap=function(e,t,i){e=m.size(e),t=m.size(t,!0);if(t.complete())return e.complete()||(e=t),this.getScaleInfo(e,i?t:null);throw"Another script, such as an extension, appears to be interfering with image loading. Please let us know about this."},f.MapData.prototype.resize=function(t,i,a,n){var o,s,r,c,e,l=this;function u(e,t,i){f.hasCanvas()?(e.width=t,e.height=i):(d(e).width(t),d(e).height(i))}function h(){var e;u(l.overlay_canvas,t,i),0<=c&&((e=l.data[c]).tempOptions={fade:!1},l.getDataForKey(e.key).highlight(),e.tempOptions=null),u(l.base_canvas,t,i),l.redrawSelections(),l.currentAction="",m.isFunction(n)&&n(),l.processCommandQueue()}function p(){d(l.image).css(r),l.scaleInfo=m.getScaleInfo({width:t,height:i},{width:l.scaleInfo.realWidth,height:l.scaleInfo.realHeight}),d.each(l.data,function(e,t){d.each(t.areas(),function(e,t){t.resize()})})}n=n||a,l.scaleInfo.width===t&&l.scaleInfo.height===i||(c=l.highlightId,t||(e=i/l.scaleInfo.realHeight,t=Math.round(l.scaleInfo.realWidth*e)),i||(e=t/l.scaleInfo.realWidth,i=Math.round(l.scaleInfo.realHeight*e)),r={width:String(t)+"px",height:String(i)+"px"},f.hasCanvas()||d(l.base_canvas).children().remove(),e=d(l.wrapper).find(".mapster_el"),!0!==l.options.enableAutoResizeSupport&&(e=e.add(l.wrapper)),a?(s=[],l.currentAction="resizing",e.filter(":visible").each(function(e,t){o=m.defer(),s.push(o),d(t).animate(r,{duration:a,complete:o.resolve,easing:"linear"})}),e.filter(":hidden").css(r),o=m.defer(),s.push(o),m.when.all(s).then(h),p(),o.resolve()):(e.css(r),p(),h()))},f.MapData.prototype.autoResize=function(e,t){this.resize(d(this.wrapper).width(),null,e,t)},f.MapData.prototype.configureAutoResize=function(){var e=this,t=e.instanceEventNamespace();function i(){!0===e.options.autoResize&&e.autoResize(e.options.autoResizeDuration,e.options.onAutoResize)}d(e.image).on("load"+t,i),d(window).on("focus"+t,i),d(window).on("resize"+t,function(){e.autoResizeTimer&&clearTimeout(e.autoResizeTimer),e.autoResizeTimer=setTimeout(i,e.options.autoResizeDelay)}),d(window).on("readystatechange"+t,i),d(window.document).on("fullscreenchange"+t,i),i()},f.MapArea=m.subclass(f.MapArea,function(){this.base.init(),this.owner.scaleInfo.scale&&this.resize()}),e.coords=function(e,t){var i,a=[],n=e||this.owner.scaleInfo.scalePct,o=t||0;if(1===n&&0===t)return this.originalCoords;for(i=0;i',showToolTip:!1,toolTip:null,toolTipFade:!0,toolTipClose:["area-mouseout","image-mouseout","generic-mouseout"],onShowToolTip:null,onHideToolTip:null}),c.extend(e.area_defaults,{toolTip:null,toolTipClose:null}),e.MapData.prototype.clearToolTip=function(){this.activeToolTip&&(this.activeToolTip.stop().remove(),this.activeToolTip=null,this.activeToolTipID=null,l.ifFunction(this.options.onHideToolTip,this))},e.AreaData.prototype.showToolTip=function(e,t){var i,a,n,o=this,s=o.owner,r=o.effectiveOptions();if(t=t?c.extend({},t):{},e=e||r.toolTip,i=t.closeEvents||r.toolTipClose||s.options.toolTipClose||"tooltip-click",n=void 0!==t.template?t.template:s.options.toolTipContainer,t.closeEvents="string"==typeof i?i=l.split(i):i,t.fadeDuration=t.fadeDuration||(s.options.toolTipFade?(l.isNumeric(r.fadeDuration)?r:s.options).fadeDuration:0),a=o.area||c.map(o.areas(),function(e){return e.area}),s.activeToolTipID!==o.areaId){s.clearToolTip();var e=l.isFunction(e)?e({key:this.key,target:a}):e;if(e)return s.activeToolTip=e=u(e,n,t.css),s.activeToolTipID=o.areaId,n=function(){s.clearToolTip()},h(i,"area-click","click",c(s.map),null,n),h(i,"tooltip-click","click",e,null,n),h(i,"image-mouseout","mouseout",c(s.image),function(e){return e.relatedTarget&&"AREA"!==e.relatedTarget.nodeName&&e.relatedTarget!==o.area},n),h(i,"image-click","click",c(s.image),null,n),p(e,a,s.image,t.container,t),l.ifFunction(s.options.onShowToolTip,o.area,{toolTip:e,options:{},areaOptions:r,key:o.key,selected:o.isSelected()}),e}},e.impl.tooltip=function(s,r){return new e.Method(this,function(){var e,t,i,a,n,o=this;s?(n=(e=c(s))&&0 ``` Alternatively, you can include the Zepto version of ImageMapster from one of the following CDNs: -1. [jsDelivr](https://www.jsdelivr.com/package/npm/imagemapster?version=1.6.0) - -2. [cdnjs](https://cdnjs.com/libraries/imagemapster/1.6.0) - +1. [jsDelivr](https://www.jsdelivr.com/package/npm/imagemapster?version=1.7.0) - +2. [cdnjs](https://cdnjs.com/libraries/imagemapster/1.7.0) - ## Basic Usage diff --git a/site/src/content/docs/resources/faq.md b/site/src/content/docs/resources/faq.md index ff54581..bf8675c 100644 --- a/site/src/content/docs/resources/faq.md +++ b/site/src/content/docs/resources/faq.md @@ -85,7 +85,7 @@ On some older Android devices, the native web browser does not seem to handle im There are lots of ways to do this. -1. Use an online tool such as [image-map.net](https://www.image-map.net/) and/or [imagemap.org](https://imagemap.org/). +1. Use an online tool such as [image-map.net](https://www.image-map.net/). 2. Commercial drawing tools like Photoshop have capabilities to create image maps. 3. If you're creating a map for a geographical entity, like states or countries, someone's probably done it already. Google is your friend. Check [Wikipedia Commons](http://commons.wikimedia.org/wiki/Commons:Image_map_resources) for public domain maps, too.