Rename _ol_MapBrowserEventType_ to MapBrowserEventType

This commit is contained in:
Marc Jansen
2017-12-15 09:43:26 +01:00
committed by Frederic Junod
parent 465c248572
commit 039bde29cc
9 changed files with 49 additions and 49 deletions

View File

@@ -3,7 +3,7 @@
*/
import {inherits} from './index.js';
import _ol_has_ from './has.js';
import _ol_MapBrowserEventType_ from './MapBrowserEventType.js';
import MapBrowserEventType from './MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from './MapBrowserPointerEvent.js';
import _ol_events_ from './events.js';
import _ol_events_EventTarget_ from './events/EventTarget.js';
@@ -119,21 +119,21 @@ inherits(_ol_MapBrowserEventHandler_, _ol_events_EventTarget_);
*/
_ol_MapBrowserEventHandler_.prototype.emulateClick_ = function(pointerEvent) {
var newEvent = new _ol_MapBrowserPointerEvent_(
_ol_MapBrowserEventType_.CLICK, this.map_, pointerEvent);
MapBrowserEventType.CLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
if (this.clickTimeoutId_ !== 0) {
// double-click
clearTimeout(this.clickTimeoutId_);
this.clickTimeoutId_ = 0;
newEvent = new _ol_MapBrowserPointerEvent_(
_ol_MapBrowserEventType_.DBLCLICK, this.map_, pointerEvent);
MapBrowserEventType.DBLCLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
} else {
// click
this.clickTimeoutId_ = setTimeout(function() {
this.clickTimeoutId_ = 0;
var newEvent = new _ol_MapBrowserPointerEvent_(
_ol_MapBrowserEventType_.SINGLECLICK, this.map_, pointerEvent);
MapBrowserEventType.SINGLECLICK, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
}.bind(this), 250);
}
@@ -149,10 +149,10 @@ _ol_MapBrowserEventHandler_.prototype.emulateClick_ = function(pointerEvent) {
_ol_MapBrowserEventHandler_.prototype.updateActivePointers_ = function(pointerEvent) {
var event = pointerEvent;
if (event.type == _ol_MapBrowserEventType_.POINTERUP ||
event.type == _ol_MapBrowserEventType_.POINTERCANCEL) {
if (event.type == MapBrowserEventType.POINTERUP ||
event.type == MapBrowserEventType.POINTERCANCEL) {
delete this.trackedTouches_[event.pointerId];
} else if (event.type == _ol_MapBrowserEventType_.POINTERDOWN) {
} else if (event.type == MapBrowserEventType.POINTERDOWN) {
this.trackedTouches_[event.pointerId] = true;
}
this.activePointers_ = Object.keys(this.trackedTouches_).length;
@@ -166,7 +166,7 @@ _ol_MapBrowserEventHandler_.prototype.updateActivePointers_ = function(pointerEv
_ol_MapBrowserEventHandler_.prototype.handlePointerUp_ = function(pointerEvent) {
this.updateActivePointers_(pointerEvent);
var newEvent = new _ol_MapBrowserPointerEvent_(
_ol_MapBrowserEventType_.POINTERUP, this.map_, pointerEvent);
MapBrowserEventType.POINTERUP, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
// We emulate click events on left mouse button click, touch contact, and pen
@@ -207,7 +207,7 @@ _ol_MapBrowserEventHandler_.prototype.isMouseActionButton_ = function(pointerEve
_ol_MapBrowserEventHandler_.prototype.handlePointerDown_ = function(pointerEvent) {
this.updateActivePointers_(pointerEvent);
var newEvent = new _ol_MapBrowserPointerEvent_(
_ol_MapBrowserEventType_.POINTERDOWN, this.map_, pointerEvent);
MapBrowserEventType.POINTERDOWN, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
this.down_ = pointerEvent;
@@ -222,10 +222,10 @@ _ol_MapBrowserEventHandler_.prototype.handlePointerDown_ = function(pointerEvent
this.dragListenerKeys_.push(
_ol_events_.listen(this.documentPointerEventHandler_,
_ol_MapBrowserEventType_.POINTERMOVE,
MapBrowserEventType.POINTERMOVE,
this.handlePointerMove_, this),
_ol_events_.listen(this.documentPointerEventHandler_,
_ol_MapBrowserEventType_.POINTERUP,
MapBrowserEventType.POINTERUP,
this.handlePointerUp_, this),
/* Note that the listener for `pointercancel is set up on
* `pointerEventHandler_` and not `documentPointerEventHandler_` like
@@ -241,7 +241,7 @@ _ol_MapBrowserEventHandler_.prototype.handlePointerDown_ = function(pointerEvent
* only registered there.
*/
_ol_events_.listen(this.pointerEventHandler_,
_ol_MapBrowserEventType_.POINTERCANCEL,
MapBrowserEventType.POINTERCANCEL,
this.handlePointerUp_, this)
);
}
@@ -259,7 +259,7 @@ _ol_MapBrowserEventHandler_.prototype.handlePointerMove_ = function(pointerEvent
if (this.isMoving_(pointerEvent)) {
this.dragging_ = true;
var newEvent = new _ol_MapBrowserPointerEvent_(
_ol_MapBrowserEventType_.POINTERDRAG, this.map_, pointerEvent,
MapBrowserEventType.POINTERDRAG, this.map_, pointerEvent,
this.dragging_);
this.dispatchEvent(newEvent);
}

View File

@@ -6,7 +6,7 @@ import _ol_Collection_ from './Collection.js';
import _ol_CollectionEventType_ from './CollectionEventType.js';
import MapBrowserEvent from './MapBrowserEvent.js';
import _ol_MapBrowserEventHandler_ from './MapBrowserEventHandler.js';
import _ol_MapBrowserEventType_ from './MapBrowserEventType.js';
import MapBrowserEventType from './MapBrowserEventType.js';
import MapEvent from './MapEvent.js';
import _ol_MapEventType_ from './MapEventType.js';
import _ol_MapProperty_ from './MapProperty.js';
@@ -173,7 +173,7 @@ var _ol_PluggableMap_ = function(options) {
_ol_events_EventType_.MOUSEDOWN,
_ol_events_EventType_.TOUCHSTART,
_ol_events_EventType_.MSPOINTERDOWN,
_ol_MapBrowserEventType_.POINTERDOWN,
MapBrowserEventType.POINTERDOWN,
_ol_events_EventType_.MOUSEWHEEL,
_ol_events_EventType_.WHEEL
];
@@ -188,8 +188,8 @@ var _ol_PluggableMap_ = function(options) {
* @type {ol.MapBrowserEventHandler}
*/
this.mapBrowserEventHandler_ = new _ol_MapBrowserEventHandler_(this, options.moveTolerance);
for (var key in _ol_MapBrowserEventType_) {
_ol_events_.listen(this.mapBrowserEventHandler_, _ol_MapBrowserEventType_[key],
for (var key in MapBrowserEventType) {
_ol_events_.listen(this.mapBrowserEventHandler_, MapBrowserEventType[key],
this.handleMapBrowserEvent, this);
}

View File

@@ -1,7 +1,7 @@
/**
* @module ol/events/condition
*/
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import _ol_asserts_ from '../asserts.js';
import {TRUE, FALSE} from '../functions.js';
import _ol_has_ from '../has.js';
@@ -61,7 +61,7 @@ _ol_events_condition_.always = TRUE;
* @api
*/
_ol_events_condition_.click = function(mapBrowserEvent) {
return mapBrowserEvent.type == _ol_MapBrowserEventType_.CLICK;
return mapBrowserEvent.type == MapBrowserEventType.CLICK;
};
@@ -113,7 +113,7 @@ _ol_events_condition_.pointerMove = function(mapBrowserEvent) {
* @api
*/
_ol_events_condition_.singleClick = function(mapBrowserEvent) {
return mapBrowserEvent.type == _ol_MapBrowserEventType_.SINGLECLICK;
return mapBrowserEvent.type == MapBrowserEventType.SINGLECLICK;
};
@@ -125,7 +125,7 @@ _ol_events_condition_.singleClick = function(mapBrowserEvent) {
* @api
*/
_ol_events_condition_.doubleClick = function(mapBrowserEvent) {
return mapBrowserEvent.type == _ol_MapBrowserEventType_.DBLCLICK;
return mapBrowserEvent.type == MapBrowserEventType.DBLCLICK;
};

View File

@@ -2,7 +2,7 @@
* @module ol/interaction/DoubleClickZoom
*/
import {inherits} from '../index.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
/**
@@ -50,7 +50,7 @@ inherits(_ol_interaction_DoubleClickZoom_, _ol_interaction_Interaction_);
_ol_interaction_DoubleClickZoom_.handleEvent = function(mapBrowserEvent) {
var stopEvent = false;
var browserEvent = mapBrowserEvent.originalEvent;
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.DBLCLICK) {
if (mapBrowserEvent.type == MapBrowserEventType.DBLCLICK) {
var map = mapBrowserEvent.map;
var anchor = mapBrowserEvent.coordinate;
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;

View File

@@ -3,7 +3,7 @@
*/
import {inherits} from '../index.js';
import _ol_Feature_ from '../Feature.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import _ol_Object_ from '../Object.js';
import _ol_coordinate_ from '../coordinate.js';
import _ol_events_ from '../events.js';
@@ -325,16 +325,16 @@ _ol_interaction_Draw_.handleEvent = function(event) {
this.freehand_ = this.mode_ !== _ol_interaction_Draw_.Mode_.POINT && this.freehandCondition_(event);
var pass = true;
if (this.freehand_ &&
event.type === _ol_MapBrowserEventType_.POINTERDRAG &&
event.type === MapBrowserEventType.POINTERDRAG &&
this.sketchFeature_ !== null) {
this.addToDrawing_(event);
pass = false;
} else if (this.freehand_ &&
event.type === _ol_MapBrowserEventType_.POINTERDOWN) {
event.type === MapBrowserEventType.POINTERDOWN) {
pass = false;
} else if (event.type === _ol_MapBrowserEventType_.POINTERMOVE) {
} else if (event.type === MapBrowserEventType.POINTERMOVE) {
pass = this.handlePointerMove_(event);
} else if (event.type === _ol_MapBrowserEventType_.DBLCLICK) {
} else if (event.type === MapBrowserEventType.DBLCLICK) {
pass = false;
}
return _ol_interaction_Pointer_.handleEvent.call(this, event) && pass;

View File

@@ -3,7 +3,7 @@
*/
import {inherits} from '../index.js';
import _ol_Feature_ from '../Feature.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js';
import _ol_coordinate_ from '../coordinate.js';
import Event from '../events/Event.js';
@@ -136,7 +136,7 @@ _ol_interaction_Extent_.handleEvent_ = function(mapBrowserEvent) {
return true;
}
//display pointer (if not dragging)
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE && !this.handlingDownUpSequence) {
if (mapBrowserEvent.type == MapBrowserEventType.POINTERMOVE && !this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent);
}
//call pointer to determine up/down/drag

View File

@@ -5,7 +5,7 @@ import {getUid, inherits} from '../index.js';
import _ol_Collection_ from '../Collection.js';
import _ol_CollectionEventType_ from '../CollectionEventType.js';
import _ol_Feature_ from '../Feature.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js';
import _ol_array_ from '../array.js';
import _ol_coordinate_ from '../coordinate.js';
@@ -806,12 +806,12 @@ _ol_interaction_Modify_.handleEvent = function(mapBrowserEvent) {
var handled;
if (!mapBrowserEvent.map.getView().getInteracting() &&
mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE &&
mapBrowserEvent.type == MapBrowserEventType.POINTERMOVE &&
!this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent);
}
if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) {
if (mapBrowserEvent.type != _ol_MapBrowserEventType_.SINGLECLICK ||
if (mapBrowserEvent.type != MapBrowserEventType.SINGLECLICK ||
!this.ignoreNextSingleClick_) {
handled = this.removePoint();
} else {
@@ -819,7 +819,7 @@ _ol_interaction_Modify_.handleEvent = function(mapBrowserEvent) {
}
}
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.SINGLECLICK) {
if (mapBrowserEvent.type == MapBrowserEventType.SINGLECLICK) {
this.ignoreNextSingleClick_ = false;
}
@@ -1026,7 +1026,7 @@ _ol_interaction_Modify_.prototype.insertVertex_ = function(segmentData, vertex)
* @api
*/
_ol_interaction_Modify_.prototype.removePoint = function() {
if (this.lastPointerEvent_ && this.lastPointerEvent_.type != _ol_MapBrowserEventType_.POINTERDRAG) {
if (this.lastPointerEvent_ && this.lastPointerEvent_.type != MapBrowserEventType.POINTERDRAG) {
var evt = this.lastPointerEvent_;
this.willModifyFeatures_(evt);
this.removeVertex_();

View File

@@ -3,7 +3,7 @@
*/
import {inherits, nullFunction} from '../index.js';
import {FALSE} from '../functions.js';
import _ol_MapBrowserEventType_ from '../MapBrowserEventType.js';
import MapBrowserEventType from '../MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from '../MapBrowserPointerEvent.js';
import _ol_interaction_Interaction_ from '../interaction/Interaction.js';
import _ol_obj_ from '../obj.js';
@@ -109,9 +109,9 @@ _ol_interaction_Pointer_.centroid = function(pointerEvents) {
*/
_ol_interaction_Pointer_.prototype.isPointerDraggingEvent_ = function(mapBrowserEvent) {
var type = mapBrowserEvent.type;
return type === _ol_MapBrowserEventType_.POINTERDOWN ||
type === _ol_MapBrowserEventType_.POINTERDRAG ||
type === _ol_MapBrowserEventType_.POINTERUP;
return type === MapBrowserEventType.POINTERDOWN ||
type === MapBrowserEventType.POINTERDRAG ||
type === MapBrowserEventType.POINTERUP;
};
@@ -124,10 +124,10 @@ _ol_interaction_Pointer_.prototype.updateTrackedPointers_ = function(mapBrowserE
var event = mapBrowserEvent.pointerEvent;
var id = event.pointerId.toString();
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERUP) {
if (mapBrowserEvent.type == MapBrowserEventType.POINTERUP) {
delete this.trackedPointers_[id];
} else if (mapBrowserEvent.type ==
_ol_MapBrowserEventType_.POINTERDOWN) {
MapBrowserEventType.POINTERDOWN) {
this.trackedPointers_[id] = event;
} else if (id in this.trackedPointers_) {
// update only when there was a pointerdown event for this pointer
@@ -185,18 +185,18 @@ _ol_interaction_Pointer_.handleEvent = function(mapBrowserEvent) {
var stopEvent = false;
this.updateTrackedPointers_(mapBrowserEvent);
if (this.handlingDownUpSequence) {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERDRAG) {
if (mapBrowserEvent.type == MapBrowserEventType.POINTERDRAG) {
this.handleDragEvent_(mapBrowserEvent);
} else if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERUP) {
} else if (mapBrowserEvent.type == MapBrowserEventType.POINTERUP) {
var handledUp = this.handleUpEvent_(mapBrowserEvent);
this.handlingDownUpSequence = handledUp && this.targetPointers.length > 0;
}
} else {
if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERDOWN) {
if (mapBrowserEvent.type == MapBrowserEventType.POINTERDOWN) {
var handled = this.handleDownEvent_(mapBrowserEvent);
this.handlingDownUpSequence = handled;
stopEvent = this.shouldStopEvent(handled);
} else if (mapBrowserEvent.type == _ol_MapBrowserEventType_.POINTERMOVE) {
} else if (mapBrowserEvent.type == MapBrowserEventType.POINTERMOVE) {
this.handleMoveEvent_(mapBrowserEvent);
}
}

View File

@@ -1,7 +1,7 @@
import _ol_Collection_ from '../../../../src/ol/Collection.js';
import _ol_Feature_ from '../../../../src/ol/Feature.js';
import _ol_Map_ from '../../../../src/ol/Map.js';
import _ol_MapBrowserEventType_ from '../../../../src/ol/MapBrowserEventType.js';
import MapBrowserEventType from '../../../../src/ol/MapBrowserEventType.js';
import _ol_MapBrowserPointerEvent_ from '../../../../src/ol/MapBrowserPointerEvent.js';
import _ol_View_ from '../../../../src/ol/View.js';
import Polygon from '../../../../src/ol/geom/Polygon.js';
@@ -148,7 +148,7 @@ describe('ol.interaction.Select', function() {
});
select.on('select', listenerSpy);
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, -10, -10);
simulateEvent(MapBrowserEventType.SINGLECLICK, -10, -10);
expect(listenerSpy.callCount).to.be(0);
@@ -162,8 +162,8 @@ describe('ol.interaction.Select', function() {
});
select.on('select', listenerSpy);
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, 10, -20);
simulateEvent(_ol_MapBrowserEventType_.SINGLECLICK, 9, -21);
simulateEvent(MapBrowserEventType.SINGLECLICK, 10, -20);
simulateEvent(MapBrowserEventType.SINGLECLICK, 9, -21);
expect(listenerSpy.callCount).to.be(1);