Added forum topic favourite function
Solves issue #12 Signed-off-by: Gergely Polonkai (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
@@ -17,6 +17,11 @@
|
||||
<dd><a href="{{ path('KekRozsakFrontBundle_groupList') }}">További csoportok</a></dd>
|
||||
|
||||
<dt>Kedvenc Fórum-témáim</dt>
|
||||
{% if app.user.userData %}
|
||||
{% for topic in app.user.userData.favouriteTopics %}
|
||||
<dd><a href="{{ path('KekRozsakFrontBundle_forumPostList', {topicGroupSlug: topic.topicGroup.slug, topicSlug: topic.slug}) }}">{{ topic.title }}</a></dd>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<dd><a href="{{ path('KekRozsakFrontBundle_forumTopicGroupList') }}">Fórum</a></dd>
|
||||
|
||||
<dt>Üzenetek</dt>
|
||||
|
@@ -18,7 +18,7 @@
|
||||
<table class="forum-lista">
|
||||
<thead>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td colspan="2"></td>
|
||||
<td>Hozzászólások száma</td>
|
||||
<td>Utolsó hozzászólás</td>
|
||||
</tr>
|
||||
@@ -26,6 +26,13 @@
|
||||
<tbody>
|
||||
{% for topic in topicGroup.topics %}
|
||||
<tr class="{{ cycle(['odd', 'even'], loop.index0) }}">
|
||||
<td>
|
||||
{% if app.user.userData and app.user.userData.isFavouriteForumTopic(topic) %}
|
||||
<span class="gomb unfavourite-topic-button" id="unfavourite-topic-button-{{ topic.slug }}">[Kedvenc ikon]</span>
|
||||
{% else %}
|
||||
<span class="gomb favourite-topic-button" id="favourite-topic-button-{{ topic.slug }}">[Nem kedvenc ikon]</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td><a href="{{ path('KekRozsakFrontBundle_forumPostList', { topicGroupSlug: topicGroup.slug, topicSlug: topic.slug }) }}">{{ topic.title }}</a></td>
|
||||
<td></td>
|
||||
<td>
|
||||
@@ -44,3 +51,64 @@
|
||||
Ebben a témakörben nincsenek témák.
|
||||
{% endif %}
|
||||
{% endblock content %}
|
||||
|
||||
{% block bottomscripts %}
|
||||
<script type="text/javascript">
|
||||
{# TODO: The following two functions should also update the top-left profile
|
||||
# box
|
||||
#}
|
||||
function favouriteOn()
|
||||
{
|
||||
var self = $(this)
|
||||
var topicSlug = self.attr('id').replace(/^favourite-topic-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_forumFavouriteTopic', {
|
||||
topicGroupSlug: '{{ topicGroup.slug }}',
|
||||
topicSlug: topicSlug
|
||||
});
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
self.html('[Kedvenc ikon]');
|
||||
self.removeClass('favourite-topic-button');
|
||||
self.addClass('unfavourite-topic-button');
|
||||
self.attr('id', 'unfavourite-topic-button-' + topicSlug);
|
||||
self.off('click.updateFav');
|
||||
self.on('click.updateFav', favouriteOff);
|
||||
}).error(function() {
|
||||
alert('Nem siker!');
|
||||
});
|
||||
}
|
||||
|
||||
function favouriteOff()
|
||||
{
|
||||
var self = $(this)
|
||||
var topicSlug = self.attr('id').replace(/^unfavourite-topic-button-/, '');
|
||||
url = Routing.generate('KekRozsakFrontBundle_forumUnfavouriteTopic', {
|
||||
topicGroupSlug: '{{ topicGroup.slug }}',
|
||||
topicSlug: topicSlug
|
||||
});
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: url
|
||||
}).done(function() {
|
||||
self.html('[Nem kedvenc ikon]');
|
||||
self.removeClass('unfavourite-topic-button');
|
||||
self.addClass('favourite-topic-button');
|
||||
self.attr('id', 'favourite-topic-button-' + topicSlug);
|
||||
self.off('click.updateFav');
|
||||
self.on('click.updateFav', favouriteOn);
|
||||
}).error(function() {
|
||||
alert('Nem siker!');
|
||||
});
|
||||
}
|
||||
|
||||
function setupFavButtons()
|
||||
{
|
||||
$('.favourite-topic-button').on('click.updateFav', favouriteOn);
|
||||
$('.unfavourite-topic-button').on('click.updateFav', favouriteOff);
|
||||
}
|
||||
|
||||
$(document).ready(setupFavButtons);
|
||||
</script>
|
||||
{% endblock bottomscripts %}
|
Reference in New Issue
Block a user