Fixed JavaScript "strict" violations.

This commit is contained in:
Tim Graham 2015-07-20 19:35:17 -04:00
parent 3c0770f23d
commit fbb4f0797c
13 changed files with 1118 additions and 1062 deletions

View File

@ -1,4 +1,6 @@
/*eslint no-cond-assign:1*/ /*eslint no-cond-assign:1*/
(function() {
'use strict';
var SelectBox = { var SelectBox = {
cache: {}, cache: {},
init: function(id) { init: function(id) {
@ -115,3 +117,5 @@ var SelectBox = {
} }
} }
}; };
window.SelectBox = SelectBox;
})();

View File

@ -5,6 +5,7 @@ SelectFilter2 - Turns a multiple-select box into a filter interface.
Requires core.js, SelectBox.js and addevent.js. Requires core.js, SelectBox.js and addevent.js.
*/ */
(function($) { (function($) {
'use strict';
function findForm(node) { function findForm(node) {
// returns the node of the form containing the given node // returns the node of the form containing the given node
if (node.tagName.toLowerCase() !== 'form') { if (node.tagName.toLowerCase() !== 'form') {

View File

@ -1,5 +1,6 @@
/*global _actions_icnt, gettext, interpolate, ngettext*/ /*global _actions_icnt, gettext, interpolate, ngettext*/
(function($) { (function($) {
'use strict';
var lastChecked; var lastChecked;
$.fn.actions = function(opts) { $.fn.actions = function(opts) {

View File

@ -2,7 +2,8 @@
// Inserts shortcut buttons after all of the following: // Inserts shortcut buttons after all of the following:
// <input type="text" class="vDateField"> // <input type="text" class="vDateField">
// <input type="text" class="vTimeField"> // <input type="text" class="vTimeField">
(function() {
'use strict';
var DateTimeShortcuts = { var DateTimeShortcuts = {
calendars: [], calendars: [],
calendarInputs: [], calendarInputs: [],
@ -359,3 +360,5 @@ var DateTimeShortcuts = {
}; };
addEvent(window, 'load', DateTimeShortcuts.init); addEvent(window, 'load', DateTimeShortcuts.init);
window.DateTimeShortcuts = DateTimeShortcuts;
})();

View File

@ -2,6 +2,9 @@
// Handles related-objects functionality: lookup link for raw_id_fields // Handles related-objects functionality: lookup link for raw_id_fields
// and Add Another links. // and Add Another links.
(function() {
'use strict';
function html_unescape(text) { function html_unescape(text) {
// Unescape a string that was escaped using django.utils.html.escape. // Unescape a string that was escaped using django.utils.html.escape.
text = text.replace(/&lt;/g, '<'); text = text.replace(/&lt;/g, '<');
@ -137,6 +140,21 @@ function dismissDeleteRelatedObjectPopup(win, objId) {
win.close(); win.close();
} }
// Global for testing purposes
window.html_unescape = html_unescape;
window.id_to_windowname = id_to_windowname;
window.windowname_to_id = windowname_to_id;
window.showRelatedObjectLookupPopup = showRelatedObjectLookupPopup;
window.dismissRelatedLookupPopup = dismissRelatedLookupPopup;
window.showRelatedObjectPopup = showRelatedObjectPopup;
window.updateRelatedObjectLinks = updateRelatedObjectLinks;
window.dismissAddRelatedObjectPopup = dismissAddRelatedObjectPopup;
window.dismissChangeRelatedObjectPopup = dismissChangeRelatedObjectPopup;
window.dismissDeleteRelatedObjectPopup = dismissDeleteRelatedObjectPopup;
// Kept for backward compatibility // Kept for backward compatibility
var showAddAnotherPopup = showRelatedObjectPopup; window.showAddAnotherPopup = showRelatedObjectPopup;
var dismissAddAnotherPopup = dismissAddRelatedObjectPopup; window.dismissAddAnotherPopup = dismissAddRelatedObjectPopup;
})();

View File

@ -4,6 +4,8 @@ calendar.js - Calendar functions by Adrian Holovaty
depends on core.js for utility functions like removeChildren or quickElement depends on core.js for utility functions like removeChildren or quickElement
*/ */
(function() {
'use strict';
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions // CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
var CalendarNamespace = { var CalendarNamespace = {
monthsOfYear: gettext('January February March April May June July August September October November December').split(' '), monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
@ -172,3 +174,5 @@ Calendar.prototype = {
this.drawCurrent(); this.drawCurrent();
} }
}; };
window.Calendar = Calendar;
})();

View File

@ -1,5 +1,6 @@
/*global gettext*/ /*global gettext*/
(function($) { (function($) {
'use strict';
$(document).ready(function() { $(document).ready(function() {
// Add anchor tag for Show/Hide link // Add anchor tag for Show/Hide link
$("fieldset.collapse").each(function(i, elem) { $("fieldset.collapse").each(function(i, elem) {

View File

@ -6,6 +6,7 @@ var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.spl
// Cross-browser event handlers. // Cross-browser event handlers.
function addEvent(obj, evType, fn) { function addEvent(obj, evType, fn) {
'use strict';
if (obj.addEventListener) { if (obj.addEventListener) {
obj.addEventListener(evType, fn, false); obj.addEventListener(evType, fn, false);
return true; return true;
@ -18,6 +19,7 @@ function addEvent(obj, evType, fn) {
} }
function removeEvent(obj, evType, fn) { function removeEvent(obj, evType, fn) {
'use strict';
if (obj.removeEventListener) { if (obj.removeEventListener) {
obj.removeEventListener(evType, fn, false); obj.removeEventListener(evType, fn, false);
return true; return true;
@ -30,6 +32,7 @@ function removeEvent(obj, evType, fn) {
} }
function cancelEventPropagation(e) { function cancelEventPropagation(e) {
'use strict';
if (!e) { if (!e) {
e = window.event; e = window.event;
} }
@ -41,6 +44,7 @@ function cancelEventPropagation(e) {
// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]); // quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
function quickElement() { function quickElement() {
'use strict';
var obj = document.createElement(arguments[0]); var obj = document.createElement(arguments[0]);
if (arguments[2]) { if (arguments[2]) {
var textNode = document.createTextNode(arguments[2]); var textNode = document.createTextNode(arguments[2]);
@ -56,6 +60,7 @@ function quickElement() {
// "a" is reference to an object // "a" is reference to an object
function removeChildren(a) { function removeChildren(a) {
'use strict';
while (a.hasChildNodes()) { while (a.hasChildNodes()) {
a.removeChild(a.lastChild); a.removeChild(a.lastChild);
} }
@ -89,6 +94,7 @@ if (!xmlhttp && typeof XMLHttpRequest !== 'undefined') {
// See http://www.quirksmode.org/js/findpos.html // See http://www.quirksmode.org/js/findpos.html
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function findPosX(obj) { function findPosX(obj) {
'use strict';
var curleft = 0; var curleft = 0;
if (obj.offsetParent) { if (obj.offsetParent) {
while (obj.offsetParent) { while (obj.offsetParent) {
@ -106,6 +112,7 @@ function findPosX(obj) {
} }
function findPosY(obj) { function findPosY(obj) {
'use strict';
var curtop = 0; var curtop = 0;
if (obj.offsetParent) { if (obj.offsetParent) {
while (obj.offsetParent) { while (obj.offsetParent) {
@ -125,7 +132,8 @@ function findPosY(obj) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Date object extensions // Date object extensions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
(function() {
'use strict';
Date.prototype.getTwelveHours = function() { Date.prototype.getTwelveHours = function() {
var hours = this.getHours(); var hours = this.getHours();
if (hours === 0) { if (hours === 0) {
@ -235,10 +243,12 @@ String.prototype.strptime = function(format) {
return new Date(year, month, day); return new Date(year, month, day);
}; };
})();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Get the computed style for and element // Get the computed style for and element
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
function getStyle(oElm, strCssRule) { function getStyle(oElm, strCssRule) {
'use strict';
var strValue = ""; var strValue = "";
if(document.defaultView && document.defaultView.getComputedStyle) { if(document.defaultView && document.defaultView.getComputedStyle) {
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);

View File

@ -16,6 +16,7 @@
* See: http://www.opensource.org/licenses/bsd-license.php * See: http://www.opensource.org/licenses/bsd-license.php
*/ */
(function($) { (function($) {
'use strict';
$.fn.formset = function(opts) { $.fn.formset = function(opts) {
var options = $.extend({}, $.fn.formset.defaults, opts); var options = $.extend({}, $.fn.formset.defaults, opts);
var $this = $(this); var $this = $(this);

View File

@ -1,5 +1,6 @@
/*global URLify*/ /*global URLify*/
(function($) { (function($) {
'use strict';
$.fn.prepopulate = function(dependencies, maxLength, allowUnicode) { $.fn.prepopulate = function(dependencies, maxLength, allowUnicode) {
/* /*
Depends on urlify.js Depends on urlify.js

View File

@ -1,3 +1,5 @@
(function() {
'use strict';
var timeParsePatterns = [ var timeParsePatterns = [
// 9 // 9
{ {
@ -99,3 +101,6 @@ function parseTimeString(s) {
} }
return s; return s;
} }
window.parseTimeString = parseTimeString;
})();

View File

@ -1,4 +1,7 @@
/*global XRegExp*/ /*global XRegExp*/
(function() {
'use strict';
var LATIN_MAP = { var LATIN_MAP = {
'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE', 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE',
'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I',
@ -47,8 +50,8 @@ var RUSSIAN_MAP = {
'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'Yu', 'Я': 'Ya' 'Ы': 'Y', 'Ь': '', 'Э': 'E', 'Ю': 'Yu', 'Я': 'Ya'
}; };
var UKRAINIAN_MAP = { var UKRAINIAN_MAP = {
'Є': 'Ye', 'І': 'I', 'Ї': 'Yi', 'Ґ': 'G', 'є': 'ye', 'і': 'i', 'ї': 'yi', 'Є': 'Ye', 'І': 'I', 'Ї': 'Yi', 'Ґ': 'G', 'є': 'ye', 'і': 'i',
'ґ': 'g' 'ї': 'yi', 'ґ': 'g'
}; };
var CZECH_MAP = { var CZECH_MAP = {
'č': 'c', 'ď': 'd', 'ě': 'e', 'ň': 'n', 'ř': 'r', 'š': 's', 'ť': 't', 'č': 'c', 'ď': 'd', 'ě': 'e', 'ň': 'n', 'ř': 'r', 'š': 's', 'ť': 't',
@ -80,8 +83,9 @@ var LITHUANIAN_MAP = {
'Ū': 'U', 'Ž': 'Z' 'Ū': 'U', 'Ž': 'Z'
}; };
var SERBIAN_MAP = { var SERBIAN_MAP = {
'ђ': 'dj', 'ј': 'j', 'љ': 'lj', 'њ': 'nj', 'ћ': 'c', 'џ': 'dz', 'đ': 'dj', 'ђ': 'dj', 'ј': 'j', 'љ': 'lj', 'њ': 'nj', 'ћ': 'c', 'џ': 'dz',
'Ђ': 'Dj', 'Ј': 'j', 'Љ': 'Lj', 'Њ': 'Nj', 'Ћ': 'C', 'Џ': 'Dz', 'Đ': 'Dj' 'đ': 'dj', 'Ђ': 'Dj', 'Ј': 'j', 'Љ': 'Lj', 'Њ': 'Nj', 'Ћ': 'C',
'Џ': 'Dz', 'Đ': 'Dj'
}; };
var AZERBAIJANI_MAP = { var AZERBAIJANI_MAP = {
'ç': 'c', 'ə': 'e', 'ğ': 'g', 'ı': 'i', 'ö': 'o', 'ş': 's', 'ü': 'u', 'ç': 'c', 'ə': 'e', 'ğ': 'g', 'ı': 'i', 'ö': 'o', 'ş': 's', 'ü': 'u',
@ -163,3 +167,5 @@ function URLify(s, num_chars, allowUnicode) {
s = s.toLowerCase(); // convert to lowercase s = s.toLowerCase(); // convert to lowercase
return s.substring(0, num_chars);// trim to first num_chars chars return s.substring(0, num_chars);// trim to first num_chars chars
} }
window.URLify = URLify;
})();

View File

@ -1,5 +1,6 @@
/*global OpenLayers*/ /*global OpenLayers*/
(function() { (function() {
'use strict';
/** /**
* Transforms an array of features to a single feature with the merged * Transforms an array of features to a single feature with the merged
* geometry of geom_type * geometry of geom_type