Skip to content

Commit

Permalink
Add appendToBody option
Browse files Browse the repository at this point in the history
  • Loading branch information
tabeth committed Aug 11, 2020
1 parent 374c850 commit 148b17f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 7 additions & 1 deletion lib/autocompletion.js

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

2 changes: 1 addition & 1 deletion lib/autocompletion.js.map

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
"bugs": {
"url": "https://github.com/experianplc/autocompletion/issues"
},
"homepage": "https://github.com/experianplc/autocompletion#readme"
"homepage": "https://github.com/experianplc/autocompletion#readme",
"devDependencies": {
"typescript": "^3.9.7"
}
}
7 changes: 6 additions & 1 deletion src/autocompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default (function () {
offsetLeft: 0,
offsetTop: 1,
cache: 1,
appendToBody: true,
menuClass: '',
dontUseOffset: false,
renderItem: function (item, search) {
Expand Down Expand Up @@ -121,7 +122,11 @@ export default (function () {
}
};
addEvent(window, 'resize', autoCompleteElement.updateSC);
document.body.appendChild(autoCompleteElement.suggestionsContainer);
if (o.appendToBody) {
document.body.appendChild(autoCompleteElement.suggestionsContainer);
} else {
nodeList[i].parentElement.appendChild(autoCompleteElement.suggestionsContainer);
}

live('edq-global-intuitive-address-suggestion', 'mouseleave', function() {
let sel = autoCompleteElement.suggestionsContainer.querySelector('.edq-global-intuitive-address-suggestion.selected');
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ interface AutoCompleteOptions extends Object {
renderItem?: (item: any, searchTerm: string) => string;
onSelect?: (e, term, item) => void;
dontUseOffset: boolean;
appendToBody: boolean;
}

0 comments on commit 148b17f

Please sign in to comment.