diff options
Diffstat (limited to 'src/main/resources/templates/parts/post_form.html')
-rw-r--r-- | src/main/resources/templates/parts/post_form.html | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/main/resources/templates/parts/post_form.html b/src/main/resources/templates/parts/post_form.html new file mode 100644 index 00000000..56184f55 --- /dev/null +++ b/src/main/resources/templates/parts/post_form.html @@ -0,0 +1,64 @@ +<form action="/post" method="post" enctype="multipart/form-data" onsubmit="return onsubmitNewMessage()"> + <section id="newmessage"> + <textarea name="body" placeholder="Новое сообщение..." + onclick="newmessage_toggleOpen()" + onkeypress="postformListener(this.form,event)"></textarea> + <div> + <input type="text" class="img" name="img" placeholder="Ссылка на изображение (JPG/PNG, до 10Мб)" style="margin-bottom: 8pt"/> или <a + href="#" onclick="return attachMessagePhoto(this)">загрузить</a><br/> + + <!--<textarea class="tags" name="tags" rows="1" id="post_tags" style="resize: none;" type="text"></textarea>--> + <input type="text" class="tags" name="tags" id="post_tags"/><br/> + <input type="submit" class="subm" value="Отправить"/> + </div> + <div id="newmessage_tags" style="padding-top: 10pt"> + <span style="display: none; border: 1px solid black; background-color: #1277aa; color: white; padding: 2pt 2pt; font-size: 9pt; margin: 2pt 2pt"> + sample + </span> + </div> + <script> + function newmessage_toggleOpen() { + $('#newmessage>div').css('display','block'); + $('#newmessage textarea').css('min-height','70px'); + + $.ajax({url:"/my_tags.json"}).done(function(data) { + $('#post_tags').textext({ + plugins: 'tags prompt focus autocomplete suggestions arrow', + tagsItems: [], + prompt: 'Теги (через ENTER)', + suggestions: data + }); + var plugin = $('#post_tags').textext()[0]; + var mtags = document.getElementById("newmessage_tags"); + var template = mtags.firstElementChild; + for(var i=0; i<data.length; i++) { + var nextItem = template.cloneNode(true); + nextItem.innerText = data[i]; + nextItem.style.display = "inline"; + var q = function(item) { + item.onclick = function() { + window.setTimeout(function() { + if (plugin.tags().getTagElement(item.innerText)) { + plugin.tags().removeTag(item.innerText); + } + plugin.tags().addTags([item.innerText]); + }, 50) + }; + item.onmouseover = function() { + item.style.fontStyle = "bold"; + item.style.backgroundColor = "#2ba4e3"; + }; + item.onmouseout = function() { + item.style.fontStyle = ""; + item.style.backgroundColor = template.style.backgroundColor; + }; + }; + q(nextItem); + mtags.appendChild(nextItem); + } + }); + newmessage_toggleOpen = function() {} + } + </script> + </section> +</form>
\ No newline at end of file |