@@ -192,13 +192,18 @@ function loadCss(cssFileName) {
192192}
193193
194194( function ( ) {
195+ const isHelpPage = window . location . pathname . endsWith ( "/help.html" ) ;
196+
195197 function loadScript ( url ) {
196198 const script = document . createElement ( "script" ) ;
197199 script . src = url ;
198200 document . head . append ( script ) ;
199201 }
200202
201203 getSettingsButton ( ) . onclick = event => {
204+ if ( event . ctrlKey || event . altKey || event . metaKey ) {
205+ return ;
206+ }
202207 addClass ( getSettingsButton ( ) , "rotate" ) ;
203208 event . preventDefault ( ) ;
204209 // Sending request for the CSS and the JS files at the same time so it will
@@ -873,7 +878,10 @@ function loadCss(cssFileName) {
873878 rustdoc_version . appendChild ( rustdoc_version_code ) ;
874879
875880 const container = document . createElement ( "div" ) ;
876- container . className = "popover" ;
881+ if ( ! isHelpPage ) {
882+ container . className = "popover" ;
883+ }
884+ container . id = "help" ;
877885 container . style . display = "none" ;
878886
879887 const side_by_side = document . createElement ( "div" ) ;
@@ -885,15 +893,22 @@ function loadCss(cssFileName) {
885893 container . appendChild ( side_by_side ) ;
886894 container . appendChild ( rustdoc_version ) ;
887895
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+ }
897912
898913 return container ;
899914 }
@@ -934,19 +949,43 @@ function loadCss(cssFileName) {
934949 }
935950 }
936951
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+ }
950989
951990 setMobileTopbar ( ) ;
952991 addSidebarItems ( ) ;
0 commit comments