! function (b, d, c) { var z = function () { function f(b, c) { this.dom = b; this.setoptions(c); this.render() } f.prototype.options = { mapname: "china", mapwidth: 850, mapheight: 680, statecolorlist: "2770b5 429dd4 5aabda 1c8dff 70b3dd c6e1f4 edf2f6".split(" "), statedataattr: ["stateinitcolor", "statehovercolor", "stateselectedcolor", "baifenbi"], statedatatype: "json", statesettingsxmlpath: "", statedata: {}, strokewidth: 1, strokecolor: "f9fcfe", strokehovercolor: "d9d9d9", stateinitcolor: "", statehovercolor: "ffffff", stateselectedcolor: "e32f02", statedisabledcolor: "eeeeee", showtip: !0, tipwidth: 280, tipheight: 110, tipouterh: 30, tipouterw: 30, statetiphtml: function (b, c) { return c.name }, hovercallback: function (b, c) {}, clickcallback: function (b, c) {}, external: !1 }; f.prototype.setoptions = function (b) { null == b && (b = null); this.options = d.extend({}, this.options, b); return this }; f.prototype.scaleraphael = function (b, c, d) { var e = document.getelementbyid(b); e.style.position || (e.style.position = "relative"); e.style.width = c + "px"; e.style.height = d + "px"; e.style.overflow = "hidden"; var l; "vml" == raphael.type ? (e.innerhtml = "", l = document.getelementbyid("vmlgroup_" + b)) : (e.innerhtml = '
', l = e.getelementsbyclassname("svggroup")[0]); var q = new raphael(l, c, d), f; "svg" == raphael.type ? q.canvas.setattribute("viewbox", "0 0 " + c + " " + d) : f = e.getelementsbytagname("div")[0]; q.changesize = function (b, m, h, k) { k = !k; var n = b / c, a = m / d, g = n < a ? n : a, n = parseint(d * g), a = parseint(c * g); if ("vml" == raphael.type) { var y = document.getelementsbytagname("textpath"), u; for (u in y) { var v = y[u]; if (v.style) { if (!v._fontsize) { var a = v.style.font.split("px"); v._fontsize = parseint(a[0]); v._font = a[1] } v.style.font = v._fontsize * g + "px" + v._font } } u = a < n ? 1e3 * a / c : 1e3 * n / d; u = parseint(u); l.style.width = u + "px"; l.style.height = u + "px"; k && (l.style.left = parseint((b - a) / 2) + "px", l.style.top = parseint((m - n) / 2) + "px"); f.style.overflow = "visible" } k && (a = b, n = m); e.style.width = a + "px"; e.style.height = n + "px"; q.setsize(a, n); h && (e.style.position = "absolute", e.style.left = parseint((b - a) / 2) + "px", e.style.top = parseint((m - n) / 2) + "px") }; q.scaleall = function (b) { q.changesize(c * b, d * b) }; q.changesize(c, d); q.w = c; q.h = d; return q }; f.prototype.render = function () { var b = this.options, c = this.dom, f = eval(b.mapname + "mapconfig"), e = {}; "xml" == b.statedatatype ? d.ajax({ type: "get", url: b.statesettingsxmlpath, async: !1, datatype: d.browser.msie ? "text" : "xml", success: function (u) { var a; d.browser.msie ? (a = new activexobject("microsoft.xmldom"), a.async = !1, a.loadxml(u)) : a = u; d(a).find("statedata").each(function (a) { var u = d(this), c = u.attr("statename"); e[c] = {}; a = 0; for (var f = b.statedataattr.length; a < f; a++) e[c][b.statedataattr[a]] = u.attr(b.statedataattr[a]) }) } }) : e = b.statedata; var l = function (a) { var c = d(a.node).offset().left + d(a.node).outerwidth() / 2, f = d(a.node).offset().top + d(a.node).outerheight() / 2, e = b.tipwidth, h = b.tipheight, k = a.direction, m = b.tipouterh, n = b.tipouterw, q = a = 0, g = [], l = [], p = [], w = [], x = [], r = e, t = h; "left" == k || "right" == k ? (r = e + n, t = h, f -= t / 2, "left" == k ? (c -= r, g = [r, t / 2], l = [0, 0], p = [e, 0], w = [0, t], x = [e, t]) : (a = n, g = [0, t / 2], l = [r, 0], p = [n, 0], w = [r, t], x = [n, t])) : (r = e, t = h + m, "top" == k ? (c -= r / 2, f -= t, g = [r / 2, t], l = [0, 0], p = [0, h], w = [r, 0], x = [r, h]) : (q = m, c -= r / 2, g = [r / 2, 0], l = [0, t], p = [0, m], w = [r, t], x = [r, m])); e = raphael("statetip", r, t); return [c, f, a, q] }, q = this.scaleraphael(c.attr("id"), f.width, f.height), z = { cursor: "pointer", stroke: "#" + b.strokecolor, "stroke-width": b.strokewidth, "stroke-linejoin": "round" }, p = {}, m, h; for (h in f.shapes) { var k = e[h], n = "#" + (k && b.statecolorlist[k.stateinitcolor] || b.stateinitcolor || f.names[h].color), a = "#" + (k && k.statehovercolor || b.statehovercolor), g = "#" + (k && k.stateselectedcolor || b.stateselectedcolor), k = "#" + (k && k.statedisabledcolor || b.statedisabledcolor); p[h] = {}; p[h].initcolor = n; p[h].hovercolor = a; p[h].selectedcolor = g; a = q.path(f.shapes[h]); a.id = h; a.name = f.names[h].name; a.attr(z); a.attr({ fill: n }); var g = a.getbbox().x + f.names[h].x, y = a.getbbox().y + f.names[h].y, g = q.text(g, y, a.name).attr({ cursor: "pointer", metadata: { mapid: 1 } }); a.font = g; g.obj = a; g.direction = f.names[h].direction; g.mapid = a.mapid = f.names[h].id; b.external && (b.external[a.id] = a); e[h] && e[h].diabled ? a.attr({ fill: k, cursor: "default" }) : (a.attr({ fill: n }), m = a, a.mousemove(function () { m.attr({ fill: p[m.id].initcolor, stroke: "#" + b.strokecolor }); m = this; this.attr({ fill: p[this.id].hovercolor, stroke: "#" + b.strokehovercolor }); if (b.showtip && d(".maptiptext.maptiptext" + this.mapid).length) { d("#statetip").empty(); var a = new l(this.font); console.log(this.font); d("#statetip").stop(!1, !0).animate({ left: 260, top: 180, display: "inline" }, 100).show().append('
'); console.log(); d("#maptipcontainer").css({ position: "absolute", left: a[2], top: a[3] }); d(".maptiptext.maptiptext" + this.mapid).clone().appendto("#maptipcontainer") } else d("#statetip").empty() }), g.mousemove(function () { m.attr({ fill: p[m.id].initcolor, stroke: "#" + b.strokecolor }); m = this.obj; this.obj.attr({ fill: p[this.obj.id].hovercolor, stroke: "#" + b.strokehovercolor }); if (b.showtip && d(".maptiptext.maptiptext" + this.mapid).length) { d("#statetip").empty(); var a = new l(this); d("#statetip").stop(!1, !0).animate({ left: a[0], top: a[1], display: "inline" }, 100).show().append('
'); console.log(); d("#maptipcontainer").css({ position: "absolute", left: a[2], top: a[3] }); d(".maptiptext.maptiptext" + this.mapid).clone().appendto("#maptipcontainer") } else d("#statetip").empty() })); q.changesize(b.mapwidth, b.mapheight, !1, !1) } d("body").mousemove(function (a) { if (a.pagex < c.offset().left || a.pagex > c.offset().left + c.innerwidth() || a.pagey < c.offset().top || a.pagey > c.offset().top + c.innerheight()) m.attr({ fill: p[m.id].initcolor, stroke: "#" + b.strokecolor }), d("#statetip").empty() }) }; return f }(); d.fn.svgmap = function (f) { var b = d(this), c = b.data(); c.svgmap && delete c.svgmap; !1 !== f && (c.svgmap = new z(b, f)); return c.svgmap } }(window, jquery);