[damned-lies] Removed onclick javascript syntax
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Removed onclick javascript syntax
- Date: Sat, 17 Apr 2021 14:03:00 +0000 (UTC)
commit 00b0ee3e4230b037bd20e38797b0b952ce194c9d
Author: Claude Paroz <claude 2xlibre net>
Date: Sat Apr 17 16:02:41 2021 +0200
Removed onclick javascript syntax
common/static/js/main.js | 15 +++++++++++++++
templates/base.html | 8 --------
templates/people/person_team_membership.html | 4 ++--
3 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/common/static/js/main.js b/common/static/js/main.js
index ab43bf97..8aeb8955 100644
--- a/common/static/js/main.js
+++ b/common/static/js/main.js
@@ -29,3 +29,18 @@ dl = (function($, undefined){
$('#hide-completed-modules').click(hide);
});
})($);
+
+// ***
+// Attach event handlers
+// ***
+$(document).ready(function () {
+ $(document).on('hidden.bs.modal', (ev) => {
+ $(ev.target).removeData('bs.modal');
+ });
+ $('button.confirm').click((ev) => {
+ if (!confirm(ev.target.dataset.confirm)) {
+ ev.preventDefault();
+ return false;
+ }
+ });
+});
diff --git a/templates/base.html b/templates/base.html
index 9eb975cf..391b0390 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -17,14 +17,6 @@
<script src="{% static 'js/modal.js' %}"></script>
<script src="{% static 'js/login.js' %}"></script>
- <script>
- $(document).ready(function () {
- $(document).on('hidden.bs.modal', function (e) {
- $(e.target).removeData('bs.modal');
- });
- });
- </script>
-
{% block extrahead %}{% endblock %}
</head>
diff --git a/templates/people/person_team_membership.html b/templates/people/person_team_membership.html
index b9c82fa0..9a50c436 100644
--- a/templates/people/person_team_membership.html
+++ b/templates/people/person_team_membership.html
@@ -10,8 +10,8 @@
{% if on_own_page %}
<form class="inline" method="post" action="{% url 'person_team_leave' role.team.name %}">
{% csrf_token %}
- <input type="submit" value="{% trans 'Leave' %}"
- onClick="javascript:return confirm('{% trans "Are you sure you want to leave the team?"
%}')">
+ <button type="submit" class="confirm"
+ data-confirm="{% trans 'Are you sure you want to leave the team?' %}">{% trans 'Leave'
%}</button>
</form>
{% endif %}
</li>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]