Skip to content

Commit 3c3a0f7

Browse files
author
Vladimir Kotal
authored
Merge pull request #1349 from tulinkry/scopes-fix
using a timeout for scopes update
2 parents e4df909 + d073bb3 commit 3c3a0f7

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

web/httpheader.jspf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if (cfg.getPrefix().equals(Prefix.HIST_L)) {
8989
<script type="text/javascript" src="<%=ctxPath%>/js/tablesorter.parsers-0.0.1.js"></script>
9090
<script type="text/javascript" src="<%=ctxPath%>/js/searchable-option-list-2.0.2.min.js"></script>
9191
<%--<script type="text/javascript" src="<%=ctxPath%>/js/jquery.autocomplete-1.1.pack.js"></script> --%>
92-
<script type="text/javascript" src="<%=ctxPath%>/js/utils-0.0.2.js"></script>
92+
<script type="text/javascript" src="<%=ctxPath%>/js/utils-0.0.3.js"></script>
9393
<title><%=cfg.getTitle()%></title><%
9494
out.write(cfg.getHeaderData());
9595
%>

web/js/utils-0.0.2.js renamed to web/js/utils-0.0.3.js

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1772,9 +1772,6 @@ function clearSearchFrom() {
17721772
$("#type :selected").prop("selected", false);
17731773
}
17741774

1775-
var scope_visible = 0;
1776-
var scope_text = '';
1777-
17781775
/**
17791776
* Fold or unfold a function definition.
17801777
*/
@@ -1787,30 +1784,38 @@ function fold(id) {
17871784
$('#' + id + '_fold').toggle('fold');
17881785
}
17891786

1787+
var scope_timeout = null;
17901788
/**
17911789
* Function that is called when the #content div element is scrolled. Checks
17921790
* if the top of the page is inside a function scope. If so, update the
17931791
* scope element to show the name of the function and a link to its definition.
17941792
*/
17951793
function scope_on_scroll() {
1796-
var cnt = document.getElementById("content");
1797-
var y = cnt.getBoundingClientRect().top + 2;
1798-
var c = document.elementFromPoint(15, y + 1);
1794+
if (scope_timeout !== null) {
1795+
clearTimeout(scope_timeout)
1796+
scope_timeout = null
1797+
}
1798+
scope_timeout = setTimeout(function () {
1799+
var cnt = document.getElementById("content");
1800+
var y = cnt.getBoundingClientRect().top + 2;
1801+
var c = document.elementFromPoint(15, y + 1);
17991802

1800-
if ($(c).is('.l, .hl')) {
1801-
var $par = $(c).closest('.scope-body, .scope-head')
1803+
if ($(c).is('.l, .hl')) {
1804+
var $par = $(c).closest('.scope-body, .scope-head')
18021805

1803-
if (!$par.length) {
1804-
return;
1805-
}
1806+
if (!$par.length) {
1807+
return;
1808+
}
18061809

1807-
var $head = $par.hasClass('scope-body') ? $par.prev() : $par;
1808-
var $sig = $head.children().first()
1809-
if ($.scopesWindow.initialized) {
1810-
$.scopesWindow.update({
1811-
'id': $head.attr('id'),
1812-
'link': $sig.html(),
1813-
})
1810+
var $head = $par.hasClass('scope-body') ? $par.prev() : $par;
1811+
var $sig = $head.children().first()
1812+
if ($.scopesWindow.initialized) {
1813+
$.scopesWindow.update({
1814+
'id': $head.attr('id'),
1815+
'link': $sig.html(),
1816+
})
1817+
}
18141818
}
1815-
}
1819+
scope_timeout = null;
1820+
}, 150);
18161821
}

0 commit comments

Comments
 (0)