WIP: adding tags to photos.

This commit is contained in:
Aaron van Geffen 2016-09-04 11:23:08 +02:00
parent 3220d361c3
commit f96ab144ef

View File

@ -26,6 +26,7 @@ class PhotoPage extends SubTemplate
<h2 class="entry-title">', $this->photo->getTitle(), '</h2>';
$this->taggedPeople();
$this->linkNewTags();
echo '
</div>';
@ -131,6 +132,50 @@ class PhotoPage extends SubTemplate
</ul>';
}
private function linkNewTags()
{
echo '
<div>
<h3>Link tags</h3>
<ul id="tag_list">
<li id="new_tag_container"><input type="text" id="new_tag" placeholder="Type to link a new tag"></li>
</ul>
</div>
<script type="text/javascript" src="', BASEURL, '/js/ajax.js"></script>
<script type="text/javascript" src="', BASEURL, '/js/autosuggest.js"></script>
<script type="text/javascript">
setTimeout(function() {
var tag_autosuggest = new TagAutoSuggest({
inputElement: "new_tag",
listElement: "tag_list",
baseUrl: "', BASEURL, '",
appendCallback: function(item) {
if (document.getElementById("linked_tag_" + item.id_tag)) {
return;
}
var newCheck = document.createElement("input");
newCheck.type = "checkbox";
newCheck.name = "tag[" + item.id_tag + "]";
newCheck.id = "linked_tag_" + item.id_tag;
newCheck.title = "Uncheck to delete";
newCheck.checked = "checked";
var newNode = document.createElement("li");
newNode.appendChild(newCheck);
var newLabel = document.createTextNode(item.label);
newNode.appendChild(newLabel);
var list = document.getElementById("tag_list");
var input = document.getElementById("new_tag_container");
list.insertBefore(newNode, input);
}
});
}, 100);
</script>';
}
public function setExif(EXIF $exif)
{
$this->exif = $exif;