diff --git a/.eslintrc b/.eslintrc index 46ef3fe926..190ba5f33a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -24,7 +24,7 @@ "space-before-blocks": ["error", "always"], "space-before-function-paren": ["error", {"anonymous": "never", "named": "never"}], "space-infix-ops": ["error", {"int32Hint": false}], - "strict": ["warn", "function"] + "strict": ["error", "global"] }, "env": { "browser": true, diff --git a/django/contrib/admin/static/admin/js/SelectBox.js b/django/contrib/admin/static/admin/js/SelectBox.js index 17f5925c3a..9fd93c7a8c 100644 --- a/django/contrib/admin/static/admin/js/SelectBox.js +++ b/django/contrib/admin/static/admin/js/SelectBox.js @@ -1,5 +1,5 @@ -(function() { - 'use strict'; +'use strict'; +{ const SelectBox = { cache: {}, init: function(id) { @@ -127,4 +127,4 @@ } }; window.SelectBox = SelectBox; -})(); +} diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js index c428aba822..83ddd55a9e 100644 --- a/django/contrib/admin/static/admin/js/SelectFilter2.js +++ b/django/contrib/admin/static/admin/js/SelectFilter2.js @@ -4,8 +4,8 @@ SelectFilter2 - Turns a multiple-select box into a filter interface. Requires core.js and SelectBox.js. */ -(function() { - 'use strict'; +'use strict'; +{ window.SelectFilter = { init: function(field_id, field_name, is_stacked) { if (field_id.match(/__prefix__/)) { @@ -234,4 +234,4 @@ Requires core.js and SelectBox.js. SelectFilter.init(el.id, data.fieldName, parseInt(data.isStacked, 10)); }); }); -})(); +} diff --git a/django/contrib/admin/static/admin/js/actions.js b/django/contrib/admin/static/admin/js/actions.js index 9cad455b60..dae69920b2 100644 --- a/django/contrib/admin/static/admin/js/actions.js +++ b/django/contrib/admin/static/admin/js/actions.js @@ -1,6 +1,7 @@ /*global gettext, interpolate, ngettext*/ -(function($) { - 'use strict'; +'use strict'; +{ + const $ = django.jQuery; let lastChecked; $.fn.actions = function(opts) { @@ -150,4 +151,4 @@ $actionsEls.actions(); } }); -})(django.jQuery); +} diff --git a/django/contrib/admin/static/admin/js/actions.min.js b/django/contrib/admin/static/admin/js/actions.min.js index a5f7cd9df3..29fd0d8c2d 100644 --- a/django/contrib/admin/static/admin/js/actions.min.js +++ b/django/contrib/admin/static/admin/js/actions.min.js @@ -1,7 +1,7 @@ -(function(a){var f;a.fn.actions=function(e){var b=a.extend({},a.fn.actions.defaults,e),g=a(this),k=!1,l=function(){a(b.acrossClears).hide();a(b.acrossQuestions).show();a(b.allContainer).hide()},m=function(){a(b.acrossClears).show();a(b.acrossQuestions).hide();a(b.actionContainer).toggleClass(b.selectedClass);a(b.allContainer).show();a(b.counterContainer).hide()},n=function(){a(b.acrossClears).hide();a(b.acrossQuestions).hide();a(b.allContainer).hide();a(b.counterContainer).show()},p=function(){n(); -a(b.acrossInput).val(0);a(b.actionContainer).removeClass(b.selectedClass)},q=function(c){c?l():n();a(g).prop("checked",c).parent().parent().toggleClass(b.selectedClass,c)},h=function(){var c=a(g).filter(":checked").length,d=a(".action-counter").data("actionsIcnt");a(b.counterContainer).html(interpolate(ngettext("%(sel)s of %(cnt)s selected","%(sel)s of %(cnt)s selected",c),{sel:c,cnt:d},!0));a(b.allToggle).prop("checked",function(){if(c===g.length){var a=!0;l()}else a=!1,p();return a})};a(b.counterContainer).show(); -a(this).filter(":checked").each(function(c){a(this).parent().parent().toggleClass(b.selectedClass);h();1===a(b.acrossInput).val()&&m()});a(b.allToggle).show().on("click",function(){q(a(this).prop("checked"));h()});a("a",b.acrossQuestions).on("click",function(c){c.preventDefault();a(b.acrossInput).val(1);m()});a("a",b.acrossClears).on("click",function(c){c.preventDefault();a(b.allToggle).prop("checked",!1);p();q(0);h()});f=null;a(g).on("click",function(c){c||(c=window.event);var d=c.target?c.target: -c.srcElement;if(f&&a.data(f)!==a.data(d)&&!0===c.shiftKey){var e=!1;a(f).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked);a(g).each(function(){if(a.data(this)===a.data(f)||a.data(this)===a.data(d))e=e?!1:!0;e&&a(this).prop("checked",d.checked).parent().parent().toggleClass(b.selectedClass,d.checked)})}a(d).parent().parent().toggleClass(b.selectedClass,d.checked);f=d;h()});a("form#changelist-form table#result_list tr").on("change","td:gt(0) :input",function(){k=!0}); -a('form#changelist-form button[name="index"]').on("click",function(a){if(k)return confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."))});a('form#changelist-form input[name="_save"]').on("click",function(c){var d=!1;a("select option:selected",b.actionContainer).each(function(){a(this).val()&&(d=!0)});if(d)return k?confirm(gettext("You have selected an action, but you haven\u2019t saved your changes to individual fields yet. Please click OK to save. You\u2019ll need to re-run the action.")): -confirm(gettext("You have selected an action, and you haven\u2019t made any changes on individual fields. You\u2019re probably looking for the Go button rather than the Save button."))})};a.fn.actions.defaults={actionContainer:"div.actions",counterContainer:"span.action-counter",allContainer:"div.actions span.all",acrossInput:"div.actions input.select-across",acrossQuestions:"div.actions span.question",acrossClears:"div.actions span.clear",allToggle:"#action-toggle",selectedClass:"selected"};a(document).ready(function(){var e= -a("tr input.action-select");0 // -(function() { - 'use strict'; +'use strict'; +{ const DateTimeShortcuts = { calendars: [], calendarInputs: [], @@ -416,4 +416,4 @@ window.addEventListener('load', DateTimeShortcuts.init); window.DateTimeShortcuts = DateTimeShortcuts; -})(); +} diff --git a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js index f45cf113f6..8c95df7c12 100644 --- a/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js +++ b/django/contrib/admin/static/admin/js/admin/RelatedObjectLookups.js @@ -1,9 +1,9 @@ /*global SelectBox, interpolate*/ // Handles related-objects functionality: lookup link for raw_id_fields // and Add Another links. - -(function($) { - 'use strict'; +'use strict'; +{ + const $ = django.jQuery; function showAdminPopup(triggeringLink, name_regexp, add_popup) { const name = triggeringLink.id.replace(name_regexp, ''); @@ -156,5 +156,4 @@ } }); }); - -})(django.jQuery); +} diff --git a/django/contrib/admin/static/admin/js/autocomplete.js b/django/contrib/admin/static/admin/js/autocomplete.js index 0689d0e305..c922b303a8 100644 --- a/django/contrib/admin/static/admin/js/autocomplete.js +++ b/django/contrib/admin/static/admin/js/autocomplete.js @@ -1,5 +1,6 @@ -(function($) { - 'use strict'; +'use strict'; +{ + const $ = django.jQuery; const init = function($element, options) { const settings = $.extend({ ajax: { @@ -34,4 +35,4 @@ return $newFormset.find('.admin-autocomplete').djangoAdminSelect2(); }; })(this)); -}(django.jQuery)); +} diff --git a/django/contrib/admin/static/admin/js/calendar.js b/django/contrib/admin/static/admin/js/calendar.js index 6c71287211..64598bbb6f 100644 --- a/django/contrib/admin/static/admin/js/calendar.js +++ b/django/contrib/admin/static/admin/js/calendar.js @@ -3,9 +3,8 @@ calendar.js - Calendar functions by Adrian Holovaty depends on core.js for utility functions like removeChildren or quickElement */ - -(function() { - 'use strict'; +'use strict'; +{ // CalendarNamespace -- Provides a collection of HTML calendar-related helper functions const CalendarNamespace = { monthsOfYear: [ @@ -205,4 +204,4 @@ depends on core.js for utility functions like removeChildren or quickElement }; window.Calendar = Calendar; window.CalendarNamespace = CalendarNamespace; -})(); +} diff --git a/django/contrib/admin/static/admin/js/cancel.js b/django/contrib/admin/static/admin/js/cancel.js index fdf7495970..cfe06c279f 100644 --- a/django/contrib/admin/static/admin/js/cancel.js +++ b/django/contrib/admin/static/admin/js/cancel.js @@ -1,6 +1,5 @@ -(function() { - 'use strict'; - +'use strict'; +{ // Call function fn when the DOM is loaded and ready. If it is already // loaded, call the function now. // http://youmightnotneedjquery.com/#ready @@ -26,4 +25,4 @@ el.addEventListener('click', handleClick); }); }); -})(); +} diff --git a/django/contrib/admin/static/admin/js/change_form.js b/django/contrib/admin/static/admin/js/change_form.js index c6ca0ac11b..cb50120b1b 100644 --- a/django/contrib/admin/static/admin/js/change_form.js +++ b/django/contrib/admin/static/admin/js/change_form.js @@ -1,5 +1,5 @@ -(function() { - 'use strict'; +'use strict'; +{ const inputTags = ['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA']; const modelName = document.getElementById('django-admin-form-add-constants').dataset.modelName; if (modelName) { @@ -14,4 +14,4 @@ } } } -})(); +} diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js index 3b001b9c53..e0e2ba9f87 100644 --- a/django/contrib/admin/static/admin/js/collapse.js +++ b/django/contrib/admin/static/admin/js/collapse.js @@ -1,6 +1,6 @@ /*global gettext*/ -(function() { - 'use strict'; +'use strict'; +{ window.addEventListener('load', function() { // Add anchor tag for Show/Hide link const fieldsets = document.querySelectorAll('fieldset.collapse'); @@ -42,4 +42,4 @@ inlineDivs[i].addEventListener('click', toggleFunc); } }); -})(); +} diff --git a/django/contrib/admin/static/admin/js/collapse.min.js b/django/contrib/admin/static/admin/js/collapse.min.js index 6041c4b037..cd78b6984c 100644 --- a/django/contrib/admin/static/admin/js/collapse.min.js +++ b/django/contrib/admin/static/admin/js/collapse.min.js @@ -1,2 +1,2 @@ -'use strict';(function(){window.addEventListener("load",function(){var d=document.querySelectorAll("fieldset.collapse");for(var c=0;c=h.val()-f.val()&&k.parent().hide();p(d.closest(".inline-group"));a.added&&a.added(d);b(document).trigger("formset:added",[d,a.prefix])},r= -function(b){b.is("tr")?b.children(":last").append('
'+a.deleteText+"
"):b.is("ul")||b.is("ol")?b.append('
  • '+a.deleteText+"
  • "):b.children(":first").append(''+a.deleteText+"");b.find("a."+a.deleteCssClass).on("click",u.bind(this))},u=function(g){g.preventDefault();var d=b(g.target).closest("."+a.formCssClass);g=d.closest(".inline-group"); +'use strict';{const b=django.jQuery;b.fn.formset=function(c){const a=b.extend({},b.fn.formset.defaults,c),e=b(this),l=e.parent(),m=function(a,d,h){const g=new RegExp("("+d+"-(\\d+|__prefix__))");d=d+"-"+h;b(a).prop("for")&&b(a).prop("for",b(a).prop("for").replace(g,d));a.id&&(a.id=a.id.replace(g,d));a.name&&(a.name=a.name.replace(g,d))},f=b("#id_"+a.prefix+"-TOTAL_FORMS").prop("autocomplete","off");let n=parseInt(f.val(),10);const h=b("#id_"+a.prefix+"-MAX_NUM_FORMS").prop("autocomplete","off"),q= +b("#id_"+a.prefix+"-MIN_NUM_FORMS").prop("autocomplete","off");let k;const t=function(g){g.preventDefault();g=b("#"+a.prefix+"-empty");const d=g.clone(!0);d.removeClass(a.emptyCssClass).addClass(a.formCssClass).attr("id",a.prefix+"-"+n);r(d);d.find("*").each(function(){m(this,a.prefix,f.val())});d.insertBefore(b(g));b(f).val(parseInt(f.val(),10)+1);n+=1;""!==h.val()&&0>=h.val()-f.val()&&k.parent().hide();p(d.closest(".inline-group"));a.added&&a.added(d);b(document).trigger("formset:added",[d,a.prefix])}, +r=function(b){b.is("tr")?b.children(":last").append('
    '+a.deleteText+"
    "):b.is("ul")||b.is("ol")?b.append('
  • '+a.deleteText+"
  • "):b.children(":first").append(''+a.deleteText+"");b.find("a."+a.deleteCssClass).on("click",u.bind(this))},u=function(g){g.preventDefault();var d=b(g.target).closest("."+a.formCssClass);g=d.closest(".inline-group"); var f=d.prev();f.length&&f.hasClass("row-form-errors")&&f.remove();d.remove();--n;a.removed&&a.removed(d);b(document).trigger("formset:removed",[d,a.prefix]);d=b("."+a.formCssClass);b("#id_"+a.prefix+"-TOTAL_FORMS").val(d.length);(""===h.val()||0'+a.addText+"");k=l.find("tr:last a")}else e.filter(":last").after('"), k=e.filter(":last").next().find("a");k.on("click",t)})();c=""===h.val()||0 tr.form-row",b(c).tabularFormset(c,a.options)}})})})(django.jQuery); +b(c).stackedFormset(c,a.options);break;case "tabular":c=a.name+"-group .tabular.inline-related tbody:first > tr.form-row",b(c).tabularFormset(c,a.options)}})})}; diff --git a/django/contrib/admin/static/admin/js/jquery.init.js b/django/contrib/admin/static/admin/js/jquery.init.js index 98bbd4a277..f40b27f47d 100644 --- a/django/contrib/admin/static/admin/js/jquery.init.js +++ b/django/contrib/admin/static/admin/js/jquery.init.js @@ -1,4 +1,5 @@ /*global jQuery:false*/ +'use strict'; /* Puts the included jQuery into our own namespace using noConflict and passing * it 'true'. This ensures that the included jQuery doesn't pollute the global * namespace (i.e. this preserves pre-existing values for both window.$ and diff --git a/django/contrib/admin/static/admin/js/popup_response.js b/django/contrib/admin/static/admin/js/popup_response.js index aa46e8f7be..2b1d3dd31d 100644 --- a/django/contrib/admin/static/admin/js/popup_response.js +++ b/django/contrib/admin/static/admin/js/popup_response.js @@ -1,6 +1,6 @@ /*global opener */ -(function() { - 'use strict'; +'use strict'; +{ const initData = JSON.parse(document.getElementById('django-admin-popup-response-constants').dataset.popupResponse); switch(initData.action) { case 'change': @@ -13,4 +13,4 @@ opener.dismissAddRelatedObjectPopup(window, initData.value, initData.obj); break; } -})(); +} diff --git a/django/contrib/admin/static/admin/js/prepopulate.js b/django/contrib/admin/static/admin/js/prepopulate.js index 5189501753..89e95ab44d 100644 --- a/django/contrib/admin/static/admin/js/prepopulate.js +++ b/django/contrib/admin/static/admin/js/prepopulate.js @@ -1,6 +1,7 @@ /*global URLify*/ -(function($) { - 'use strict'; +'use strict'; +{ + const $ = django.jQuery; $.fn.prepopulate = function(dependencies, maxLength, allowUnicode) { /* Depends on urlify.js @@ -39,4 +40,4 @@ } }); }; -})(django.jQuery); +} diff --git a/django/contrib/admin/static/admin/js/prepopulate.min.js b/django/contrib/admin/static/admin/js/prepopulate.min.js index fbfe3dd325..11ead49905 100644 --- a/django/contrib/admin/static/admin/js/prepopulate.min.js +++ b/django/contrib/admin/static/admin/js/prepopulate.min.js @@ -1 +1 @@ -'use strict';(function(b){b.fn.prepopulate=function(d,f,g){return this.each(function(){const a=b(this),h=function(){if(!a.data("_changed")){var e=[];b.each(d,function(a,c){c=b(c);0