Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tootip overlay closing. #1440

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion BrainPortal/app/helpers/rich_ui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def html_tool_tip(text = "<span class=\"action_link\">?</span>".html_safe, optio
@content_sig_cache[content_signature] = html_tool_tip_id
content_div = "<div id=\"html_tool_tip_#{html_tool_tip_id}\" class=\"#{content_class}\">" +
h(content) +
"</div>"
"<a class=\"close_html_tool_tip\" id=\"close_html_tool_tip_#{html_tool_tip_id}\" data-tool-tip-id=\"html_tool_tip_#{html_tool_tip_id}\" href=\"#\">Close</a>" +
"</div>"
end

# Create tooltip trigger
Expand Down
23 changes: 19 additions & 4 deletions BrainPortal/public/javascripts/cbrain.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@

//html_tool_tip_code based on xstooltip provided by
//http://www.texsoft.it/index.php?%20m=sw.js.htmltooltip&c=software&l=it
$(document).delegate(".html_tool_tip_trigger", "mouseenter", function(event) {
$(document).on("mouseenter click", ".html_tool_tip_trigger", function(event) {
var trigger = $(this);
var tool_tip_id = trigger.data("tool-tip-id");
var tool_tip = $("#" + tool_tip_id);
Expand All @@ -763,13 +763,28 @@
tool_tip.css('top', y + 'px');
tool_tip.css('left', x + 'px');

tool_tip.show();
}).delegate(".html_tool_tip_trigger", "mouseleave", function(event) {
// If click event, show the tooltip even if other tooltips are visible
if (event.type === "click") {
tool_tip.show();
event.preventDefault();
}
// If mouseenter event, show the tooltip only if no other tooltips are visible
if (event.type === "mouseenter") {
// Only show the tooltip if other tooltips are not visible
if ($('.html_tool_tip:visible').length == 0) {
tool_tip.show();
}
}
})

// Close the tooltip when clicking on the close button
$(document).delegate(".close_html_tool_tip", "click", function(event) {
var trigger = $(this);
var tool_tip_id = trigger.data("tool-tip-id");
var tool_tip = $("#" + tool_tip_id);

tool_tip.hide();
// To prevent jump to the top of the page
event.preventDefault();
});

/////////////////////////////////////////////////////////////////////
Expand Down
Loading