Created
January 10, 2011 14:29
-
-
Save staaky/772825 to your computer and use it in GitHub Desktop.
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
/* A quick parent/child helper idea for tipped.js | |
* blocks parent tooltips from hiding when child tooltips are open | |
* http://groups.google.com/group/tippedjs/browse_thread/thread/29a65b3a4c0a37df | |
*/ | |
(function($) { | |
window.TippedParentChildHelper = { | |
showChild: function(content, element) { | |
var parent = element.getAttribute('data-tipped-parent'); | |
if (parent) { | |
var vc = $('#' + parent).data('tipped_visible_children') || 0; | |
$('#' + parent).data('tipped_visible_children', vc++); | |
} | |
}, | |
hideChild: function(content, element) { | |
var parent = element.getAttribute('data-tipped-parent'); | |
if (parent) { | |
var vc = $('#' + parent).data('tipped_visible_children') || 1; | |
$('#' + parent).data('tipped_visible_children', vc--); | |
} | |
}, | |
hideParent: function(content, element) { | |
if ($(element).data('tipped_visible_children')) > 0) { | |
Tipped.show(element); | |
} | |
} | |
}; | |
})(jQuery); | |
// then on the child tooltips | |
data-tipped-parent='id_of_parent' | |
data-tipped-options=" | |
onShow: TippedParentChildHelper.showChild, | |
onHide: TippedParentChildHelper.hideChild | |
" | |
/* On the parent tooltips to block hiding when | |
* child tooltips are open: | |
* fadeDuration is set to 0 otherwise the tooltip | |
*/ will first fade out on browsers that support it | |
id='id_of_parent', | |
data-tipped-options=" | |
fadeDuration: 0, | |
onHide: TippedParentChildHelper.hideParent | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment