Last active
August 28, 2017 20:51
-
-
Save nbelyh/69ab7d3687965fb1073c58d9dfed88fc to your computer and use it in GitHub Desktop.
SvgPublish: Pokemon building demo. Please use with the corresponding diagrams.
https://nbelyh.github.io/svgpublishdemo/PokemonBldgPlan.html, http://unmanagedvisio.com/download/svgexportsamples/PokemonBldgPlan.zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
.popover { | |
min-width: 400px; | |
min-height: 250px; | |
max-width: none; | |
} | |
.popover img { | |
height: 150px; | |
width: auto; | |
float: left; | |
margin-right: 10px; | |
} | |
.popover p { | |
margin: 0 0 0 170px; | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.each(diagram.shapes, function (shapeId, shapeData) { | |
var props = shapeData.Props; | |
if (!props) | |
return; | |
var $shape = $("#" + shapeId); | |
// build options for popover: placement function, iframe url from properties | |
var options = { | |
placement: function (context, source) { | |
var position = $(source).position(); | |
if (position.right > 500) | |
return "left"; | |
if (position.left < 500) | |
return "right"; | |
if (position.top < 300) | |
return "bottom"; | |
return "top"; | |
}, | |
trigger: "manual", | |
container: "html", | |
html: true, | |
content: ''+ | |
'<img src="'+props.Image+'"></img>'+ | |
'<p>'+ | |
'<span class="h4"> '+props.Name+'<br/>' + | |
'<span class="text-muted small"> ' + props.Title + '</span>' + | |
'</p>' + | |
'<p><b>Phone:</b> ' + '<a href="callto:'+props['Telephone']+'">'+props['Telephone']+'</a>'+'</p>'+ | |
'<p><b>E-Mail:</b> ' + '<a href="mailto:'+props['E-Mail']+'">'+props['E-Mail']+'</a>'+'</p>'+ | |
'<p><b>Responsibilities:</b><br/>' + (""+props.Responsibilities).replace(/(?:\r\n|\r|\n)/g, '<br />') + '</p>', | |
title: props.Name | |
}; | |
// create the popover for the shape | |
$shape.popover(options); | |
// decorate the shape with "hand" cursor | |
$shape.css("cursor", "pointer"); | |
// hide the popover hiding when clicked outside | |
$('body').on('click', function (e) { | |
$shape.popover('hide'); | |
}); | |
$shape.on('click', function (evt) { | |
evt.stopPropagation(); | |
$shape.popover('toggle'); | |
}); | |
$shape.on('mouseover', function () { | |
$(this).attr('filter', 'url(#hover)'); | |
}); | |
$shape.on('mouseout', function () { | |
$(this).removeAttr('filter'); | |
}); | |
$shape.tooltip({ | |
container: "body", | |
title: props.Name | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment