Skip to content

Commit 0cea2e4

Browse files
Raxel Gutierrezstephenfin
authored andcommitted
views: Move js code to separate file
Move patch-list related JS code to a new patch-list.js file, to make the JavaScript easy to read and change in one place. This makes automatic code formatting easier, makes it more straightforward to measure test coverage and discover opportunities for refactoring, and simplifies a possible future migration to TypeScript if the project chooses to go in that direction. No user-visible change should be noticed. Signed-off-by: Raxel Gutierrez <raxel@google.com> Signed-off-by: Stephen Finucane <stephen@that.guru> [stephenfin: Addressed merged conflicts]
1 parent 09613eb commit 0cea2e4

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

htdocs/README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ js
122122
:GitHub: https://github.com/js-cookie/js-cookie/
123123
:Version: 3.0.0
124124

125+
``patch-list.js.``
126+
Event helpers and other application logic for patch-list.html. These
127+
support patch list manipulation.
128+
129+
Part of Patchwork.
130+
125131
``rest.js.``
126132
Utility module for REST API requests to be used by other Patchwork JS files.
127133

htdocs/js/patch-list.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$( document ).ready(function() {
2+
$("#patch-list").stickyTableHeaders();
3+
4+
$("#patch-list").checkboxes("range", true);
5+
6+
$("#check-all").change(function(e) {
7+
if(this.checked) {
8+
$("#patch-list > tbody").checkboxes("check");
9+
} else {
10+
$("#patch-list > tbody").checkboxes("uncheck");
11+
}
12+
e.preventDefault();
13+
});
14+
});

patchwork/templates/patchwork/partials/patch-list.html

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
{% load project %}
55
{% load static %}
66

7+
{% block headers %}
8+
<script src="{% static "js/patch-list.js" %}"></script>
9+
{% endblock %}
10+
711
{% include "patchwork/partials/filters.html" %}
812
{% include "patchwork/partials/pagination.html" %}
913

@@ -32,23 +36,6 @@
3236
</div>
3337
{% endif %}
3438

35-
<script type="text/javascript">
36-
$(document).ready(function() {
37-
$('#patch-list').stickyTableHeaders();
38-
39-
$('#patch-list').checkboxes('range', true);
40-
41-
$('#check-all').change(function(e) {
42-
if(this.checked) {
43-
$('#patch-list > tbody').checkboxes('check');
44-
} else {
45-
$('#patch-list > tbody').checkboxes('uncheck');
46-
}
47-
e.preventDefault();
48-
});
49-
});
50-
</script>
51-
5239
<form method="post">
5340
{% csrf_token %}
5441
<input type="hidden" name="form" value="patch-list-form"/>

0 commit comments

Comments
 (0)