Browse Source

Add possibility to go back to search results with back button, refs #184

Jordi Boggiano 12 years ago
parent
commit
b9efecc34a
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/Packagist/WebBundle/Resources/public/js/search.js

+ 8 - 0
src/Packagist/WebBundle/Resources/public/js/search.js

@@ -32,6 +32,14 @@
             return;
         }
 
+        if (history.pushState) {
+            if (typeof previousQuery === 'undefined') {
+                history.pushState(null, "Search", "/search/?q=" + $('input[type="search"]', form).val());
+            } else {
+                history.replaceState(null, "Search", "/search/?q=" + $('input[type="search"]', form).val());
+            }
+        }
+
         currentQuery = form.serialize();
 
         if (previousQuery === currentQuery) {