aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--assets/default/js/base.js2
-rw-r--r--assets/vintage/js/base.js45
-rw-r--r--tpl/vintage/includes.html4
-rw-r--r--tpl/vintage/linklist.html2
-rw-r--r--tpl/vintage/page.footer.html6
5 files changed, 34 insertions, 25 deletions
diff --git a/assets/default/js/base.js b/assets/default/js/base.js
index e7bf4909..37069d69 100644
--- a/assets/default/js/base.js
+++ b/assets/default/js/base.js
@@ -217,7 +217,7 @@ function init(description) {
217(() => { 217(() => {
218 const basePath = document.querySelector('input[name="js_base_path"]').value; 218 const basePath = document.querySelector('input[name="js_base_path"]').value;
219 const tagsSeparatorElement = document.querySelector('input[name="tags_separator"]'); 219 const tagsSeparatorElement = document.querySelector('input[name="tags_separator"]');
220 const tagsSeparator = tagsSeparatorElement ? tagsSeparatorElement.value || '\s' : '\s'; 220 const tagsSeparator = tagsSeparatorElement ? tagsSeparatorElement.value || ' ' : ' ';
221 221
222 /** 222 /**
223 * Handle responsive menu. 223 * Handle responsive menu.
diff --git a/assets/vintage/js/base.js b/assets/vintage/js/base.js
index 66830b59..15b664ce 100644
--- a/assets/vintage/js/base.js
+++ b/assets/vintage/js/base.js
@@ -2,29 +2,36 @@ import Awesomplete from 'awesomplete';
2import 'awesomplete/awesomplete.css'; 2import 'awesomplete/awesomplete.css';
3 3
4(() => { 4(() => {
5 const awp = Awesomplete.$;
6 const autocompleteFields = document.querySelectorAll('input[data-multiple]'); 5 const autocompleteFields = document.querySelectorAll('input[data-multiple]');
6 const tagsSeparatorElement = document.querySelector('input[name="tags_separator"]');
7 const tagsSeparator = tagsSeparatorElement ? tagsSeparatorElement.value || " " : " ";
8
7 [...autocompleteFields].forEach((autocompleteField) => { 9 [...autocompleteFields].forEach((autocompleteField) => {
8 const awesomplete = new Awesomplete(awp(autocompleteField)); 10 const awesome = new Awesomplete(Awesomplete.$(autocompleteField));
9 awesomplete.filter = (text, input) => Awesomplete.FILTER_CONTAINS(text, input.match(/[^ ]*$/)[0]);
10 awesomplete.replace = (text) => {
11 const before = awesomplete.input.value.match(/^.+ \s*|/)[0];
12 awesomplete.input.value = `${before}${text} `;
13 };
14 awesomplete.minChars = 1;
15 11
16 autocompleteField.addEventListener('input', () => { 12 // Tags are separated by separator
17 const proposedTags = autocompleteField.getAttribute('data-list').replace(/,/g, '').split(' '); 13 awesome.filter = (text, input) => Awesomplete.FILTER_CONTAINS(
18 const reg = /(\w+) /g; 14 text,
19 let match; 15 input.match(new RegExp(`[^${tagsSeparator}]*$`))[0])
20 while ((match = reg.exec(autocompleteField.value)) !== null) { 16 ;
21 const id = proposedTags.indexOf(match[1]); 17 // Insert new selected tag in the input
22 if (id !== -1) { 18 awesome.replace = (text) => {
23 proposedTags.splice(id, 1); 19 const before = awesome.input.value.match(new RegExp(`^.+${tagsSeparator}+|`))[0];
20 awesome.input.value = `${before}${text}${tagsSeparator}`;
21 };
22 // Highlight found items
23 awesome.item = (text, input) => Awesomplete.ITEM(text, input.match(new RegExp(`[^${tagsSeparator}]*$`))[0]);
24 // Don't display already selected items
25 const reg = new RegExp(`/(\w+)${tagsSeparator}/g`);
26 let match;
27 awesome.data = (item, input) => {
28 while ((match = reg.exec(input))) {
29 if (item === match[1]) {
30 return '';
24 } 31 }
25 } 32 }
26 33 return item;
27 awesomplete.list = proposedTags; 34 };
28 }); 35 awesome.minChars = 1;
29 }); 36 });
30})(); 37})();
diff --git a/tpl/vintage/includes.html b/tpl/vintage/includes.html
index eac05701..2ce9da42 100644
--- a/tpl/vintage/includes.html
+++ b/tpl/vintage/includes.html
@@ -5,13 +5,13 @@
5<meta name="referrer" content="same-origin"> 5<meta name="referrer" content="same-origin">
6<link rel="alternate" type="application/rss+xml" href="{$feedurl}feed/rss?{$searchcrits}#" title="RSS Feed" /> 6<link rel="alternate" type="application/rss+xml" href="{$feedurl}feed/rss?{$searchcrits}#" title="RSS Feed" />
7<link rel="alternate" type="application/atom+xml" href="{$feedurl}feed/atom?{$searchcrits}#" title="ATOM Feed" /> 7<link rel="alternate" type="application/atom+xml" href="{$feedurl}feed/atom?{$searchcrits}#" title="ATOM Feed" />
8<link href="img/favicon.ico" rel="shortcut icon" type="image/x-icon" /> 8<link href="{$asset_path}/img/favicon.ico#" rel="shortcut icon" type="image/x-icon" />
9<link type="text/css" rel="stylesheet" href="{$asset_path}/css/shaarli.min.css#" /> 9<link type="text/css" rel="stylesheet" href="{$asset_path}/css/shaarli.min.css#" />
10{if="$formatter==='markdown'"} 10{if="$formatter==='markdown'"}
11 <link type="text/css" rel="stylesheet" href="{$asset_path}/css/markdown.min.css?v={$version_hash}#" /> 11 <link type="text/css" rel="stylesheet" href="{$asset_path}/css/markdown.min.css?v={$version_hash}#" />
12{/if} 12{/if}
13{loop="$plugins_includes.css_files"} 13{loop="$plugins_includes.css_files"}
14<link type="text/css" rel="stylesheet" href="{$base_path}/{$value}#"/> 14<link type="text/css" rel="stylesheet" href="{$root_path}/{$value}#"/>
15{/loop} 15{/loop}
16{if="is_file('data/user.css')"}<link type="text/css" rel="stylesheet" href="{$base_path}/data/user.css#" />{/if} 16{if="is_file('data/user.css')"}<link type="text/css" rel="stylesheet" href="{$base_path}/data/user.css#" />{/if}
17<link rel="search" type="application/opensearchdescription+xml" href="{$base_path}/open-search#" 17<link rel="search" type="application/opensearchdescription+xml" href="{$base_path}/open-search#"
diff --git a/tpl/vintage/linklist.html b/tpl/vintage/linklist.html
index 90f5cf8f..ff0dd40c 100644
--- a/tpl/vintage/linklist.html
+++ b/tpl/vintage/linklist.html
@@ -61,7 +61,7 @@
61 for <em>{$search_term}</em> 61 for <em>{$search_term}</em>
62 {/if} 62 {/if}
63 {if="!empty($search_tags)"} 63 {if="!empty($search_tags)"}
64 {$exploded_tags=explode(' ', $search_tags)} 64 {$exploded_tags=tags_str2array($search_tags, $tags_separator)}
65 tagged 65 tagged
66 {loop="$exploded_tags"} 66 {loop="$exploded_tags"}
67 <span class="linktag" title="Remove tag"> 67 <span class="linktag" title="Remove tag">
diff --git a/tpl/vintage/page.footer.html b/tpl/vintage/page.footer.html
index 0fe4c736..be709aeb 100644
--- a/tpl/vintage/page.footer.html
+++ b/tpl/vintage/page.footer.html
@@ -23,8 +23,6 @@
23</div> 23</div>
24{/if} 24{/if}
25 25
26<script src="{$asset_path}/js/shaarli.min.js#"></script>
27
28{if="$is_logged_in"} 26{if="$is_logged_in"}
29<script>function confirmDeleteLink() { var agree=confirm("Are you sure you want to delete this link ?"); if (agree) return true ; else return false ; }</script> 27<script>function confirmDeleteLink() { var agree=confirm("Are you sure you want to delete this link ?"); if (agree) return true ; else return false ; }</script>
30{/if} 28{/if}
@@ -34,3 +32,7 @@
34{/loop} 32{/loop}
35 33
36<input type="hidden" name="js_base_path" value="{$base_path}" /> 34<input type="hidden" name="js_base_path" value="{$base_path}" />
35<input type="hidden" name="token" value="{$token}" id="token" />
36<input type="hidden" name="tags_separator" value="{$tags_separator}" id="tags_separator" />
37
38<script src="{$asset_path}/js/shaarli.min.js#"></script>