js: Don't leak to global ns in position_caret.js
This commit is contained in:
parent
c8a92a0851
commit
b82823d76a
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2015 Artur Shaik <ashaihullin@gmail.com>
|
* Copyright 2015 Artur Shaik <ashaihullin@gmail.com>
|
||||||
* Copyright 2015 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
* Copyright 2015-2016 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
||||||
*
|
*
|
||||||
* This file is part of qutebrowser.
|
* This file is part of qutebrowser.
|
||||||
*
|
*
|
||||||
@ -32,7 +32,8 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function isElementInViewport(node) { // eslint-disable-line complexity
|
(function() {
|
||||||
|
function isElementInViewport(node) { // eslint-disable-line complexity
|
||||||
var i;
|
var i;
|
||||||
var boundingRect = (node.getClientRects()[0] ||
|
var boundingRect = (node.getClientRects()[0] ||
|
||||||
node.getBoundingClientRect());
|
node.getBoundingClientRect());
|
||||||
@ -80,9 +81,9 @@ function isElementInViewport(node) { // eslint-disable-line complexity
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return boundingRect.top >= -20;
|
return boundingRect.top >= -20;
|
||||||
}
|
}
|
||||||
|
|
||||||
(function() {
|
function positionCaret() {
|
||||||
var walker = document.createTreeWalker(document.body, 4, null);
|
var walker = document.createTreeWalker(document.body, 4, null);
|
||||||
var node;
|
var node;
|
||||||
var textNodes = [];
|
var textNodes = [];
|
||||||
@ -107,4 +108,7 @@ function isElementInViewport(node) { // eslint-disable-line complexity
|
|||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange(range);
|
sel.addRange(range);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
positionCaret();
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user