Skip to content

Commit

Permalink
Replace history when languages are filtered on download pages, instea…
Browse files Browse the repository at this point in the history
…d of appending (Bug 1134936 follow-up)
  • Loading branch information
kyoshino committed Mar 3, 2015
1 parent 306eb45 commit dad2e2d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions media/js/firefox/firefox-language-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@

function filter (e) {
e.preventDefault();

var historyEnabled = typeof history.replaceState === 'function' && e.originalEvent;
var search_q = $.trim($input.val()); // trim whitespace

if (!search_q) {
show_all();

// Replace the browser history to clear the search query
if (historyEnabled) {
history.replaceState({}, document.title, '.');
}

return;
}

Expand Down Expand Up @@ -56,9 +65,9 @@
});

// Replace the browser history to save the search query
if (typeof history.pushState === 'function' && e.originalEvent) {
history.pushState({ query: search_q }, document.title,
'?q=' + encodeURI(search_q));
if (historyEnabled) {
history.replaceState({ query: search_q }, document.title,
'?q=' + encodeURI(search_q));
}
}

Expand Down

0 comments on commit dad2e2d

Please sign in to comment.