Better code indentation

This commit is contained in:
Frederic Junod
2018-02-28 16:46:45 +01:00
parent cf0c42ae7d
commit 73b15ef8d7
6 changed files with 29 additions and 41 deletions
+2 -4
View File
@@ -105,8 +105,7 @@ Observable.prototype.on = function(type, listener) {
} }
return keys; return keys;
} else { } else {
return listen( return listen(this, /** @type {string} */ (type), listener);
this, /** @type {string} */ (type), listener);
} }
}; };
@@ -129,8 +128,7 @@ Observable.prototype.once = function(type, listener) {
} }
return keys; return keys;
} else { } else {
return listenOnce( return listenOnce(this, /** @type {string} */ (type), listener);
this, /** @type {string} */ (type), listener);
} }
}; };
+19 -21
View File
@@ -361,50 +361,50 @@ const PluggableMap = function(options) {
this.controls.forEach( this.controls.forEach(
/** /**
* @param {ol.control.Control} control Control. * @param {ol.control.Control} control Control.
* @this {ol.PluggableMap} * @this {ol.PluggableMap}
*/ */
function(control) { function(control) {
control.setMap(this); control.setMap(this);
}.bind(this)); }.bind(this));
listen(this.controls, CollectionEventType.ADD, listen(this.controls, CollectionEventType.ADD,
/** /**
* @param {ol.CollectionEvent} event CollectionEvent. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
event.element.setMap(this); event.element.setMap(this);
}, this); }, this);
listen(this.controls, CollectionEventType.REMOVE, listen(this.controls, CollectionEventType.REMOVE,
/** /**
* @param {ol.CollectionEvent} event CollectionEvent. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
event.element.setMap(null); event.element.setMap(null);
}, this); }, this);
this.interactions.forEach( this.interactions.forEach(
/** /**
* @param {ol.interaction.Interaction} interaction Interaction. * @param {ol.interaction.Interaction} interaction Interaction.
* @this {ol.PluggableMap} * @this {ol.PluggableMap}
*/ */
function(interaction) { function(interaction) {
interaction.setMap(this); interaction.setMap(this);
}.bind(this)); }.bind(this));
listen(this.interactions, CollectionEventType.ADD, listen(this.interactions, CollectionEventType.ADD,
/** /**
* @param {ol.CollectionEvent} event CollectionEvent. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
event.element.setMap(this); event.element.setMap(this);
}, this); }, this);
listen(this.interactions, CollectionEventType.REMOVE, listen(this.interactions, CollectionEventType.REMOVE,
/** /**
* @param {ol.CollectionEvent} event CollectionEvent. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
event.element.setMap(null); event.element.setMap(null);
}, this); }, this);
@@ -413,16 +413,16 @@ const PluggableMap = function(options) {
listen(this.overlays_, CollectionEventType.ADD, listen(this.overlays_, CollectionEventType.ADD,
/** /**
* @param {ol.CollectionEvent} event CollectionEvent. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element)); this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
}, this); }, this);
listen(this.overlays_, CollectionEventType.REMOVE, listen(this.overlays_, CollectionEventType.REMOVE,
/** /**
* @param {ol.CollectionEvent} event CollectionEvent. * @param {ol.CollectionEvent} event CollectionEvent.
*/ */
function(event) { function(event) {
const overlay = /** @type {ol.Overlay} */ (event.element); const overlay = /** @type {ol.Overlay} */ (event.element);
const id = overlay.getId(); const id = overlay.getId();
@@ -685,9 +685,7 @@ PluggableMap.prototype.getTarget = function() {
PluggableMap.prototype.getTargetElement = function() { PluggableMap.prototype.getTargetElement = function() {
const target = this.getTarget(); const target = this.getTarget();
if (target !== undefined) { if (target !== undefined) {
return typeof target === 'string' ? return typeof target === 'string' ? document.getElementById(target) : target;
document.getElementById(target) :
target;
} else { } else {
return null; return null;
} }
+1 -2
View File
@@ -197,8 +197,7 @@ View.prototype.applyOptions_ = function(options) {
this.minResolution_, this.maxResolution_); this.minResolution_, this.maxResolution_);
} }
} }
properties[ViewProperty.ROTATION] = properties[ViewProperty.ROTATION] = options.rotation !== undefined ? options.rotation : 0;
options.rotation !== undefined ? options.rotation : 0;
this.setProperties(properties); this.setProperties(properties);
/** /**
+3 -6
View File
@@ -33,8 +33,7 @@ export function bindListener(listenerObj) {
* listener, for {@link ol.events.unlistenByKey}. * listener, for {@link ol.events.unlistenByKey}.
* @return {ol.EventsKey|undefined} The matching listener object. * @return {ol.EventsKey|undefined} The matching listener object.
*/ */
export function findListener(listeners, listener, opt_this, export function findListener(listeners, listener, opt_this, opt_setDeleteIndex) {
opt_setDeleteIndex) {
let listenerObj; let listenerObj;
for (let i = 0, ii = listeners.length; i < ii; ++i) { for (let i = 0, ii = listeners.length; i < ii; ++i) {
listenerObj = listeners[i]; listenerObj = listeners[i];
@@ -124,8 +123,7 @@ export function listen(target, type, listener, opt_this, opt_once) {
if (!listeners) { if (!listeners) {
listeners = listenerMap[type] = []; listeners = listenerMap[type] = [];
} }
let listenerObj = findListener(listeners, listener, opt_this, let listenerObj = findListener(listeners, listener, opt_this, false);
false);
if (listenerObj) { if (listenerObj) {
if (!opt_once) { if (!opt_once) {
// Turn one-off listener into a permanent one. // Turn one-off listener into a permanent one.
@@ -188,8 +186,7 @@ export function listenOnce(target, type, listener, opt_this) {
export function unlisten(target, type, listener, opt_this) { export function unlisten(target, type, listener, opt_this) {
const listeners = getListeners(target, type); const listeners = getListeners(target, type);
if (listeners) { if (listeners) {
const listenerObj = findListener(listeners, listener, opt_this, const listenerObj = findListener(listeners, listener, opt_this, true);
true);
if (listenerObj) { if (listenerObj) {
unlistenByKey(listenerObj); unlistenByKey(listenerObj);
} }
+2 -4
View File
@@ -43,13 +43,11 @@ let HAS_WEBGL = false;
if ('WebGLRenderingContext' in window) { if ('WebGLRenderingContext' in window) {
try { try {
const canvas = /** @type {HTMLCanvasElement} */ const canvas = /** @type {HTMLCanvasElement} */ (document.createElement('CANVAS'));
(document.createElement('CANVAS'));
const gl = getContext(canvas, {failIfMajorPerformanceCaveat: true}); const gl = getContext(canvas, {failIfMajorPerformanceCaveat: true});
if (gl) { if (gl) {
HAS_WEBGL = true; HAS_WEBGL = true;
WEBGL_MAX_TEXTURE_SIZE = /** @type {number} */ WEBGL_MAX_TEXTURE_SIZE = /** @type {number} */ (gl.getParameter(gl.MAX_TEXTURE_SIZE));
(gl.getParameter(gl.MAX_TEXTURE_SIZE));
WEBGL_EXTENSIONS = gl.getSupportedExtensions(); WEBGL_EXTENSIONS = gl.getSupportedExtensions();
} }
} catch (e) { } catch (e) {
+2 -4
View File
@@ -48,10 +48,8 @@ export function tile(tileGrid) {
const extents = []; const extents = [];
/** @type {ol.TileCoord} */ /** @type {ol.TileCoord} */
const tileCoord = [z, 0, 0]; const tileCoord = [z, 0, 0];
for (tileCoord[1] = tileRange.minX; tileCoord[1] <= tileRange.maxX; for (tileCoord[1] = tileRange.minX; tileCoord[1] <= tileRange.maxX; ++tileCoord[1]) {
++tileCoord[1]) { for (tileCoord[2] = tileRange.minY; tileCoord[2] <= tileRange.maxY; ++tileCoord[2]) {
for (tileCoord[2] = tileRange.minY; tileCoord[2] <= tileRange.maxY;
++tileCoord[2]) {
extents.push(tileGrid.getTileCoordExtent(tileCoord)); extents.push(tileGrid.getTileCoordExtent(tileCoord));
} }
} }