@@ -60,7 +60,7 @@ var $articleContainer,
6060 // Back/Forward navigation
6161 window . addEventListener ( 'popstate' , function ( ev ) {
6262 ev . preventDefault ( ) ;
63- navigate ( window . location . href ) ;
63+ navigate ( window . location . href , false ) ;
6464 } ) ;
6565
6666 $articleContainer . on ( "scroll" , debounce ( function ( ev ) {
@@ -106,9 +106,7 @@ function init() {
106106
107107 if ( ! searchControl ) {
108108 searchControl = new SearchControl ( ".search-bar" , {
109- navigate : function ( href ) {
110- navigate ( href ) ;
111- } ,
109+ navigate : navigate ,
112110 pathPrefix : window . pathPrefix ,
113111 animateInOnStart : ! hasShownSearch
114112 } ) ;
@@ -176,7 +174,7 @@ function setScrollPosition() {
176174var $menuButton = $ ( '[for="nav-trigger"]' ) ;
177175var $navTrigger = $ ( '#nav-trigger' ) ;
178176
179- function navigate ( href ) {
177+ function navigate ( href , updateLocation ) {
180178 // make sure we're in the right spot
181179 if ( href === "javascript://" ) { // jshint ignore:line
182180 return ;
@@ -219,7 +217,9 @@ function navigate(href) {
219217 } ,
220218 success : function ( content ) {
221219
222- window . history . pushState ( null , null , href ) ;
220+ if ( updateLocation !== false ) {
221+ window . history . pushState ( null , null , href ) ;
222+ }
223223
224224 // Google Analytics
225225 ga ( 'send' , 'pageview' , window . location . pathname ) ;
@@ -275,7 +275,9 @@ function navigate(href) {
275275 }
276276 } ,
277277 error : function ( ) {
278- window . history . pushState ( null , null , href ) ;
278+ if ( updateLocation !== false ) {
279+ window . history . pushState ( null , null , href ) ;
280+ }
279281 // just reload the page if this fails
280282 window . location . reload ( ) ;
281283 } ,
0 commit comments