浏览代码

Focus the search box on the main page only

Lorna Jane Mitchell 7 年之前
父节点
当前提交
b0686ba3fd
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/Packagist/WebBundle/Resources/public/js/search.js

+ 5 - 1
src/Packagist/WebBundle/Resources/public/js/search.js

@@ -57,13 +57,17 @@ var search = instantsearch({
     searchParameters: searchParameters
 });
 
+var autofocus = false;
+if(location.pathname == "/") {
+    autofocus = true;
+}
 search.addWidget(
     instantsearch.widgets.searchBox({
         container: '#search_query_query',
         magnifier: false,
         reset: false,
         wrapInput: false,
-        autofocus: true
+        autofocus: autofocus
     })
 );