From db17fe051c7d473b658e7825fa57b04382fe53f8 Mon Sep 17 00:00:00 2001 From: Uksusov Kirill Date: Wed, 1 Feb 2017 23:55:32 +0400 Subject: [PATCH] Fix click by not found individual. --- _js/jquery.imagemapster.init.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/_js/jquery.imagemapster.init.js b/_js/jquery.imagemapster.init.js index 45d8560..1d97a0e 100644 --- a/_js/jquery.imagemapster.init.js +++ b/_js/jquery.imagemapster.init.js @@ -23,7 +23,7 @@ jQuery(document).bind("cbox_complete", function() { strokeWidth: 2, showToolTip: true, onClick: function(data) { - if (data.key) { + if (data.key && $(data.e.target).data('found')) { window.location = 'individual.php?pid=' + data.key; } return false; @@ -38,21 +38,24 @@ jQuery(document).bind("cbox_complete", function() { pids: pids } }).done(function(data) { - jQuery('#cboxTitle').html(jQuery.map(data, function(item) { + var areas = [], + text = []; + jQuery.each(data, function(key, item) { + $map.find('area[data-pid="' + item.pid + '"]').data('found', item.found); var link = item.found ? 'individual.php?pid=' + item.pid : '#'; - return '' + item.name + ''; - }).join(', ')); + areas.push({ + key: item.pid, + toolTip: '
' + + '

' + item.name + '

' + + '

' + item.life + '

' + + '
' + }); + text.push('' + item.name + ''); + }); $image.mapster('set_options', { - areas: jQuery.map(data, function(item) { - return { - key: item.pid, - toolTip: '
' + - '

' + item.name + '

' + - '

' + item.life + '

' + - '
' - }; - }) + areas: areas }); + jQuery('#cboxTitle').html(text.join(', ')); jQuery('.pnwim-title-name').hover(function(e) { $image.mapster('set', null, $(e.target).data('pid')); });