{"version":3,"sources":["../assets/scripts/jquery.maphilight.js"],"names":["root","factory","define","amd","jQuery","this","$","has_VML","has_canvas","create_canvas_for","add_shape_to","clear_canvas","shape_from_area","canvas_style","hex_to_decimal","css3color","is_image_loaded","options_from_area","document","createElement","getContext","a","innerHTML","b","firstChild","style","behavior","adj","fn","maphilight","hex","Math","max","min","parseInt","color","opacity","substr","img","c","width","height","get","clearRect","draw_shape","context","shape","coords","x_shift","y_shift","beginPath","rect","moveTo","i","length","lineTo","arc","PI","closePath","canvas","options","name","shadow","save","shadowPosition","clip","shadowOffsetX","shadowX","shadowOffsetY","shadowY","shadowBlur","shadowRadius","shadowColor","shadowOpacity","shadowFrom","strokeStyle","stroke","fillStyle","fill","restore","globalCompositeOperation","fillColor","fillOpacity","strokeColor","strokeOpacity","lineWidth","strokeWidth","fade","css","animate","e","join","append","$html","children","remove","html","area","getAttribute","split","parseFloat","toLowerCase","$area","extend","metadata","data","complete","naturalWidth","position","left","top","padding","border","ie_hax_done","opts","defaults","window","ready","namespaces","add","createStyleSheet","shapes","each","addRule","wrap","map","canvas_always","usemap","setTimeout","is","hasClass","wrapper","parent","insertBefore","unbind","display","backgroundImage","src","backgroundSize","wrapClass","addClass","attr","before","bind","empty","find","area_options","alwaysOn","alwaysOnFade","trigger","target","neverOn","groupBy","areas","test","first","subarea_options"],"mappings":"CAAA,SAAAA,EAAAC,GACA,kBAAAC,SAAAA,OAAAC,IACAD,QAAA,UAAAD,GAEAA,EAAAD,EAAAI,SAEAC,KAAA,SAAAC,GACA,GAAAC,GAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EACAC,EAAAC,EAAAC,EAAAC,EAAAC,CAaA,IAXAT,IAAAU,SAAAC,cAAA,UAAAC,WAGAb,EAAA,WACA,GAAAc,GAAAH,SAAAC,cAAA,MACAE,GAAAC,UAAA,oCACA,IAAAC,GAAAF,EAAAG,UAEA,OADAD,GAAAE,MAAAC,SAAA,qBACAH,GAAA,gBAAAA,GAAAI,QAGAnB,IAA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G,EAAA,SAIAG,QAAA,uBACAN,KAAA,yCAAA,SAAArD,GACA,GAAA5C,GAAAoG,EAAAjD,EAAAP,EAAA4D,MAEA,IADAJ,EAAAjI,EAAAgF,EAAArC,IACAsF,EAAAK,UAAAL,EAAAC,SAAA,CAGA,GAFArG,EAAAlC,EAAAqF,GACAvF,EAAAiD,EAAAb,EAAA,GAAAA,EAAA,GAAAoG,EAAA,eACAA,EAAAM,QAAA,CACA,GAAAC,EAGAA,GADA,wBAAAC,KAAAR,EAAAM,SACA3B,EAAAoB,KAAA,QAAAC,EAAAM,QAAA,KAAAlJ,EAAA2F,GAAA4C,KAAAK,EAAAM,SAAA,MAEA3B,EAAAoB,KAAAC,EAAAM,QAEA,IAAAG,GAAA1D,CACAwD,GAAA/B,KAAA,WACA,GAAArH,MAAAsJ,EAAA,CACA,GAAAC,GAAA3I,EAAAZ,KAAAuD,EACA,KAAAgG,EAAAL,UAAAK,EAAAT,SAAA,CACA,GAAArG,GAAAlC,EAAAP,KACAK,GAAAiD,EAAAb,EAAA,GAAAA,EAAA,GAAA8G,EAAA,mBAMApJ,GACAF,EAAAqD,GAAAiC,OAAA,wBAGAmD,KAAA,uCAAA,SAAArD,GACA/E,EAAAgD,KAGArB,EAAAwG,OAAAnF,GAEArB,EAAAsG,SAAA,oBAGAtI,EAAAsB,GAAAC,WAAAsF,UACArC,MAAA,EACAG,UAAA,SACAC,YAAA,GACAN,QAAA,EACAO,YAAA,SACAC,cAAA,EACAE,YAAA,EACAC,MAAA,EACA4D,UAAA,EACAI,SAAA,EACAC,SAAA,EACAb,WAAA,EAEA7E,QAAA,EACAK,QAAA,EACAE,QAAA,EACAE,aAAA,EACAC,YAAA,SACAC,cAAA,GACAT,eAAA,UACAU,YAAA","file":"jquery.maphilight.js","sourcesContent":["(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n define(['jquery'], factory);\n } else {\n factory(root.jQuery);\n }\n})(this, function ($) {\n var has_VML, has_canvas, create_canvas_for, add_shape_to, clear_canvas, shape_from_area,\n canvas_style, hex_to_decimal, css3color, is_image_loaded, options_from_area;\n\n has_canvas = !!document.createElement('canvas').getContext;\n\n // VML: more complex\n has_VML = (function () {\n var a = document.createElement('div');\n a.innerHTML = '<v:shape id=\"vml_flag1\" adj=\"1\" />';\n var b = a.firstChild;\n b.style.behavior = \"url(#default#VML)\";\n return b ? typeof b.adj == \"object\" : true;\n })();\n\n if (!(has_canvas || has_VML)) {\n $.fn.maphilight = function () {\n return this;\n };\n return;\n }\n\n if (has_canvas) {\n hex_to_decimal = function (hex) {\n return Math.max(0, Math.min(parseInt(hex, 16), 255));\n };\n css3color = function (color, opacity) {\n return 'rgba(' + hex_to_decimal(color.substr(0, 2)) + ',' + hex_to_decimal(color.substr(2, 2)) + ',' + hex_to_decimal(color.substr(4, 2)) + ',' + opacity + ')';\n };\n create_canvas_for = function (img) {\n var c = $('<canvas style=\"width:' + $(img).width() + 'px;height:' + $(img).height() + 'px;\"></canvas>').get(0);\n c.getContext(\"2d\").clearRect(0, 0, $(img).width(), $(img).height());\n return c;\n };\n var draw_shape = function (context, shape, coords, x_shift, y_shift) {\n x_shift = x_shift || 0;\n y_shift = y_shift || 0;\n\n context.beginPath();\n if (shape == 'rect') {\n // x, y, width, height\n context.rect(coords[0] + x_shift, coords[1] + y_shift, coords[2] - coords[0], coords[3] - coords[1]);\n } else if (shape == 'poly') {\n context.moveTo(coords[0] + x_shift, coords[1] + y_shift);\n for (i = 2; i < coords.length; i += 2) {\n context.lineTo(coords[i] + x_shift, coords[i + 1] + y_shift);\n }\n } else if (shape == 'circ') {\n // x, y, radius, startAngle, endAngle, anticlockwise\n context.arc(coords[0] + x_shift, coords[1] + y_shift, coords[2], 0, Math.PI * 2, false);\n }\n context.closePath();\n };\n add_shape_to = function (canvas, shape, coords, options, name) {\n var i, context = canvas.getContext('2d');\n\n // Because I don't want to worry about setting things back to a base state\n\n // Shadow has to happen first, since it's on the bottom, and it does some clip /\n // fill operations which would interfere with what comes next.\n if (options.shadow) {\n context.save();\n if (options.shadowPosition == \"inside\") {\n // Cause the following stroke to only apply to the inside of the path\n draw_shape(context, shape, coords);\n context.clip();\n }\n\n // Redraw the shape shifted off the canvas massively so we can cast a shadow\n // onto the canvas without having to worry about the stroke or fill (which\n // cannot have 0 opacity or width, since they're what cast the shadow).\n var x_shift = canvas.width * 100;\n var y_shift = canvas.height * 100;\n draw_shape(context, shape, coords, x_shift, y_shift);\n\n context.shadowOffsetX = options.shadowX - x_shift;\n context.shadowOffsetY = options.shadowY - y_shift;\n context.shadowBlur = options.shadowRadius;\n context.shadowColor = css3color(options.shadowColor, options.shadowOpacity);\n\n // Now, work out where to cast the shadow from! It looks better if it's cast\n // from a fill when it's an outside shadow or a stroke when it's an interior\n // shadow. Allow the user to override this if they need to.\n var shadowFrom = options.shadowFrom;\n if (!shadowFrom) {\n if (options.shadowPosition == 'outside') {\n shadowFrom = 'fill';\n } else {\n shadowFrom = 'stroke';\n }\n }\n if (shadowFrom == 'stroke') {\n context.strokeStyle = \"rgba(0,0,0,1)\";\n context.stroke();\n } else if (shadowFrom == 'fill') {\n context.fillStyle = \"rgba(0,0,0,1)\";\n context.fill();\n }\n context.restore();\n\n // and now we clean up\n if (options.shadowPosition == \"outside\") {\n context.save();\n // Clear out the center\n draw_shape(context, shape, coords);\n context.globalCompositeOperation = \"destination-out\";\n context.fillStyle = \"rgba(0,0,0,1);\";\n context.fill();\n context.restore();\n }\n }\n\n context.save();\n\n draw_shape(context, shape, coords);\n\n // fill has to come after shadow, otherwise the shadow will be drawn over the fill,\n // which mostly looks weird when the shadow has a high opacity\n if (options.fill) {\n context.fillStyle = css3color(options.fillColor, options.fillOpacity);\n context.fill();\n }\n // Likewise, stroke has to come at the very end, or it'll wind up under bits of the\n // shadow or the shadow-background if it's present.\n if (options.stroke) {\n context.strokeStyle = css3color(options.strokeColor, options.strokeOpacity);\n context.lineWidth = options.strokeWidth;\n context.stroke();\n }\n\n context.restore();\n\n if (options.fade) {\n $(canvas).css('opacity', 0).animate({opacity: 1}, 100);\n }\n };\n clear_canvas = function (canvas) {\n canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);\n };\n } else { // ie executes this code\n create_canvas_for = function (img) {\n return $('<var style=\"zoom:1;overflow:hidden;display:block;width:' + img.width + 'px;height:' + img.height + 'px;\"></var>').get(0);\n };\n add_shape_to = function (canvas, shape, coords, options, name) {\n var fill, stroke, opacity, e;\n for (var i in coords) {\n coords[i] = parseInt(coords[i], 10);\n }\n fill = '<v:fill color=\"#' + options.fillColor + '\" opacity=\"' + (options.fill ? options.fillOpacity : 0) + '\" />';\n stroke = (options.stroke ? 'strokeweight=\"' + options.strokeWidth + '\" stroked=\"t\" strokecolor=\"#' + options.strokeColor + '\"' : 'stroked=\"f\"');\n opacity = '<v:stroke opacity=\"' + options.strokeOpacity + '\"/>';\n if (shape == 'rect') {\n e = $('<v:rect name=\"' + name + '\" filled=\"t\" ' + stroke + ' style=\"zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + coords[0] + 'px;top:' + coords[1] + 'px;width:' + (coords[2] - coords[0]) + 'px;height:' + (coords[3] - coords[1]) + 'px;\"></v:rect>');\n } else if (shape == 'poly') {\n e = $('<v:shape name=\"' + name + '\" filled=\"t\" ' + stroke + ' coordorigin=\"0,0\" coordsize=\"' + canvas.width + ',' + canvas.height + '\" path=\"m ' + coords[0] + ',' + coords[1] + ' l ' + coords.join(',') + ' x e\" style=\"zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:' + canvas.width + 'px;height:' + canvas.height + 'px;\"></v:shape>');\n } else if (shape == 'circ') {\n e = $('<v:oval name=\"' + name + '\" filled=\"t\" ' + stroke + ' style=\"zoom:1;margin:0;padding:0;display:block;position:absolute;left:' + (coords[0] - coords[2]) + 'px;top:' + (coords[1] - coords[2]) + 'px;width:' + (coords[2] * 2) + 'px;height:' + (coords[2] * 2) + 'px;\"></v:oval>');\n }\n e.get(0).innerHTML = fill + opacity;\n $(canvas).append(e);\n };\n clear_canvas = function (canvas) {\n // jquery1.8 + ie7\n var $html = $(\"<div>\" + canvas.innerHTML + \"</div>\");\n $html.children('[name=highlighted]').remove();\n canvas.innerHTML = $html.html();\n };\n }\n\n shape_from_area = function (area) {\n var i, coords = area.getAttribute('coords').split(',');\n for (i = 0; i < coords.length; i++) {\n coords[i] = parseFloat(coords[i]);\n }\n return [area.getAttribute('shape').toLowerCase().substr(0, 4), coords];\n };\n\n options_from_area = function (area, options) {\n var $area = $(area);\n return $.extend({}, options, $.metadata ? $area.metadata() : false, $area.data('maphilight'));\n };\n\n is_image_loaded = function (img) {\n if (!img.complete) {\n return false;\n } // IE\n if (typeof img.naturalWidth != \"undefined\" && img.naturalWidth === 0) {\n return false;\n } // Others\n return true;\n };\n\n canvas_style = {\n position: 'absolute',\n left: 0,\n top: 0,\n padding: 0,\n border: 0\n };\n\n var ie_hax_done = false;\n $.fn.maphilight = function (opts) {\n opts = $.extend({}, $.fn.maphilight.defaults, opts);\n\n if (!has_canvas && !ie_hax_done) {\n $(window).ready(function () {\n document.namespaces.add(\"v\", \"urn:schemas-microsoft-com:vml\");\n var style = document.createStyleSheet();\n var shapes = ['shape', 'rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group', 'textbox'];\n $.each(shapes,\n function () {\n style.addRule('v\\\\:' + this, \"behavior: url(#default#VML); antialias:true\");\n }\n );\n });\n ie_hax_done = true;\n }\n\n return this.each(function () {\n var img, wrap, options, map, canvas, canvas_always, highlighted_shape, usemap;\n img = $(this);\n\n if (!is_image_loaded(this)) {\n // If the image isn't fully loaded, this won't work right. Try again later.\n return window.setTimeout(function () {\n img.maphilight(opts);\n }, 200);\n }\n\n options = $.extend({}, opts, $.metadata ? img.metadata() : false, img.data('maphilight'));\n\n // jQuery bug with Opera, results in full-url#usemap being returned from jQuery's attr.\n // So use raw getAttribute instead.\n usemap = img.get(0).getAttribute('usemap');\n\n if (!usemap) {\n return;\n }\n\n map = $('map[name=\"' + usemap.substr(1) + '\"]');\n\n if (!(img.is('img,input[type=\"image\"]') && usemap && map.length > 0)) {\n return;\n }\n\n if (img.hasClass('maphilighted')) {\n // We're redrawing an old map, probably to pick up changes to the options.\n // Just clear out all the old stuff.\n var wrapper = img.parent();\n img.insertBefore(wrapper);\n wrapper.remove();\n $(map).unbind('.maphilight');\n }\n\n wrap = $('<div></div>').css({\n display: 'block',\n backgroundImage: 'url(\"' + this.src + '\")',\n backgroundSize: 'contain',\n position: 'relative',\n padding: 0,\n width: this.width,\n height: this.height\n });\n if (options.wrapClass) {\n if (options.wrapClass === true) {\n wrap.addClass($(this).attr('class'));\n } else {\n wrap.addClass(options.wrapClass);\n }\n }\n img.before(wrap).css('opacity', 0).css(canvas_style).remove();\n if (has_VML) {\n img.css('filter', 'Alpha(opacity=0)');\n }\n wrap.append(img);\n\n canvas = create_canvas_for(this);\n $(canvas).css(canvas_style);\n canvas.height = this.height;\n canvas.width = this.width;\n\n $(map).bind('alwaysOn.maphilight', function () {\n // Check for areas with alwaysOn set. These are added to a *second* canvas,\n // which will get around flickering during fading.\n if (canvas_always) {\n clear_canvas(canvas_always);\n }\n if (!has_canvas) {\n $(canvas).empty();\n }\n $(map).find('area[coords]').each(function () {\n var shape, area_options;\n area_options = options_from_area(this, options);\n if (area_options.alwaysOn) {\n if (!canvas_always && has_canvas) {\n canvas_always = create_canvas_for(img[0]);\n $(canvas_always).css(canvas_style);\n canvas_always.width = img[0].width;\n canvas_always.height = img[0].height;\n img.before(canvas_always);\n }\n area_options.fade = area_options.alwaysOnFade; // alwaysOn shouldn't fade in initially\n shape = shape_from_area(this);\n if (has_canvas) {\n add_shape_to(canvas_always, shape[0], shape[1], area_options, \"\");\n } else {\n add_shape_to(canvas, shape[0], shape[1], area_options, \"\");\n }\n }\n });\n }).trigger('alwaysOn.maphilight')\n .bind('mouseover.maphilight, focus.maphilight', function (e) {\n var shape, area_options, area = e.target;\n area_options = options_from_area(area, options);\n if (!area_options.neverOn && !area_options.alwaysOn) {\n shape = shape_from_area(area);\n add_shape_to(canvas, shape[0], shape[1], area_options, \"highlighted\");\n if (area_options.groupBy) {\n var areas;\n // two ways groupBy might work; attribute and selector\n if (/^[a-zA-Z][\\-a-zA-Z]+$/.test(area_options.groupBy)) {\n areas = map.find('area[' + area_options.groupBy + '=\"' + $(area).attr(area_options.groupBy) + '\"]');\n } else {\n areas = map.find(area_options.groupBy);\n }\n var first = area;\n areas.each(function () {\n if (this != first) {\n var subarea_options = options_from_area(this, options);\n if (!subarea_options.neverOn && !subarea_options.alwaysOn) {\n var shape = shape_from_area(this);\n add_shape_to(canvas, shape[0], shape[1], subarea_options, \"highlighted\");\n }\n }\n });\n }\n // workaround for IE7, IE8 not rendering the final rectangle in a group\n if (!has_canvas) {\n $(canvas).append('<v:rect></v:rect>');\n }\n }\n }).bind('mouseout.maphilight, blur.maphilight', function (e) {\n clear_canvas(canvas);\n });\n\n img.before(canvas); // if we put this after, the mouseover events wouldn't fire.\n\n img.addClass('maphilighted');\n });\n };\n $.fn.maphilight.defaults = {\n fill: true,\n fillColor: '000000',\n fillOpacity: 0.2,\n stroke: true,\n strokeColor: 'ff0000',\n strokeOpacity: 1,\n strokeWidth: 1,\n fade: true,\n alwaysOn: false,\n neverOn: false,\n groupBy: false,\n wrapClass: true,\n // plenty of shadow:\n shadow: false,\n shadowX: 0,\n shadowY: 0,\n shadowRadius: 6,\n shadowColor: '000000',\n shadowOpacity: 0.8,\n shadowPosition: 'outside',\n shadowFrom: false\n };\n});\n"],"sourceRoot":"assets/scripts/"}