1function switchpanel(){ 2 if( jQuery( '#switchpanel_tooltip' ).length == 0 ){ 3 jQuery( '<div id="switchpanel_tooltip"></div>' ).appendTo( 'body' ); 4 } 5 6 this.showToolTip = function( oEvent, sLabel, sTitle, sText, sLink ){ 7 var sHtml = ''; 8 if( ( sLabel + sTitle ) != '' ){ 9 sHtml += '<div class="switchpanel_tooltip_title">' + sLabel + ( sTitle != '' ? ' : ' : '' ) + sTitle + '</div>'; 10 } 11 sHtml += '<div class="switchpanel_tooltip_text">' + sText + '</div>'; 12 if( sLink != '' ){ 13 sHtml += '<div class="switchpanel_tooltip_link">' + sLink + '</div>'; 14 } 15 jQuery( '#switchpanel_tooltip' ) 16 .html( sHtml ) 17 .css( { top: oEvent.clientY + 20, display: 'block' } ); 18 19 // calcul positioning coefficient to the left 20 var iPosPopup = jQuery( oEvent.target ).attr( 'x' ); 21 var iWidthSvg = jQuery( oEvent.target ).closest( 'svg' ).attr( 'width' ).replace( 'px', '' ); 22 var iCoef = iPosPopup / iWidthSvg; 23 24 // Move popup to the left 25 jQuery( '#switchpanel_tooltip' ) 26 .css( { left: oEvent.clientX - ( jQuery( '#switchpanel_tooltip' ).width() * iCoef ) } ); 27 }; 28 29 this.hideToolTip = function(){ 30 jQuery( '#switchpanel_tooltip' ).css( { display: 'none' } ); 31 }; 32} 33 34jQuery( document ).ready( function(){ 35 window.oSwitchPanel = new switchpanel(); 36} ); 37