浏览代码

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

Jordi Boggiano 12 年之前
父节点
当前提交
b9efecc34a
共有 1 个文件被更改,包括 8 次插入0 次删除
  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) {