blob: 56184f55e7d20685abaf7be9e1277023473a611b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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>
|