File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
src/librustdoc/html/static Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change 13751375
13761376 function search ( e ) {
13771377 var params = getQueryStringParams ( ) ;
1378- var query = getQuery ( document . getElementsByClassName ( 'search-input' ) [ 0 ] . value . trim ( ) ) ;
1378+ var search_input = document . getElementsByClassName ( 'search-input' ) [ 0 ] ;
1379+ var query = getQuery ( search_input . value . trim ( ) ) ;
13791380
13801381 if ( e ) {
13811382 e . preventDefault ( ) ;
13821383 }
13831384
13841385 if ( ! query . query || query . id === currentResults ) {
1386+ if ( query . query . length > 0 ) {
1387+ putBackSearch ( search_input ) ;
1388+ }
13851389 return ;
13861390 }
13871391
20722076 } ;
20732077 } ) ;
20742078
2079+ function putBackSearch ( search_input ) {
2080+ if ( search_input . value !== "" ) {
2081+ addClass ( document . getElementById ( "main" ) , "hidden" ) ;
2082+ removeClass ( document . getElementById ( "search" ) , "hidden" ) ;
2083+ if ( browserSupportsHistoryApi ( ) ) {
2084+ history . replaceState ( search_input . value ,
2085+ "" ,
2086+ "?search=" + encodeURIComponent ( search_input . value ) ) ;
2087+ }
2088+ }
2089+ }
2090+
20752091 var search_input = document . getElementsByClassName ( "search-input" ) [ 0 ] ;
20762092
20772093 if ( search_input ) {
20782094 search_input . onfocus = function ( ) {
2079- if ( search_input . value !== "" ) {
2080- addClass ( document . getElementById ( "main" ) , "hidden" ) ;
2081- removeClass ( document . getElementById ( "search" ) , "hidden" ) ;
2082- if ( browserSupportsHistoryApi ( ) ) {
2083- history . replaceState ( search_input . value ,
2084- "" ,
2085- "?search=" + encodeURIComponent ( search_input . value ) ) ;
2086- }
2087- }
2095+ putBackSearch ( this ) ;
20882096 } ;
20892097 }
20902098
You can’t perform that action at this time.
0 commit comments