aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2015-07-12 11:01:24 +0200
committerArthur <arthur@hoa.ro>2015-07-12 11:01:24 +0200
commit7bd3542b1b030070fa3412a2769f9632bd4e6d1b (patch)
treee2b0bfffec3063025e1872025c805626f3027dc5 /tpl
parentbba021defce15184c986d5e3db138bdbdd4df5d5 (diff)
parent781e8aadea7590dc87b61915b6e65ec52f7d250e (diff)
downloadShaarli-7bd3542b1b030070fa3412a2769f9632bd4e6d1b.tar.gz
Shaarli-7bd3542b1b030070fa3412a2769f9632bd4e6d1b.tar.zst
Shaarli-7bd3542b1b030070fa3412a2769f9632bd4e6d1b.zip
Merge pull request #262 from ArthurHoaro/dup-tags
Avoid tag duplicates
Diffstat (limited to 'tpl')
-rw-r--r--tpl/editlink.html24
1 files changed, 23 insertions, 1 deletions
diff --git a/tpl/editlink.html b/tpl/editlink.html
index a32748ab..3733ca21 100644
--- a/tpl/editlink.html
+++ b/tpl/editlink.html
@@ -42,7 +42,7 @@
42{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn())"} 42{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn())"}
43<script> 43<script>
44 $ = Awesomplete.$; 44 $ = Awesomplete.$;
45 new Awesomplete($('input[data-multiple]'), { 45 awesomplete = new Awesomplete($('input[data-multiple]'), {
46 filter: function(text, input) { 46 filter: function(text, input) {
47 return Awesomplete.FILTER_CONTAINS(text, input.match(/[^ ]*$/)[0]); 47 return Awesomplete.FILTER_CONTAINS(text, input.match(/[^ ]*$/)[0]);
48 }, 48 },
@@ -52,6 +52,28 @@
52 }, 52 },
53 minChars: 1 53 minChars: 1
54 }); 54 });
55
56 /**
57 * Remove already selected items from autocompletion list.
58 * HTML list is never updated, so removing a tag will add it back to awesomplete.
59 *
60 * FIXME: This a workaround waiting for awesomplete to handle this.
61 * https://github.com/LeaVerou/awesomplete/issues/16749
62 */
63 var input = document.querySelector('#lf_tags');
64 input.addEventListener('input', function()
65 {
66 proposedTags = input.getAttribute('data-list').replace(/,/g, '').split(' ');
67 reg = /(\w+) /g;
68 while((match = reg.exec(input.value)) !== null) {
69 id = proposedTags.indexOf(match[1]);
70 if(id != -1 ) {
71 proposedTags.splice(id, 1);
72 }
73 }
74
75 awesomplete.list = proposedTags;
76 });
55</script> 77</script>
56{/if} 78{/if}
57</body> 79</body>