Skip to content

Commit 2c30747

Browse files
authored
Merge pull request #1403 from chris34/summary-details
Use HTML `<summary>` and `<details>` instead of own JS collapse
2 parents c031e2d + fa985ad commit 2c30747

File tree

5 files changed

+13
-37
lines changed

5 files changed

+13
-37
lines changed

inyoka/forum/jinja2/forum/edit.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ <h2>{% trans forum=forum.name|e %}New topic in “{{ forum }}”{% endtrans %}</
9494
<dd class="license_note">{{ storage['license_note_rendered'] }}</dd>
9595
{%- endif %}
9696
<dd style="display: none"><input type="submit" value="Absenden" name="send"></dd>
97+
9798
{%- if (isnewtopic or isfirstpost) and can_create_poll %}
98-
<dt class="collapse{% if poll_form.errors %} has_errors{% endif %}">Umfragen:</dt>
99+
<details {% if poll_form.errors or polls %}open{% endif %}>
100+
<summary>{% trans %}Polls{% endtrans %}</summary>
99101
{%- if polls %}
100102
<dd>{% trans %}Existing polls:{% endtrans %}
101103
<ul>
@@ -120,9 +122,12 @@ <h2>{% trans forum=forum.name|e %}New topic in “{{ forum }}”{% endtrans %}</
120122
<dd>{% trans duration=poll_form.duration %}Duration of the poll: {{ duration }} days{% endtrans %} {{ poll_form.duration.errors }}</dd>
121123
<dd class="note">{% trans %}Leave that feel empty for an endless duration{% endtrans %}</dd>
122124
<dd><input type="submit" name="add_poll" value="{% trans %}Add poll{% endtrans %}"></dd>
125+
</details>
123126
{%- endif %}
127+
124128
{%- if can_attach %}
125-
<dt class="collapse{% if attach_form.errors %} has_errors{% endif %}">{% trans %}Attachments:{% endtrans %}</dt>
129+
<details {% if attach_form.errors or attachments %}open{% endif %}>
130+
<summary>{% trans %}Attachments{% endtrans %}</summary>
126131
<dd>
127132
{%- if attachments %}
128133
<ul>
@@ -144,9 +149,10 @@ <h2>{% trans forum=forum.name|e %}New topic in “{{ forum }}”{% endtrans %}</
144149
Overwrite existing attachment with the same name.{%- endtrans %}</label></p>
145150
<p><input type="submit" value="{% trans %}upload attachment{% endtrans %}" name="attach"></p>
146151
</dd>
152+
</details>
147153
{%- endif %}
154+
148155
{%- if can_sticky and (isnewtopic or isfirstpost) %}
149-
<dt>Optionen:</dt>
150156
<dd>{{ form.sticky }} <label for="id_sticky">{% trans %}Mark topic as “Important:”{% endtrans %}</label></dd>
151157
{%- endif %}
152158
</dl>

inyoka/static/img/collapsed.png

-138 Bytes
Binary file not shown.

inyoka/static/img/expanded.png

-126 Bytes
Binary file not shown.

inyoka/static/js/forum.js

+1-19
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,7 @@
88
* :license: BSD, see LICENSE for more details.
99
*/
1010

11-
$(function () { /* collapsable elements for the input forms */
12-
$('dt.collapse').each(function () {
13-
$(this).nextWhile('dd').addClass('collapse_enabled').toggle($(this).hasClass('has_errors'));
14-
$(this).click(function () {
15-
$(this).toggleClass('collapsed').nextWhile('dd').toggle();
16-
}).addClass('collapse_enabled collapsed');
17-
});
18-
19-
/* poll helpers */
20-
(function () {
21-
$('#id_add_option').click(function addReply() {
22-
count = $('.newtopic_polls_replies').length;
23-
$($('.newtopic_polls_replies')[count - 1]).after('<dd class="newtopic_polls_replies collapse_enabled">Antwort ' + (count + 1) + ': <input type="text" name="options" value="" /></dd>');
24-
$('#id_add_option').remove();
25-
$($('.newtopic_polls_replies')[count]).append(' <input type="submit" name="add_option" value="Weitere Antwort" ' + 'id="id_add_option" />');
26-
$('#id_add_option').click(addReply);
27-
return false;
28-
});
29-
})();
11+
$(function () {
3012

3113
/* expand and collapse button for categories */
3214
(function () {

inyoka/static/style/forum.less

+3-15
Original file line numberDiff line numberDiff line change
@@ -471,22 +471,10 @@ form.post_editor {
471471
height: 250px;
472472
}
473473
}
474-
dt.collapse_enabled {
474+
475+
summary {
475476
cursor: pointer;
476-
padding-left: 20px;
477-
background: #eee url(../img/expanded.png) no-repeat 4px center;
478-
border: 1px solid #ccc;
479-
}
480-
dt.collapse_enabled:hover {
481-
background-color: #f2f2f2;
482-
}
483-
dt.collapsed {
484-
background: white url(../img/collapsed.png) no-repeat 0 center;
485-
border: 1px solid white;
486-
}
487-
dd.collapse_enabled {
488-
margin: 0;
489-
padding: 5px 10px 10px 10px;
477+
font-weight: bold;
490478
}
491479
}
492480

0 commit comments

Comments
 (0)