Skip to content

Instantly share code, notes, and snippets.

@clytras
Created November 17, 2016 15:59
Show Gist options
  • Save clytras/fecb83d456499e032859c99319d493a9 to your computer and use it in GitHub Desktop.
Save clytras/fecb83d456499e032859c99319d493a9 to your computer and use it in GitHub Desktop.
$.ajax({
type: "GET",
url: 'steel_agg_bof_flash_en.xml',
dataType: "xml",
success: xmlParser
});
function xmlParser(xml) {
$(xml).find("hotspot").each(function() {
var position = $(this).find('position').text();
var arr = position.split(",");
var hotspotid = $(this).find('hsid').text();
var title = $(this).find('title').text();
//$('#clickAreas').prepend('<div id="' + hotspotid + '_clickable" class="circle" title="'+title+'" onclick="changeStyle(id);" style="background: #004593; position: absolute; top: ' + arr[1] + 'px' + '; left: ' + arr[0] + 'px' + '; width: ' + Math.floor(arr[2] / 3.28148) + 'px; height: ' + Math.floor(arr[2] / 3.28148) + 'px; border-radius: 100%; cursor: pointer; opacity: 0.5;"></div>');
addCircle({
id: hotspotid,
title: title,
top: arr[0],
left: arr[1],
width: Math.floor(arr[2] / 3.28148),
height: Math.floor(arr[2] / 3.28148)
});
});
$(".circle").tooltip({
track:true
});
}*/
function addCircle(options) {
$('#clickAreas').append(
$('<div/>', {
id: options.hotspotid,
title: options.title,
'class': 'circle',
css: {
top: options.top+'px',
left: options.left+'px',
width: options.width+'px',
height: options.height+'px'
}
}).tooltipster({
theme: 'tooltipster-borderless',
plugins: ['follower']
})/*.tooltip({
track:true,
tooltipClass: 'circle-tooltip'
})*/.on('click', function() {
$('.circle.do-anim > *').removeClass('anim');
$('.circle.do-anim').removeClass('do-anim');
$(this).addClass('do-anim');
$('.back-circle-1, .back-circle-2', this).addClass('anim');
}).append(
$('<div class="back-circle-1"/>'),
$('<div class="back-circle-2"/>'),
$('<div class="front-circle"/>')
)
);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment