]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - inc/awesomplete-multiple-tags.js
1 var awp
= Awesomplete
.$;
2 awesomplete
= new Awesomplete(awp('input[data-multiple]'), {
3 filter: function(text
, input
) {
4 return Awesomplete
.FILTER_CONTAINS(text
, input
.match(/[^ ]*$/)[0]);
6 replace: function(text
) {
7 var before
= this.input
.value
.match(/^.+ \s
*|/)[0];
8 this.input
.value
= before
+ text
+ " ";
14 * Remove already selected items from autocompletion list.
15 * HTML list is never updated, so removing a tag will add it back to awesomplete.
17 * FIXME: This a workaround waiting for awesomplete to handle this.
18 * https://github.com/LeaVerou/awesomplete/issues/16749
20 function awesompleteUniqueTag(selector
) {
21 var input
= document
.querySelector(selector
);
22 input
.addEventListener('input', function()
24 proposedTags
= input
.getAttribute('data-list').replace(/,/g
, '').split(' ');
26 while((match
= reg
.exec(input
.value
)) !== null) {
27 id
= proposedTags
.indexOf(match
[1]);
29 proposedTags
.splice(id
, 1);
33 awesomplete
.list
= proposedTags
;