fix new tabs with instant redirect
This commit is contained in:
+15
-8
@@ -389,6 +389,15 @@
|
|||||||
var searchForm = $('#js-search-form');
|
var searchForm = $('#js-search-form');
|
||||||
var searchInput = $('#js-search-input');
|
var searchInput = $('#js-search-input');
|
||||||
|
|
||||||
|
var execute = function(query, redirect) {
|
||||||
|
Suggestions.add(query);
|
||||||
|
Suggestions.show('');
|
||||||
|
searchInput.value = '';
|
||||||
|
|
||||||
|
if (config.newTab) window.open(redirect, '_blank');
|
||||||
|
else window.location.href = redirect;
|
||||||
|
}
|
||||||
|
|
||||||
var keyPress = function(event) {
|
var keyPress = function(event) {
|
||||||
var char = String.fromCharCode(event.which);
|
var char = String.fromCharCode(event.which);
|
||||||
|
|
||||||
@@ -400,8 +409,11 @@
|
|||||||
if (config.instantRedirect) {
|
if (config.instantRedirect) {
|
||||||
config.categories.forEach(function(category) {
|
config.categories.forEach(function(category) {
|
||||||
category.commands.forEach(function(command) {
|
category.commands.forEach(function(command) {
|
||||||
if (command.key === searchInput.value + char) {
|
var query = searchInput.value + char;
|
||||||
window.location.href = command.url;
|
|
||||||
|
if (command.key === query) {
|
||||||
|
event.preventDefault();
|
||||||
|
execute(query, command.url);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -458,12 +470,7 @@
|
|||||||
if (breakLoop) return;
|
if (breakLoop) return;
|
||||||
});
|
});
|
||||||
|
|
||||||
Suggestions.add(q);
|
execute(q, redirect);
|
||||||
Suggestions.show('');
|
|
||||||
searchInput.value = '';
|
|
||||||
|
|
||||||
if (config.newTab) window.open(redirect, '_blank');
|
|
||||||
else window.location.href = redirect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyUp = function(event) {
|
var keyUp = function(event) {
|
||||||
|
|||||||
Reference in New Issue
Block a user