Skip to content

Commit

Permalink
Refs #31493 -- Changed IIFE to ES6 blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdufresne authored and carltongibson committed Apr 29, 2020
1 parent 5d37cc7 commit 7271c8d
Show file tree
Hide file tree
Showing 32 changed files with 77 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions django/contrib/admin/static/admin/js/SelectBox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function() {
'use strict';
'use strict';
{
const SelectBox = {
cache: {},
init: function(id) {
Expand Down Expand Up @@ -127,4 +127,4 @@
}
};
window.SelectBox = SelectBox;
})();
}
6 changes: 3 additions & 3 deletions django/contrib/admin/static/admin/js/SelectFilter2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__/)) {
Expand Down Expand Up @@ -234,4 +234,4 @@ Requires core.js and SelectBox.js.
SelectFilter.init(el.id, data.fieldName, parseInt(data.isStacked, 10));
});
});
})();
}
7 changes: 4 additions & 3 deletions django/contrib/admin/static/admin/js/actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*global gettext, interpolate, ngettext*/
(function($) {
'use strict';
'use strict';
{
const $ = django.jQuery;
let lastChecked;

$.fn.actions = function(opts) {
Expand Down Expand Up @@ -150,4 +151,4 @@
$actionsEls.actions();
}
});
})(django.jQuery);
}
14 changes: 7 additions & 7 deletions django/contrib/admin/static/admin/js/actions.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Inserts shortcut buttons after all of the following:
// <input type="text" class="vDateField">
// <input type="text" class="vTimeField">
(function() {
'use strict';
'use strict';
{
const DateTimeShortcuts = {
calendars: [],
calendarInputs: [],
Expand Down Expand Up @@ -416,4 +416,4 @@

window.addEventListener('load', DateTimeShortcuts.init);
window.DateTimeShortcuts = DateTimeShortcuts;
})();
}
Original file line number Diff line number Diff line change
@@ -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, '');
Expand Down Expand Up @@ -156,5 +156,4 @@
}
});
});

})(django.jQuery);
}
7 changes: 4 additions & 3 deletions django/contrib/admin/static/admin/js/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(function($) {
'use strict';
'use strict';
{
const $ = django.jQuery;
const init = function($element, options) {
const settings = $.extend({
ajax: {
Expand Down Expand Up @@ -34,4 +35,4 @@
return $newFormset.find('.admin-autocomplete').djangoAdminSelect2();
};
})(this));
}(django.jQuery));
}
7 changes: 3 additions & 4 deletions django/contrib/admin/static/admin/js/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down Expand Up @@ -205,4 +204,4 @@ depends on core.js for utility functions like removeChildren or quickElement
};
window.Calendar = Calendar;
window.CalendarNamespace = CalendarNamespace;
})();
}
7 changes: 3 additions & 4 deletions django/contrib/admin/static/admin/js/cancel.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -26,4 +25,4 @@
el.addEventListener('click', handleClick);
});
});
})();
}
6 changes: 3 additions & 3 deletions django/contrib/admin/static/admin/js/change_form.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -14,4 +14,4 @@
}
}
}
})();
}
6 changes: 3 additions & 3 deletions django/contrib/admin/static/admin/js/collapse.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -42,4 +42,4 @@
inlineDivs[i].addEventListener('click', toggleFunc);
}
});
})();
}
4 changes: 2 additions & 2 deletions django/contrib/admin/static/admin/js/collapse.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions django/contrib/admin/static/admin/js/core.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Core javascript helper functions
'use strict';

// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
function quickElement() {
'use strict';
const obj = document.createElement(arguments[0]);
if (arguments[2]) {
const textNode = document.createTextNode(arguments[2]);
Expand All @@ -18,7 +18,6 @@ function quickElement() {

// "a" is reference to an object
function removeChildren(a) {
'use strict';
while (a.hasChildNodes()) {
a.removeChild(a.lastChild);
}
Expand All @@ -29,7 +28,6 @@ function removeChildren(a) {
// See https://www.quirksmode.org/js/findpos.html
// ----------------------------------------------------------------------------
function findPosX(obj) {
'use strict';
let curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
Expand All @@ -43,7 +41,6 @@ function findPosX(obj) {
}

function findPosY(obj) {
'use strict';
let curtop = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
Expand All @@ -59,8 +56,7 @@ function findPosY(obj) {
//-----------------------------------------------------------------------------
// Date object extensions
// ----------------------------------------------------------------------------
(function() {
'use strict';
{
Date.prototype.getTwelveHours = function() {
return this.getHours() % 12 || 12;
};
Expand Down Expand Up @@ -164,5 +160,4 @@ function findPosY(obj) {
// date extraction.
return new Date(Date.UTC(year, month, day));
};

})();
}
7 changes: 4 additions & 3 deletions django/contrib/admin/static/admin/js/inlines.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
* Licensed under the New BSD License
* See: https://opensource.org/licenses/bsd-license.php
*/
(function($) {
'use strict';
'use strict';
{
const $ = django.jQuery;
$.fn.formset = function(opts) {
const options = $.extend({}, $.fn.formset.defaults, opts);
const $this = $(this);
Expand Down Expand Up @@ -344,4 +345,4 @@
}
});
});
})(django.jQuery);
}
Loading

0 comments on commit 7271c8d

Please sign in to comment.