Skip to content
This repository has been archived by the owner on Apr 20, 2019. It is now read-only.

Commit

Permalink
version 1.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbe committed Jan 9, 2017
1 parent 8e2713d commit 81da30e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "autocompeter",
"version": "1.2.2",
"version": "1.2.3",
"homepage": "https://autocompeter.com",
"authors": [
"Peter Bengtsson <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "autocompeter",
"version": "1.2.2",
"version": "1.2.3",
"description": "A really fast AJAX autocomplete service and widget",
"main": "index.js",
"scripts": {
Expand Down
13 changes: 6 additions & 7 deletions public/dist/autocompeter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
*
* Copyright (c) 2015, Peter Bengtsson
* Copyright (c) 2015-2017, Peter Bengtsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -89,7 +89,7 @@
options.url += 'd=' + options.domain + '&q=';

var results_ps = [];
var selected_pointer = 0;
var selected_pointer = -1;
var actually_selected_pointer = false;
q.spellcheck = false;
q.autocomplete = 'off';
Expand Down Expand Up @@ -208,8 +208,7 @@

hint_candidate = found[found.length - 1];
if (hint_candidate !== undefined && !matched.test(q.value)) {

if (selected_pointer === i) {
if (selected_pointer === i || (selected_pointer === -1 && i === 0)) {
hint_candidates.push(hint_candidate);
}
}
Expand All @@ -231,7 +230,7 @@
}
r.appendChild(p_fragments);
if (hint_candidates.length && q.value.charAt(q.value.length - 1) !== ' ') {
hint_candidate = hint_candidates[selected_pointer % hint_candidates.length];
hint_candidate = hint_candidates[Math.max(0, selected_pointer) % hint_candidates.length];
hint.value = q.value + hint_candidate;
} else {
// If there are no candidates there's no point putting the
Expand Down Expand Up @@ -282,7 +281,7 @@
displayResults();
} else if (name === 'enter') {
if (results_ps.length && actually_selected_pointer) {
var p = results_ps[selected_pointer];
var p = results_ps[Math.max(0, selected_pointer)];
var a = p.getElementsByTagName('a')[0];
q.value = hint.value = a.textContent;
r.style.display = 'none';
Expand Down Expand Up @@ -346,7 +345,7 @@
}
}
// New character, let's reset the selected_pointer
selected_pointer = 0;
selected_pointer = -1;
// Also, reset that none of the results have been explicitly
// selected yet.
actually_selected_pointer = false;
Expand Down
2 changes: 1 addition & 1 deletion public/dist/autocompeter.min.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Autocompeter.com 1.2.2 */
/* Autocompeter.com 1.2.3 */
._ac-wrap{position:relative;display:inline-block}
._ac-wrap ._ac-hint{position:absolute;top:0;left:0;border-color:transparent;box-shadow:none;opacity:1;color:#b4b4b4;background:#fff}
._ac-wrap ._ac-foreground{background-color:transparent;position:relative;vertical-align:top}
Expand Down
4 changes: 2 additions & 2 deletions public/dist/autocompeter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions src/autocompeter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
*
* Copyright (c) 2015, Peter Bengtsson
* Copyright (c) 2015-2017, Peter Bengtsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -89,7 +89,7 @@
options.url += 'd=' + options.domain + '&q=';

var results_ps = [];
var selected_pointer = 0;
var selected_pointer = -1;
var actually_selected_pointer = false;
q.spellcheck = false;
q.autocomplete = 'off';
Expand Down Expand Up @@ -208,8 +208,7 @@

hint_candidate = found[found.length - 1];
if (hint_candidate !== undefined && !matched.test(q.value)) {

if (selected_pointer === i) {
if (selected_pointer === i || (selected_pointer === -1 && i === 0)) {
hint_candidates.push(hint_candidate);
}
}
Expand All @@ -231,7 +230,7 @@
}
r.appendChild(p_fragments);
if (hint_candidates.length && q.value.charAt(q.value.length - 1) !== ' ') {
hint_candidate = hint_candidates[selected_pointer % hint_candidates.length];
hint_candidate = hint_candidates[Math.max(0, selected_pointer) % hint_candidates.length];
hint.value = q.value + hint_candidate;
} else {
// If there are no candidates there's no point putting the
Expand Down Expand Up @@ -282,7 +281,7 @@
displayResults();
} else if (name === 'enter') {
if (results_ps.length && actually_selected_pointer) {
var p = results_ps[selected_pointer];
var p = results_ps[Math.max(0, selected_pointer)];
var a = p.getElementsByTagName('a')[0];
q.value = hint.value = a.textContent;
r.style.display = 'none';
Expand Down Expand Up @@ -346,7 +345,7 @@
}
}
// New character, let's reset the selected_pointer
selected_pointer = 0;
selected_pointer = -1;
// Also, reset that none of the results have been explicitly
// selected yet.
actually_selected_pointer = false;
Expand Down

0 comments on commit 81da30e

Please sign in to comment.