@@ -192,13 +192,18 @@ function loadCss(cssFileName) {
192
192
}
193
193
194
194
( function ( ) {
195
+ const isHelpPage = window . location . pathname . endsWith ( "/help.html" ) ;
196
+
195
197
function loadScript ( url ) {
196
198
const script = document . createElement ( "script" ) ;
197
199
script . src = url ;
198
200
document . head . append ( script ) ;
199
201
}
200
202
201
203
getSettingsButton ( ) . onclick = event => {
204
+ if ( event . ctrlKey || event . altKey || event . metaKey ) {
205
+ return ;
206
+ }
202
207
addClass ( getSettingsButton ( ) , "rotate" ) ;
203
208
event . preventDefault ( ) ;
204
209
// Sending request for the CSS and the JS files at the same time so it will
@@ -873,7 +878,10 @@ function loadCss(cssFileName) {
873
878
rustdoc_version . appendChild ( rustdoc_version_code ) ;
874
879
875
880
const container = document . createElement ( "div" ) ;
876
- container . className = "popover" ;
881
+ if ( ! isHelpPage ) {
882
+ container . className = "popover" ;
883
+ }
884
+ container . id = "help" ;
877
885
container . style . display = "none" ;
878
886
879
887
const side_by_side = document . createElement ( "div" ) ;
@@ -885,15 +893,22 @@ function loadCss(cssFileName) {
885
893
container . appendChild ( side_by_side ) ;
886
894
container . appendChild ( rustdoc_version ) ;
887
895
888
- const help_button = getHelpButton ( ) ;
889
- help_button . appendChild ( container ) ;
890
-
891
- container . onblur = helpBlurHandler ;
892
- container . onclick = event => {
893
- event . preventDefault ( ) ;
894
- } ;
895
- help_button . onblur = helpBlurHandler ;
896
- help_button . children [ 0 ] . onblur = helpBlurHandler ;
896
+ if ( isHelpPage ) {
897
+ const help_section = document . createElement ( "section" ) ;
898
+ help_section . appendChild ( container ) ;
899
+ document . getElementById ( "main-content" ) . appendChild ( help_section ) ;
900
+ container . style . display = "block" ;
901
+ } else {
902
+ const help_button = getHelpButton ( ) ;
903
+ help_button . appendChild ( container ) ;
904
+
905
+ container . onblur = helpBlurHandler ;
906
+ container . onclick = event => {
907
+ event . preventDefault ( ) ;
908
+ } ;
909
+ help_button . onblur = helpBlurHandler ;
910
+ help_button . children [ 0 ] . onblur = helpBlurHandler ;
911
+ }
897
912
898
913
return container ;
899
914
}
@@ -934,19 +949,43 @@ function loadCss(cssFileName) {
934
949
}
935
950
}
936
951
937
- document . querySelector ( `#${ HELP_BUTTON_ID } > button` ) . addEventListener ( "click" , event => {
938
- const target = event . target ;
939
- if ( target . tagName !== "BUTTON" || target . parentElement . id !== HELP_BUTTON_ID ) {
940
- return ;
941
- }
942
- const menu = getHelpMenu ( true ) ;
943
- const shouldShowHelp = menu . style . display === "none" ;
944
- if ( shouldShowHelp ) {
945
- showHelp ( ) ;
946
- } else {
947
- window . hidePopoverMenus ( ) ;
948
- }
949
- } ) ;
952
+ if ( isHelpPage ) {
953
+ showHelp ( ) ;
954
+ document . querySelector ( `#${ HELP_BUTTON_ID } > a` ) . addEventListener ( "click" , event => {
955
+ // Already on the help page, make help button a no-op.
956
+ const target = event . target ;
957
+ if ( target . tagName !== "A" ||
958
+ target . parentElement . id !== HELP_BUTTON_ID ||
959
+ event . ctrlKey ||
960
+ event . altKey ||
961
+ event . metaKey ) {
962
+ return ;
963
+ }
964
+ event . preventDefault ( ) ;
965
+ } ) ;
966
+ } else {
967
+ document . querySelector ( `#${ HELP_BUTTON_ID } > a` ) . addEventListener ( "click" , event => {
968
+ // By default, have help button open docs in a popover.
969
+ // If user clicks with a moderator, though, use default browser behavior,
970
+ // probably opening in a new window or tab.
971
+ const target = event . target ;
972
+ if ( target . tagName !== "A" ||
973
+ target . parentElement . id !== HELP_BUTTON_ID ||
974
+ event . ctrlKey ||
975
+ event . altKey ||
976
+ event . metaKey ) {
977
+ return ;
978
+ }
979
+ event . preventDefault ( ) ;
980
+ const menu = getHelpMenu ( true ) ;
981
+ const shouldShowHelp = menu . style . display === "none" ;
982
+ if ( shouldShowHelp ) {
983
+ showHelp ( ) ;
984
+ } else {
985
+ window . hidePopoverMenus ( ) ;
986
+ }
987
+ } ) ;
988
+ }
950
989
951
990
setMobileTopbar ( ) ;
952
991
addSidebarItems ( ) ;
0 commit comments