Merge branch 'tag-improvements' of Public/pics into master
This commit is contained in:
commit
3fc8ccf550
@ -41,8 +41,9 @@ class ProvideAutoSuggest extends JSONController
|
|||||||
$results = Tag::matchPeople($data);
|
$results = Tag::matchPeople($data);
|
||||||
foreach ($results as $id_tag => $tag)
|
foreach ($results as $id_tag => $tag)
|
||||||
$this->payload['items'][] = [
|
$this->payload['items'][] = [
|
||||||
'label' => $tag,
|
'label' => $tag['tag'],
|
||||||
'id_tag' => $id_tag,
|
'id_tag' => $id_tag,
|
||||||
|
'url' => BASEURL . '/' . $tag['slug'] . '/',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,19 @@ class ViewPhoto extends HTMLController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We are!
|
// We are!
|
||||||
|
if (!isset($_POST['delete']))
|
||||||
|
{
|
||||||
$photo->linkTags([(int) $_POST['id_tag']]);
|
$photo->linkTags([(int) $_POST['id_tag']]);
|
||||||
echo json_encode(['success' => true]);
|
echo json_encode(['success' => true]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ... deleting, that is.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$photo->unlinkTags([(int) $_POST['id_tag']]);
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,8 +335,8 @@ class Tag
|
|||||||
if (!is_array($tokens))
|
if (!is_array($tokens))
|
||||||
$tokens = explode(' ', $tokens);
|
$tokens = explode(' ', $tokens);
|
||||||
|
|
||||||
return Registry::get('db')->queryPair('
|
return Registry::get('db')->queryPairs('
|
||||||
SELECT id_tag, tag
|
SELECT id_tag, tag, slug
|
||||||
FROM tags
|
FROM tags
|
||||||
WHERE LOWER(tag) LIKE {string:tokens} AND
|
WHERE LOWER(tag) LIKE {string:tokens} AND
|
||||||
kind = {string:person}
|
kind = {string:person}
|
||||||
|
@ -588,14 +588,16 @@ a#previous_photo:hover, a#next_photo:hover {
|
|||||||
}
|
}
|
||||||
#sub_photo #tag_list li {
|
#sub_photo #tag_list li {
|
||||||
display: inline;
|
display: inline;
|
||||||
|
padding-right: 0.75em;
|
||||||
}
|
}
|
||||||
#sub_photo #tag_list li:after {
|
#tag_list .delete-tag {
|
||||||
content: ', ';
|
opacity: 0.25;
|
||||||
}
|
}
|
||||||
#sub_photo #tag_list li:last-child:after {
|
#tag_list .delete-tag:hover {
|
||||||
content: '';
|
opacity: 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#photo_exif_box {
|
#photo_exif_box {
|
||||||
background: #fff;
|
background: #fff;
|
||||||
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
|
||||||
|
@ -158,8 +158,6 @@ TagAutoSuggest.prototype.fillContainer = function(response) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
node.addEventListener('click', function(event) {
|
node.addEventListener('click', function(event) {
|
||||||
self.createNewTag(function(response) {
|
self.createNewTag(function(response) {
|
||||||
console.log('Nieuwe tag!!');
|
|
||||||
console.log(response);
|
|
||||||
self.appendCallback(response);
|
self.appendCallback(response);
|
||||||
});
|
});
|
||||||
self.closeContainer();
|
self.closeContainer();
|
||||||
|
@ -148,8 +148,14 @@ class PhotoPage extends SubTemplate
|
|||||||
foreach ($this->photo->getTags() as $tag)
|
foreach ($this->photo->getTags() as $tag)
|
||||||
{
|
{
|
||||||
echo '
|
echo '
|
||||||
<li>
|
<li id="tag-', $tag->id_tag, '">
|
||||||
<a rel="tag" title="View all posts tagged ', $tag->tag, '" href="', $tag->getUrl(), '" class="entry-tag">', $tag->tag, '</a>
|
<a rel="tag" title="View all posts tagged ', $tag->tag, '" href="', $tag->getUrl(), '" class="entry-tag">', $tag->tag, '</a>';
|
||||||
|
|
||||||
|
if ($tag->kind === 'Person')
|
||||||
|
echo '
|
||||||
|
<a class="delete-tag" title="Unlink this tag from this photo" href="#" data-id="', $tag->id_tag, '">❌</a>';
|
||||||
|
|
||||||
|
echo '
|
||||||
</li>';
|
</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +174,25 @@ class PhotoPage extends SubTemplate
|
|||||||
<script type="text/javascript" src="', BASEURL, '/js/autosuggest.js"></script>
|
<script type="text/javascript" src="', BASEURL, '/js/autosuggest.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
var removeTag = function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
var that = this;
|
||||||
|
var request = new HttpRequest("post", "', $this->photo->getPageUrl(), '",
|
||||||
|
"id_tag=" + this.dataset["id"] + "&delete", function(response) {
|
||||||
|
if (!response.success) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tagNode = document.getElementById("tag-" + that.dataset["id"]);
|
||||||
|
tagNode.parentNode.removeChild(tagNode);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var tagRemovalTargets = document.getElementsByClassName("delete-tag");
|
||||||
|
Array.forEach(tagRemovalTargets, function(el) {
|
||||||
|
el.addEventListener("click", removeTag);
|
||||||
|
});
|
||||||
|
|
||||||
var tag_autosuggest = new TagAutoSuggest({
|
var tag_autosuggest = new TagAutoSuggest({
|
||||||
inputElement: "new_tag",
|
inputElement: "new_tag",
|
||||||
listElement: "tag_list",
|
listElement: "tag_list",
|
||||||
@ -175,9 +200,25 @@ class PhotoPage extends SubTemplate
|
|||||||
appendCallback: function(item) {
|
appendCallback: function(item) {
|
||||||
var request = new HttpRequest("post", "', $this->photo->getPageUrl(), '",
|
var request = new HttpRequest("post", "', $this->photo->getPageUrl(), '",
|
||||||
"id_tag=" + item.id_tag, function(response) {
|
"id_tag=" + item.id_tag, function(response) {
|
||||||
var newNode = document.createElement("li");
|
var newLink = document.createElement("a");
|
||||||
|
newLink.href = item.url;
|
||||||
|
|
||||||
var newLabel = document.createTextNode(item.label);
|
var newLabel = document.createTextNode(item.label);
|
||||||
newNode.appendChild(newLabel);
|
newLink.appendChild(newLabel);
|
||||||
|
|
||||||
|
var removeLink = document.createElement("a");
|
||||||
|
removeLink.className = "delete-tag";
|
||||||
|
removeLink.dataset["id"] = item.id_tag;
|
||||||
|
removeLink.href = "#";
|
||||||
|
removeLink.addEventListener("click", removeTag);
|
||||||
|
|
||||||
|
var crossmark = document.createTextNode("❌");
|
||||||
|
removeLink.appendChild(crossmark);
|
||||||
|
|
||||||
|
var newNode = document.createElement("li");
|
||||||
|
newNode.id = "tag-" + item.id_tag;
|
||||||
|
newNode.appendChild(newLink);
|
||||||
|
newNode.appendChild(removeLink);
|
||||||
|
|
||||||
var list = document.getElementById("tag_list");
|
var list = document.getElementById("tag_list");
|
||||||
list.appendChild(newNode);
|
list.appendChild(newNode);
|
||||||
|
Loading…
Reference in New Issue
Block a user