Rename _ol_CollectionEventType_ to CollectionEventType

This commit is contained in:
Frederic Junod
2017-12-18 10:39:52 +01:00
parent 4275a66b49
commit 64e7ae6eb8
8 changed files with 39 additions and 39 deletions

View File

@@ -3,7 +3,7 @@
*/ */
import {inherits} from './index.js'; import {inherits} from './index.js';
import AssertionError from './AssertionError.js'; import AssertionError from './AssertionError.js';
import _ol_CollectionEventType_ from './CollectionEventType.js'; import CollectionEventType from './CollectionEventType.js';
import _ol_Object_ from './Object.js'; import _ol_Object_ from './Object.js';
import Event from './events/Event.js'; import Event from './events/Event.js';
@@ -158,7 +158,7 @@ _ol_Collection_.prototype.insertAt = function(index, elem) {
this.array_.splice(index, 0, elem); this.array_.splice(index, 0, elem);
this.updateLength_(); this.updateLength_();
this.dispatchEvent( this.dispatchEvent(
new _ol_Collection_.Event(_ol_CollectionEventType_.ADD, elem)); new _ol_Collection_.Event(CollectionEventType.ADD, elem));
}; };
@@ -219,7 +219,7 @@ _ol_Collection_.prototype.removeAt = function(index) {
this.array_.splice(index, 1); this.array_.splice(index, 1);
this.updateLength_(); this.updateLength_();
this.dispatchEvent( this.dispatchEvent(
new _ol_Collection_.Event(_ol_CollectionEventType_.REMOVE, prev)); new _ol_Collection_.Event(CollectionEventType.REMOVE, prev));
return prev; return prev;
}; };
@@ -239,9 +239,9 @@ _ol_Collection_.prototype.setAt = function(index, elem) {
var prev = this.array_[index]; var prev = this.array_[index];
this.array_[index] = elem; this.array_[index] = elem;
this.dispatchEvent( this.dispatchEvent(
new _ol_Collection_.Event(_ol_CollectionEventType_.REMOVE, prev)); new _ol_Collection_.Event(CollectionEventType.REMOVE, prev));
this.dispatchEvent( this.dispatchEvent(
new _ol_Collection_.Event(_ol_CollectionEventType_.ADD, elem)); new _ol_Collection_.Event(CollectionEventType.ADD, elem));
} else { } else {
var j; var j;
for (j = n; j < index; ++j) { for (j = n; j < index; ++j) {

View File

@@ -3,7 +3,7 @@
*/ */
import {getUid, inherits} from './index.js'; import {getUid, inherits} from './index.js';
import _ol_Collection_ from './Collection.js'; import _ol_Collection_ from './Collection.js';
import _ol_CollectionEventType_ from './CollectionEventType.js'; import CollectionEventType from './CollectionEventType.js';
import MapBrowserEvent from './MapBrowserEvent.js'; import MapBrowserEvent from './MapBrowserEvent.js';
import MapBrowserEventHandler from './MapBrowserEventHandler.js'; import MapBrowserEventHandler from './MapBrowserEventHandler.js';
import MapBrowserEventType from './MapBrowserEventType.js'; import MapBrowserEventType from './MapBrowserEventType.js';
@@ -359,7 +359,7 @@ var _ol_PluggableMap_ = function(options) {
control.setMap(this); control.setMap(this);
}, this); }, this);
_ol_events_.listen(this.controls, _ol_CollectionEventType_.ADD, _ol_events_.listen(this.controls, CollectionEventType.ADD,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.Collection.Event} event Collection event.
*/ */
@@ -367,7 +367,7 @@ var _ol_PluggableMap_ = function(options) {
event.element.setMap(this); event.element.setMap(this);
}, this); }, this);
_ol_events_.listen(this.controls, _ol_CollectionEventType_.REMOVE, _ol_events_.listen(this.controls, CollectionEventType.REMOVE,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.Collection.Event} event Collection event.
*/ */
@@ -384,7 +384,7 @@ var _ol_PluggableMap_ = function(options) {
interaction.setMap(this); interaction.setMap(this);
}, this); }, this);
_ol_events_.listen(this.interactions, _ol_CollectionEventType_.ADD, _ol_events_.listen(this.interactions, CollectionEventType.ADD,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.Collection.Event} event Collection event.
*/ */
@@ -392,7 +392,7 @@ var _ol_PluggableMap_ = function(options) {
event.element.setMap(this); event.element.setMap(this);
}, this); }, this);
_ol_events_.listen(this.interactions, _ol_CollectionEventType_.REMOVE, _ol_events_.listen(this.interactions, CollectionEventType.REMOVE,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.Collection.Event} event Collection event.
*/ */
@@ -402,7 +402,7 @@ var _ol_PluggableMap_ = function(options) {
this.overlays_.forEach(this.addOverlayInternal_, this); this.overlays_.forEach(this.addOverlayInternal_, this);
_ol_events_.listen(this.overlays_, _ol_CollectionEventType_.ADD, _ol_events_.listen(this.overlays_, CollectionEventType.ADD,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.Collection.Event} event Collection event.
*/ */
@@ -410,7 +410,7 @@ var _ol_PluggableMap_ = function(options) {
this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element)); this.addOverlayInternal_(/** @type {ol.Overlay} */ (event.element));
}, this); }, this);
_ol_events_.listen(this.overlays_, _ol_CollectionEventType_.REMOVE, _ol_events_.listen(this.overlays_, CollectionEventType.REMOVE,
/** /**
* @param {ol.Collection.Event} event Collection event. * @param {ol.Collection.Event} event Collection event.
*/ */

View File

@@ -3,7 +3,7 @@
*/ */
import {getUid, inherits} from '../index.js'; import {getUid, inherits} from '../index.js';
import _ol_Collection_ from '../Collection.js'; import _ol_Collection_ from '../Collection.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js'; import CollectionEventType from '../CollectionEventType.js';
import _ol_Feature_ from '../Feature.js'; import _ol_Feature_ from '../Feature.js';
import MapBrowserEventType from '../MapBrowserEventType.js'; import MapBrowserEventType from '../MapBrowserEventType.js';
import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js'; import MapBrowserPointerEvent from '../MapBrowserPointerEvent.js';
@@ -214,9 +214,9 @@ var _ol_interaction_Modify_ = function(options) {
this.features_ = features; this.features_ = features;
this.features_.forEach(this.addFeature_, this); this.features_.forEach(this.addFeature_, this);
_ol_events_.listen(this.features_, _ol_CollectionEventType_.ADD, _ol_events_.listen(this.features_, CollectionEventType.ADD,
this.handleFeatureAdd_, this); this.handleFeatureAdd_, this);
_ol_events_.listen(this.features_, _ol_CollectionEventType_.REMOVE, _ol_events_.listen(this.features_, CollectionEventType.REMOVE,
this.handleFeatureRemove_, this); this.handleFeatureRemove_, this);
/** /**

View File

@@ -2,7 +2,7 @@
* @module ol/interaction/Select * @module ol/interaction/Select
*/ */
import {getUid, inherits} from '../index.js'; import {getUid, inherits} from '../index.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js'; import CollectionEventType from '../CollectionEventType.js';
import _ol_array_ from '../array.js'; import _ol_array_ from '../array.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import Event from '../events/Event.js'; import Event from '../events/Event.js';
@@ -135,9 +135,9 @@ var _ol_interaction_Select_ = function(opt_options) {
this.featureLayerAssociation_ = {}; this.featureLayerAssociation_ = {};
var features = this.featureOverlay_.getSource().getFeaturesCollection(); var features = this.featureOverlay_.getSource().getFeaturesCollection();
_ol_events_.listen(features, _ol_CollectionEventType_.ADD, _ol_events_.listen(features, CollectionEventType.ADD,
this.addFeature_, this); this.addFeature_, this);
_ol_events_.listen(features, _ol_CollectionEventType_.REMOVE, _ol_events_.listen(features, CollectionEventType.REMOVE,
this.removeFeature_, this); this.removeFeature_, this);
}; };

View File

@@ -3,7 +3,7 @@
*/ */
import {getUid, inherits} from '../index.js'; import {getUid, inherits} from '../index.js';
import _ol_Collection_ from '../Collection.js'; import _ol_Collection_ from '../Collection.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js'; import CollectionEventType from '../CollectionEventType.js';
import _ol_coordinate_ from '../coordinate.js'; import _ol_coordinate_ from '../coordinate.js';
import _ol_events_ from '../events.js'; import _ol_events_ from '../events.js';
import EventType from '../events/EventType.js'; import EventType from '../events/EventType.js';
@@ -309,9 +309,9 @@ _ol_interaction_Snap_.prototype.setMap = function(map) {
if (map) { if (map) {
if (this.features_) { if (this.features_) {
keys.push( keys.push(
_ol_events_.listen(this.features_, _ol_CollectionEventType_.ADD, _ol_events_.listen(this.features_, CollectionEventType.ADD,
this.handleFeatureAdd_, this), this.handleFeatureAdd_, this),
_ol_events_.listen(this.features_, _ol_CollectionEventType_.REMOVE, _ol_events_.listen(this.features_, CollectionEventType.REMOVE,
this.handleFeatureRemove_, this) this.handleFeatureRemove_, this)
); );
} else if (this.source_) { } else if (this.source_) {

View File

@@ -3,7 +3,7 @@
*/ */
import {getUid, inherits} from '../index.js'; import {getUid, inherits} from '../index.js';
import _ol_Collection_ from '../Collection.js'; import _ol_Collection_ from '../Collection.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js'; import CollectionEventType from '../CollectionEventType.js';
import _ol_Object_ from '../Object.js'; import _ol_Object_ from '../Object.js';
import _ol_ObjectEventType_ from '../ObjectEventType.js'; import _ol_ObjectEventType_ from '../ObjectEventType.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
@@ -89,9 +89,9 @@ _ol_layer_Group_.prototype.handleLayersChanged_ = function(event) {
var layers = this.getLayers(); var layers = this.getLayers();
this.layersListenerKeys_.push( this.layersListenerKeys_.push(
_ol_events_.listen(layers, _ol_CollectionEventType_.ADD, _ol_events_.listen(layers, CollectionEventType.ADD,
this.handleLayersAdd_, this), this.handleLayersAdd_, this),
_ol_events_.listen(layers, _ol_CollectionEventType_.REMOVE, _ol_events_.listen(layers, CollectionEventType.REMOVE,
this.handleLayersRemove_, this)); this.handleLayersRemove_, this));
for (var id in this.listenerKeys_) { for (var id in this.listenerKeys_) {

View File

@@ -4,7 +4,7 @@
import {getUid, inherits, nullFunction} from '../index.js'; import {getUid, inherits, nullFunction} from '../index.js';
import _ol_Collection_ from '../Collection.js'; import _ol_Collection_ from '../Collection.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js'; import CollectionEventType from '../CollectionEventType.js';
import _ol_ObjectEventType_ from '../ObjectEventType.js'; import _ol_ObjectEventType_ from '../ObjectEventType.js';
import _ol_array_ from '../array.js'; import _ol_array_ from '../array.js';
import {assert} from '../asserts.js'; import {assert} from '../asserts.js';
@@ -314,7 +314,7 @@ _ol_source_Vector_.prototype.bindFeaturesCollection_ = function(collection) {
modifyingCollection = false; modifyingCollection = false;
} }
}); });
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, _ol_events_.listen(collection, CollectionEventType.ADD,
function(evt) { function(evt) {
if (!modifyingCollection) { if (!modifyingCollection) {
modifyingCollection = true; modifyingCollection = true;
@@ -322,7 +322,7 @@ _ol_source_Vector_.prototype.bindFeaturesCollection_ = function(collection) {
modifyingCollection = false; modifyingCollection = false;
} }
}, this); }, this);
_ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, _ol_events_.listen(collection, CollectionEventType.REMOVE,
function(evt) { function(evt) {
if (!modifyingCollection) { if (!modifyingCollection) {
modifyingCollection = true; modifyingCollection = true;

View File

@@ -1,6 +1,6 @@
import _ol_events_ from '../../../src/ol/events.js'; import _ol_events_ from '../../../src/ol/events.js';
import _ol_Collection_ from '../../../src/ol/Collection.js'; import _ol_Collection_ from '../../../src/ol/Collection.js';
import _ol_CollectionEventType_ from '../../../src/ol/CollectionEventType.js'; import CollectionEventType from '../../../src/ol/CollectionEventType.js';
describe('ol.collection', function() { describe('ol.collection', function() {
@@ -129,7 +129,7 @@ describe('ol.collection', function() {
it('fires a remove event', function() { it('fires a remove event', function() {
var collection = new _ol_Collection_([0, 1, 2]); var collection = new _ol_Collection_([0, 1, 2]);
var cb = sinon.spy(); var cb = sinon.spy();
_ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb); _ol_events_.listen(collection, CollectionEventType.REMOVE, cb);
expect(collection.remove(1)).to.eql(1); expect(collection.remove(1)).to.eql(1);
expect(cb).to.be.called(); expect(cb).to.be.called();
expect(cb.lastCall.args[0].element).to.eql(1); expect(cb.lastCall.args[0].element).to.eql(1);
@@ -152,11 +152,11 @@ describe('ol.collection', function() {
it('does dispatch events', function() { it('does dispatch events', function() {
var collection = new _ol_Collection_(['a', 'b']); var collection = new _ol_Collection_(['a', 'b']);
var added, removed; var added, removed;
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { _ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
added = e.element; added = e.element;
}); });
_ol_events_.listen( _ol_events_.listen(
collection, _ol_CollectionEventType_.REMOVE, function(e) { collection, CollectionEventType.REMOVE, function(e) {
removed = e.element; removed = e.element;
}); });
collection.setAt(1, 1); collection.setAt(1, 1);
@@ -170,7 +170,7 @@ describe('ol.collection', function() {
var collection = new _ol_Collection_(['a']); var collection = new _ol_Collection_(['a']);
var removed; var removed;
_ol_events_.listen( _ol_events_.listen(
collection, _ol_CollectionEventType_.REMOVE, function(e) { collection, CollectionEventType.REMOVE, function(e) {
removed = e.element; removed = e.element;
}); });
collection.pop(); collection.pop();
@@ -183,7 +183,7 @@ describe('ol.collection', function() {
var collection = new _ol_Collection_([0, 2]); var collection = new _ol_Collection_([0, 2]);
var added; var added;
_ol_events_.listen( _ol_events_.listen(
collection, _ol_CollectionEventType_.ADD, function(e) { collection, CollectionEventType.ADD, function(e) {
added = e.element; added = e.element;
}); });
collection.insertAt(1, 1); collection.insertAt(1, 1);
@@ -195,7 +195,7 @@ describe('ol.collection', function() {
it('triggers events properly', function() { it('triggers events properly', function() {
var added = []; var added = [];
_ol_events_.listen( _ol_events_.listen(
collection, _ol_CollectionEventType_.ADD, function(e) { collection, CollectionEventType.ADD, function(e) {
added.push(e.element); added.push(e.element);
}); });
collection.setAt(2, 0); collection.setAt(2, 0);
@@ -244,7 +244,7 @@ describe('ol.collection', function() {
it('triggers add when pushing', function() { it('triggers add when pushing', function() {
var collection = new _ol_Collection_(); var collection = new _ol_Collection_();
var elem; var elem;
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { _ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
elem = e.element; elem = e.element;
}); });
var length = collection.push(1); var length = collection.push(1);
@@ -261,8 +261,8 @@ describe('ol.collection', function() {
}); });
describe('setAt', function() { describe('setAt', function() {
it('triggers remove', function() { it('triggers remove', function() {
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, cb1); _ol_events_.listen(collection, CollectionEventType.ADD, cb1);
_ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb2); _ol_events_.listen(collection, CollectionEventType.REMOVE, cb2);
collection.setAt(0, 2); collection.setAt(0, 2);
expect(cb2.lastCall.args[0].element).to.eql(1); expect(cb2.lastCall.args[0].element).to.eql(1);
expect(cb1.lastCall.args[0].element).to.eql(2); expect(cb1.lastCall.args[0].element).to.eql(2);
@@ -270,7 +270,7 @@ describe('ol.collection', function() {
}); });
describe('pop', function() { describe('pop', function() {
it('triggers remove', function() { it('triggers remove', function() {
_ol_events_.listen(collection, _ol_CollectionEventType_.REMOVE, cb1); _ol_events_.listen(collection, CollectionEventType.REMOVE, cb1);
collection.pop(); collection.pop();
expect(cb1.lastCall.args[0].element).to.eql(1); expect(cb1.lastCall.args[0].element).to.eql(1);
}); });
@@ -288,7 +288,7 @@ describe('ol.collection', function() {
it('fires events', function() { it('fires events', function() {
var collection = new _ol_Collection_(); var collection = new _ol_Collection_();
var elems = []; var elems = [];
_ol_events_.listen(collection, _ol_CollectionEventType_.ADD, function(e) { _ol_events_.listen(collection, CollectionEventType.ADD, function(e) {
elems.push(e.element); elems.push(e.element);
}); });
collection.extend([1, 2]); collection.extend([1, 2]);