##// END OF EJS Templates
Subscribe/unsubscribe thread by ajax
Subscribe/unsubscribe thread by ajax

File last commit:

r2089:676b3885 default
r2089:676b3885 default
Show More
thread_normal.html
73 lines | 2.5 KiB | text/html | HtmlLexer
{% extends "boards/thread.html" %}
{% load i18n %}
{% load static from staticfiles %}
{% load board %}
{% load tz %}
{% block thread_content %}
{% get_current_language as LANGUAGE_CODE %}
{% get_current_timezone as TIME_ZONE %}
<button id="quote-button">{% trans 'Quote' %}</button>
<div class="tag_info">
<h2>
<form action="{% url 'thread' opening_post.id %}" method="post" class="post-button-form ajax-form">
{% csrf_token %}
{% if is_favorite %}
<input type="hidden" name="method" value="unsubscribe" />
<button id="thread-fav-button" class="fav"></button>
{% else %}
<input type="hidden" name="method" value="subscribe" />
<button id="thread-fav-button" class="not_fav"></button>
{% endif %}
</form>
{{ opening_post.get_title_or_text }}
</h2>
</div>
<script>
function afterForm(form, data) {
if (data.status == 'success') {
var button = form.children('button');
var newMethod;
if (data.fav == 'true') {
button.addClass('fav');
button.removeClass('not_fav');
newMethod = 'unsubscribe';
} else {
button.addClass('not_fav');
button.removeClass('fav');
newMethod = 'subscribe';
}
form.children('input[name=method]').attr('value', newMethod);
}
}
</script>
{% if bumpable and thread.has_post_limit %}
<div class="bar-bg">
<div class="bar-value" style="width:{{ bumplimit_progress }}%" id="bumplimit_progress">
</div>
<div class="bar-text">
<span id="left_to_limit">{{ posts_left }}</span> {% trans 'posts to bumplimit' %}
</div>
</div>
{% endif %}
<div class="thread">
{% for post in thread.get_viewable_replies %}
{% post_view post reply_link=True thread=thread %}
{% endfor %}
</div>
{% if not thread.is_archived %}
{% form_view form=form new_thread=False opening_post_id=opening_post.id %}
<script src="{% static 'js/thread.js' %}"></script>
<script src="{% static 'js/thread_update.js' %}"></script>
{% endif %}
<script src="{% static 'js/3party/centrifuge.js' %}"></script>
{% endblock %}