Skip to content

Commit

Permalink
Merge pull request #3064 from /issues/3063/1
Browse files Browse the repository at this point in the history
Fixes #3063 - Move search bar handling into shared navbar.js
  • Loading branch information
Karl Dubost authored Oct 29, 2019
2 parents b6a2d3a + 68109c8 commit 55a196c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 45 deletions.
1 change: 0 additions & 1 deletion grunt-tasks/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ module.exports = function(grunt) {
},
index: {
src: [
"<%= jsPath %>/lib/homepage.js",
"<%= jsPath %>/lib/models/label-list.js",
"<%= jsPath %>/lib/models/issue.js",
"<%= jsPath %>/lib/untriaged.js"
Expand Down
32 changes: 31 additions & 1 deletion tests/functional/search-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ registerSuite("Search (auth)", {
.end();
},

"Search works by icon click"() {
"Search works by icon click (issues page)"() {
return FunctionalHelpers.openPage(
this,
url("/issues"),
Expand All @@ -116,6 +116,36 @@ registerSuite("Search (auth)", {
.end();
},

"Search opens by icon click (new issue page)"() {
return FunctionalHelpers.openPage(
this,
url("/issues/new"),
".js-ReportForm"
)
.findByCssSelector(".js-SearchBarOpen")
.click()
.end()
.findDisplayedByCssSelector("#search-bar")
.isDisplayed()
.then(function(isDisplayed) {
assert.equal(isDisplayed, true, "Search form is visible.");
})
.end();
},

"Search works by icon click (home page)"() {
return FunctionalHelpers.openPage(this, url("/"), ".js-SearchBarOpen")
.findByCssSelector(".js-SearchBarOpen")
.click()
.end()
.findDisplayedByCssSelector("#search-bar")
.isDisplayed()
.then(function(isDisplayed) {
assert.equal(isDisplayed, true, "Search form is visible.");
})
.end();
},

"Search works by Return key"() {
return FunctionalHelpers.openPage(
this,
Expand Down
41 changes: 0 additions & 41 deletions webcompat/static/js/lib/homepage.js

This file was deleted.

19 changes: 18 additions & 1 deletion webcompat/static/js/lib/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,25 @@ function NavBar() {
};

this.setUpEvents = function() {
this.navbarHandler();
this.dropDownHandler();
this.navbarHandler();
this.searchHandler();
};

this.searchHandler = function() {
var searchBar = $(".js-SearchBar");
var searchBarOpen = $(".js-SearchBarOpen");
var searchBarClose = $(".js-SearchBarClose");

searchBarOpen.click(function() {
searchBar.addClass("is-active");
searchBar.find("input").focus();
});

searchBarClose.click(function() {
searchBar.removeClass("is-active");
searchBar.find("input").blur();
});
};

this.navbarHandler = function() {
Expand Down
1 change: 0 additions & 1 deletion webcompat/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
{%- if config.PRODUCTION or config.STAGING -%}
<script src="{{ url_for('static', filename='js/dist/index.min.js')|bust_cache }}"></script>
{%- else -%}
<script src="{{ url_for('static', filename='js/lib/homepage.js') }}"></script>
<script src="{{ url_for('static', filename='js/lib/models/label-list.js') }}"></script>
<script src="{{ url_for('static', filename='js/lib/models/issue.js') }}"></script>
<script src="{{ url_for('static', filename='js/lib/untriaged.js') }}"></script>
Expand Down

0 comments on commit 55a196c

Please sign in to comment.