function switchpanel(){ if( jQuery( '#switchpanel_tooltip' ).length == 0 ){ jQuery( '
' ).appendTo( 'body' ); } this.showToolTip = function( oEvent, sLabel, sTitle, sText, sLink ){ var sHtml = ''; if( ( sLabel + sTitle ) != '' ){ sHtml += '
' + sLabel + ( sTitle != '' ? ' : ' : '' ) + sTitle + '
'; } sHtml += '
' + sText + '
'; if( sLink != '' ){ sHtml += ''; } jQuery( '#switchpanel_tooltip' ) .html( sHtml ) .css( { top: oEvent.clientY + 20, display: 'block' } ); // calcul positioning coefficient to the left var iPosPopup = jQuery( oEvent.target ).attr( 'x' ); var iWidthSvg = jQuery( oEvent.target ).closest( 'svg' ).attr( 'width' ).replace( 'px', '' ); var iCoef = iPosPopup / iWidthSvg; // Move popup to the left jQuery( '#switchpanel_tooltip' ) .css( { left: oEvent.clientX - ( jQuery( '#switchpanel_tooltip' ).width() * iCoef ) } ); }; this.hideToolTip = function(){ jQuery( '#switchpanel_tooltip' ).css( { display: 'none' } ); }; } jQuery( document ).ready( function(){ window.oSwitchPanel = new switchpanel(); } );