diff --git a/config/jsdoc/api/index.md b/config/jsdoc/api/index.md index 78f996ec6b..4fbb628855 100644 --- a/config/jsdoc/api/index.md +++ b/config/jsdoc/api/index.md @@ -34,7 +34,7 @@ Interactions for [vector features](ol.Feature.html) ProjectionsObservable objectsOther components

All coordinates and extents need to be provided in view projection (default: EPSG:3857). To transform, use [ol.proj.transform()](ol.proj.html#.transform) and [ol.proj.transformExtent()](ol.proj.html#.transformExtent).

[ol.proj](ol.proj.html) -

Changes to all [ol.Objects](ol.Object.html) can observed by calling the [object.on('propertychange')](ol.Object.html#on) method. Listeners receive an [ol.ObjectEvent](ol.ObjectEvent.html) with information on the changed property and old value.

+

Changes to all [ol.Objects](ol.Object.html) can observed by calling the [object.on('propertychange')](ol.Object.html#on) method. Listeners receive an [ol.Object.Event](ol.Object.Event.html) with information on the changed property and old value.

[ol.DeviceOrientation](ol.DeviceOrientation.html)
[ol.Geolocation](ol.Geolocation.html)
[ol.Overlay](ol.Overlay.html)
diff --git a/config/jsdoc/api/plugins/observable.js b/config/jsdoc/api/plugins/observable.js index b3bc7f3925..e662d81626 100644 --- a/config/jsdoc/api/plugins/observable.js +++ b/config/jsdoc/api/plugins/observable.js @@ -47,7 +47,7 @@ exports.handlers = { if (!cls.fires) { cls.fires = []; } - event = 'ol.ObjectEvent#event:change:' + name; + event = 'ol.Object.Event#event:change:' + name; if (cls.fires.indexOf(event) == -1) { cls.fires.push(event); } diff --git a/config/jsdoc/api/template/tmpl/observables.tmpl b/config/jsdoc/api/template/tmpl/observables.tmpl index 38e257270b..e6859aad70 100644 --- a/config/jsdoc/api/template/tmpl/observables.tmpl +++ b/config/jsdoc/api/template/tmpl/observables.tmpl @@ -8,7 +8,7 @@ Name Type Settable - ol.ObjectEvent type + ol.Object.Event type Description diff --git a/externs/oli.js b/externs/oli.js index eadebe516a..c45c80b969 100644 --- a/externs/oli.js +++ b/externs/oli.js @@ -109,22 +109,28 @@ oli.ModifyEvent.prototype.features; oli.ModifyEvent.prototype.mapBrowserEvent; +/** + * @type {Object} + */ +oli.Object; + + /** * @interface */ -oli.ObjectEvent = function() {}; +oli.Object.Event = function() {}; /** * @type {string} */ -oli.ObjectEvent.prototype.key; +oli.Object.Event.prototype.key; /** * @type {*} */ -oli.ObjectEvent.prototype.oldValue; +oli.Object.Event.prototype.oldValue; /** diff --git a/src/ol/control/overviewmap.js b/src/ol/control/overviewmap.js index 791a358264..681d6eddc9 100644 --- a/src/ol/control/overviewmap.js +++ b/src/ol/control/overviewmap.js @@ -187,7 +187,7 @@ ol.control.OverviewMap.prototype.setMap = function(map) { /** * Handle map property changes. This only deals with changes to the map's view. - * @param {ol.ObjectEvent} event The propertychange event. + * @param {ol.Object.Event} event The propertychange event. * @private */ ol.control.OverviewMap.prototype.handleMapPropertyChange_ = function(event) { diff --git a/src/ol/object.js b/src/ol/object.js index fb1d63e260..2e1f27bd46 100644 --- a/src/ol/object.js +++ b/src/ol/object.js @@ -1,5 +1,4 @@ goog.provide('ol.Object'); -goog.provide('ol.ObjectEvent'); goog.require('ol'); goog.require('ol.Observable'); @@ -7,39 +6,6 @@ goog.require('ol.events.Event'); goog.require('ol.obj'); -/** - * @classdesc - * Events emitted by {@link ol.Object} instances are instances of this type. - * - * @param {string} type The event type. - * @param {string} key The property name. - * @param {*} oldValue The old value for `key`. - * @extends {ol.events.Event} - * @implements {oli.ObjectEvent} - * @constructor - */ -ol.ObjectEvent = function(type, key, oldValue) { - ol.events.Event.call(this, type); - - /** - * The name of the property whose value is changing. - * @type {string} - * @api stable - */ - this.key = key; - - /** - * The old value. To get the new value use `e.target.get(e.key)` where - * `e` is the event object. - * @type {*} - * @api stable - */ - this.oldValue = oldValue; - -}; -ol.inherits(ol.ObjectEvent, ol.events.Event); - - /** * @classdesc * Abstract base class; normally only used for creating subclasses and not @@ -82,7 +48,7 @@ ol.inherits(ol.ObjectEvent, ol.events.Event); * @constructor * @extends {ol.Observable} * @param {Object.=} opt_values An object with key-value pairs. - * @fires ol.ObjectEvent + * @fires ol.Object.Event * @api */ ol.Object = function(opt_values) { @@ -167,9 +133,9 @@ ol.Object.prototype.getProperties = function() { ol.Object.prototype.notify = function(key, oldValue) { var eventType; eventType = ol.Object.getChangeEventType(key); - this.dispatchEvent(new ol.ObjectEvent(eventType, key, oldValue)); + this.dispatchEvent(new ol.Object.Event(eventType, key, oldValue)); eventType = ol.Object.EventType.PROPERTYCHANGE; - this.dispatchEvent(new ol.ObjectEvent(eventType, key, oldValue)); + this.dispatchEvent(new ol.Object.Event(eventType, key, oldValue)); }; @@ -231,8 +197,41 @@ ol.Object.prototype.unset = function(key, opt_silent) { ol.Object.EventType = { /** * Triggered when a property is changed. - * @event ol.ObjectEvent#propertychange + * @event ol.Object.Event#propertychange * @api stable */ PROPERTYCHANGE: 'propertychange' }; + + +/** + * @classdesc + * Events emitted by {@link ol.Object} instances are instances of this type. + * + * @param {string} type The event type. + * @param {string} key The property name. + * @param {*} oldValue The old value for `key`. + * @extends {ol.events.Event} + * @implements {oli.Object.Event} + * @constructor + */ +ol.Object.Event = function(type, key, oldValue) { + ol.events.Event.call(this, type); + + /** + * The name of the property whose value is changing. + * @type {string} + * @api stable + */ + this.key = key; + + /** + * The old value. To get the new value use `e.target.get(e.key)` where + * `e` is the event object. + * @type {*} + * @api stable + */ + this.oldValue = oldValue; + +}; +ol.inherits(ol.Object.Event, ol.events.Event);