mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 06:07:59 +01:00
Make sure that the hint number is in the viewport
This commit is contained in:
@@ -1201,52 +1201,51 @@ function Events() //{{{
|
||||
// global escape handler, is called in ALL modes
|
||||
onEscape: function ()
|
||||
{
|
||||
if (!modes.passNextKey)
|
||||
if (modes.passNextKey)
|
||||
return;
|
||||
if (modes.passAllKeys)
|
||||
{
|
||||
if (modes.passAllKeys)
|
||||
{
|
||||
modes.passAllKeys = false;
|
||||
return;
|
||||
}
|
||||
modes.passAllKeys = false;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (liberator.mode)
|
||||
{
|
||||
case modes.NORMAL:
|
||||
// clear any selection made
|
||||
let selection = window.content.getSelection();
|
||||
try
|
||||
{ // a simple if (selection) does not seem to work
|
||||
selection.collapseToStart();
|
||||
}
|
||||
catch (e) {}
|
||||
switch (liberator.mode)
|
||||
{
|
||||
case modes.NORMAL:
|
||||
// clear any selection made
|
||||
let selection = window.content.getSelection();
|
||||
try
|
||||
{ // a simple if (selection) does not seem to work
|
||||
selection.collapseToStart();
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
modes.reset();
|
||||
break;
|
||||
|
||||
case modes.VISUAL:
|
||||
if (modes.extended & modes.TEXTAREA)
|
||||
liberator.mode = modes.TEXTAREA;
|
||||
else if (modes.extended & modes.CARET)
|
||||
liberator.mode = modes.CARET;
|
||||
break;
|
||||
|
||||
case modes.CARET:
|
||||
// setting this option will trigger an observer which will
|
||||
// care about all other details like setting the NORMAL mode
|
||||
options.setPref("accessibility.browsewithcaret", false);
|
||||
break;
|
||||
|
||||
case modes.INSERT:
|
||||
if ((modes.extended & modes.TEXTAREA) && !options["insertmode"])
|
||||
liberator.mode = modes.TEXTAREA;
|
||||
else
|
||||
modes.reset();
|
||||
break;
|
||||
break;
|
||||
|
||||
case modes.VISUAL:
|
||||
if (modes.extended & modes.TEXTAREA)
|
||||
liberator.mode = modes.TEXTAREA;
|
||||
else if (modes.extended & modes.CARET)
|
||||
liberator.mode = modes.CARET;
|
||||
break;
|
||||
|
||||
case modes.CARET:
|
||||
// setting this option will trigger an observer which will
|
||||
// care about all other details like setting the NORMAL mode
|
||||
options.setPref("accessibility.browsewithcaret", false);
|
||||
break;
|
||||
|
||||
case modes.INSERT:
|
||||
if ((modes.extended & modes.TEXTAREA) && !options["insertmode"])
|
||||
liberator.mode = modes.TEXTAREA;
|
||||
else
|
||||
modes.reset();
|
||||
break;
|
||||
|
||||
default: // HINTS, CUSTOM or COMMAND_LINE
|
||||
modes.reset();
|
||||
break;
|
||||
}
|
||||
default: // HINTS, CUSTOM or COMMAND_LINE
|
||||
modes.reset();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -154,8 +154,8 @@ function Hints() //{{{
|
||||
text = elem.textContent.toLowerCase();
|
||||
|
||||
span = baseNodeAbsolute.cloneNode(true);
|
||||
span.style.left = (rect.left + scrollX) + "px";
|
||||
span.style.top = (rect.top + scrollY) + "px";
|
||||
span.style.left = Math.max((rect.left + scrollX), scrollX) + "px";
|
||||
span.style.top = Math.max((rect.top + scrollY), scrollY) + "px";
|
||||
fragment.appendChild(span);
|
||||
|
||||
pageHints.push([elem, text, span, null, elem.style.backgroundColor, elem.style.color]);
|
||||
|
||||
@@ -311,6 +311,15 @@ const util = { //{{{
|
||||
|
||||
identity: function identity(k) k,
|
||||
|
||||
intersection: function (r1, r2) ({
|
||||
get width() this.right - this.left,
|
||||
get height() this.bottom - this.top,
|
||||
left: Math.max(r1.left, r2.left),
|
||||
right: Math.min(r1.right, r2.right),
|
||||
top: Math.max(r1.top, r2.top),
|
||||
bottom: Math.min(r1.bottom, r2.bottom)
|
||||
}),
|
||||
|
||||
map: function map(obj, fn)
|
||||
{
|
||||
let ary = [];
|
||||
|
||||
Reference in New Issue
Block a user