Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F35134391
behavior-watch-anchor.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
1 KB
Subscribers
None
behavior-watch-anchor.js
View Options
/**
* @provides javelin-behavior-phabricator-watch-anchor
* @requires javelin-behavior
* javelin-stratcom
* javelin-dom
* javelin-vector
*/
JX
.
behavior
(
'phabricator-watch-anchor'
,
function
()
{
var
highlighted
;
function
highlight
()
{
highlighted
&&
JX
.
DOM
.
alterClass
(
highlighted
,
'anchor-target'
,
false
);
try
{
highlighted
=
JX
.
$
(
'anchor-'
+
window
.
location
.
hash
.
replace
(
'#'
,
''
));
}
catch
(
ex
)
{
highlighted
=
null
;
}
highlighted
&&
JX
.
DOM
.
alterClass
(
highlighted
,
'anchor-target'
,
true
);
}
// Defer invocation so other listeners can update the document.
function
defer_highlight
()
{
setTimeout
(
highlight
,
0
);
}
// In some cases, we link to an anchor but the anchor target ajaxes in
// later. If it pops in within the first few seconds, jump to it.
function
try_anchor
(
anchor
)
{
try
{
// If the anchor exists, assume the browser handled the jump.
JX
.
$
(
anchor
);
defer_highlight
();
}
catch
(
e
)
{
var
n
=
50
;
var
try_anchor_again
=
function
()
{
try
{
window
.
scrollTo
(
0
,
JX
.
$V
(
JX
.
$
(
anchor
)).
y
-
60
);
defer_highlight
();
}
catch
(
e
)
{
if
(
n
--
)
{
setTimeout
(
try_anchor_again
,
100
);
}
}
};
try_anchor_again
();
}
}
JX
.
Stratcom
.
listen
(
'hashchange'
,
null
,
try_anchor
);
var
anchor
=
window
.
location
.
hash
.
replace
(
'#'
,
''
);
if
(
anchor
)
{
try_anchor
(
anchor
);
}
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 1, 7:24 PM (1 d, 3 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4e/58/f20f2520e9ae4058c3a5a45e496f
Attached To
rPHAB Phabricator
Event Timeline
Log In to Comment