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"}],
"comma-spacing": [1, {"before": false, "after": true}],
"dot-notation": [1, {"allowKeywords": true}],
"curly": [1, "all"],
"curly": [2, "all"],
"indent": [
2,
4

View File

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

View File

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

View File

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

View File

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

View File

@ -30,9 +30,13 @@ function removeEvent(obj, evType, fn) {
}
function cancelEventPropagation(e) {
if (!e) e = window.event;
if (!e) {
e = window.event;
}
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();
if (e.stopPropagation) {
e.stopPropagation();
}
}
// quickElement(tagType, parentReference [, textInChildNode, attribute, attributeValue ...]);
@ -52,7 +56,9 @@ function quickElement() {
// "a" is reference to an object
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();
// Mapping from OGRGeomType name to OpenLayers.Geometry name
if (options['geom_name'] === 'Unknown') options['geom_type'] = OpenLayers.Geometry;
else if (options['geom_name'] === 'GeometryCollection') options['geom_type'] = OpenLayers.Geometry.Collection;
else options['geom_type'] = eval('OpenLayers.Geometry.' + options['geom_name']);
if (options['geom_name'] === 'Unknown') {
options['geom_type'] = OpenLayers.Geometry;
} else if (options['geom_name'] === 'GeometryCollection') {
options['geom_type'] = OpenLayers.Geometry.Collection;
} else {
options['geom_type'] = eval('OpenLayers.Geometry.' + options['geom_name']);
}
// Default options
this.options = {
@ -261,8 +265,11 @@ function MapWidget(options) {
MapWidget.prototype.create_map = function() {
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;
else this.layers.base = new OpenLayers.Layer.WMS('OpenLayers WMS', 'http://vmap0.tiles.osgeo.org/wms/vmap0', {layers: 'basic'});
if (this.options.base_layer) {
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);
return map;
};
@ -359,8 +366,9 @@ MapWidget.prototype.enableEditing = function () {
MapWidget.prototype.getControls = function(layer) {
this.panel = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
this.controls = [new OpenLayers.Control.Navigation()];
if (!this.options.modifiable && layer.features.length)
if (!this.options.modifiable && layer.features.length) {
return;
}
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'}));
}