Advertisement
DeMorgan

Untitled

Dec 11th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 100.09 KB | None | 0 0
  1. (function($) {
  2. "use strict";
  3. $.fn.CSSMap = function(o) {
  4. var d = {
  5. size: 0,
  6. mapStyle: "default",
  7. tooltips: "floating",
  8. tooltipArrowHeight: 5,
  9. cities: false,
  10. responsive: "auto",
  11. fitHeight: false,
  12. activateOnLoad: [],
  13. tapOnce: false,
  14. mobileSupport: false,
  15. loadingText: "Loading ...",
  16. visibleList: {
  17. enable: false,
  18. containerId: "",
  19. listPosition: "bottom",
  20. columns: 1,
  21. columnsGap: 0,
  22. columnWidth: 0,
  23. hideItems: []
  24. },
  25. multipleClick: {
  26. enable: false,
  27. searchUrl: "search.php",
  28. searchLink: "Search",
  29. searchLinkVar: "region",
  30. separator: "+",
  31. hideSearchLink: false,
  32. clicksLimit: 0,
  33. clicksLimitAlert: "You can select only %d region! || regions!"
  34. },
  35. agentsList: {
  36. enable: false,
  37. agentsListId: "",
  38. agentsListSpeed: 0,
  39. agentsListOnHover: false
  40. },
  41. pins: {
  42. enable: false,
  43. pinsId: "",
  44. mapSize: 0,
  45. markerClass: "cssmap-marker",
  46. pinTooltipClass: "cssmap-tooltip-content",
  47. markerPosition: "middle",
  48. tooltipPosition: "top",
  49. tooltipOnClick: false,
  50. clickableRegions: true
  51. },
  52. formSupport: {
  53. enable: false,
  54. inputId: "",
  55. selectId: "",
  56. selectLabel: "",
  57. value: "name"
  58. },
  59. navigation: {
  60. enable: false,
  61. loop: false,
  62. next: "",
  63. prev: "",
  64. separator: "|",
  65. label: "",
  66. description: ""
  67. },
  68. onClick: function(e) {},
  69. onSecondClick: function(e) {},
  70. onHover: function(e) {},
  71. unHover: function(e) {},
  72. onLoad: function(e) {},
  73. authorInfo: false,
  74. disableClicks: false
  75. },
  76. CSSMapError = function(a) {
  77. return "<div class=\"cssmap-error\"><p><b>CSSMap error</b> - " + a + "</p></div>"
  78. },
  79. CSSMapSignature = "<div class=\"cssmap-signature\"><a href=\"http://cssmapsplugin.com/?ref=" + window.location.href + "\" rel=\"external\"><b>CSSMap plugin</b> by Łukasz Popardowski</a></div>";
  80. if (o) {
  81. var w = window,
  82. s = $.extend(true, d, o || {}),
  83. wHash = w.location.hash,
  84. bW = $(w).width(),
  85. bH = $(w).height(),
  86. ie = ((navigator.appVersion.indexOf("MSIE 7.") != -1 || navigator.appVersion.indexOf("MSIE 8.") != -1) ? true : false),
  87. resizeTimer, mapContainerID, MAPS = {
  88. "africa": {
  89. abbr: "afr",
  90. cs: [34, 17, 7, 14, 11, 5, 18, 2, 4, 20, 21, 3, 14, 9, 29, 3, 9, 3, 11, 22, 10, 4, 7, 11, 3, 13, 5, 7, 23, 12, 2, 7, 24, 17, 2, 2, 13, 26, 13, 19, 14, 3, 4, 7, 3, 10, 3, 4, 18, 6, 28, 19, 21, 3, 4, 9, 6, 14, 16, 11],
  91. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  92. heights: [235, 300, 405, 510, 610, 700, 800, 900, 1200, 1360]
  93. },
  94. "argentina": {
  95. abbr: "ar",
  96. cs: [3, 37, 32, 25, 23, 21, 24, 19, 31, 23, 17, 25, 26, 14, 28, 36, 38, 27, 12, 34, 30, 17, 21, 13, 11],
  97. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  98. heights: [445, 540, 680, 900, 1135, 1370, 1595, 1825, 2040]
  99. },
  100. "australia": {
  101. abbr: "au",
  102. cs: [3, 26, 18, 31, 13, 11, 21, 31],
  103. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280],
  104. heights: [200, 305, 410, 515, 620, 710, 810, 915, 1215]
  105. },
  106. "austria": {
  107. abbr: "at",
  108. cs: [25, 29, 50, 45, 36, 38, 45, 12, 6],
  109. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  110. heights: [115, 175, 240, 300, 360, 410, 460, 525, 700, 800]
  111. },
  112. "belgium": {
  113. abbr: "be",
  114. cs: [32, 9, 43, 46, 53, 48, 41, 48, 49, 22, 32],
  115. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  116. heights: [175, 265, 360, 450, 540, 620, 705, 800, 1065, 1205]
  117. },
  118. "brazil": {
  119. abbr: "br",
  120. cs: [14, 9, 18, 44, 38, 13, 3, 8, 24, 24, 31, 23, 31, 38, 14, 14, 19, 21, 11, 9, 25, 16, 17, 15, 22, 8, 23],
  121. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  122. heights: [220, 335, 445, 560, 675, 780, 885, 1000, 1330, 1505]
  123. },
  124. "canada": {
  125. abbr: "ca",
  126. cs: [21, 32, 14, 14, 37, 35, 10, 45, 31, 3, 42, 14, 28],
  127. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  128. heights: [215, 275, 370, 465, 560, 645, 730, 825, 1100, 1245]
  129. },
  130. "chile": {
  131. abbr: "cl",
  132. cs: [11, 4, 10, 13, 9, 8, 12, 7, 9, 7, 20, 7, 11, 7, 9],
  133. sizes: [200, 300, 350, 400, 450, 550],
  134. heights: [575, 855, 1125, 1405, 1675, 1950]
  135. },
  136. "colombia": {
  137. abbr: "co",
  138. cs: [51, 47, 16, 5, 9, 29, 36, 17, 49, 28, 30, 27, 38, 20, 30, 29, 33, 24, 20, 20, 44, 26, 21, 22, 7, 10, 2, 25, 17, 20, 23, 36, 23],
  139. sizes: [210, 320, 430, 540, 650, 750, 850, 960],
  140. heights: [285, 435, 580, 725, 875, 1015, 1155, 1300]
  141. },
  142. "continents": {
  143. abbr: "c",
  144. cs: [20, 35, 19, 23, 35, 15, 3],
  145. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  146. heights: [105, 130, 165, 220, 280, 340, 395, 445, 495, 665, 755]
  147. },
  148. "croatia": {
  149. abbr: "hr",
  150. cs: [24, 27, 36, 10, 15, 24, 20, 11, 26, 8, 21, 18, 21, 30, 28, 29, 13, 18, 21, 33, 35],
  151. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  152. heights: [200, 315, 415, 525, 640, 740, 830, 945, 1255, 1425]
  153. },
  154. "cuba": {
  155. abbr: "cu",
  156. cs: [7, 24, 22, 11, 15, 13, 4, 19, 10, 13, 15, 6, 16, 17, 11, 20],
  157. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  158. heights: [95, 125, 175, 215, 255, 285, 320, 370, 495, 565]
  159. },
  160. "czech-republic": {
  161. abbr: "cs",
  162. cs: [8, 34, 38, 15, 34, 26, 18, 30, 38, 26, 25, 46, 24, 23],
  163. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  164. heights: [125, 195, 265, 330, 395, 450, 505, 580, 770, 875]
  165. },
  166. "europe": {
  167. abbr: "eu",
  168. cs: [5, 2, 9, 10, 5, 6, 7, 10, 4, 9, 9, 5, 15, 22, 7, 14, 12, 8, 7, 7, 2, 24, 2, 7, 2, 7, 2, 4, 3, 7, 2, 4, 8, 30, 12, 4, 11, 42, 6, 5, 5, 11, 26, 6, 10, 20, 17, 10, 2, 6, 9, 3],
  169. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  170. heights: [210, 260, 340, 425, 520, 605, 690, 770, 1040, 1160]
  171. },
  172. "finland": {
  173. abbr: "fi",
  174. cs: [10, 33, 34, 43, 43, 20, 25, 47, 22, 80, 32, 34, 43, 72, 40, 24, 26, 27, 25],
  175. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  176. heights: [410, 500, 630, 825, 1040, 1260, 1465, 1670, 1875]
  177. },
  178. "france": {
  179. abbr: "fr",
  180. cs: [43, 50, 52, 41, 20, 36, 10, 16, 43, 30, 24, 34, 32, 2, 2, 2, 2, 2],
  181. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280],
  182. heights: [305, 385, 505, 640, 770, 900, 1025, 1150, 1530]
  183. },
  184. "france-departments": {
  185. abbr: "frd",
  186. cs: [14, 14, 17, 15, 20, 11, 13, 11, 15, 13, 15, 19, 14, 10, 14, 16, 15, 16, 13, 9, 10, 15, 13, 13, 18, 15, 15, 14, 13, 9, 20, 22, 12, 20, 16, 12, 11, 12, 17, 14, 15, 16, 11, 12, 17, 15, 14, 14, 10, 16, 13, 16, 17, 9, 17, 13, 12, 15, 15, 16, 14, 15, 13, 14, 14, 12, 7, 14, 7, 9, 13, 15, 11, 15, 9, 11, 14, 14, 8, 13, 12, 12, 13, 11, 11, 15, 16, 15, 18, 15, 3, 5, 14, 19, 14, 7, 2, 2, 2, 2, 2],
  187. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280],
  188. heights: [325, 410, 525, 665, 800, 940, 1080, 1200, 1600]
  189. },
  190. "germany": {
  191. abbr: "de",
  192. cs: [48, 77, 10, 66, 10, 10, 58, 53, 87, 60, 44, 11, 37, 50, 38, 46],
  193. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  194. heights: [280, 340, 430, 570, 720, 865, 1005, 1145, 1285]
  195. },
  196. "greece": {
  197. abbr: "gr",
  198. cs: [15, 37, 26, 13, 25, 23, 22, 5, 16, 32, 35, 35, 29, 20],
  199. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280],
  200. heights: [210, 320, 430, 540, 650, 750, 850, 960, 1280]
  201. },
  202. "hungary": {
  203. abbr: "hu",
  204. cs: [40, 23, 23, 35, 8, 20, 25, 25, 25, 30, 31, 18, 19, 39, 28, 28, 28, 19, 23, 19],
  205. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  206. heights: [135, 205, 280, 350, 420, 480, 540, 615, 820, 935]
  207. },
  208. "italy": {
  209. abbr: "it",
  210. cs: [19, 17, 20, 28, 29, 19, 33, 23, 35, 19, 15, 33, 33, 23, 44, 40, 25, 17, 9, 36, 2],
  211. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  212. heights: [260, 315, 400, 535, 670, 810, 940, 1065, 1195]
  213. },
  214. "netherlands": {
  215. abbr: "nl",
  216. cs: [37, 27, 41, 58, 36, 29, 41, 36, 48, 33, 20, 40],
  217. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  218. heights: [245, 295, 375, 500, 630, 760, 880, 1000, 1125]
  219. },
  220. "norway": {
  221. abbr: "no",
  222. cs: [15, 21, 23, 28, 23, 21, 22, 18, 37, 28, 3, 10, 17, 18, 27, 12, 24, 13, 6, 8],
  223. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  224. heights: [290, 345, 435, 580, 730, 880, 1020, 1160, 1305]
  225. },
  226. "poland": {
  227. abbr: "pl",
  228. cs: [39, 38, 36, 31, 35, 25, 56, 25, 33, 34, 39, 32, 29, 38, 51, 39],
  229. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  230. heights: [200, 240, 305, 410, 515, 620, 710, 805, 910]
  231. },
  232. "slovakia": {
  233. abbr: "sk",
  234. cs: [36, 20, 36, 36, 37, 29, 40, 31],
  235. sizes: [210, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  236. heights: [115, 170, 235, 290, 350, 395, 445, 510, 680, 775]
  237. },
  238. "south-america": {
  239. abbr: "sam",
  240. cs: [80, 30, 100, 52, 36, 21, 18, 6, 18, 44, 10, 13, 36, 6],
  241. sizes: [150, 210, 320, 430, 540, 650, 750, 850, 960],
  242. heights: [225, 315, 475, 620, 790, 960, 1115, 1275, 1420]
  243. },
  244. "spain": {
  245. abbr: "es",
  246. cs: [15, 19, 11, 14, 14, 18, 24, 12, 24, 20, 14, 15, 14, 19, 15, 13, 17, 13, 19, 22, 6, 15, 20, 9, 13, 19, 15, 16, 18, 11, 14, 21, 14, 15, 8, 11, 15, 16, 6, 14, 19, 21, 15, 25, 25, 21, 15, 10, 14, 32, 2, 2],
  247. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  248. heights: [210, 270, 360, 450, 540, 620, 710, 800, 1060, 1200]
  249. },
  250. "spain-autonomies": {
  251. abbr: "esa",
  252. cs: [40, 36, 19, 8, 2, 13, 57, 64, 28, 32, 31, 22, 13, 16, 19, 18, 14, 2, 2],
  253. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  254. heights: [210, 270, 360, 450, 540, 620, 710, 800, 1060, 1200]
  255. },
  256. "sweden": {
  257. abbr: "se",
  258. cs: [14, 51, 43, 10, 19, 73, 34, 34, 25, 55, 26, 32, 18, 24, 22, 21, 34, 62, 46, 24, 39],
  259. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  260. heights: [435, 525, 665, 875, 1105, 1335, 1555, 1775, 1985]
  261. },
  262. "switzerland": {
  263. abbr: "ch",
  264. cs: [27, 14, 8, 18, 6, 65, 37, 10, 13, 38, 16, 30, 18, 14, 12, 13, 21, 29, 30, 21, 23, 18, 38, 51, 8, 22],
  265. sizes: [250, 320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  266. heights: [165, 215, 290, 360, 435, 495, 560, 640, 850, 965]
  267. },
  268. "turkey": {
  269. abbr: "tr",
  270. cs: [16, 8, 12, 12, 7, 11, 19, 17, 7, 7, 9, 12, 5, 10, 6, 6, 8, 10, 8, 10, 10, 8, 9, 13, 13, 13, 6, 7, 10, 10, 18, 8, 11, 9, 10, 6, 6, 4, 11, 9, 13, 10, 8, 14, 8, 10, 13, 4, 6, 8, 9, 7, 23, 10, 12, 11, 9, 12, 13, 10, 7, 10, 8, 6, 8, 6, 10, 12, 8, 7, 16, 7, 8, 10, 6, 8, 6, 8, 3, 10, 5],
  271. sizes: [320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  272. heights: [150, 210, 260, 315, 355, 400, 455, 610, 695]
  273. },
  274. "uruguay": {
  275. abbr: "uy",
  276. cs: [35, 24, 47, 22, 51, 22, 37, 34, 31, 9, 40, 41, 39, 31, 33, 26, 33, 43, 32],
  277. sizes: [210, 250, 320, 430, 540, 650, 750, 850, 960],
  278. heights: [230, 275, 355, 470, 590, 715, 825, 935, 1055]
  279. },
  280. "usa": {
  281. abbr: "usa",
  282. cs: [8, 14, 12, 9, 23, 8, 5, 5, 17, 11, 9, 17, 12, 7, 7, 5, 10, 7, 10, 14, 7, 13, 14, 7, 12, 13, 7, 20, 7, 8, 9, 14, 13, 5, 7, 7, 17, 8, 5, 9, 5, 8, 28, 10, 6, 13, 11, 3, 11, 10, 8, 5],
  283. sizes: [320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  284. heights: [226, 310, 385, 460, 530, 595, 680, 905, 1030]
  285. },
  286. "usa-canada": {
  287. abbr: "usacan",
  288. cs: [13, 22, 10, 9, 22, 26, 7, 28, 23, 3, 30, 6, 19, 6, 21, 8, 5, 12, 5, 6, 5, 9, 7, 5, 10, 6, 5, 4, 4, 7, 6, 7, 9, 5, 10, 11, 5, 8, 6, 4, 11, 6, 3, 4, 11, 10, 4, 5, 4, 10, 5, 4, 8, 4, 6, 18, 5, 6, 7, 6, 5, 7, 8, 5, 32, 6, 6, 6, 5, 2, 5],
  289. sizes: [320, 430, 540, 650, 750, 850, 960, 1280, 1450],
  290. heights: [330, 445, 555, 670, 775, 880, 995, 1325, 1500]
  291. },
  292. },
  293. doMaps = function(T, g) {
  294. var h = "#" + T.id,
  295. mapContainer = $(h),
  296. mapList = mapContainer.find("UL").eq(0),
  297. mapName = $(mapList).attr("class").split(" ")[0],
  298. getMapSize = function() {
  299. var r = parseInt(s.size),
  300. f = s.fitHeight,
  301. mapSizes = MAPS[mapName].sizes,
  302. mapHeights = MAPS[mapName].heights;
  303. if ((!$.isEmptyObject(s.responsive) || s.responsive.toString() === "auto" || f) && !ie) {
  304. if (s.responsive.toString() === "auto" || f) {
  305. var a = document.getElementById(h.slice(1)),
  306. topOffset = M.getTopOffset(a),
  307. parent = mapContainer.parent();
  308. for (var i = 0; i < mapSizes.length; i++) {
  309. if (f) {
  310. mapContainer.css({
  311. height: mapHeights[i]
  312. })
  313. } else {
  314. mapContainer.css({
  315. height: "auto"
  316. })
  317. }
  318. var b = (i + 1),
  319. parentW = parent.outerWidth(),
  320. parentH = (parent.outerHeight() >= mapHeights[0] ? parent.outerHeight() : mapHeights[0]),
  321. fitH = (parentH <= mapHeights[i] && parentH >= mapHeights[0] ? 1 : 0),
  322. fitS = ((bH - topOffset) <= mapHeights[b] && topOffset < bH ? 1 : 0),
  323. fitW = (parentW <= mapSizes[b] && mapSizes[i] < r ? 1 : 0);
  324. if (fitW || f && (fitH || fitS)) {
  325. r = mapSizes[i];
  326. break
  327. }
  328. }
  329. }
  330. if (!$.isEmptyObject(s.responsive)) {
  331. for (var c in s.responsive) {
  332. if (bW <= c) {
  333. if ($.inArray(parseInt(s.responsive[c]), mapSizes) == -1) {
  334. r = 0;
  335. break
  336. } else {
  337. r = s.responsive[c];
  338. break
  339. }
  340. }
  341. }
  342. }
  343. }
  344. return r
  345. },
  346. li = mapList.find("LI"),
  347. mapStyles = ["default", "blue", "dark", "vintage", "custom"],
  348. pinsContainer = $(s.pins.pinsId),
  349. pin = pinsContainer.find("LI"),
  350. countClicks = 0,
  351. clicksLimit = false,
  352. cli = "",
  353. tooltips = s.tooltips.toString(),
  354. DonClick = (s.pins.tooltipOnClick.toString() === "false" ? false : true),
  355. clickableRegions = s.pins.clickableRegions.toString(),
  356. aa = (s.activateOnLoad ? s.activateOnLoad : mapContainer.find(".active-region")),
  357. M = {
  358. init: function() {
  359. var a = getMapSize();
  360. M.clearMap();
  361. mapContainer.addClass("cssmap-container cssmap-" + a);
  362. if (s.mapStyle && s.mapStyle != "default") {
  363. mapList.addClass("cssmap-" + s.mapStyle)
  364. }
  365. var b = mapList.css("background-image").replace(/^url\("?([^\"\))]+)"?\)$/i, "$1");
  366. this.loader(b)
  367. },
  368. loader: function(a) {
  369. var b = new Image(),
  370. preloader = $("<span />", {
  371. "class": "cssmap-loader",
  372. "text": s.loadingText
  373. }).appendTo(mapContainer),
  374. loaderPosition = {
  375. left: Math.round(mapContainer.outerWidth() / 2) + "px",
  376. marginLeft: Math.round(preloader.outerWidth() / -2) + "px",
  377. marginTop: Math.round(preloader.outerHeight() / -2) + "px",
  378. top: Math.round(mapContainer.outerHeight() / 2) + "px"
  379. };
  380. preloader.css(loaderPosition);
  381. mapList.addClass("cssmap");
  382. $(b).on({
  383. load: function() {
  384. if (s.cities && !ie) {
  385. mapContainer.append("<span class=\"cssmap-cities " + mapName + "-cities cssmap-" + s.mapStyle + "\" />")
  386. }
  387. if (clickableRegions !== "false") {
  388. M.regions.init()
  389. }
  390. if (s.agentsList.enable.toString() !== "false") {
  391. M.agentslist.init()
  392. }
  393. if (s.multipleClick.enable.toString() !== "false" && !s.multipleClick.hideSearchLink) {
  394. M.searchButton();
  395. M.selectRegion.multiple()
  396. }
  397. if (s.navigation.enable.toString() !== "false" && !s.multipleClick.enable) {
  398. M.navigation.init()
  399. }
  400. if (s.visibleList.enable.toString() !== "false") {
  401. M.visibleList.init()
  402. }
  403. if (s.pins.enable.toString() !== "false") {
  404. M.pins.init()
  405. }
  406. if (s.formSupport.enable.toString() !== "false") {
  407. M.formSupport.init()
  408. }
  409. if (s.authorInfo.toString() !== "false") {
  410. mapContainer.after(CSSMapSignature)
  411. }
  412. preloader.fadeOut("slow");
  413. s.onLoad(mapContainer)
  414. },
  415. error: function() {
  416. M.clearMap();
  417. if (!s.mobileSupport) {
  418. mapContainer.prepend(CSSMapError("Map image cannot be found!<br/><br/>- incorrect path: " + a))
  419. }
  420. return false
  421. }
  422. }).attr("src", a)
  423. },
  424. regions: {
  425. init: function() {
  426. var b = M.regions;
  427. b.hideTooltips();
  428. li.each(function(a) {
  429. var t = $(this),
  430. lC = (t.attr("class") ? t.attr("class").split(" ")[0] : null),
  431. lA = t.children("A").eq(0),
  432. lH = $(lA).attr("href");
  433. if (typeof lH === "undefined" || lC === null || lH.length <= 1) {
  434. $(t).remove()
  435. }
  436. if (s.visibleList.enable.toString() !== "false") {
  437. b.copyList($(t), lC, lA, lH, a)
  438. }
  439. b.createSpans($(t), lC);
  440. M.selectRegion.init($(t), lC, lA)
  441. });
  442. if (s.visibleList.enable.toString() !== "false") {
  443. b.createList(cli);
  444. M.selectRegion.initVisibleList()
  445. }
  446. b.autoSelectRegion();
  447. M.formSupport.inputFn()
  448. },
  449. createSpans: function(l, a) {
  450. var m = "<span class=\"m\">",
  451. cs = MAPS[mapName].cs,
  452. abbr = MAPS[mapName].abbr,
  453. lA = l.children("A").eq(0);
  454. if (tooltips !== "visible" && tooltips.split("-")[0] != "floating") {
  455. var b = $("<span class=\"tooltip-arrow\" />").appendTo(lA)
  456. }
  457. for (var i = 0; i < cs.length; i++) {
  458. var c = i + 1;
  459. if (a == abbr + c) {
  460. for (var s = 1; s < cs[i]; s++) {
  461. m += "<span class=\"s" + s + "\" />"
  462. }
  463. break
  464. }
  465. }
  466. m += "</span>";
  467. l.prepend(m).append("<span class=\"bg\" />")
  468. },
  469. showTooltip: function(l) {
  470. var a = mapList.find(l).children("A")[0];
  471. if (tooltips == "true" || tooltips == "sticky" || tooltips == "visible") {
  472. var b = mapList.outerWidth(),
  473. aMT = parseInt($(a).outerHeight() * -1) - s.tooltipArrowHeight,
  474. aMTm = parseInt($(a).outerHeight() / -2),
  475. aML = parseInt($(a).outerWidth() / -2),
  476. aL = $(a).position().left,
  477. aT = $(a).position().top;
  478. if ((aML * -1) > aL) {
  479. $(a).addClass("tooltip-left").css("left", 0);
  480. aML = 0
  481. }
  482. if ((aML * -1) + aL > b) {
  483. $(a).addClass("tooltip-right");
  484. aML = 0
  485. }
  486. if ((aMT * -1) > aT) {
  487. $(a).addClass("tooltip-top");
  488. aMT = s.tooltipArrowHeight
  489. }
  490. if ($(a).hasClass("tooltip-middle")) {
  491. aMT = aMTm
  492. }
  493. a.style.clip = "auto";
  494. a.style.marginLeft = aML + "px";
  495. if (tooltips == "visible") {
  496. a.style.marginTop = aMTm + "px"
  497. } else {
  498. a.style.marginTop = aMT + "px"
  499. }
  500. } else if (tooltips.split("-")[0] == "floating") {
  501. var c = $(a).html(),
  502. floatingTooltip = $("<div />", {
  503. "id": "cssmap-tooltip",
  504. "class": "cssmap-tooltip-content cssmap-" + s.mapStyle,
  505. "html": c
  506. }).appendTo("BODY")
  507. }
  508. },
  509. hideTooltips: function() {
  510. var a = mapList.find("a");
  511. $("#cssmap-tooltip").remove();
  512. for (var i = 0; i < a.length; i++) {
  513. var b = a[i],
  514. tTmL = Math.round($(b).outerWidth() / -2),
  515. tTmT = Math.round($(b).outerHeight() / -2);
  516. if (tooltips == "visible") {
  517. b.style.marginTop = tTmT + "px";
  518. b.style.marginLeft = tTmL + "px"
  519. } else {
  520. b.style.clip = "rect(1px 1px 1px 1px)";
  521. b.style.clip = "rect(1px, 1px, 1px, 1px)"
  522. }
  523. }
  524. },
  525. copyList: function(l, a, b, c, d) {
  526. var e = b.html(),
  527. columns = parseInt(s.visibleList.columns),
  528. items = Math.round((li.length / columns));
  529. if (typeof c !== "undefined" && c.length >= 2 && $.inArray(a, s.visibleList.hideItems) == -1) {
  530. cli += " <li class=\"" + a + "\"><a href=\"" + c + "\">" + e + "</a></li>\n"
  531. }
  532. for (var i = 1; i < columns; i++) {
  533. if (Math.round((items * i) == (d + 1))) {
  534. cli += " </ul>\n <ul class=\"cssmap-visible-list cssmap-visible-list-column\">\n";
  535. break
  536. }
  537. }
  538. },
  539. createList: function(a) {
  540. var b = "<div id=\"" + h.slice(1) + "-visible-list\" class=\"cssmap-visible-list-container\">\n <ul class=\"cssmap-visible-list";
  541. if (parseInt(s.visibleList.columns) > 1) {
  542. b += " cssmap-visible-list-column"
  543. }
  544. b += "\">" + a + " </ul>\n</div>";
  545. if (s.visibleList.containerId && $(s.visibleList.containerId).length) {
  546. $(s.visibleList.containerId).html(b).css({
  547. "overflow": "hidden"
  548. })
  549. } else {
  550. $(mapList).after(b)
  551. }
  552. },
  553. autoSelectRegion: function() {
  554. if (aa.length) {
  555. for (var i = 0; i < aa.length; i++) {
  556. M.selectRegion.activated($("." + aa[i]))
  557. }
  558. }
  559. }
  560. },
  561. selectRegion: {
  562. init: function(l, b, d) {
  563. var f = M.selectRegion,
  564. lC = $(h).find("." + b).eq(0),
  565. lMapSpan = $(lC).children("SPAN").eq(0),
  566. code = null;
  567. f.autoSelect(d);
  568. lMapSpan.on({
  569. mouseenter: function() {
  570. f.onHover($(lC))
  571. },
  572. mouseleave: function() {
  573. f.unHover($(lC))
  574. },
  575. mousemove: function(c) {
  576. if (tooltips.split("-")[0] == "floating") {
  577. f.onMouseMove($(lC), c)
  578. }
  579. },
  580. touchmove: function(c) {
  581. if (tooltips.split("-")[0] == "floating" && s.tapOnce.toString() !== "false") {
  582. f.onMouseMove($(lC), c)
  583. }
  584. },
  585. touchend: function(a) {
  586. if (s.tapOnce.toString() !== "false") {
  587. f.clicked($(lC));
  588. if (a.preventDefault()) {
  589. a.preventDefault()
  590. } else {
  591. return false
  592. }
  593. }
  594. },
  595. click: function(a) {
  596. f.clicked($(lC));
  597. if (a.preventDefault()) {
  598. a.preventDefault()
  599. } else {
  600. return false
  601. }
  602. }
  603. });
  604. $(d).on({
  605. focus: function() {
  606. f.onHover($(lC))
  607. },
  608. blur: function() {
  609. f.unHover($(lC))
  610. },
  611. keypress: function(e) {
  612. code = (e.keyCode ? e.keyCode : e.which);
  613. if (code === 13) {
  614. f.clicked($(lC))
  615. }
  616. },
  617. click: function(a) {
  618. f.clicked($(lC));
  619. if (a.preventDefault()) {
  620. a.preventDefault()
  621. } else {
  622. return false
  623. }
  624. }
  625. })
  626. },
  627. initVisibleList: function() {
  628. var c = M.selectRegion,
  629. vLi = $(h + " .cssmap-visible-list").find("LI"),
  630. code = null;
  631. if (s.visibleList.containerId && s.visibleList.containerId != "#") {
  632. vLi = $(s.visibleList.containerId + " .cssmap-visible-list").find("LI")
  633. }
  634. vLi.each(function() {
  635. var b = $(this).children("A"),
  636. vC = h + " ." + $(this).attr("class");
  637. b.on({
  638. mouseenter: function() {
  639. c.onHover($(vC))
  640. },
  641. mouseleave: function() {
  642. c.unHover($(vC))
  643. },
  644. focus: function() {
  645. c.onHover($(vC))
  646. },
  647. blur: function() {
  648. c.unHover($(vC))
  649. },
  650. keypress: function(e) {
  651. code = (e.keyCode ? e.keyCode : e.which);
  652. if (code === 13) {
  653. c.clicked($(vC))
  654. }
  655. },
  656. click: function(a) {
  657. c.clicked($(vC));
  658. if (a.preventDefault()) {
  659. a.preventDefault()
  660. } else {
  661. return false
  662. }
  663. }
  664. })
  665. })
  666. },
  667. onHover: function(e) {
  668. var a = e.children("A").eq(0).attr("href");
  669. M.regions.hideTooltips();
  670. M.regions.showTooltip(e);
  671. e.addClass("focus");
  672. s.onHover(e);
  673. if (s.agentsList.agentsListOnHover.toString() !== "false") {
  674. M.agentslist.showAgent(a)
  675. }
  676. },
  677. onMouseMove: function(e, c) {
  678. var a = $("#cssmap-tooltip").eq(0),
  679. mT = parseInt(s.tooltipArrowHeight),
  680. oL = 10,
  681. oT = 15 + mT,
  682. tH = $(a).outerHeight(),
  683. tW = $(a).outerWidth(),
  684. bT = $(w).scrollTop(),
  685. pT = c.pageY - tH - mT,
  686. pL = c.pageX - (tW / 2);
  687. if (mT < 3) {
  688. mT = 3
  689. }
  690. switch (tooltips) {
  691. case "floating-left":
  692. case "floating-left-top":
  693. case "floating-top-left":
  694. if (c.clientX - tW <= oL) {
  695. pL = c.pageX + oL
  696. } else {
  697. pL = c.pageX - tW - oL
  698. }
  699. break;
  700. case "floating-right":
  701. case "floating-right-top":
  702. case "floating-top-right":
  703. if (bW <= c.clientX + tW + oL) {
  704. pL = c.pageX - tW - oL
  705. } else {
  706. pL = c.pageX + oL
  707. }
  708. break;
  709. case "floating-middle":
  710. case "floating-middle-right":
  711. case "floating-right-middle":
  712. if (bW <= c.clientX + tW + oL) {
  713. pL = c.pageX - tW - oL
  714. } else {
  715. pL = c.pageX + oL
  716. }
  717. if (bT >= c.pageY - (tH / 2) - mT) {
  718. pT = c.pageY + oT - mT
  719. } else if (c.clientY + (tH / 2) >= bH) {
  720. pT = c.pageY - tH - mT
  721. } else {
  722. pT = c.pageY - (tH / 2)
  723. }
  724. break;
  725. case "floating-middle-left":
  726. case "floating-left-middle":
  727. if (c.clientX - tW <= oL) {
  728. pL = c.pageX + oL
  729. } else {
  730. pL = c.pageX - tW - oL
  731. }
  732. if (bT >= c.pageY - (tH / 2) - mT) {
  733. pT = c.pageY + oT - mT
  734. } else if (c.clientY + (tH / 2) >= bH) {
  735. pT = c.pageY - tH - mT
  736. } else {
  737. pT = c.pageY - (tH / 2)
  738. }
  739. break;
  740. case "floating-bottom-left":
  741. case "floating-left-bottom":
  742. if (c.clientX - tW < oL) {
  743. pL = c.pageX + oL
  744. } else {
  745. pL = c.pageX - tW - oL
  746. }
  747. pT = c.pageY + oT;
  748. break;
  749. case "floating-bottom":
  750. case "floating-bottom-center":
  751. case "floating-center-bottom":
  752. if (c.clientX - (tW / 2) + oL <= oL) {
  753. pL = c.pageX + oL
  754. } else if (bW <= c.clientX + (tW / 2)) {
  755. pL = c.pageX - tW - oL
  756. } else {
  757. pL = c.pageX - (tW / 2)
  758. }
  759. pT = c.pageY + oT;
  760. break;
  761. case "floating-bottom-right":
  762. case "floating-right-bottom":
  763. if (bW <= c.clientX + tW + oL) {
  764. pL = c.pageX - tW - oL
  765. } else {
  766. pL = c.pageX + oL
  767. }
  768. pT = c.pageY + oT;
  769. break;
  770. default:
  771. if (c.clientX - (tW / 2) + oL <= oL) {
  772. pL = c.pageX + oL
  773. } else if (bW <= c.clientX + (tW / 2)) {
  774. pL = c.pageX - tW - oL
  775. } else {
  776. pL = c.pageX - (tW / 2)
  777. }
  778. }
  779. if (bT >= c.pageY - tH - mT) {
  780. pT = c.pageY + oT
  781. }
  782. if (c.clientY + tH + oT >= bH) {
  783. pT = c.pageY - tH - mT
  784. }
  785. a.css({
  786. "left": pL + "px",
  787. "top": pT + "px"
  788. })
  789. },
  790. unHover: function(e) {
  791. var b = e.children("a").eq(0).attr("href");
  792. M.regions.hideTooltips();
  793. e.removeClass("focus");
  794. if (s.agentsList.agentsListOnHover.toString() !== "false") {
  795. M.agentslist.hideAgents(b);
  796. $(mapList).find(".active-region").each(function() {
  797. var a = $(this).children("a").eq(0).attr("href");
  798. M.agentslist.showAgent(a)
  799. })
  800. }
  801. s.unHover(e)
  802. },
  803. activated: function(e) {
  804. var a = s.multipleClick.clicksLimitAlert.split(" %d ")[0],
  805. clicksLimitAlert2 = s.multipleClick.clicksLimitAlert.split(" %d ")[1],
  806. r = "",
  807. lClass = e.attr("class").split(" ")[0],
  808. lH = e.children("A").eq(0).attr("href"),
  809. agentsListContainer = $(s.agentsList.agentsListId),
  810. selectField = $(s.formSupport.selectId);
  811. if (s.multipleClick.clicksLimit === 0 || !s.multipleClick.enable) {
  812. s.multipleClick.clicksLimit = Infinity
  813. }
  814. if (s.multipleClick.clicksLimit == 1) {
  815. r = clicksLimitAlert2.split(" || ")[0]
  816. } else {
  817. r = clicksLimitAlert2.split(" || ")[1]
  818. }
  819. if (e.hasClass("active-region")) {
  820. e.removeClass("active-region");
  821. if (selectField.length) {
  822. if (!s.formSupport.selectLabel) {
  823. selectField.val("")
  824. } else {
  825. selectField.val(0)
  826. }
  827. }
  828. countClicks--;
  829. clicksLimit = false
  830. } else {
  831. if (countClicks < s.multipleClick.clicksLimit) {
  832. if (!s.multipleClick.enable && $.inArray(lClass, aa) == -1) {
  833. mapContainer.find(".active-region").removeClass("active-region")
  834. }
  835. if (selectField.length) {
  836. $(s.formSupport.selectId + " option:selected").removeAttr("selected");
  837. selectField.val(lClass)
  838. }
  839. countClicks++;
  840. e.addClass("active-region")
  841. } else {
  842. alert(a + " " + s.multipleClick.clicksLimit + " " + r);
  843. clicksLimit = true
  844. }
  845. }
  846. if (agentsListContainer.length && lH.charAt(0) === "#") {
  847. M.agentslist.init()
  848. }
  849. },
  850. clicked: function(e) {
  851. if (typeof e === "undefined" || e === null) {
  852. return false
  853. }
  854. var a = e.children("A").eq(0),
  855. lH = a.attr("href"),
  856. target = a.attr("target"),
  857. rel = a.attr("rel");
  858. if (s.disableClicks) {
  859. return false
  860. }
  861. M.selectRegion.activated(e);
  862. M.selectRegion.multiple();
  863. M.formSupport.inputFn();
  864. if (e.hasClass("active-region")) {
  865. s.onClick(e)
  866. } else {
  867. s.onSecondClick(e);
  868. M.selectRegion.removeHash()
  869. }
  870. aa = [];
  871. if (clicksLimit === false) {
  872. if (typeof target !== "undefined" && target !== false) {
  873. w.open(lH, target)
  874. } else if (lH !== "undefined" && lH.charAt(0) === "#") {
  875. if (s.agentsList.enable.toString() !== "false" || s.multipleClick.enable.toString() !== "false") {
  876. return false
  877. } else {
  878. if (rel !== "nofollow") {
  879. w.location.hash = lH
  880. }
  881. }
  882. } else {
  883. if (rel !== "nofollow") {
  884. w.location.href = lH
  885. } else {
  886. return false
  887. }
  888. }
  889. }
  890. },
  891. multiple: function() {
  892. var a = M.getActiveRegions(),
  893. sb = mapContainer.find(".cssmap-search-link"),
  894. newLink = s.multipleClick.searchUrl,
  895. v = "";
  896. for (var i = 0; i < a.length; i++) {
  897. var b = $("." + a[i]).children("A").eq(0),
  898. lH = b.attr("href"),
  899. nlH;
  900. if (lH !== "undefined" && lH.charAt(0) == "#") {
  901. nlH = lH.slice(1)
  902. } else if (/&/i.test(lH)) {
  903. nlH = lH.slice(lH.indexOf("?") + (s.multipleClick.searchLinkVar.length) + 2, lH.indexOf("&"))
  904. } else {
  905. nlH = lH.slice(lH.indexOf("?") + (s.multipleClick.searchLinkVar.length) + 2)
  906. }
  907. if (i > 0) {
  908. v += s.multipleClick.separator
  909. }
  910. v += nlH
  911. }
  912. if (a.length) {
  913. newLink += "?" + s.multipleClick.searchLinkVar + "=" + v
  914. }
  915. sb.attr("href", newLink)
  916. },
  917. autoSelect: function(e) {
  918. var a = e.attr("href"),
  919. wH = wHash,
  920. li = e.parent("LI");
  921. if (a !== "undefined" && a.charAt(0) == "#" && a == wH) {
  922. var b = li.attr("class").split(" ")[0];
  923. aa[b];
  924. li.addClass("active-region");
  925. return false
  926. }
  927. },
  928. removeHash: function() {
  929. history.pushState("", d.title, w.location.pathname + w.location.search)
  930. }
  931. },
  932. searchButton: function() {
  933. var a = $("<a />", {
  934. "href": s.multipleClick.searchUrl,
  935. "class": "cssmap-search-link",
  936. "text": s.multipleClick.searchLink
  937. });
  938. $(mapList).after(a)
  939. },
  940. visibleList: {
  941. init: function() {
  942. var a = $(h + "-visible-list"),
  943. VI = a.find("UL");
  944. M.visibleList.listSize(VI);
  945. if (!s.visibleList.containerId || !$(s.visibleList.containerId).length) {
  946. M.visibleList.setPosition(a)
  947. }
  948. },
  949. listSize: function(l) {
  950. var a = parseInt(s.visibleList.columnWidth),
  951. cGap = parseInt(s.visibleList.columnsGap),
  952. cNum = parseInt(s.visibleList.columns),
  953. vListParentWidth = ($(s.visibleList.containerId).length ? $(s.visibleList.containerId).outerWidth() : getMapSize()),
  954. vListWidth = Math.round((vListParentWidth / cNum) - cGap);
  955. if (a > 0) {
  956. vListWidth = Math.round(a + cGap)
  957. }
  958. var b = Math.round(cGap / 2),
  959. listCSS = {
  960. float: "left",
  961. marginLeft: b + "px",
  962. marginRight: b + "px",
  963. width: vListWidth + "px"
  964. };
  965. l.each(function() {
  966. $(this).css(listCSS)
  967. })
  968. },
  969. setPosition: function(e) {
  970. var b = function() {
  971. var a = getMapSize(),
  972. nMw = 0,
  973. mapsParentWidth = mapContainer.parent().outerWidth(),
  974. cWidth = parseInt(s.visibleList.columnWidth),
  975. cNum = parseInt(s.visibleList.columns),
  976. cGap = parseInt(s.visibleList.columnsGap * 2),
  977. sumWidth = Math.round(2 + (cWidth + cGap) * cNum);
  978. switch (s.visibleList.listPosition) {
  979. case "left":
  980. case "right":
  981. if (Math.round(a + sumWidth) >= mapsParentWidth) {
  982. nMw = mapsParentWidth
  983. } else {
  984. nMw = Math.round(a + sumWidth)
  985. }
  986. break;
  987. default:
  988. nMw = a;
  989. break
  990. }
  991. return nMw
  992. };
  993. switch (s.visibleList.listPosition) {
  994. case "left":
  995. var c = {
  996. "clear": "left",
  997. "float": "left"
  998. },
  999. mapListCSS = {
  1000. "float": "right"
  1001. };
  1002. mapContainer.find(".cssmap-cities").css({
  1003. "left": "auto",
  1004. "right": 0
  1005. });
  1006. break;
  1007. case "right":
  1008. var c = {
  1009. "clear": "right",
  1010. "float": "right"
  1011. },
  1012. mapListCSS = {
  1013. "float": "left"
  1014. };
  1015. break;
  1016. default:
  1017. var c = {
  1018. "clear": "both"
  1019. },
  1020. mapListCSS = {};
  1021. break
  1022. }
  1023. mapContainer.css({
  1024. height: "auto",
  1025. width: b() + "px"
  1026. });
  1027. mapList.css(mapListCSS);
  1028. e.css(c)
  1029. }
  1030. },
  1031. agentslist: {
  1032. init: function() {
  1033. var a = $(s.agentsList.agentsListId),
  1034. activeRegions = M.getActiveRegions();
  1035. if (a.length) {
  1036. $(s.agentsList.agentsListId).find("LI").hide();
  1037. a.find("UL").css({
  1038. listStyleType: "none"
  1039. })
  1040. }
  1041. if (activeRegions.length) {
  1042. for (var i = 0; i < activeRegions.length; i++) {
  1043. var b = $("." + activeRegions[i]).children("A").eq(0).attr("href");
  1044. M.agentslist.showAgent(b)
  1045. }
  1046. }
  1047. if (aa.length) {
  1048. for (var c = 0; c < aa.length; c++) {
  1049. var d = $("." + aa[c]).children("A").eq(0).attr("href");
  1050. M.agentslist.showAgent(d)
  1051. }
  1052. }
  1053. },
  1054. showAgent: function(a) {
  1055. if (!s.multipleClick.enable) {
  1056. $(s.agentsList.agentsListId).find("LI").hide()
  1057. }
  1058. if (!s.agentsList.agentsListOnHover) {
  1059. $(a + "," + a + " LI").fadeIn(parseInt(s.agentsList.agentsListSpeed))
  1060. } else {
  1061. $(a + "," + a + " LI").show()
  1062. }
  1063. },
  1064. hideAgents: function(a) {
  1065. if (!s.agentsList.agentsListOnHover) {
  1066. $(a + "," + a + " LI").fadeOut(parseInt(s.agentsList.agentsListSpeed))
  1067. } else {
  1068. $(a + "," + a + " LI").hide()
  1069. }
  1070. }
  1071. },
  1072. formSupport: {
  1073. init: function() {
  1074. M.formSupport.createOptions();
  1075. M.formSupport.selectFn()
  1076. },
  1077. createOptions: function() {
  1078. var a = "";
  1079. if (s.formSupport.selectLabel) {
  1080. a += "<option value=\"0\">" + s.formSupport.selectLabel + "</option>"
  1081. }
  1082. li.each(function() {
  1083. var A = $(this).children("A").eq(0),
  1084. optVal = this.className.split(" ")[0],
  1085. optText = A.text(),
  1086. regionHref = A.attr("href");
  1087. a += "<option value=\"" + optVal + "\"";
  1088. if (regionHref === wHash) {
  1089. a += " selected"
  1090. }
  1091. a += ">" + optText + "</option>";
  1092. A.attr("rel", "nofollow")
  1093. });
  1094. $(s.formSupport.selectId).html(a)
  1095. },
  1096. selectFn: function() {
  1097. var a = $(s.formSupport.selectId);
  1098. if (a.length) {
  1099. a.on("change", function() {
  1100. $(s.formSupport.selectId + " option:selected").each(function() {
  1101. M.formSupport.formActivateRegion($(this).val());
  1102. M.formSupport.inputFn()
  1103. })
  1104. })
  1105. }
  1106. },
  1107. inputFn: function() {
  1108. var a = $(s.formSupport.inputId),
  1109. activeRegions = M.getActiveRegions(),
  1110. v = "";
  1111. if (a.length) {
  1112. switch (s.formSupport.value) {
  1113. case "name":
  1114. for (var i = 0; i < activeRegions.length; i++) {
  1115. if (i > 0) {
  1116. v += s.multipleClick.separator
  1117. }
  1118. v += $("." + activeRegions[i]).children("A").eq(0).text()
  1119. }
  1120. break;
  1121. case "slug":
  1122. for (var b = 0; b < activeRegions.length; b++) {
  1123. var c = $("." + activeRegions[b]).children("A").eq(0).attr("href");
  1124. if (b > 0) {
  1125. v += s.multipleClick.separator
  1126. }
  1127. if (c !== undefined && c.charAt(0) === "#") {
  1128. v += c.slice(1)
  1129. } else {
  1130. v += c
  1131. }
  1132. }
  1133. break;
  1134. default:
  1135. v = activeRegions.join(s.multipleClick.separator);
  1136. break
  1137. }
  1138. a.val(v)
  1139. }
  1140. },
  1141. formActivateRegion: function(a) {
  1142. mapList.find(".active-region").removeClass("active-region");
  1143. if (a) {
  1144. mapList.find("." + a).addClass("active-region");
  1145. if ($(s.agentsList.agentsListId).length) {
  1146. M.agentslist.init()
  1147. }
  1148. }
  1149. }
  1150. },
  1151. navigation: {
  1152. init: function() {
  1153. $(mapList).after(this.createNav());
  1154. this.navFunctions();
  1155. if (s.fitHeight) {
  1156. $(mapContainer).css({
  1157. height: mapContainer.outerHeight() + mapContainer.find(".cssmap-navigation").outerHeight() + "px"
  1158. })
  1159. }
  1160. },
  1161. getClasses: function() {
  1162. var a = [];
  1163. for (var i = 0; i < li.length; i++) {
  1164. var b = li[i].className.split(" ")[0];
  1165. a.push(b)
  1166. }
  1167. return a
  1168. },
  1169. createNav: function() {
  1170. var a = document.createElement("DIV"),
  1171. getNavNext = s.navigation.next.replace(/<a\b[^>]*>(.*?)<\/a>/i, ""),
  1172. getNavPrev = s.navigation.prev.replace(/<a\b[^>]*>(.*?)<\/a>/i, ""),
  1173. navNext = "<li class=\"cssmap-nav-next\"><a href=\"#next-region\">" + (getNavNext ? getNavNext : "Next &#187;") + "</a></li>",
  1174. navPrev = "<li class=\"cssmap-nav-prev\"><a href=\"#previous-region\">" + (getNavPrev ? getNavPrev : "&#171; Previous") + "</a></li>",
  1175. navSeparator = (s.navigation.separator ? "<li class=\"cssmap-nav-separator\">" + s.navigation.separator + "</li>" : "");
  1176. a.id = h.slice(1) + "-navigation";
  1177. a.className = "cssmap-navigation";
  1178. if (s.navigation.label) {
  1179. a.innerHTML += "<h5 class=\"cssmap-nav-label\">" + s.navigation.label + "</h5>"
  1180. }
  1181. if (s.navigation.description) {
  1182. a.innerHTML += "<p class=\"cssmap-nav-description\">" + s.navigation.description + "</p>"
  1183. }
  1184. a.innerHTML += "<ul class=\"cssmap-nav-list\">" + navPrev + navSeparator + navNext + "</ul>";
  1185. return a
  1186. },
  1187. navFunctions: function() {
  1188. var b = document.getElementById(h.slice(1) + "-navigation"),
  1189. getNavLinks = b.getElementsByTagName("A");
  1190. $(getNavLinks).on({
  1191. keypress: function(e) {
  1192. code = (e.keyCode ? e.keyCode : e.which);
  1193. if (code === 13) {
  1194. M.selectRegion.clicked(M.navigation.getRegionToActivate(this))
  1195. }
  1196. },
  1197. click: function(a) {
  1198. M.selectRegion.clicked(M.navigation.getRegionToActivate(this));
  1199. if (a.preventDefault()) {
  1200. a.preventDefault()
  1201. } else {
  1202. return false
  1203. }
  1204. }
  1205. })
  1206. },
  1207. getRegionToActivate: function(e) {
  1208. var a = M.navigation.getClasses(),
  1209. regions = M.getActiveRegions()[0],
  1210. linkHref = e.hash,
  1211. returnClass;
  1212. if (a.indexOf(regions) !== -1) {
  1213. switch (linkHref) {
  1214. case "#next-region":
  1215. if (s.navigation.loop && typeof a[a.indexOf(regions) + 1] === "undefined") {
  1216. returnClass = a[0]
  1217. } else {
  1218. returnClass = a[a.indexOf(regions) + 1]
  1219. }
  1220. break;
  1221. case "#previous-region":
  1222. if (s.navigation.loop && typeof a[a.indexOf(regions) - 1] === "undefined") {
  1223. returnClass = a[a.length - 1]
  1224. } else {
  1225. returnClass = a[a.indexOf(regions) - 1]
  1226. }
  1227. break
  1228. }
  1229. } else {
  1230. switch (linkHref) {
  1231. case "#next-region":
  1232. returnClass = a[0];
  1233. break;
  1234. case "#previous-region":
  1235. returnClass = a[a.length - 1];
  1236. break
  1237. }
  1238. }
  1239. if (typeof returnClass !== "undefined" && returnClass !== null) {
  1240. return $("." + returnClass)
  1241. }
  1242. }
  1243. },
  1244. pins: {
  1245. init: function() {
  1246. var c = mapContainer.position().top,
  1247. mapY = function() {
  1248. var a, mapR, mapMargin = "auto";
  1249. switch (s.visibleList.listPosition) {
  1250. case "left":
  1251. a = "auto";
  1252. mapR = Math.round(mapList.offset().left) + "px";
  1253. break;
  1254. case "right":
  1255. a = Math.round(mapList.offset().left) + "px";
  1256. mapR = "auto";
  1257. break;
  1258. default:
  1259. a = Math.round(mapList.offset().left) + "px";
  1260. mapR = "auto";
  1261. break
  1262. }
  1263. return {
  1264. left: a,
  1265. right: mapR
  1266. }
  1267. },
  1268. mapW = $(mapList).outerWidth(),
  1269. mapH = $(mapList).outerHeight(),
  1270. pinsContainerCSS = {
  1271. height: mapH + "px",
  1272. left: mapY().left,
  1273. position: "absolute",
  1274. right: mapY().right,
  1275. top: c + "px",
  1276. width: mapW + "px"
  1277. };
  1278. pinsContainer.addClass("cssmap-markers-container");
  1279. pinsContainer.css(pinsContainerCSS);
  1280. pin.each(function() {
  1281. var t = $(this);
  1282. M.pins.pinContent(t);
  1283. var m = t.find("." + s.pins.markerClass).eq(0),
  1284. pC = t.find("." + s.pins.pinTooltipClass).eq(0),
  1285. pTlink = pC.find("A"),
  1286. mHref = m.attr("href"),
  1287. code = null,
  1288. coords = t.attr("data-cssmap-coords").split(","),
  1289. cMargin = function(a) {
  1290. var b, ct;
  1291. switch (a) {
  1292. case "210":
  1293. b = 7;
  1294. ct = 7;
  1295. break;
  1296. case "200":
  1297. b = 50;
  1298. ct = 15;
  1299. break;
  1300. case "250":
  1301. b = 5;
  1302. ct = 5;
  1303. break;
  1304. case "300":
  1305. b = 100;
  1306. ct = 20;
  1307. break;
  1308. case "320":
  1309. b = 10;
  1310. ct = 10;
  1311. break;
  1312. case "350":
  1313. b = 85;
  1314. ct = 20;
  1315. break;
  1316. case "400":
  1317. b = 70;
  1318. ct = 25;
  1319. break;
  1320. case "430":
  1321. case "850":
  1322. b = 20;
  1323. ct = 20;
  1324. break;
  1325. case "450":
  1326. b = 50;
  1327. ct = 25;
  1328. break;
  1329. case "540":
  1330. case "750":
  1331. b = 22;
  1332. ct = 22;
  1333. break;
  1334. case "550":
  1335. b = 85;
  1336. ct = 25;
  1337. break;
  1338. case "650":
  1339. b = 25;
  1340. ct = 25;
  1341. break;
  1342. case "1280":
  1343. b = 40;
  1344. ct = 40;
  1345. break;
  1346. case "1450":
  1347. b = 50;
  1348. ct = 50;
  1349. break;
  1350. default:
  1351. b = 30;
  1352. ct = 30;
  1353. break
  1354. }
  1355. return {
  1356. l: b,
  1357. t: ct
  1358. }
  1359. },
  1360. x = (s.pins.mapSize > 0 && s.pins.mapSize !== getMapSize() ? Math.round((coords[0] - cMargin(getMapSize()).l + cMargin(s.pins.mapSize).l) * getMapSize() / s.pins.mapSize) : parseInt(coords[0])),
  1361. y = (s.pins.mapSize > 0 && s.pins.mapSize !== getMapSize() ? Math.round((coords[1] - cMargin(getMapSize()).t + cMargin(s.pins.mapSize).t) * getMapSize() / s.pins.mapSize) : parseInt(coords[1])),
  1362. mW = m.outerWidth(),
  1363. mL = Math.round(mW / -2),
  1364. mH = parseInt(m.outerHeight()),
  1365. pCH = pC.outerHeight(),
  1366. pCW = pC.outerWidth(),
  1367. pCL = Math.round(pCW / -2),
  1368. mTop = function() {
  1369. var a;
  1370. switch (s.pins.markerPosition) {
  1371. case "middle":
  1372. a = y - (mH / 2);
  1373. break;
  1374. case "bottom":
  1375. a = y;
  1376. break;
  1377. default:
  1378. a = y - mH;
  1379. break
  1380. }
  1381. return a
  1382. },
  1383. pCTop = function() {
  1384. var a;
  1385. switch (s.pins.tooltipPosition) {
  1386. case "hidden":
  1387. a = "-9999em";
  1388. break;
  1389. case "bottom":
  1390. a = mTop() + mH;
  1391. break;
  1392. default:
  1393. a = mTop() - pCH;
  1394. break
  1395. }
  1396. return a
  1397. },
  1398. mpos = {
  1399. left: x + "px",
  1400. marginLeft: mL + "px",
  1401. position: "absolute",
  1402. textAlign: "center",
  1403. top: mTop() + "px",
  1404. zIndex: 200
  1405. },
  1406. pCpos = {
  1407. display: "block",
  1408. left: x + "px",
  1409. marginLeft: pCL + "px",
  1410. marginTop: "-9999em",
  1411. position: "absolute",
  1412. top: pCTop() + "px",
  1413. zIndex: 201
  1414. };
  1415. m.css(mpos);
  1416. pC.css(pCpos);
  1417. t.on({
  1418. mouseenter: function() {
  1419. if (!DonClick) {
  1420. M.pins.pinOpen(t, m, pC)
  1421. } else {
  1422. M.pins.pinClose(t, m, pC)
  1423. }
  1424. },
  1425. mouseleave: function() {
  1426. if (!DonClick) {
  1427. M.pins.pinClose(t, m, pC)
  1428. }
  1429. },
  1430. focus: function() {
  1431. if (!DonClick) {
  1432. M.pins.pinOpen(t, m, pC)
  1433. } else {
  1434. M.pins.pinClose(t, m, pC)
  1435. }
  1436. },
  1437. blur: function() {
  1438. if (!DonClick) {
  1439. M.pins.pinClose(t, m, pC)
  1440. }
  1441. },
  1442. keypress: function(e) {
  1443. code = (e.keyCode ? e.keyCode : e.which);
  1444. if (code === 13) {
  1445. if (DonClick) {
  1446. if (t.hasClass("hide-tooltip")) {
  1447. M.pins.pinClose(t, m, pC)
  1448. } else {
  1449. M.pins.pinOpen(t, m, pC)
  1450. }
  1451. if (event.preventDefault()) {
  1452. event.preventDefault()
  1453. } else {
  1454. return false
  1455. }
  1456. }
  1457. if (mHref !== undefined && mHref.charAt(0) === "#") {
  1458. if (event.preventDefault()) {
  1459. event.preventDefault()
  1460. } else {
  1461. return false
  1462. }
  1463. }
  1464. }
  1465. },
  1466. click: function(a) {
  1467. if (DonClick) {
  1468. if (t.hasClass("hide-tooltip")) {
  1469. M.pins.pinClose(t, m, pC)
  1470. } else {
  1471. M.pins.pinOpen(t, m, pC)
  1472. }
  1473. if (a.preventDefault()) {
  1474. a.preventDefault()
  1475. } else {
  1476. return false
  1477. }
  1478. }
  1479. if (mHref !== undefined && mHref.charAt(0) === "#") {
  1480. if (a.preventDefault()) {
  1481. a.preventDefault()
  1482. } else {
  1483. return false
  1484. }
  1485. }
  1486. }
  1487. });
  1488. pTlink.on({
  1489. click: function(a) {
  1490. var b = $(this).attr("href"),
  1491. pTtarget = $(this).attr("target");
  1492. if (typeof pTtarget !== "undefined" && pTtarget !== false) {
  1493. w.open(b, pTtarget)
  1494. } else if (b !== undefined && b.charAt(0) !== "#") {
  1495. w.location.href = b
  1496. } else {
  1497. w.location.hash = b
  1498. }
  1499. if (a.preventDefault()) {
  1500. a.preventDefault()
  1501. } else {
  1502. return false
  1503. }
  1504. }
  1505. })
  1506. })
  1507. },
  1508. pinContent: function(p) {
  1509. var a = p.find("." + s.pins.pinTooltipClass),
  1510. pL = p.find("." + s.pins.markerClass);
  1511. if (!a.length) {
  1512. p.wrapInner($("<div />").addClass(s.pins.pinTooltipClass + " cssmap-" + s.mapStyle).hide())
  1513. } else {
  1514. a.addClass("cssmap-" + s.mapStyle).hide()
  1515. }
  1516. if (!pL.length) {
  1517. var b = $("<a />", {
  1518. "class": s.pins.markerClass,
  1519. "href": "#",
  1520. "text": ""
  1521. }).appendTo(p)
  1522. }
  1523. },
  1524. pinOpen: function(t, m, a) {
  1525. $(pinsContainer).find(".hide-tooltip").each(function() {
  1526. var t = $(this),
  1527. m = t.find("." + s.pins.markerClass),
  1528. a = t.find("." + s.pins.pinTooltipClass);
  1529. M.pins.pinClose(t, m, a)
  1530. });
  1531. t.addClass("hide-tooltip");
  1532. a.css("margin-top", 0)
  1533. },
  1534. pinClose: function(t, m, a) {
  1535. t.removeClass("hide-tooltip");
  1536. a.css("margin-top", "-9999em")
  1537. }
  1538. },
  1539. getActiveRegions: function() {
  1540. var a = [];
  1541. li.each(function() {
  1542. if ($(this).hasClass("active-region")) {
  1543. a.push($(this).attr("class").split(" ")[0])
  1544. }
  1545. });
  1546. return a
  1547. },
  1548. getTopOffset: function(a) {
  1549. var b = a.getBoundingClientRect(),
  1550. body = document.body,
  1551. docElem = document.documentElement,
  1552. scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop,
  1553. clientTop = docElem.clientTop || body.clientTop || 0,
  1554. top = b.top + scrollTop - clientTop;
  1555. return Math.round(top)
  1556. },
  1557. clearMap: function() {
  1558. var a = "",
  1559. allStyles = "",
  1560. mapSizes = MAPS[mapName].sizes;
  1561. cli = "";
  1562. if ($.inArray(parseInt(s.size), mapSizes) == -1) {
  1563. mapContainer.html(CSSMapError("Incorrect size: " + s.size + "<br/><br/>- available sizes: " + mapSizes.join(", ").toString()));
  1564. return false
  1565. }
  1566. for (var i = 0; i < mapSizes.length; i++) {
  1567. a += " cssmap-" + mapSizes[i]
  1568. }
  1569. for (var i = 0; i < mapStyles.length; i++) {
  1570. allStyles += " cssmap-" + mapStyles[i]
  1571. };
  1572. mapContainer.removeClass(a).removeClass("cssmap-container");
  1573. mapContainer.find(".cssmap-loader, .cssmap-cities, .m, .bg, .tooltip-arrow, .cssmap-visible-list-container, .cssmap-visible-list, .cssmap-navigation, .cssmap-search-link, .cssmap-signature, .cssmap-error").remove();
  1574. mapContainer.find("LI").removeClass("focus").removeClass("active-region");
  1575. mapList.removeClass(allStyles).removeClass("cssmap");
  1576. $("body").find(".cssmap-tooltip-content").removeClass(allStyles);
  1577. $(h + "-navigation").remove();
  1578. $(h + "-visible-list" + (g + 1)).remove();
  1579. $("body").find(".cssmap-signature").remove();
  1580. if ($(s.formSupport.inputId).length) {
  1581. $(s.formSupport.inputId).val("")
  1582. }
  1583. if ($(s.formSupport.selectId).length) {
  1584. $(s.formSupport.selectId).html("")
  1585. }
  1586. }
  1587. };
  1588. $(w).on("resize", function(e) {
  1589. bW = $(w).width();
  1590. bH = $(w).height();
  1591. clearTimeout(resizeTimer);
  1592. resizeTimer = setTimeout(function() {
  1593. M.init()
  1594. }, 250)
  1595. });
  1596. M.init()
  1597. };
  1598. return this.each(function(a) {
  1599. if (!s.size) {
  1600. $(this).html(CSSMapError("map size must be set!"));
  1601. return false
  1602. }
  1603. if (typeof $.fn.on === "undefined" && !$.isFunction($.fn.on)) {
  1604. $(this).html(CSSMapError("<b>at least jQuery 1.7 is required!</b><br/><br/>- jQuery version used: " + $.fn.jquery + "<br/>- get a current version: <a href=\"http://jquery.com/download\">http://jquery.com/download</a>"));
  1605. return false
  1606. }
  1607. if (typeof $(this).attr("id") != "undefined") {
  1608. this.id
  1609. } else {
  1610. this.id = "cssmap" + (a + 1)
  1611. }
  1612. doMaps(this, a)
  1613. })
  1614. } else {
  1615. return this.html(CSSMapError("map size must be set!"))
  1616. }
  1617. }
  1618. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement