]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tpl/editlink.html
CachedPage: move to a proper file, add tests
[github/shaarli/Shaarli.git] / tpl / editlink.html
CommitLineData
45034273
SS
1<!DOCTYPE html>
2<html>
246e9b4e 3<head>{include="includes"}
bdd1715b
A
4 <link type="text/css" rel="stylesheet" href="../inc/awesomplete.css" />
5 <script src="inc/awesomplete.min.js#"></script>
246e9b4e 6</head>
bb8f712d 7<body
ae22a12b
T
8{if="$link.title==''"}onload="document.linkform.lf_title.focus();"
9{elseif="$link.description==''"}onload="document.linkform.lf_description.focus();"
45034273
SS
10{else}onload="document.linkform.lf_tags.focus();"{/if} >
11<div id="pageheader">
d33c5d4c 12 {if="$source !== 'firefoxsocialapi'"}
45034273 13 {include="page.header"}
d33c5d4c 14 {/if}
45034273
SS
15 <div id="editlinkform">
16 <form method="post" name="linkform">
17 <input type="hidden" name="lf_linkdate" value="{$link.linkdate}">
5f85fcd8
A
18 <label for="lf_url"><i>URL</i></label><br><input type="text" name="lf_url" id="lf_url" value="{$link.url}" class="lf_input"><br>
19 <label for="lf_title"><i>Title</i></label><br><input type="text" name="lf_title" id="lf_title" value="{$link.title}" class="lf_input"><br>
20 <label for="lf_description"><i>Description</i></label><br><textarea name="lf_description" id="lf_description" rows="4" cols="25">{$link.description}</textarea><br>
bdd1715b 21 <label for="lf_tags"><i>Tags</i></label><br>
eae648d4 22 <input type="text" name="lf_tags" id="lf_tags" value="{$link.tags}" class="lf_input"
bdd1715b 23 data-list="{loop="$tags"}{$key}, {/loop}" data-multiple autocomplete="off" ><br>
ae22a12b 24 {if="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"}
bb8f712d
KT
25 <input type="checkbox" checked="checked" name="lf_private" id="lf_private">
26 &nbsp;<label for="lf_private"><i>Private</i></label><br>
27 {else}
28 <input type="checkbox" name="lf_private" id="lf_private">
29 &nbsp;<label for="lf_private"><i>Private</i></label><br>
30 {/if}
c133612f
V
31 <input type="submit" value="Save" name="save_edit" class="bigbutton">
32 <input type="submit" value="Cancel" name="cancel_edit" class="bigbutton">
33 {if="!$link_is_new"}<input type="submit" value="Delete" name="delete_link" class="bigbutton delete" onClick="return confirmDeleteLink();">{/if}
45034273 34 <input type="hidden" name="token" value="{$token}">
5f85fcd8 35 {if="$http_referer"}<input type="hidden" name="returnurl" value="{$http_referer}">{/if}
45034273
SS
36 </form>
37 </div>
38</div>
d33c5d4c 39{if="$source !== 'firefoxsocialapi'"}
45034273 40{include="page.footer"}
d33c5d4c 41{/if}
bdd1715b 42{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn())"}
fe16b01e 43<script>
bdd1715b 44 $ = Awesomplete.$;
781e8aad 45 awesomplete = new Awesomplete($('input[data-multiple]'), {
bdd1715b
A
46 filter: function(text, input) {
47 return Awesomplete.FILTER_CONTAINS(text, input.match(/[^ ]*$/)[0]);
48 },
49 replace: function(text) {
50 var before = this.input.value.match(/^.+ \s*|/)[0];
51 this.input.value = before + text + " ";
52 },
53 minChars: 1
54 });
781e8aad
A
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 });
246e9b4e
SS
77</script>
78{/if}
45034273 79</body>
ae22a12b 80</html>