From c6a9bc66d6d7e6afb4f933243abee734075d2c43 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Wed, 7 Sep 2016 16:54:28 +0200 Subject: [PATCH] Rename ol.interaction.ModifyEvent to ol.interaction.Modify.Event --- changelog/upgrade-notes.md | 1 + src/ol/interaction/modify.js | 81 ++++++++++++------------- test/spec/ol/interaction/modify.test.js | 9 ++- 3 files changed, 45 insertions(+), 46 deletions(-) diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 776ee5ec4c..dca6fc5f64 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -24,6 +24,7 @@ A number of internal types have been renamed. This will not affect those who us * rename `ol.interaction.ExtentEventType` to `ol.interaction.Extent.EventType` * rename `ol.interaction.DragAndDropEvent` to `ol.interaction.DragAndDrop.Event` * rename `ol.interaction.DragAndDropEventType` to `ol.interaction.DragAndDrop.EventType` + * rename `ol.interaction.ModifyEvent` to `ol.interaction.Modify.Event` * rename `ol.interaction.SelectEvent` to `ol.interaction.Select.Event` * rename `ol.interaction.SelectEventType` to `ol.interaction.Select.EventType` * rename `ol.interaction.TranslateEvent` to `ol.interaction.Translate.Event` diff --git a/src/ol/interaction/modify.js b/src/ol/interaction/modify.js index 4b93f3399d..8b6f1fbc30 100644 --- a/src/ol/interaction/modify.js +++ b/src/ol/interaction/modify.js @@ -1,5 +1,4 @@ goog.provide('ol.interaction.Modify'); -goog.provide('ol.interaction.ModifyEvent'); goog.require('ol'); goog.require('ol.Collection'); @@ -29,53 +28,19 @@ goog.require('ol.style.Style'); ol.ModifyEventType = { /** * Triggered upon feature modification start - * @event ol.interaction.ModifyEvent#modifystart + * @event ol.interaction.Modify.Event#modifystart * @api */ MODIFYSTART: 'modifystart', /** * Triggered upon feature modification end - * @event ol.interaction.ModifyEvent#modifyend + * @event ol.interaction.Modify.Event#modifyend * @api */ MODIFYEND: 'modifyend' }; -/** - * @classdesc - * Events emitted by {@link ol.interaction.Modify} instances are instances of - * this type. - * - * @constructor - * @extends {ol.events.Event} - * @implements {oli.ModifyEvent} - * @param {ol.ModifyEventType} type Type. - * @param {ol.Collection.} features The features modified. - * @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated - * {@link ol.MapBrowserPointerEvent}. - */ -ol.interaction.ModifyEvent = function(type, features, mapBrowserPointerEvent) { - - ol.events.Event.call(this, type); - - /** - * The features being modified. - * @type {ol.Collection.} - * @api - */ - this.features = features; - - /** - * Associated {@link ol.MapBrowserEvent}. - * @type {ol.MapBrowserEvent} - * @api - */ - this.mapBrowserEvent = mapBrowserPointerEvent; -}; -ol.inherits(ol.interaction.ModifyEvent, ol.events.Event); - - /** * @classdesc * Interaction for modifying feature geometries. @@ -83,7 +48,7 @@ ol.inherits(ol.interaction.ModifyEvent, ol.events.Event); * @constructor * @extends {ol.interaction.Pointer} * @param {olx.interaction.ModifyOptions} options Options. - * @fires ol.interaction.ModifyEvent + * @fires ol.interaction.Modify.Event * @api */ ol.interaction.Modify = function(options) { @@ -267,7 +232,7 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) { ol.interaction.Modify.prototype.willModifyFeatures_ = function(evt) { if (!this.modified_) { this.modified_ = true; - this.dispatchEvent(new ol.interaction.ModifyEvent( + this.dispatchEvent(new ol.interaction.Modify.Event( ol.ModifyEventType.MODIFYSTART, this.features_, evt)); } }; @@ -674,7 +639,7 @@ ol.interaction.Modify.handleUpEvent_ = function(evt) { segmentData); } if (this.modified_) { - this.dispatchEvent(new ol.interaction.ModifyEvent( + this.dispatchEvent(new ol.interaction.Modify.Event( ol.ModifyEventType.MODIFYEND, this.features_, evt)); this.modified_ = false; } @@ -872,7 +837,7 @@ ol.interaction.Modify.prototype.removePoint = function() { var evt = this.lastPointerEvent_; this.willModifyFeatures_(evt); handled = this.removeVertex_(); - this.dispatchEvent(new ol.interaction.ModifyEvent( + this.dispatchEvent(new ol.interaction.Modify.Event( ol.ModifyEventType.MODIFYEND, this.features_, evt)); this.modified_ = false; } @@ -1040,3 +1005,37 @@ ol.interaction.Modify.getDefaultStyleFunction = function() { return style[ol.geom.GeometryType.POINT]; }; }; + + +/** + * @classdesc + * Events emitted by {@link ol.interaction.Modify} instances are instances of + * this type. + * + * @constructor + * @extends {ol.events.Event} + * @implements {oli.ModifyEvent} + * @param {ol.ModifyEventType} type Type. + * @param {ol.Collection.} features The features modified. + * @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Associated + * {@link ol.MapBrowserPointerEvent}. + */ +ol.interaction.Modify.Event = function(type, features, mapBrowserPointerEvent) { + + ol.events.Event.call(this, type); + + /** + * The features being modified. + * @type {ol.Collection.} + * @api + */ + this.features = features; + + /** + * Associated {@link ol.MapBrowserEvent}. + * @type {ol.MapBrowserEvent} + * @api + */ + this.mapBrowserEvent = mapBrowserPointerEvent; +}; +ol.inherits(ol.interaction.Modify.Event, ol.events.Event); diff --git a/test/spec/ol/interaction/modify.test.js b/test/spec/ol/interaction/modify.test.js index a21d2b50c5..66b91f7209 100644 --- a/test/spec/ol/interaction/modify.test.js +++ b/test/spec/ol/interaction/modify.test.js @@ -11,7 +11,6 @@ goog.require('ol.geom.LineString'); goog.require('ol.geom.Point'); goog.require('ol.geom.Polygon'); goog.require('ol.interaction.Modify'); -goog.require('ol.interaction.ModifyEvent'); goog.require('ol.layer.Vector'); goog.require('ol.pointer.PointerEvent'); goog.require('ol.source.Vector'); @@ -102,7 +101,7 @@ describe('ol.interaction.Modify', function() { * modifications. Helper function to * @param {ol.Feature} feature Modified feature. * @param {ol.interaction.Modify} interaction The interaction. - * @return {Array} events + * @return {Array} events */ function trackEvents(feature, interaction) { var events = []; @@ -122,7 +121,7 @@ describe('ol.interaction.Modify', function() { * Validates the event array to verify proper event sequence. Checks * that first and last event are correct ModifyEvents and that feature * modifications event are in between. - * @param {Array} events The events. + * @param {Array} events The events. * @param {Array} features The features. */ function validateEvents(events, features) { @@ -131,11 +130,11 @@ describe('ol.interaction.Modify', function() { var endevent = events[events.length - 1]; // first event should be modifystary - expect(startevent).to.be.an(ol.interaction.ModifyEvent); + expect(startevent).to.be.an(ol.interaction.Modify.Event); expect(startevent.type).to.eql('modifystart'); // last event should be modifyend - expect(endevent).to.be.an(ol.interaction.ModifyEvent); + expect(endevent).to.be.an(ol.interaction.Modify.Event); expect(endevent.type).to.eql('modifyend'); // make sure we get change events to events array