Commit 9ad84912 authored by Nigel McNie's avatar Nigel McNie
Browse files

Ensure that the help popups won't run off the screen if opened right near the...

Ensure that the help popups won't run off the screen if opened right near the bottom of the viewport. Fixes bug #1787.

Note if the popup is bigger than the viewport then things get weird. I don't think that case is worth worrying about.
parent eb868e71
...@@ -354,6 +354,7 @@ function contextualHelp(formName, helpName, pluginType, pluginName, page, sectio ...@@ -354,6 +354,7 @@ function contextualHelp(formName, helpName, pluginType, pluginName, page, sectio
if (contextualHelpCache[key]) { if (contextualHelpCache[key]) {
buildContextualHelpBox(contextualHelpCache[key]); buildContextualHelpBox(contextualHelpCache[key]);
callLater(0, function() { contextualHelpOpened = true; }); callLater(0, function() { contextualHelpOpened = true; });
ensureHelpIsOnScreen(contextualHelpContainer, position);
} }
else { else {
if (contextualHelpDeferrable && contextualHelpDeferrable.cancel) { if (contextualHelpDeferrable && contextualHelpDeferrable.cancel) {
...@@ -371,6 +372,7 @@ function contextualHelp(formName, helpName, pluginType, pluginName, page, sectio ...@@ -371,6 +372,7 @@ function contextualHelp(formName, helpName, pluginType, pluginName, page, sectio
buildContextualHelpBox(contextualHelpCache[key]); buildContextualHelpBox(contextualHelpCache[key]);
} }
contextualHelpOpened = true; contextualHelpOpened = true;
ensureHelpIsOnScreen(contextualHelpContainer, position);
processingStop(); processingStop();
}, },
function (error) { function (error) {
...@@ -397,6 +399,19 @@ function buildContextualHelpBox(content) { ...@@ -397,6 +399,19 @@ function buildContextualHelpBox(content) {
connect('helpstop', 'onclick', function(e) { e.stop(); }); connect('helpstop', 'onclick', function(e) { e.stop(); });
} }
/*
* Ensures that the contextual help box given is fully visible on screen. This
* will adjust the position of the help vertically if the help has opened right
* next to the bottom or top of the viewport
*/
function ensureHelpIsOnScreen(container, position) {
var dimensions = getElementDimensions(container);
if (position.y + dimensions.h > screenDimensions.h + getFirstElementByTagAndClassName('html').scrollTop) {
position.y -= dimensions.h - 18;
setElementPosition(container, position);
}
}
/* Only works in non-ie at the moment. Using 'document' as the element /* Only works in non-ie at the moment. Using 'document' as the element
makes IE detect the event, but then makes it so you need to click on makes IE detect the event, but then makes it so you need to click on
the help twice before it opens. */ the help twice before it opens. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment