Toward natural JavaScript syntax

This commit is contained in:
Tim Schaub
2015-09-25 12:16:42 -06:00
parent d610b206f7
commit 0927c55b3c
40 changed files with 146 additions and 188 deletions

View File

@@ -59,8 +59,7 @@ ol.layer.Heatmap = function(opt_options) {
* @private
* @type {number}
*/
this.shadow_ = ol.isDef(options.shadow) ?
/** @type {number} */ (options.shadow) : 250;
this.shadow_ = options.shadow !== undefined ? options.shadow : 250;
/**
* @private
@@ -81,10 +80,10 @@ ol.layer.Heatmap = function(opt_options) {
this.setGradient(options.gradient ?
options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT);
this.setBlur(ol.isDef(options.blur) ?
this.setBlur(options.blur !== undefined ?
/** @type {number} */ (options.blur) : 15);
this.setRadius(ol.isDef(options.radius) ?
this.setRadius(options.radius !== undefined ?
/** @type {number} */ (options.radius) : 8);
goog.events.listen(this, [
@@ -112,8 +111,8 @@ ol.layer.Heatmap = function(opt_options) {
goog.asserts.assert(this.circleImage_ !== undefined,
'this.circleImage_ should be defined');
var weight = weightFunction(feature);
var opacity = ol.isDef(weight) ?
goog.math.clamp(/** @type {number} */ (weight), 0, 1) : 1;
var opacity = weight !== undefined ?
goog.math.clamp(weight, 0, 1) : 1;
// cast to 8 bits
var index = (255 * opacity) | 0;
var style = this.styleCache_[index];

View File

@@ -109,8 +109,7 @@ ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) {
*/
ol.layer.Layer.prototype.getSource = function() {
var source = this.get(ol.layer.LayerProperty.SOURCE);
return ol.isDef(source) ?
/** @type {ol.source.Source} */ (source) : null;
return /** @type {ol.source.Source} */ (source) || null;
};

View File

@@ -68,23 +68,23 @@ ol.layer.Base = function(options) {
*/
var properties = goog.object.clone(options);
properties[ol.layer.LayerProperty.BRIGHTNESS] =
ol.isDef(options.brightness) ? options.brightness : 0;
options.brightness !== undefined ? options.brightness : 0;
properties[ol.layer.LayerProperty.CONTRAST] =
ol.isDef(options.contrast) ? options.contrast : 1;
options.contrast !== undefined ? options.contrast : 1;
properties[ol.layer.LayerProperty.HUE] =
ol.isDef(options.hue) ? options.hue : 0;
options.hue !== undefined ? options.hue : 0;
properties[ol.layer.LayerProperty.OPACITY] =
ol.isDef(options.opacity) ? options.opacity : 1;
options.opacity !== undefined ? options.opacity : 1;
properties[ol.layer.LayerProperty.SATURATION] =
ol.isDef(options.saturation) ? options.saturation : 1;
options.saturation !== undefined ? options.saturation : 1;
properties[ol.layer.LayerProperty.VISIBLE] =
ol.isDef(options.visible) ? options.visible : true;
options.visible !== undefined ? options.visible : true;
properties[ol.layer.LayerProperty.Z_INDEX] =
ol.isDef(options.zIndex) ? options.zIndex : 0;
options.zIndex !== undefined ? options.zIndex : 0;
properties[ol.layer.LayerProperty.MAX_RESOLUTION] =
ol.isDef(options.maxResolution) ? options.maxResolution : Infinity;
options.maxResolution !== undefined ? options.maxResolution : Infinity;
properties[ol.layer.LayerProperty.MIN_RESOLUTION] =
ol.isDef(options.minResolution) ? options.minResolution : 0;
options.minResolution !== undefined ? options.minResolution : 0;
this.setProperties(properties);
};

View File

@@ -38,10 +38,9 @@ ol.layer.Tile = function(opt_options) {
delete baseOptions.useInterimTilesOnError;
goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions));
this.setPreload(ol.isDef(options.preload) ?
/** @type {number} */ (options.preload) : 0);
this.setUseInterimTilesOnError(ol.isDef(options.useInterimTilesOnError) ?
/** @type {boolean} */ (options.useInterimTilesOnError) : true);
this.setPreload(options.preload !== undefined ? options.preload : 0);
this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
options.useInterimTilesOnError : true);
};
goog.inherits(ol.layer.Tile, ol.layer.Layer);

View File

@@ -51,8 +51,8 @@ ol.layer.Vector = function(opt_options) {
* @type {number}
* @private
*/
this.renderBuffer_ = ol.isDef(options.renderBuffer) ?
/** @type {number} */ (options.renderBuffer) : 100;
this.renderBuffer_ = options.renderBuffer !== undefined ?
options.renderBuffer : 100;
/**
* User provided style.
@@ -74,15 +74,15 @@ ol.layer.Vector = function(opt_options) {
* @type {boolean}
* @private
*/
this.updateWhileAnimating_ = ol.isDef(options.updateWhileAnimating) ?
/** @type {boolean} */ (options.updateWhileAnimating) : false;
this.updateWhileAnimating_ = options.updateWhileAnimating !== undefined ?
options.updateWhileAnimating : false;
/**
* @type {boolean}
* @private
*/
this.updateWhileInteracting_ = ol.isDef(options.updateWhileInteracting) ?
/** @type {boolean} */ (options.updateWhileInteracting) : false;
this.updateWhileInteracting_ = options.updateWhileInteracting !== undefined ?
options.updateWhileInteracting : false;
};
goog.inherits(ol.layer.Vector, ol.layer.Layer);
@@ -180,11 +180,7 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
* @api stable
*/
ol.layer.Vector.prototype.setStyle = function(style) {
this.style_ = ol.isDef(style) ?
/**
* @type {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|null}
*/
(style) : ol.style.defaultStyleFunction;
this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction;
this.styleFunction_ = goog.isNull(style) ?
undefined : ol.style.createStyleFunction(this.style_);
this.changed();