Skip to content

Commit f64d7db

Browse files
author
Clinton Gormley
committed
Set the search-input to be autocomplete only after the focus event fires, so that mobile browsers have time to resize the input field correctly
1 parent 1ae2282 commit f64d7db

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

root/static/js/cpan.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -131,32 +131,34 @@ $(document).ready(function() {
131131
}
132132
});
133133

134-
$("#search-input").autocomplete('/search/autocomplete', {
135-
dataType: 'json',
136-
delay: 100,
137-
max: 20,
138-
selectFirst: false,
139-
width: $("#search-input").innerWidth(),
140-
parse: function(data) {
141-
var result = $.map(data, function(row) {
142-
return {
143-
data: row,
144-
value: row.documentation,
145-
result: row.documentation
146-
}
147-
});
148-
var uniq = {};
149-
result = $.grep(result, function(row) {
150-
uniq[row.result] = typeof(uniq[row.result]) == 'undefined' ? 0 : uniq[row.result];
151-
return uniq[row.result]++ < 1;
152-
});
153-
return result;
154-
},
155-
formatItem: function(item) {
156-
return item.documentation;
157-
}
158-
}).result(function(e, item) {
159-
document.location.href = '/module/'+ item.documentation;
134+
$("#search-input").focus(function() {
135+
$(this).autocomplete('/search/autocomplete', {
136+
dataType: 'json',
137+
delay: 100,
138+
max: 20,
139+
selectFirst: false,
140+
width: $("#search-input").innerWidth(),
141+
parse: function(data) {
142+
var result = $.map(data, function(row) {
143+
return {
144+
data: row,
145+
value: row.documentation,
146+
result: row.documentation
147+
}
148+
});
149+
var uniq = {};
150+
result = $.grep(result, function(row) {
151+
uniq[row.result] = typeof(uniq[row.result]) == 'undefined' ? 0 : uniq[row.result];
152+
return uniq[row.result]++ < 1;
153+
});
154+
return result;
155+
},
156+
formatItem: function(item) {
157+
return item.documentation;
158+
}
159+
}).result(function(e, item) {
160+
document.location.href = '/module/'+ item.documentation;
161+
});
160162
});
161163

162164
$('#search-input.autofocus').focus();

0 commit comments

Comments
 (0)