Move opt_useCapture arg to the end of the list

This commit is contained in:
Tim Schaub
2016-02-02 07:03:00 -07:00
committed by Andreas Hocevar
parent dc0393acff
commit 80df1f5ae8
48 changed files with 161 additions and 165 deletions

View File

@@ -95,8 +95,7 @@ ol.control.Attribution = function(opt_options) {
'title': tipLabel
}, activeLabel);
ol.events.listen(button, ol.events.EventType.CLICK,
this.handleClick_, false, this);
ol.events.listen(button, ol.events.EventType.CLICK, this.handleClick_, this);
var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' +
ol.css.CLASS_CONTROL +

View File

@@ -118,7 +118,7 @@ ol.control.Control.prototype.setMap = function(map) {
target.appendChild(this.element);
if (this.render !== ol.nullFunction) {
this.listenerKeys.push(ol.events.listen(map,
ol.MapEventType.POSTRENDER, this.render, false, this));
ol.MapEventType.POSTRENDER, this.render, this));
}
map.render();
}

View File

@@ -65,11 +65,11 @@ ol.control.FullScreen = function(opt_options) {
}, this.labelNode_);
ol.events.listen(button, ol.events.EventType.CLICK,
this.handleClick_, false, this);
this.handleClick_, this);
ol.events.listen(goog.global.document,
goog.dom.fullscreen.EventType.CHANGE,
this.handleFullScreenChange_, false, this);
this.handleFullScreenChange_, this);
var cssClasses = this.cssClassName_ + ' ' + ol.css.CLASS_UNSELECTABLE +
' ' + ol.css.CLASS_CONTROL + ' ' +

View File

@@ -55,7 +55,7 @@ ol.control.MousePosition = function(opt_options) {
ol.events.listen(this,
ol.Object.getChangeEventType(ol.control.MousePositionProperty.PROJECTION),
this.handleProjectionChanged_, false, this);
this.handleProjectionChanged_, this);
if (options.coordinateFormat) {
this.setCoordinateFormat(options.coordinateFormat);
@@ -184,9 +184,9 @@ ol.control.MousePosition.prototype.setMap = function(map) {
var viewport = map.getViewport();
this.listenerKeys.push(
ol.events.listen(viewport, ol.events.EventType.MOUSEMOVE,
this.handleMouseMove, false, this),
this.handleMouseMove, this),
ol.events.listen(viewport, ol.events.EventType.MOUSEOUT,
this.handleMouseOut, false, this)
this.handleMouseOut, this)
);
}
};

View File

@@ -84,7 +84,7 @@ ol.control.OverviewMap = function(opt_options) {
}, activeLabel);
ol.events.listen(button, ol.events.EventType.CLICK,
this.handleClick_, false, this);
this.handleClick_, this);
var ovmapDiv = goog.dom.createDom('DIV', 'ol-overviewmap-map');
@@ -161,7 +161,7 @@ ol.control.OverviewMap.prototype.setMap = function(map) {
if (map) {
this.listenerKeys.push(ol.events.listen(
map, ol.ObjectEventType.PROPERTYCHANGE,
this.handleMapPropertyChange_, false, this));
this.handleMapPropertyChange_, this));
// TODO: to really support map switching, this would need to be reworked
if (this.ovmap_.getLayers().getLength() === 0) {
@@ -205,7 +205,7 @@ ol.control.OverviewMap.prototype.handleMapPropertyChange_ = function(event) {
ol.control.OverviewMap.prototype.bindView_ = function(view) {
ol.events.listen(view,
ol.Object.getChangeEventType(ol.ViewProperty.ROTATION),
this.handleRotationChanged_, false, this);
this.handleRotationChanged_, this);
};
@@ -217,7 +217,7 @@ ol.control.OverviewMap.prototype.bindView_ = function(view) {
ol.control.OverviewMap.prototype.unbindView_ = function(view) {
ol.events.unlisten(view,
ol.Object.getChangeEventType(ol.ViewProperty.ROTATION),
this.handleRotationChanged_, false, this);
this.handleRotationChanged_, this);
};
@@ -463,7 +463,7 @@ ol.control.OverviewMap.prototype.handleToggle_ = function() {
function(event) {
this.updateBox_();
},
false, this);
this);
}
};

View File

@@ -54,7 +54,7 @@ ol.control.Rotate = function(opt_options) {
}, this.label_);
ol.events.listen(button, ol.events.EventType.CLICK,
ol.control.Rotate.prototype.handleClick_, false, this);
ol.control.Rotate.prototype.handleClick_, this);
var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' +
ol.css.CLASS_CONTROL;

View File

@@ -111,7 +111,7 @@ ol.control.ScaleLine = function(opt_options) {
ol.events.listen(
this, ol.Object.getChangeEventType(ol.control.ScaleLineProperty.UNITS),
this.handleUnitsChanged_, false, this);
this.handleUnitsChanged_, this);
this.setUnits(/** @type {ol.control.ScaleLineUnits} */ (options.units) ||
ol.control.ScaleLineUnits.METRIC);

View File

@@ -44,7 +44,7 @@ ol.control.Zoom = function(opt_options) {
ol.events.listen(inElement,
ol.events.EventType.CLICK, goog.partial(
ol.control.Zoom.prototype.handleClick_, delta), false, this);
ol.control.Zoom.prototype.handleClick_, delta), this);
var outElement = goog.dom.createDom('BUTTON', {
'class': className + '-out',
@@ -54,7 +54,7 @@ ol.control.Zoom = function(opt_options) {
ol.events.listen(outElement,
ol.events.EventType.CLICK, goog.partial(
ol.control.Zoom.prototype.handleClick_, -delta), false, this);
ol.control.Zoom.prototype.handleClick_, -delta), this);
var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' +
ol.css.CLASS_CONTROL;

View File

@@ -111,14 +111,14 @@ ol.control.ZoomSlider = function(opt_options) {
this.registerDisposable(dragger);
ol.events.listen(dragger, ol.pointer.EventType.POINTERDOWN,
this.handleDraggerStart_, false, this);
this.handleDraggerStart_, this);
ol.events.listen(dragger, ol.pointer.EventType.POINTERMOVE,
this.handleDraggerDrag_, false, this);
this.handleDraggerDrag_, this);
ol.events.listen(dragger, ol.pointer.EventType.POINTERUP,
this.handleDraggerEnd_, false, this);
this.handleDraggerEnd_, this);
ol.events.listen(containerElement, ol.events.EventType.CLICK,
this.handleContainerClick_, false, this);
this.handleContainerClick_, this);
ol.events.listen(thumbElement, ol.events.EventType.CLICK,
ol.events.Event.stopPropagation);
@@ -255,12 +255,12 @@ ol.control.ZoomSlider.prototype.handleDraggerStart_ = function(event) {
ol.events.EventType.MOUSEMOVE,
ol.events.EventType.TOUCHMOVE,
ol.pointer.EventType.POINTERMOVE
], this.handleDraggerDrag_, false, this),
], this.handleDraggerDrag_, this),
ol.events.listen(document, [
ol.events.EventType.MOUSEUP,
ol.events.EventType.TOUCHEND,
ol.pointer.EventType.POINTERUP
], this.handleDraggerEnd_, false, this)
], this.handleDraggerEnd_, this)
];
}
}

View File

@@ -39,7 +39,7 @@ ol.control.ZoomToExtent = function(opt_options) {
}, label);
ol.events.listen(button, ol.events.EventType.CLICK,
this.handleClick_, false, this);
this.handleClick_, this);
var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' +
ol.css.CLASS_CONTROL;

View File

@@ -89,7 +89,7 @@ ol.DeviceOrientation = function(opt_options) {
ol.events.listen(this,
ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING),
this.handleTrackingChanged_, false, this);
this.handleTrackingChanged_, this);
this.setTracking(options.tracking !== undefined ? options.tracking : false);
@@ -209,7 +209,7 @@ ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() {
var tracking = this.getTracking();
if (tracking && !this.listenerKey_) {
this.listenerKey_ = ol.events.listen(goog.global, 'deviceorientation',
this.orientationChange_, false, this);
this.orientationChange_, this);
} else if (!tracking && this.listenerKey_ !== null) {
ol.events.unlistenByKey(this.listenerKey_);
this.listenerKey_ = null;

View File

@@ -125,20 +125,21 @@ ol.events.bindListener_ = function(listenerObj) {
*
* @param {!Array<!ol.events.ListenerObjType>} listenerArray Array of listeners.
* @param {!Function} listener The listener function.
* @param {boolean} useCapture The capture flag for the listener.
* @param {Object=} opt_this The `this` value inside the listener.
* @param {boolean=} opt_remove Remove the found listener from the array.
* @param {boolean=} opt_useCapture The capture flag for the listener.
* @return {ol.events.ListenerObjType|undefined} The matching listener.
* @private
*/
ol.events.findListener_ = function(
listenerArray, listener, useCapture, opt_this, opt_remove) {
listenerArray, listener, opt_this, opt_remove, opt_useCapture) {
var listenerObj;
var useCapture = !!opt_useCapture;
for (var i = 0, ii = listenerArray.length; i < ii; ++i) {
listenerObj = listenerArray[i];
if (listenerObj.listener === listener &&
listenerObj.useCapture == useCapture &&
listenerObj.bindTo === opt_this) {
listenerObj.bindTo === opt_this &&
listenerObj.useCapture === useCapture) {
if (opt_remove) {
listenerArray.splice(i, 1);
}
@@ -173,21 +174,21 @@ ol.events.getListeners = function(target, type) {
* @param {ol.events.EventType|string|Array.<(ol.events.EventType|string)>} type
* Event type.
* @param {ol.events.ListenerFunctionType} listener Listener.
* @param {boolean=} opt_useCapture Use capture. For listeners on an
* {@link ol.events.EventTarget}, `true` simply means that the listener will
* be called before already registered listeners. Default is false.
* @param {Object=} opt_this Object referenced by the `this` keyword in the
* listener. Default is the `target`.
* @param {boolean=} opt_once If true, add the listener as one-off listener.
* @param {boolean=} opt_useCapture Use capture. For listeners on an
* {@link ol.events.EventTarget}, `true` simply means that the listener will
* be called before already registered listeners. Default is false.
* @return {ol.events.Key} Unique key for the listener.
*/
ol.events.listen = function(
target, type, listener, opt_useCapture, opt_this, opt_once) {
target, type, listener, opt_this, opt_once, opt_useCapture) {
if (Array.isArray(type)) {
var keys = [];
type.forEach(function(t) {
keys.push(ol.events.listen(target, t, listener, opt_useCapture, opt_this,
opt_once));
keys.push(ol.events.listen(target, t, listener, opt_this, opt_once,
opt_useCapture));
});
return keys;
}
@@ -201,8 +202,8 @@ ol.events.listen = function(
if (!listenerArray) {
listenerArray = listenerMap[type] = [];
}
var listenerObj = ol.events.findListener_(listenerArray, listener, useCapture,
opt_this);
var listenerObj = ol.events.findListener_(listenerArray, listener, opt_this,
false, useCapture);
if (listenerObj) {
if (!opt_once) {
// Turn one-off listener into a permanent one.
@@ -243,17 +244,17 @@ ol.events.listen = function(
* @param {ol.events.EventType|string|Array.<(ol.events.EventType|string)>} type
* Event type.
* @param {ol.events.ListenerFunctionType} listener Listener.
* @param {Object=} opt_this Object referenced by the `this` keyword in the
* listener. Default is the `target`.
* @param {boolean=} opt_useCapture Use capture. For listeners on an
* {@link ol.events.EventTarget}, `true` simply means that the listener will
* be called before already registered listeners. Default is false.
* @param {Object=} opt_this Object referenced by the `this` keyword in the
* listener. Default is the `target`.
* @return {ol.events.Key} Key for unlistenByKey.
*/
ol.events.listenOnce = function(
target, type, listener, opt_useCapture, opt_this) {
return ol.events.listen(target, type, listener, opt_useCapture, opt_this,
true);
target, type, listener, opt_this, opt_useCapture) {
return ol.events.listen(target, type, listener, opt_this, true,
opt_useCapture);
};
@@ -268,17 +269,17 @@ ol.events.listenOnce = function(
* @param {ol.events.EventType|string|Array.<(ol.events.EventType|string)>} type
* Event type.
* @param {ol.events.ListenerFunctionType} listener Listener.
* @param {Object=} opt_this Object referenced by the `this` keyword in the
* listener. Default is the `target`.
* @param {boolean=} opt_useCapture Use capture. For listeners on an
* {@link ol.events.EventTarget}, `true` simply means that the listener will
* be called before already registered listeners. Default is false.
* @param {Object=} opt_this Object referenced by the `this` keyword in the
* listener. Default is the `target`.
*/
ol.events.unlisten = function(
target, type, listener, opt_useCapture, opt_this) {
target, type, listener, opt_this, opt_useCapture) {
if (Array.isArray(type)) {
type.forEach(function(t) {
ol.events.unlisten(target, t, listener, opt_useCapture, opt_this);
ol.events.unlisten(target, t, listener, opt_this, opt_useCapture);
});
return;
}
@@ -286,7 +287,7 @@ ol.events.unlisten = function(
var listenerArray = ol.events.getListeners(target, type);
if (listenerArray) {
var listenerObj = ol.events.findListener_(listenerArray, listener,
!!opt_useCapture, opt_this);
opt_this, false, !!opt_useCapture);
if (listenerObj) {
ol.events.unlistenByKey(listenerObj);
}
@@ -314,7 +315,7 @@ ol.events.unlistenByKey = function(key) {
var listenerArray = ol.events.getListeners(key.target, key.type);
if (listenerArray) {
ol.events.findListener_(listenerArray, key.listener,
key.useCapture, key.bindTo, true);
key.bindTo, true, key.useCapture);
if (listenerArray.length === 0) {
var listenerMap = key.target[ol.events.LISTENER_MAP_PROP_];
delete listenerMap[key.type];

View File

@@ -93,7 +93,7 @@ ol.Feature = function(opt_geometryOrProperties) {
ol.events.listen(
this, ol.Object.getChangeEventType(this.geometryName_),
this.handleGeometryChanged_, false, this);
this.handleGeometryChanged_, this);
if (opt_geometryOrProperties !== undefined) {
if (opt_geometryOrProperties instanceof ol.geom.Geometry ||
@@ -215,7 +215,7 @@ ol.Feature.prototype.handleGeometryChanged_ = function() {
var geometry = this.getGeometry();
if (geometry) {
this.geometryChangeKey_ = ol.events.listen(geometry,
ol.events.EventType.CHANGE, this.handleGeometryChange_, false, this);
ol.events.EventType.CHANGE, this.handleGeometryChange_, this);
}
this.changed();
};
@@ -275,11 +275,11 @@ ol.Feature.prototype.setId = function(id) {
ol.Feature.prototype.setGeometryName = function(name) {
ol.events.unlisten(
this, ol.Object.getChangeEventType(this.geometryName_),
this.handleGeometryChanged_, false, this);
this.handleGeometryChanged_, this);
this.geometryName_ = name;
ol.events.listen(
this, ol.Object.getChangeEventType(this.geometryName_),
this.handleGeometryChanged_, false, this);
this.handleGeometryChanged_, this);
this.handleGeometryChanged_();
};

View File

@@ -85,10 +85,10 @@ ol.Geolocation = function(opt_options) {
ol.events.listen(
this, ol.Object.getChangeEventType(ol.GeolocationProperty.PROJECTION),
this.handleProjectionChanged_, false, this);
this.handleProjectionChanged_, this);
ol.events.listen(
this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING),
this.handleTrackingChanged_, false, this);
this.handleTrackingChanged_, this);
if (options.projection !== undefined) {
this.setProjection(ol.proj.get(options.projection));

View File

@@ -58,7 +58,7 @@ ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() {
for (i = 0, ii = this.geometries_.length; i < ii; ++i) {
ol.events.unlisten(
this.geometries_[i], ol.events.EventType.CHANGE,
this.changed, false, this);
this.changed, this);
}
};
@@ -74,7 +74,7 @@ ol.geom.GeometryCollection.prototype.listenGeometriesChange_ = function() {
for (i = 0, ii = this.geometries_.length; i < ii; ++i) {
ol.events.listen(
this.geometries_[i], ol.events.EventType.CHANGE,
this.changed, false, this);
this.changed, this);
}
};

View File

@@ -132,9 +132,9 @@ ol.Image.prototype.load = function() {
'this.imageListenerKeys_ should be null');
this.imageListenerKeys_ = [
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
this.handleImageError_, false, this),
this.handleImageError_, this),
ol.events.listenOnce(this.image_, ol.events.EventType.LOAD,
this.handleImageLoad_, false, this)
this.handleImageLoad_, this)
];
this.imageLoadFunction_(this, this.src_);
}

View File

@@ -147,9 +147,9 @@ ol.ImageTile.prototype.load = function() {
'this.imageListenerKeys_ should be null');
this.imageListenerKeys_ = [
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
this.handleImageError_, false, this),
this.handleImageError_, this),
ol.events.listenOnce(this.image_, ol.events.EventType.LOAD,
this.handleImageLoad_, false, this)
this.handleImageLoad_, this)
];
this.tileLoadFunction_(this, this.src_);
}

View File

@@ -152,10 +152,10 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
var dropArea = map.getViewport();
this.dropListenKeys_ = [
ol.events.listen(dropArea, ol.events.EventType.DROP,
ol.interaction.DragAndDrop.handleDrop_, false, this),
ol.interaction.DragAndDrop.handleDrop_, this),
ol.events.listen(dropArea, [ol.events.EventType.DRAGENTER,
ol.events.EventType.DRAGOVER, ol.events.EventType.DROP],
ol.interaction.DragAndDrop.handleStop_, false, this)
ol.interaction.DragAndDrop.handleStop_, this)
]
}
};

View File

@@ -302,7 +302,7 @@ ol.interaction.Draw = function(options) {
ol.events.listen(this,
ol.Object.getChangeEventType(ol.interaction.InteractionProperty.ACTIVE),
this.updateState_, false, this);
this.updateState_, this);
};
goog.inherits(ol.interaction.Draw, ol.interaction.Pointer);

View File

@@ -230,9 +230,9 @@ ol.interaction.Modify = function(options) {
this.features_.forEach(this.addFeature_, this);
ol.events.listen(this.features_, ol.CollectionEventType.ADD,
this.handleFeatureAdd_, false, this);
this.handleFeatureAdd_, this);
ol.events.listen(this.features_, ol.CollectionEventType.REMOVE,
this.handleFeatureRemove_, false, this);
this.handleFeatureRemove_, this);
};
goog.inherits(ol.interaction.Modify, ol.interaction.Pointer);
@@ -252,7 +252,7 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) {
this.handlePointerAtPixel_(this.lastPixel_, map);
}
ol.events.listen(feature, ol.events.EventType.CHANGE,
this.handleFeatureChange_, false, this);
this.handleFeatureChange_, this);
};
@@ -282,7 +282,7 @@ ol.interaction.Modify.prototype.removeFeature_ = function(feature) {
this.vertexFeature_ = null;
}
ol.events.unlisten(feature, ol.events.EventType.CHANGE,
this.handleFeatureChange_, false, this);
this.handleFeatureChange_, this);
};

View File

@@ -209,9 +209,9 @@ ol.interaction.Select = function(opt_options) {
var features = this.featureOverlay_.getSource().getFeaturesCollection();
ol.events.listen(features, ol.CollectionEventType.ADD,
this.addFeature_, false, this);
this.addFeature_, this);
ol.events.listen(features, ol.CollectionEventType.REMOVE,
this.removeFeature_, false, this);
this.removeFeature_, this);
};
goog.inherits(ol.interaction.Select, ol.interaction.Interaction);

View File

@@ -74,7 +74,7 @@ ol.layer.Heatmap = function(opt_options) {
ol.events.listen(this,
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.GRADIENT),
this.handleGradientChanged_, false, this);
this.handleGradientChanged_, this);
this.setGradient(options.gradient ?
options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT);
@@ -86,7 +86,7 @@ ol.layer.Heatmap = function(opt_options) {
ol.events.listen(this, [
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.BLUR),
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.RADIUS)
], this.handleStyleChanged_, false, this);
], this.handleStyleChanged_, this);
this.handleStyleChanged_();
@@ -129,8 +129,7 @@ ol.layer.Heatmap = function(opt_options) {
// The render order is not relevant for a heatmap representation.
this.setRenderOrder(null);
ol.events.listen(this, ol.render.EventType.RENDER,
this.handleRender_, false, this);
ol.events.listen(this, ol.render.EventType.RENDER, this.handleRender_, this);
};
goog.inherits(ol.layer.Heatmap, ol.layer.Vector);

View File

@@ -63,7 +63,7 @@ ol.layer.Layer = function(options) {
ol.events.listen(this,
ol.Object.getChangeEventType(ol.layer.LayerProperty.SOURCE),
this.handleSourcePropertyChange_, false, this);
this.handleSourcePropertyChange_, this);
var source = options.source ? options.source : null;
this.setSource(source);
@@ -145,7 +145,7 @@ ol.layer.Layer.prototype.handleSourcePropertyChange_ = function() {
var source = this.getSource();
if (source) {
this.sourceChangeKey_ = ol.events.listen(source,
ol.events.EventType.CHANGE, this.handleSourceChange_, false, this);
ol.events.EventType.CHANGE, this.handleSourceChange_, this);
}
this.changed();
};
@@ -179,9 +179,9 @@ ol.layer.Layer.prototype.setMap = function(map) {
layerState.zIndex = Infinity;
evt.frameState.layerStatesArray.push(layerState);
evt.frameState.layerStates[goog.getUid(this)] = layerState;
}, false, this);
}, this);
this.mapRenderKey_ = ol.events.listen(
this, ol.events.EventType.CHANGE, map.render, false, map);
this, ol.events.EventType.CHANGE, map.render, map);
this.changed();
}
};

View File

@@ -58,7 +58,7 @@ ol.layer.Group = function(opt_options) {
ol.events.listen(this,
ol.Object.getChangeEventType(ol.layer.GroupProperty.LAYERS),
this.handleLayersChanged_, false, this);
this.handleLayersChanged_, this);
if (layers) {
if (goog.isArray(layers)) {
@@ -99,9 +99,9 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
var layers = this.getLayers();
this.layersListenerKeys_.push(
ol.events.listen(layers, ol.CollectionEventType.ADD,
this.handleLayersAdd_, false, this),
this.handleLayersAdd_, this),
ol.events.listen(layers, ol.CollectionEventType.REMOVE,
this.handleLayersRemove_, false, this));
this.handleLayersRemove_, this));
goog.object.forEach(this.listenerKeys_, function(keys) {
keys.forEach(ol.events.unlistenByKey);
@@ -114,9 +114,9 @@ ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
layer = layersArray[i];
this.listenerKeys_[goog.getUid(layer).toString()] = [
ol.events.listen(layer, ol.ObjectEventType.PROPERTYCHANGE,
this.handleLayerChange_, false, this),
this.handleLayerChange_, this),
ol.events.listen(layer, ol.events.EventType.CHANGE,
this.handleLayerChange_, false, this)
this.handleLayerChange_, this)
];
}
@@ -135,9 +135,9 @@ ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
'listeners already registered');
this.listenerKeys_[key] = [
ol.events.listen(layer, ol.ObjectEventType.PROPERTYCHANGE,
this.handleLayerChange_, false, this),
this.handleLayerChange_, this),
ol.events.listen(layer, ol.events.EventType.CHANGE,
this.handleLayerChange_, false, this)
this.handleLayerChange_, this)
];
this.changed();
};

View File

@@ -298,7 +298,7 @@ ol.Map = function(options) {
var mapBrowserEventHandler = new ol.MapBrowserEventHandler(this);
ol.events.listen(mapBrowserEventHandler,
goog.object.getValues(ol.MapBrowserEvent.EventType),
this.handleMapBrowserEvent, false, this);
this.handleMapBrowserEvent, this);
this.registerDisposable(mapBrowserEventHandler);
/**
@@ -314,9 +314,9 @@ ol.Map = function(options) {
this.keyHandlerKey_;
ol.events.listen(this.viewport_, ol.events.EventType.WHEEL,
this.handleBrowserEvent, false, this);
this.handleBrowserEvent, this);
ol.events.listen(this.viewport_, ol.events.EventType.MOUSEWHEEL,
this.handleBrowserEvent, false, this);
this.handleBrowserEvent, this);
/**
* @type {ol.Collection.<ol.control.Control>}
@@ -392,13 +392,13 @@ ol.Map = function(options) {
ol.events.listen(
this, ol.Object.getChangeEventType(ol.MapProperty.LAYERGROUP),
this.handleLayerGroupChanged_, false, this);
this.handleLayerGroupChanged_, this);
ol.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.VIEW),
this.handleViewChanged_, false, this);
this.handleViewChanged_, this);
ol.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.SIZE),
this.handleSizeChanged_, false, this);
this.handleSizeChanged_, this);
ol.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.TARGET),
this.handleTargetChanged_, false, this);
this.handleTargetChanged_, this);
// setProperties will trigger the rendering of the map if the map
// is "defined" already.
@@ -419,7 +419,7 @@ ol.Map = function(options) {
*/
function(event) {
event.element.setMap(this);
}, false, this);
}, this);
ol.events.listen(this.controls_, ol.CollectionEventType.REMOVE,
/**
@@ -427,7 +427,7 @@ ol.Map = function(options) {
*/
function(event) {
event.element.setMap(null);
}, false, this);
}, this);
this.interactions_.forEach(
/**
@@ -444,7 +444,7 @@ ol.Map = function(options) {
*/
function(event) {
event.element.setMap(this);
}, false, this);
}, this);
ol.events.listen(this.interactions_, ol.CollectionEventType.REMOVE,
/**
@@ -452,7 +452,7 @@ ol.Map = function(options) {
*/
function(event) {
event.element.setMap(null);
}, false, this);
}, this);
this.overlays_.forEach(this.addOverlayInternal_, this);
@@ -462,7 +462,7 @@ ol.Map = function(options) {
*/
function(event) {
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
}, false, this);
}, this);
ol.events.listen(this.overlays_, ol.CollectionEventType.REMOVE,
/**
@@ -474,7 +474,7 @@ ol.Map = function(options) {
delete this.overlayIdIndex_[id.toString()];
}
event.element.setMap(null);
}, false, this);
}, this);
};
goog.inherits(ol.Map, ol.Object);
@@ -572,9 +572,9 @@ ol.Map.prototype.removePreRenderFunction = function(preRenderFunction) {
*/
ol.Map.prototype.disposeInternal = function() {
ol.events.unlisten(this.viewport_, ol.events.EventType.WHEEL,
this.handleBrowserEvent, false, this);
this.handleBrowserEvent, this);
ol.events.unlisten(this.viewport_, ol.events.EventType.MOUSEWHEEL,
this.handleBrowserEvent, false, this);
this.handleBrowserEvent, this);
if (this.handleResize_ !== undefined) {
goog.global.removeEventListener(ol.events.EventType.RESIZE,
this.handleResize_, false);
@@ -1078,7 +1078,7 @@ ol.Map.prototype.handleTargetChanged_ = function() {
targetElement : this.keyboardEventTarget_;
this.keyHandlerKey_ = ol.events.listen(keyboardEventTarget,
[ol.events.EventType.KEYDOWN, ol.events.EventType.KEYPRESS],
this.handleBrowserEvent, false, this);
this.handleBrowserEvent, this);
if (!this.handleResize_) {
this.handleResize_ = this.updateSize.bind(this);
@@ -1121,7 +1121,7 @@ ol.Map.prototype.handleViewChanged_ = function() {
if (view) {
this.viewPropertyListenerKey_ = ol.events.listen(
view, ol.ObjectEventType.PROPERTYCHANGE,
this.handleViewPropertyChanged_, false, this);
this.handleViewPropertyChanged_, this);
}
this.render();
};
@@ -1162,10 +1162,10 @@ ol.Map.prototype.handleLayerGroupChanged_ = function() {
this.layerGroupPropertyListenerKeys_ = [
ol.events.listen(
layerGroup, ol.ObjectEventType.PROPERTYCHANGE,
this.handleLayerGroupPropertyChanged_, false, this),
this.handleLayerGroupPropertyChanged_, this),
ol.events.listen(
layerGroup, ol.events.EventType.CHANGE,
this.handleLayerGroupMemberChanged_, false, this)
this.handleLayerGroupMemberChanged_, this)
];
}
this.render();

View File

@@ -201,11 +201,11 @@ ol.MapBrowserEventHandler = function(map) {
this.pointerdownListenerKey_ = ol.events.listen(this.pointerEventHandler_,
ol.pointer.EventType.POINTERDOWN,
this.handlePointerDown_, false, this);
this.handlePointerDown_, this);
this.relayedListenerKey_ = ol.events.listen(this.pointerEventHandler_,
ol.pointer.EventType.POINTERMOVE,
this.relayEvent_, false, this);
this.relayEvent_, this);
};
goog.inherits(ol.MapBrowserEventHandler, ol.events.EventTarget);
@@ -323,10 +323,10 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent)
this.dragListenerKeys_ = [
ol.events.listen(this.documentPointerEventHandler_,
ol.MapBrowserEvent.EventType.POINTERMOVE,
this.handlePointerMove_, false, this),
this.handlePointerMove_, this),
ol.events.listen(this.documentPointerEventHandler_,
ol.MapBrowserEvent.EventType.POINTERUP,
this.handlePointerUp_, false, this),
this.handlePointerUp_, this),
/* Note that the listener for `pointercancel is set up on
* `pointerEventHandler_` and not `documentPointerEventHandler_` like
* the `pointerup` and `pointermove` listeners.
@@ -342,7 +342,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent)
*/
ol.events.listen(this.pointerEventHandler_,
ol.MapBrowserEvent.EventType.POINTERCANCEL,
this.handlePointerUp_, false, this)
this.handlePointerUp_, this)
];
}
};

View File

@@ -94,7 +94,7 @@ ol.Observable.prototype.getRevision = function() {
* @api stable
*/
ol.Observable.prototype.on = function(type, listener, opt_this) {
return ol.events.listen(this, type, listener, false, opt_this);
return ol.events.listen(this, type, listener, opt_this);
};
@@ -107,7 +107,7 @@ ol.Observable.prototype.on = function(type, listener, opt_this) {
* @api stable
*/
ol.Observable.prototype.once = function(type, listener, opt_this) {
return ol.events.listenOnce(this, type, listener, false, opt_this);
return ol.events.listenOnce(this, type, listener, opt_this);
};
@@ -120,7 +120,7 @@ ol.Observable.prototype.once = function(type, listener, opt_this) {
* @api stable
*/
ol.Observable.prototype.un = function(type, listener, opt_this) {
ol.events.unlisten(this, type, listener, false, opt_this);
ol.events.unlisten(this, type, listener, opt_this);
};

View File

@@ -143,23 +143,23 @@ ol.Overlay = function(options) {
ol.events.listen(
this, ol.Object.getChangeEventType(ol.OverlayProperty.ELEMENT),
this.handleElementChanged, false, this);
this.handleElementChanged, this);
ol.events.listen(
this, ol.Object.getChangeEventType(ol.OverlayProperty.MAP),
this.handleMapChanged, false, this);
this.handleMapChanged, this);
ol.events.listen(
this, ol.Object.getChangeEventType(ol.OverlayProperty.OFFSET),
this.handleOffsetChanged, false, this);
this.handleOffsetChanged, this);
ol.events.listen(
this, ol.Object.getChangeEventType(ol.OverlayProperty.POSITION),
this.handlePositionChanged, false, this);
this.handlePositionChanged, this);
ol.events.listen(
this, ol.Object.getChangeEventType(ol.OverlayProperty.POSITIONING),
this.handlePositioningChanged, false, this);
this.handlePositioningChanged, this);
if (options.element !== undefined) {
this.setElement(options.element);
@@ -275,7 +275,7 @@ ol.Overlay.prototype.handleMapChanged = function() {
var map = this.getMap();
if (map) {
this.mapPostrenderListenerKey_ = ol.events.listen(map,
ol.MapEventType.POSTRENDER, this.render, false, this);
ol.MapEventType.POSTRENDER, this.render, this);
this.updatePixelPosition();
var container = this.stopEvent_ ?
map.getOverlayContainerStopEvent() : map.getOverlayContainer();

View File

@@ -176,8 +176,7 @@ ol.pointer.PointerEventHandler.prototype.eventHandler_ = function(inEvent) {
*/
ol.pointer.PointerEventHandler.prototype.addEvents_ = function(events) {
events.forEach(function(eventName) {
ol.events.listen(this.element_, eventName,
this.eventHandler_, false, this);
ol.events.listen(this.element_, eventName, this.eventHandler_, this);
}, this);
};
@@ -189,8 +188,7 @@ ol.pointer.PointerEventHandler.prototype.addEvents_ = function(events) {
*/
ol.pointer.PointerEventHandler.prototype.removeEvents_ = function(events) {
events.forEach(function(e) {
ol.events.unlisten(this.element_, e,
this.eventHandler_, false, this);
ol.events.unlisten(this.element_, e, this.eventHandler_, this);
}, this);
};

View File

@@ -150,7 +150,7 @@ ol.renderer.Layer.prototype.loadImage = function(image) {
imageState == ol.ImageState.LOADING,
'imageState is "idle" or "loading"');
ol.events.listen(image, ol.events.EventType.CHANGE,
this.handleImageChange_, false, this);
this.handleImageChange_, this);
}
if (imageState == ol.ImageState.IDLE) {
image.load();

View File

@@ -256,8 +256,7 @@ ol.renderer.Map.prototype.getLayerRenderer = function(layer) {
var layerRenderer = this.createLayerRenderer(layer);
this.layerRenderers_[layerKey] = layerRenderer;
this.layerRendererListeners_[layerKey] = ol.events.listen(layerRenderer,
ol.events.EventType.CHANGE, this.handleLayerRendererChange_,
false, this);
ol.events.EventType.CHANGE, this.handleLayerRendererChange_, this);
return layerRenderer;
}

View File

@@ -107,9 +107,9 @@ ol.renderer.webgl.Map = function(container, map) {
this.context_ = new ol.webgl.Context(this.canvas_, this.gl_);
ol.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.LOST,
this.handleWebGLContextLost, false, this);
this.handleWebGLContextLost, this);
ol.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.RESTORED,
this.handleWebGLContextRestored, false, this);
this.handleWebGLContextRestored, this);
/**
* @private

View File

@@ -191,7 +191,7 @@ ol.reproj.Image.prototype.load = function() {
this.unlistenSource_();
this.reproject_();
}
}, false, this);
}, this);
this.sourceImage_.load();
}
}

View File

@@ -312,7 +312,7 @@ ol.reproj.Tile.prototype.load = function() {
this.reproject_();
}
}
}, false, this);
}, this);
this.sourcesListenerKeys_.push(sourceListenKey);
}
}, this);

View File

@@ -144,7 +144,7 @@ ol.source.ImageMapGuide.prototype.getImageInternal = function(extent, resolution
this.getAttributions(), imageUrl, this.crossOrigin_,
this.imageLoadFunction_);
ol.events.listen(image, ol.events.EventType.CHANGE,
this.handleImageChange, false, this);
this.handleImageChange, this);
} else {
image = null;
}

View File

@@ -53,7 +53,7 @@ ol.source.ImageStatic = function(options) {
this.imageSize_ = options.imageSize ? options.imageSize : null;
ol.events.listen(this.image_, ol.events.EventType.CHANGE,
this.handleImageChange, false, this);
this.handleImageChange, this);
};
goog.inherits(ol.source.ImageStatic, ol.source.Image);

View File

@@ -90,7 +90,7 @@ ol.source.ImageVector = function(options) {
this.setStyle(options.style);
ol.events.listen(this.source_, ol.events.EventType.CHANGE,
this.handleSourceChange_, undefined, this);
this.handleSourceChange_, this);
};
goog.inherits(ol.source.ImageVector, ol.source.ImageCanvas);

View File

@@ -242,7 +242,7 @@ ol.source.ImageWMS.prototype.getImageInternal = function(extent, resolution, pix
this.renderedRevision_ = this.getRevision();
ol.events.listen(this.image_, ol.events.EventType.CHANGE,
this.handleImageChange, false, this);
this.handleImageChange, this);
return this.image_;

View File

@@ -63,7 +63,7 @@ ol.source.Raster = function(options) {
for (var r = 0, rr = this.renderers_.length; r < rr; ++r) {
ol.events.listen(this.renderers_[r], ol.events.EventType.CHANGE,
this.changed, false, this);
this.changed, this);
}
/**

View File

@@ -198,7 +198,7 @@ ol.source.TileImage.prototype.createTile_ = function(z, x, y, pixelRatio, projec
this.tileLoadFunction);
tile.key = key;
ol.events.listen(tile, ol.events.EventType.CHANGE,
this.handleTileChange, false, this);
this.handleTileChange, this);
return tile;
};

View File

@@ -308,7 +308,7 @@ ol.source.TileUTFGridTile_.prototype.forDataAtCoordinate = function(coordinate,
if (this.state == ol.TileState.IDLE && opt_request === true) {
ol.events.listenOnce(this, ol.events.EventType.CHANGE, function(e) {
callback.call(opt_this, this.getData(coordinate));
}, false, this);
}, this);
this.loadInternal_();
} else {
if (opt_request === true) {

View File

@@ -228,12 +228,10 @@ ol.source.Vector.prototype.setupChangeEvents_ = function(featureKey, feature) {
goog.asserts.assert(!(featureKey in this.featureChangeKeys_),
'key (%s) not yet registered in featureChangeKey', featureKey);
this.featureChangeKeys_[featureKey] = [
ol.events.listen(feature,
ol.events.EventType.CHANGE,
this.handleFeatureChange_, false, this),
ol.events.listen(feature,
ol.ObjectEventType.PROPERTYCHANGE,
this.handleFeatureChange_, false, this)
ol.events.listen(feature, ol.events.EventType.CHANGE,
this.handleFeatureChange_, this),
ol.events.listen(feature, ol.ObjectEventType.PROPERTYCHANGE,
this.handleFeatureChange_, this)
];
};
@@ -352,7 +350,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
this.addFeature(feature);
modifyingCollection = false;
}
}, false, this);
}, this);
ol.events.listen(collection, ol.CollectionEventType.REMOVE,
function(evt) {
if (!modifyingCollection) {
@@ -362,7 +360,7 @@ ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
this.removeFeature(feature);
modifyingCollection = false;
}
}, false, this);
}, this);
this.featuresCollection_ = collection;
};

View File

@@ -80,7 +80,7 @@ ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projectio
tileUrl !== undefined ? tileUrl : '',
this.format_, this.tileLoadFunction);
ol.events.listen(tile, ol.events.EventType.CHANGE,
this.handleTileChange, false, this);
this.handleTileChange, this);
this.tileCache.set(tileCoordKey, tile);
return tile;

View File

@@ -346,7 +346,7 @@ ol.style.Icon.prototype.getSize = function() {
*/
ol.style.Icon.prototype.listenImageChange = function(listener, thisArg) {
return ol.events.listen(this.iconImage_, ol.events.EventType.CHANGE,
listener, false, thisArg);
listener, thisArg);
};
@@ -367,7 +367,7 @@ ol.style.Icon.prototype.load = function() {
*/
ol.style.Icon.prototype.unlistenImageChange = function(listener, thisArg) {
ol.events.unlisten(this.iconImage_, ol.events.EventType.CHANGE,
listener, false, thisArg);
listener, thisArg);
};
@@ -586,9 +586,9 @@ ol.style.IconImage_.prototype.load = function() {
this.imageState_ = ol.style.ImageState.LOADING;
this.imageListenerKeys_ = [
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
this.handleImageError_, false, this),
this.handleImageError_, this),
ol.events.listenOnce(this.image_, ol.events.EventType.LOAD,
this.handleImageLoad_, false, this)
this.handleImageLoad_, this)
];
try {
this.image_.src = this.src_;

View File

@@ -72,7 +72,7 @@ ol.TileQueue.prototype.enqueue = function(element) {
if (added) {
var tile = element[0];
ol.events.listen(tile, ol.events.EventType.CHANGE,
this.handleTileChange, false, this);
this.handleTileChange, this);
}
return added;
};
@@ -96,7 +96,7 @@ ol.TileQueue.prototype.handleTileChange = function(event) {
if (state === ol.TileState.LOADED || state === ol.TileState.ERROR ||
state === ol.TileState.EMPTY) {
ol.events.unlisten(tile, ol.events.EventType.CHANGE,
this.handleTileChange, false, this);
this.handleTileChange, this);
var tileKey = tile.getKey();
if (tileKey in this.tilesLoadingKeys_) {
delete this.tilesLoadingKeys_[tileKey];

View File

@@ -96,9 +96,9 @@ ol.webgl.Context = function(canvas, gl) {
}
ol.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.LOST,
this.handleWebGLContextLost, false, this);
this.handleWebGLContextLost, this);
ol.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.RESTORED,
this.handleWebGLContextRestored, false, this);
this.handleWebGLContextRestored, this);
};

View File

@@ -56,14 +56,14 @@ describe('ol.events', function() {
useCapture: false
};
var listenerArray = [listenerObj];
var result = ol.events.findListener_(listenerArray, listener, false);
var result = ol.events.findListener_(listenerArray, listener);
expect(result).to.be(listenerObj);
result = ol.events.findListener_(listenerArray, listener, false, bindTo);
result = ol.events.findListener_(listenerArray, listener, bindTo);
expect(result).to.be(undefined);
listenerObj.bindTo = bindTo;
result = ol.events.findListener_(listenerArray, listener, false);
result = ol.events.findListener_(listenerArray, listener);
expect(result).to.be(undefined);
result = ol.events.findListener_(listenerArray, listener, false, bindTo);
result = ol.events.findListener_(listenerArray, listener, bindTo);
expect(result).to.be(listenerObj);
});
});
@@ -105,9 +105,9 @@ describe('ol.events', function() {
});
it('only treats listeners as same when all args are equal', function() {
var listener = function() {};
ol.events.listen(target, 'foo', listener, false);
ol.events.listen(target, 'foo', listener, true);
ol.events.listen(target, 'foo', listener, true, {});
ol.events.listen(target, 'foo', listener, {}, false);
ol.events.listen(target, 'foo', listener, {}, true);
ol.events.listen(target, 'foo', listener, undefined, true);
expect(add.callCount).to.be(3);
});
});
@@ -187,16 +187,18 @@ describe('ol.events', function() {
it('works despite different meaning of the useCapture arg', function() {
var target = new ol.events.EventTarget();
var listener = function() {};
var key1 = ol.events.listen(target, 'foo', listener, false);
var key1 = ol.events.listen(target, 'foo', listener, undefined, undefined,
false);
expect(target.getListeners('foo')).to.eql([key1.boundListener]);
var key2 = ol.events.listen(target, 'foo', listener, true);
var key2 = ol.events.listen(target, 'foo', listener, undefined, undefined,
true);
expect(target.getListeners('foo')).to.eql(
[key1.boundListener, key2.boundListener]);
});
it('because the created bound listeners are different', function() {
var listener = function() {};
var key1 = ol.events.listen(target, 'foo', listener, false);
var key2 = ol.events.listen(target, 'foo', listener, true);
var key1 = ol.events.listen(target, 'foo', listener, {}, false);
var key2 = ol.events.listen(target, 'foo', listener, {}, true);
expect(key1.boundListener).to.not.equal(key2.boundListener);
});
});

View File

@@ -144,7 +144,7 @@ describe('ol.events.EventTarget', function() {
describe('#dispose()', function() {
it('cleans up foreign references', function() {
ol.events.listen(eventTarget, 'foo', spy1, false, document);
ol.events.listen(eventTarget, 'foo', spy1, document);
expect(eventTarget.hasListener('foo')).to.be(true);
eventTarget.dispose();
expect(eventTarget.hasListener('foo')).to.be(false);