PDA

View Full Version : StickyTooltip left click



Channiro
10-21-2013, 06:50 PM
Hi,

Script: DD Tab Menu
http://www.dynamicdrive.com/dynamicindex5/stickytooltip.htm

I've been trying to use this script to display persistent information on a map. However, I have to display the tooltip on left click not right click. What changes do I need to make? I tried fiddling with it but it's a bit over my head.

Map here: http://candelascommunity.businesscatalyst.com/recreation-amenities-reservations


Thanks!

traq
10-21-2013, 08:54 PM
not extensively tested, but seems to work.

take this:
$(this).bind("click", function(e){
if (e.button==0){
stickytooltip.isdocked=false
stickytooltip.hidebox($, $tooltip)
}
})
and replace it with:
$(this).bind("click", function(e){
if ( stickytooltip.isdocked ){ // to undock, instead of checking for left click, check if a tooltip is currently docked
stickytooltip.isdocked=false
stickytooltip.hidebox($, $tooltip)
}
})

Then, take this:
$(this).bind("contextmenu", function(e){
if (stickytooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length==1){ //if oncontextmenu over a target element
stickytooltip.docktooltip($, $tooltip, e)
return false
}
})
and replace it with:
$(this).bind("click", function(e){ // bind to click instead of contextmenu
// and check if it is a left click
if (e.button==0 && stickytooltip.rightclickstick && $(e.target).parents().andSelf().filter(targetselector).length==1){
stickytooltip.docktooltip($, $tooltip, e)
return false
}
})

jsfiddle (http://jsfiddle.net/LpSkm/)

Channiro
10-22-2013, 12:09 PM
Thank you m8, you're a life saver!

traq
10-22-2013, 02:30 PM
No problem. : )