Fixed JavaScript "curly" violations.

This commit is contained in:
Tim Graham 2015-07-17 08:36:36 -04:00
parent e25ba6e8bb
commit ac6164948e
7 changed files with 41 additions and 17 deletions

View File

@ -3,7 +3,7 @@
"camelcase": [1, {"properties": "always"}], "camelcase": [1, {"properties": "always"}],
"comma-spacing": [1, {"before": false, "after": true}], "comma-spacing": [1, {"before": false, "after": true}],
"dot-notation": [1, {"allowKeywords": true}], "dot-notation": [1, {"allowKeywords": true}],
"curly": [1, "all"], "curly": [2, "all"],
"indent": [ "indent": [
2, 2,
4 4

View File

@ -95,8 +95,12 @@ var SelectBox = {
a = a.text.toLowerCase(); a = a.text.toLowerCase();
b = b.text.toLowerCase(); b = b.text.toLowerCase();
try { try {
if (a > b) return 1; if (a > b) {
if (a < b) return -1; return 1;
}
if (a < b) {
return -1;
}
} }
catch (e) { catch (e) {
// silently fail on IE 'unknown' exception // silently fail on IE 'unknown' exception

View File

@ -56,12 +56,14 @@ var DateTimeShortcuts = {
var timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600; var timezoneOffset = DateTimeShortcuts.timezoneOffset / 3600;
// Only warn if there is a time zone mismatch. // Only warn if there is a time zone mismatch.
if (!timezoneOffset) if (!timezoneOffset) {
return; return;
}
// Check if warning is already there. // Check if warning is already there.
if ($(inp).siblings('.' + warningClass).length) if ($(inp).siblings('.' + warningClass).length) {
return; return;
}
var message; var message;
if (timezoneOffset > 0) { if (timezoneOffset > 0) {

View File

@ -66,7 +66,9 @@ function showRelatedObjectPopup(triggeringLink) {
function updateRelatedObjectLinks(triggeringLink) { function updateRelatedObjectLinks(triggeringLink) {
var $this = django.jQuery(triggeringLink); var $this = django.jQuery(triggeringLink);
var siblings = $this.nextAll('.change-related, .delete-related'); var siblings = $this.nextAll('.change-related, .delete-related');
if (!siblings.length) return; if (!siblings.length) {
return;
}
var value = $this.val(); var value = $this.val();
if (value) { if (value) {
siblings.each(function() { siblings.each(function() {

View File

@ -91,7 +91,9 @@ var CalendarNamespace = {
// use UTC function; see above for explanation. // use UTC function; see above for explanation.
if (isSelectedMonth && currentDay === selected.getUTCDate()) { if (isSelectedMonth && currentDay === selected.getUTCDate()) {
if (todayClass !== '') todayClass += " "; if (todayClass !== '') {
todayClass += " ";
}
todayClass += "selected"; todayClass += "selected";
} }

View File

@ -30,9 +30,13 @@ function removeEvent(obj, evType, fn) {
} }
function cancelEventPropagation(e) { function cancelEventPropagation(e) {
if (!e) e = window.event; if (!e) {
e = window.event;
}
e.cancelBubble = true; e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation(); if (e.stopPropagation) {
e.stopPropagation();
}
} }
// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]); // quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
@ -52,7 +56,9 @@ function quickElement() {
// "a" is reference to an object // "a" is reference to an object
function removeChildren(a) { function removeChildren(a) {
while (a.hasChildNodes()) a.removeChild(a.lastChild); while (a.hasChildNodes()) {
a.removeChild(a.lastChild);
}
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -170,9 +170,13 @@ function MapWidget(options) {
this.wkt_f = new OpenLayers.Format.DjangoWKT(); this.wkt_f = new OpenLayers.Format.DjangoWKT();
// Mapping from OGRGeomType name to OpenLayers.Geometry name // Mapping from OGRGeomType name to OpenLayers.Geometry name
if (options['geom_name'] === 'Unknown') options['geom_type'] = OpenLayers.Geometry; if (options['geom_name'] === 'Unknown') {
else if (options['geom_name'] === 'GeometryCollection') options['geom_type'] = OpenLayers.Geometry.Collection; options['geom_type'] = OpenLayers.Geometry;
else options['geom_type'] = eval('OpenLayers.Geometry.' + options['geom_name']); } else if (options['geom_name'] === 'GeometryCollection') {
options['geom_type'] = OpenLayers.Geometry.Collection;
} else {
options['geom_type'] = eval('OpenLayers.Geometry.' + options['geom_name']);
}
// Default options // Default options
this.options = { this.options = {
@ -261,8 +265,11 @@ function MapWidget(options) {
MapWidget.prototype.create_map = function() { MapWidget.prototype.create_map = function() {
var map = new OpenLayers.Map(this.options.map_id, this.options.map_options); var map = new OpenLayers.Map(this.options.map_id, this.options.map_options);
if (this.options.base_layer) this.layers.base = this.options.base_layer; if (this.options.base_layer) {
else this.layers.base = new OpenLayers.Layer.WMS('OpenLayers WMS', 'http://vmap0.tiles.osgeo.org/wms/vmap0', {layers: 'basic'}); this.layers.base = this.options.base_layer;
} else {
this.layers.base = new OpenLayers.Layer.WMS('OpenLayers WMS', 'http://vmap0.tiles.osgeo.org/wms/vmap0', {layers: 'basic'});
}
map.addLayer(this.layers.base); map.addLayer(this.layers.base);
return map; return map;
}; };
@ -359,8 +366,9 @@ MapWidget.prototype.enableEditing = function () {
MapWidget.prototype.getControls = function(layer) { MapWidget.prototype.getControls = function(layer) {
this.panel = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'}); this.panel = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
this.controls = [new OpenLayers.Control.Navigation()]; this.controls = [new OpenLayers.Control.Navigation()];
if (!this.options.modifiable && layer.features.length) if (!this.options.modifiable && layer.features.length) {
return; return;
}
if (this.options.geom_name.indexOf('LineString') >= 0 || this.options.geom_name === 'GeometryCollection' || this.options.geom_name === 'Unknown') { if (this.options.geom_name.indexOf('LineString') >= 0 || this.options.geom_name === 'GeometryCollection' || this.options.geom_name === 'Unknown') {
this.controls.push(new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {'displayClass': 'olControlDrawFeaturePath'})); this.controls.push(new OpenLayers.Control.DrawFeature(layer, OpenLayers.Handler.Path, {'displayClass': 'olControlDrawFeaturePath'}));
} }