From efc144aba064510abc0fdd25ec3deaa3e6f27427 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Fri, 17 Jul 2015 12:00:39 -0400 Subject: [PATCH] Fixed JavaScript "space-infix-ops" violations. --- .eslintrc | 5 +--- .../admin/static/admin/js/SelectBox.js | 2 +- .../admin/static/admin/js/SelectFilter2.js | 2 +- .../admin/js/admin/DateTimeShortcuts.js | 16 ++++++------ .../contrib/admin/static/admin/js/calendar.js | 26 +++++++++---------- .../contrib/admin/static/admin/js/collapse.js | 2 +- django/contrib/admin/static/admin/js/core.js | 8 +++--- .../contrib/admin/static/admin/js/inlines.js | 21 +++++++-------- .../contrib/admin/static/admin/js/urlify.js | 2 +- .../contrib/gis/static/gis/js/OLMapWidget.js | 24 ++++++++--------- 10 files changed, 52 insertions(+), 56 deletions(-) diff --git a/.eslintrc b/.eslintrc index 70a401366b..59b66f6a24 100644 --- a/.eslintrc +++ b/.eslintrc @@ -36,10 +36,7 @@ ], "space-before-blocks": [2, "always"], "space-before-function-paren": [2, {"anonymous": "never", "named": "never"}], - "space-infix-ops": [ - 1, - {"int32Hint": false} - ], + "space-infix-ops": [2, {"int32Hint": false}], "strict": [1, "function"] }, "env": { diff --git a/django/contrib/admin/static/admin/js/SelectBox.js b/django/contrib/admin/static/admin/js/SelectBox.js index e859b182b8..be97864984 100644 --- a/django/contrib/admin/static/admin/js/SelectBox.js +++ b/django/contrib/admin/static/admin/js/SelectBox.js @@ -49,7 +49,7 @@ var SelectBox = { } var j = SelectBox.cache[id].length - 1; for (i = delete_index; i < j; i++) { - SelectBox.cache[id][i] = SelectBox.cache[id][i+1]; + SelectBox.cache[id][i] = SelectBox.cache[id][i + 1]; } SelectBox.cache[id].length--; }, diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js index f8aba12fd6..616ec9bb5f 100644 --- a/django/contrib/admin/static/admin/js/SelectFilter2.js +++ b/django/contrib/admin/static/admin/js/SelectFilter2.js @@ -24,7 +24,7 @@ Requires core.js, SelectBox.js and addevent.js. from_box.className = 'filtered'; var ps = from_box.parentNode.getElementsByTagName('p'); - for (var i=0; i, because it just gets in the way. from_box.parentNode.removeChild(ps[i]); diff --git a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js index 648b33b3ef..a0e750de82 100644 --- a/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js +++ b/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js @@ -25,7 +25,7 @@ var DateTimeShortcuts = { } var inputs = document.getElementsByTagName('input'); - for (var i=0; i', 'href', 'javascript:DateTimeShortcuts.drawNext('+num+');'); + var cal_nav_next = quickElement('a', cal_nav, '>', 'href', 'javascript:DateTimeShortcuts.drawNext(' + num + ');'); cal_nav_next.className = 'calendarnav-next'; // main box @@ -285,8 +285,8 @@ var DateTimeShortcuts = { }); }, openCalendar: function(num) { - var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1+num); - var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName+num); + var cal_box = document.getElementById(DateTimeShortcuts.calendarDivName1 + num); + var cal_link = document.getElementById(DateTimeShortcuts.calendarLinkName + num); var inp = DateTimeShortcuts.calendarInputs[num]; // Determine if the current value in the input has a valid date. @@ -320,7 +320,7 @@ var DateTimeShortcuts = { addEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]); }, dismissCalendar: function(num) { - document.getElementById(DateTimeShortcuts.calendarDivName1+num).style.display = 'none'; + document.getElementById(DateTimeShortcuts.calendarDivName1 + num).style.display = 'none'; removeEvent(document, 'click', DateTimeShortcuts.dismissCalendarFunc[num]); }, drawPrev: function(num) { diff --git a/django/contrib/admin/static/admin/js/calendar.js b/django/contrib/admin/static/admin/js/calendar.js index 4eb28af461..bc64634bad 100644 --- a/django/contrib/admin/static/admin/js/calendar.js +++ b/django/contrib/admin/static/admin/js/calendar.js @@ -10,17 +10,17 @@ var CalendarNamespace = { daysOfWeek: gettext('S M T W T F S').split(' '), firstDayOfWeek: parseInt(get_format('FIRST_DAY_OF_WEEK')), isLeapYear: function(year) { - return (((year % 4)===0) && ((year % 100)!==0) || ((year % 400)===0)); + return (((year % 4) === 0) && ((year % 100) !== 0 ) || ((year % 400) === 0)); }, getDaysInMonth: function(month, year) { var days; - if (month===1 || month===3 || month===5 || month===7 || month===8 || month===10 || month===12) { + if (month === 1 || month === 3 || month === 5 || month === 7 || month === 8 || month === 10 || month === 12) { days = 31; } - else if (month===4 || month===6 || month===9 || month===11) { + else if (month === 4 || month === 6 || month === 9 || month === 11) { days = 30; } - else if (month===2 && CalendarNamespace.isLeapYear(year)) { + else if (month === 2 && CalendarNamespace.isLeapYear(year)) { days = 29; } else { @@ -31,7 +31,7 @@ var CalendarNamespace = { draw: function(month, year, div_id, callback, selected) { // month = 1-12, year = 1-9999 var today = new Date(); var todayDay = today.getDate(); - var todayMonth = today.getMonth()+1; + var todayMonth = today.getMonth() + 1; var todayYear = today.getFullYear(); var todayClass = ''; @@ -48,7 +48,7 @@ var CalendarNamespace = { // zone. var isSelectedMonth = false; if (typeof selected !== 'undefined') { - isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth()+1) === month); + isSelectedMonth = (selected.getUTCFullYear() === year && (selected.getUTCMonth() + 1) === month); } month = parseInt(month); @@ -56,7 +56,7 @@ var CalendarNamespace = { var calDiv = document.getElementById(div_id); removeChildren(calDiv); var calTable = document.createElement('table'); - quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month-1] + ' ' + year); + quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month - 1] + ' ' + year); var tableBody = quickElement('tbody', calTable); // Draw days-of-week header @@ -65,7 +65,7 @@ var CalendarNamespace = { quickElement('th', tableRow, CalendarNamespace.daysOfWeek[(i + CalendarNamespace.firstDayOfWeek) % 7]); } - var startingPos = new Date(year, month-1, 1 - CalendarNamespace.firstDayOfWeek).getDay(); + var startingPos = new Date(year, month - 1, 1 - CalendarNamespace.firstDayOfWeek).getDay(); var days = CalendarNamespace.getDaysInMonth(month, year); var _cell; @@ -80,13 +80,13 @@ var CalendarNamespace = { // Draw days of month var currentDay = 1; for (i = startingPos; currentDay <= days; i++) { - if (i%7 === 0 && currentDay !== 1) { + if (i % 7 === 0 && currentDay !== 1) { tableRow = quickElement('tr', tableBody); } - if ((currentDay===todayDay) && (month===todayMonth) && (year===todayYear)) { - todayClass='today'; + if ((currentDay === todayDay) && (month === todayMonth) && (year === todayYear)) { + todayClass = 'today'; } else { - todayClass=''; + todayClass = ''; } // use UTC function; see above for explanation. @@ -99,7 +99,7 @@ var CalendarNamespace = { var cell = quickElement('td', tableRow, '', 'class', todayClass); - quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));'); + quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '(' + year + ',' + month + ',' + currentDay + '));'); currentDay++; } diff --git a/django/contrib/admin/static/admin/js/collapse.js b/django/contrib/admin/static/admin/js/collapse.js index b11fcd68f3..4a018cf614 100644 --- a/django/contrib/admin/static/admin/js/collapse.js +++ b/django/contrib/admin/static/admin/js/collapse.js @@ -6,7 +6,7 @@ // Don't hide if fields in this fieldset have errors if ($(elem).find("div.errors").length === 0) { $(elem).addClass("collapsed").find("h2").first().append(' (' + gettext("Show") + + i + '" class="collapse-toggle" href="#">' + gettext("Show") + ')'); } }); diff --git a/django/contrib/admin/static/admin/js/core.js b/django/contrib/admin/static/admin/js/core.js index d1e2e5831c..3df0a8a807 100644 --- a/django/contrib/admin/static/admin/js/core.js +++ b/django/contrib/admin/static/admin/js/core.js @@ -1,7 +1,7 @@ // Core javascript helper functions // basic browser identification & version -var isOpera = (navigator.userAgent.indexOf("Opera")>=0) && parseFloat(navigator.appVersion); +var isOpera = (navigator.userAgent.indexOf("Opera") >= 0) && parseFloat(navigator.appVersion); var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]); // Cross-browser event handlers. @@ -48,7 +48,7 @@ function quickElement() { } var len = arguments.length; for (var i = 3; i < len; i += 2) { - obj.setAttribute(arguments[i], arguments[i+1]); + obj.setAttribute(arguments[i], arguments[i + 1]); } arguments[1].appendChild(obj); return obj; @@ -132,12 +132,12 @@ Date.prototype.getTwelveHours = function() { return 12; } else { - return hours <= 12 ? hours : hours-12; + return hours <= 12 ? hours : hours - 12; } }; Date.prototype.getTwoDigitMonth = function() { - return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1); + return (this.getMonth() < 9) ? '0' + (this.getMonth() + 1) : (this.getMonth() + 1); }; Date.prototype.getTwoDigitDate = function() { diff --git a/django/contrib/admin/static/admin/js/inlines.js b/django/contrib/admin/static/admin/js/inlines.js index e977fc9fa5..dd8a446349 100644 --- a/django/contrib/admin/static/admin/js/inlines.js +++ b/django/contrib/admin/static/admin/js/inlines.js @@ -38,7 +38,7 @@ var maxForms = $("#id_" + options.prefix + "-MAX_NUM_FORMS").prop("autocomplete", "off"); // only show the add button if we are allowed to add more items, // note that max_num = None translates to a blank string. - var showAddButton = maxForms.val() === '' || (maxForms.val()-totalForms.val()) > 0; + var showAddButton = maxForms.val() === '' || (maxForms.val() - totalForms.val()) > 0; $this.each(function(i) { $(this).not("." + options.emptyCssClass).addClass(options.formCssClass); }); @@ -66,11 +66,11 @@ if (row.is("tr")) { // If the forms are laid out in table rows, insert // the remove button into the last table cell: - row.children(":last").append('
' + options.deleteText + "
"); + row.children(":last").append('
' + options.deleteText + "
"); } else if (row.is("ul") || row.is("ol")) { // If they're laid out as an ordered/unordered list, // insert an
  • after the last list item: - row.append('
  • ' + options.deleteText + "
  • "); + row.append('
  • ' + options.deleteText + "
  • "); } else { // Otherwise, just insert the remove button as the // last child element of the form's container: @@ -85,7 +85,7 @@ $(totalForms).val(parseInt(totalForms.val(), 10) + 1); nextIndex += 1; // Hide add button in case we've hit the max, except we want to add infinitely - if ((maxForms.val() !== '') && (maxForms.val()-totalForms.val()) <= 0) { + if ((maxForms.val() !== '') && (maxForms.val() - totalForms.val()) <= 0) { addButton.parent().hide(); } // The delete button of each row triggers a bunch of other things @@ -103,7 +103,7 @@ var forms = $("." + options.formCssClass); $("#id_" + options.prefix + "-TOTAL_FORMS").val(forms.length); // Show add button again once we drop below max - if ((maxForms.val() === '') || (maxForms.val()-forms.length) > 0) { + if ((maxForms.val() === '') || (maxForms.val() - forms.length) > 0) { addButton.parent().show(); } // Also, update names and ids for all remaining form controls @@ -112,8 +112,7 @@ var updateElementCallback = function() { updateElementIndex(this, options.prefix, i); }; - for (i=0, formCount=forms.length; i0) { + for (var i = 0, len = collection.length; i < len; ++i) { + if (i > 0) { pieces.push(','); } pieces.push(this.extractGeometry(collection[i])); @@ -220,7 +220,7 @@ var feat = OpenLayers.Util.properFeatures(this.read_wkt(wkt), this.options.geom_type); this.write_wkt(feat); if (this.options.is_collection) { - for (var i=0; i