mirror of https://gitlab.com/tildes/tildes.git
Browse Source
Make topic bookmark button toggle properly
Make topic bookmark button toggle properly
I'll do some more work on this later because this is still pretty ugly, but it'll do the job for now.merge-requests/69/head
Deimos
6 years ago
5 changed files with 94 additions and 41 deletions
-
14tildes/tildes/templates/intercooler/post_action_toggle_button.jinja2
-
39tildes/tildes/templates/macros/buttons.jinja2
-
30tildes/tildes/templates/macros/comments.jinja2
-
29tildes/tildes/templates/topic.jinja2
-
23tildes/tildes/views/api/web/topic.py
@ -0,0 +1,14 @@ |
|||
{# Copyright (c) 2019 Tildes contributors <code@tildes.net> #} |
|||
{# SPDX-License-Identifier: AGPL-3.0-or-later #} |
|||
|
|||
{% from 'macros/buttons.jinja2' import post_action_toggle_button with context %} |
|||
|
|||
{{ post_action_toggle_button( |
|||
subject=subject, |
|||
is_toggled=is_toggled, |
|||
normal_name=normal_name, |
|||
normal_label=normal_label, |
|||
toggled_name=toggled_name, |
|||
toggled_label=toggled_label, |
|||
route_name=route_name, |
|||
) }} |
@ -0,0 +1,39 @@ |
|||
{# Copyright (c) 2019 Tildes contributors <code@tildes.net> #} |
|||
{# SPDX-License-Identifier: AGPL-3.0-or-later #} |
|||
|
|||
{% macro post_action_toggle_button(subject, is_toggled, normal_name, normal_label, toggled_name, toggled_label, route_name) %} |
|||
{% if is_toggled %} |
|||
<li><button class="btn-post-action btn-post-action-used" name="{{ toggled_name }}" |
|||
{% if subject is comment %} |
|||
data-ic-delete-from="{{ request.route_url( |
|||
route_name, |
|||
comment_id36=subject.comment_id36, |
|||
) }}" |
|||
data-ic-target="#comment-{{ subject.comment_id36 }} .comment-itself:first" |
|||
{% elif subject is topic %} |
|||
data-ic-delete-from="{{ request.route_url( |
|||
route_name, |
|||
topic_id36=subject.topic_id36, |
|||
) }}" |
|||
{% endif %} |
|||
data-ic-replace-target="true" |
|||
>{{ toggled_label }} |
|||
{% else %} |
|||
<li><button class="btn-post-action" name="{{ normal_name }}" |
|||
{% if subject is comment %} |
|||
data-ic-put-to="{{ request.route_url( |
|||
route_name, |
|||
comment_id36=subject.comment_id36, |
|||
) }}" |
|||
data-ic-target="#comment-{{ subject.comment_id36 }} .comment-itself:first" |
|||
{% elif subject is topic %} |
|||
data-ic-put-to="{{ request.route_url( |
|||
route_name, |
|||
topic_id36=subject.topic_id36, |
|||
) }}" |
|||
{% endif %} |
|||
data-ic-replace-target="true" |
|||
>{{ normal_label }} |
|||
{% endif %} |
|||
</button></li> |
|||
{% endmacro %} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue