Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit fd56ca2

Browse files
committed
adding support for open anno and move to anno via query string vars
1 parent e8808e7 commit fd56ca2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

public/styleguide/js/annotations-viewer.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ var annotationsViewer = {
1010

1111
// set-up default sections
1212
commentsActive: false,
13-
targetOrigin: (window.location.protocol === "file:") ? "*" : window.location.protocol+"//"+window.location.host,
13+
targetOrigin: (window.location.protocol === "file:") ? "*" : window.location.protocol+"//"+window.location.host,
14+
moveToOnInit: 0,
1415

1516
/**
1617
* add the onclick handler to the annotations link in the main nav
@@ -34,6 +35,15 @@ var annotationsViewer = {
3435
// initialize the annotations viewer
3536
annotationsViewer.commentContainerInit();
3637

38+
// load the query strings in case code view has to show by default
39+
var queryStringVars = urlHandler.getRequestVars();
40+
if ((queryStringVars.view !== undefined) && ((queryStringVars.view === "annotations") || (queryStringVars.view === "a"))) {
41+
annotationsViewer.openComments();
42+
if (queryStringVars.number !== undefined) {
43+
annotationsViewer.moveToOnInit = queryStringVars.number;
44+
}
45+
}
46+
3747
},
3848

3949
/**
@@ -187,6 +197,11 @@ var annotationsViewer = {
187197
// slide the comment section into view
188198
annotationsViewer.slideComment(0);
189199

200+
if (annotationsViewer.moveToOnInit != "0") {
201+
annotationsViewer.moveTo(annotationsViewer.moveToOnInit);
202+
annotationsViewer.moveToOnInit = "0";
203+
}
204+
190205
},
191206

192207
/**

0 commit comments

Comments
 (0)