]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
views: Move js code to separate file
authorRaxel Gutierrez <raxel@google.com>
Mon, 23 Aug 2021 18:28:30 +0000 (18:28 +0000)
committerStephen Finucane <stephen@that.guru>
Fri, 1 Nov 2024 15:47:20 +0000 (15:47 +0000)
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]

htdocs/README.rst
htdocs/js/patch-list.js [new file with mode: 0644]
patchwork/templates/patchwork/partials/patch-list.html

index 22fe58d1f38869cf69de42b9f3c1d73f409b0c4b..9a5211233a62560d46066779235df88fa613fc43 100644 (file)
@@ -122,6 +122,12 @@ js
   :GitHub: https://github.com/js-cookie/js-cookie/
   :Version: 3.0.0
 
+``patch-list.js.``
+  Event helpers and other application logic for patch-list.html. These
+  support patch list manipulation.
+
+  Part of Patchwork.
+
 ``rest.js.``
   Utility module for REST API requests to be used by other Patchwork JS files.
 
diff --git a/htdocs/js/patch-list.js b/htdocs/js/patch-list.js
new file mode 100644 (file)
index 0000000..6be031a
--- /dev/null
@@ -0,0 +1,14 @@
+$( document ).ready(function() {
+    $("#patch-list").stickyTableHeaders();
+
+    $("#patch-list").checkboxes("range", true);
+
+    $("#check-all").change(function(e) {
+        if(this.checked) {
+            $("#patch-list > tbody").checkboxes("check");
+        } else {
+            $("#patch-list > tbody").checkboxes("uncheck");
+        }
+        e.preventDefault();
+    });
+});
index 48b81f3d5cbd460c718318c07f2a431363cc1153..1bdef36d23b03747a374befc91467efdccd27f87 100644 (file)
@@ -4,6 +4,10 @@
 {% load project %}
 {% load static %}
 
+{% block headers %}
+  <script src="{% static "js/patch-list.js" %}"></script>
+{% endblock %}
+
 {% include "patchwork/partials/filters.html" %}
 {% include "patchwork/partials/pagination.html" %}
 
 </div>
 {% endif %}
 
-<script type="text/javascript">
-$(document).ready(function() {
-    $('#patch-list').stickyTableHeaders();
-
-    $('#patch-list').checkboxes('range', true);
-
-    $('#check-all').change(function(e) {
-        if(this.checked) {
-            $('#patch-list > tbody').checkboxes('check');
-        } else {
-            $('#patch-list > tbody').checkboxes('uncheck');
-        }
-        e.preventDefault();
-    });
-});
-</script>
-
 <form method="post">
   {% csrf_token %}
   <input type="hidden" name="form" value="patch-list-form"/>