aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--assets/default/js/base.js3
-rw-r--r--assets/vintage/js/base.js10
2 files changed, 8 insertions, 5 deletions
diff --git a/assets/default/js/base.js b/assets/default/js/base.js
index 37069d69..dd532bb7 100644
--- a/assets/default/js/base.js
+++ b/assets/default/js/base.js
@@ -55,7 +55,8 @@ function createAwesompleteInstance(element, separator, tags = []) {
55 // Highlight found items 55 // Highlight found items
56 awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${separator}]*$`))[0]); 56 awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${separator}]*$`))[0]);
57 // Don't display already selected items 57 // Don't display already selected items
58 const reg = new RegExp(`/(\w+)${separator}/g`); 58 // WARNING: pseudo classes does not seem to work with string litterals...
59 const reg = new RegExp(`([^${separator}]+)${separator}`, 'g');
59 let match; 60 let match;
60 awesome.data = (item, input) => { 61 awesome.data = (item, input) => {
61 while ((match = reg.exec(input))) { 62 while ((match = reg.exec(input))) {
diff --git a/assets/vintage/js/base.js b/assets/vintage/js/base.js
index 15b664ce..55f1c37d 100644
--- a/assets/vintage/js/base.js
+++ b/assets/vintage/js/base.js
@@ -4,7 +4,7 @@ import 'awesomplete/awesomplete.css';
4(() => { 4(() => {
5 const autocompleteFields = document.querySelectorAll('input[data-multiple]'); 5 const autocompleteFields = document.querySelectorAll('input[data-multiple]');
6 const tagsSeparatorElement = document.querySelector('input[name="tags_separator"]'); 6 const tagsSeparatorElement = document.querySelector('input[name="tags_separator"]');
7 const tagsSeparator = tagsSeparatorElement ? tagsSeparatorElement.value || " " : " "; 7 const tagsSeparator = tagsSeparatorElement ? tagsSeparatorElement.value || ' ' : ' ';
8 8
9 [...autocompleteFields].forEach((autocompleteField) => { 9 [...autocompleteFields].forEach((autocompleteField) => {
10 const awesome = new Awesomplete(Awesomplete.$(autocompleteField)); 10 const awesome = new Awesomplete(Awesomplete.$(autocompleteField));
@@ -12,8 +12,8 @@ import 'awesomplete/awesomplete.css';
12 // Tags are separated by separator 12 // Tags are separated by separator
13 awesome.filter = (text, input) => Awesomplete.FILTER_CONTAINS( 13 awesome.filter = (text, input) => Awesomplete.FILTER_CONTAINS(
14 text, 14 text,
15 input.match(new RegExp(`[^${tagsSeparator}]*$`))[0]) 15 input.match(new RegExp(`[^${tagsSeparator}]*$`))[0],
16 ; 16 );
17 // Insert new selected tag in the input 17 // Insert new selected tag in the input
18 awesome.replace = (text) => { 18 awesome.replace = (text) => {
19 const before = awesome.input.value.match(new RegExp(`^.+${tagsSeparator}+|`))[0]; 19 const before = awesome.input.value.match(new RegExp(`^.+${tagsSeparator}+|`))[0];
@@ -21,8 +21,10 @@ import 'awesomplete/awesomplete.css';
21 }; 21 };
22 // Highlight found items 22 // Highlight found items
23 awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${tagsSeparator}]*$`))[0]); 23 awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${tagsSeparator}]*$`))[0]);
24
24 // Don't display already selected items 25 // Don't display already selected items
25 const reg = new RegExp(`/(\w+)${tagsSeparator}/g`); 26 // WARNING: pseudo classes does not seem to work with string litterals...
27 const reg = new RegExp(`([^${tagsSeparator}]+)${tagsSeparator}`, 'g');
26 let match; 28 let match;
27 awesome.data = (item, input) => { 29 awesome.data = (item, input) => {
28 while ((match = reg.exec(input))) { 30 while ((match = reg.exec(input))) {