diff --git a/django/contrib/admin/static/admin/js/cancel.js b/django/contrib/admin/static/admin/js/cancel.js
index 8809ee773f..fdf7495970 100644
--- a/django/contrib/admin/static/admin/js/cancel.js
+++ b/django/contrib/admin/static/admin/js/cancel.js
@@ -1,13 +1,29 @@
-(function($) {
+(function() {
'use strict';
- $(function() {
- $('.cancel-link').on('click', function(e) {
- e.preventDefault();
+
+ // Call function fn when the DOM is loaded and ready. If it is already
+ // loaded, call the function now.
+ // http://youmightnotneedjquery.com/#ready
+ function ready(fn) {
+ if (document.readyState !== 'loading') {
+ fn();
+ } else {
+ document.addEventListener('DOMContentLoaded', fn);
+ }
+ }
+
+ ready(function() {
+ function handleClick(event) {
+ event.preventDefault();
if (window.location.search.indexOf('&_popup=1') === -1) {
window.history.back(); // Go back if not a popup.
} else {
window.close(); // Otherwise, close the popup.
}
+ }
+
+ document.querySelectorAll('.cancel-link').forEach(function(el) {
+ el.addEventListener('click', handleClick);
});
});
-})(django.jQuery);
+})();
diff --git a/django/contrib/admin/templates/admin/delete_confirmation.html b/django/contrib/admin/templates/admin/delete_confirmation.html
index bfece58ada..d4c9b295a1 100644
--- a/django/contrib/admin/templates/admin/delete_confirmation.html
+++ b/django/contrib/admin/templates/admin/delete_confirmation.html
@@ -4,7 +4,7 @@
{% block extrahead %}
{{ block.super }}
{{ media }}
-
+
{% endblock %}
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation{% endblock %}
diff --git a/django/contrib/admin/templates/admin/delete_selected_confirmation.html b/django/contrib/admin/templates/admin/delete_selected_confirmation.html
index 346d280738..a49b6adeeb 100644
--- a/django/contrib/admin/templates/admin/delete_selected_confirmation.html
+++ b/django/contrib/admin/templates/admin/delete_selected_confirmation.html
@@ -4,7 +4,7 @@
{% block extrahead %}
{{ block.super }}
{{ media }}
-
+
{% endblock %}
{% block bodyclass %}{{ block.super }} app-{{ opts.app_label }} model-{{ opts.model_name }} delete-confirmation delete-selected-confirmation{% endblock %}