Rename _ol_interaction_DragAndDrop_ to DragAndDrop
This commit is contained in:
@@ -6,7 +6,7 @@ import _ol_format_IGC_ from '../src/ol/format/IGC.js';
|
|||||||
import _ol_format_KML_ from '../src/ol/format/KML.js';
|
import _ol_format_KML_ from '../src/ol/format/KML.js';
|
||||||
import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js';
|
import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js';
|
||||||
import _ol_interaction_ from '../src/ol/interaction.js';
|
import _ol_interaction_ from '../src/ol/interaction.js';
|
||||||
import _ol_interaction_DragAndDrop_ from '../src/ol/interaction/DragAndDrop.js';
|
import DragAndDrop from '../src/ol/interaction/DragAndDrop.js';
|
||||||
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
|
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
|
||||||
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
||||||
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
|
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
|
||||||
@@ -83,7 +83,7 @@ var styleFunction = function(feature, resolution) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var dragAndDropInteraction = new _ol_interaction_DragAndDrop_({
|
var dragAndDropInteraction = new DragAndDrop({
|
||||||
formatConstructors: [
|
formatConstructors: [
|
||||||
_ol_format_GPX_,
|
_ol_format_GPX_,
|
||||||
_ol_format_GeoJSON_,
|
_ol_format_GeoJSON_,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import _ol_format_IGC_ from '../src/ol/format/IGC.js';
|
|||||||
import _ol_format_KML_ from '../src/ol/format/KML.js';
|
import _ol_format_KML_ from '../src/ol/format/KML.js';
|
||||||
import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js';
|
import _ol_format_TopoJSON_ from '../src/ol/format/TopoJSON.js';
|
||||||
import _ol_interaction_ from '../src/ol/interaction.js';
|
import _ol_interaction_ from '../src/ol/interaction.js';
|
||||||
import _ol_interaction_DragAndDrop_ from '../src/ol/interaction/DragAndDrop.js';
|
import DragAndDrop from '../src/ol/interaction/DragAndDrop.js';
|
||||||
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
|
||||||
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
|
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
|
||||||
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
|
import _ol_source_BingMaps_ from '../src/ol/source/BingMaps.js';
|
||||||
@@ -83,7 +83,7 @@ var styleFunction = function(feature, resolution) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var dragAndDropInteraction = new _ol_interaction_DragAndDrop_({
|
var dragAndDropInteraction = new DragAndDrop({
|
||||||
formatConstructors: [
|
formatConstructors: [
|
||||||
_ol_format_GPX_,
|
_ol_format_GPX_,
|
||||||
_ol_format_GeoJSON_,
|
_ol_format_GeoJSON_,
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ import {get as getProjection} from '../proj.js';
|
|||||||
* @param {olx.interaction.DragAndDropOptions=} opt_options Options.
|
* @param {olx.interaction.DragAndDropOptions=} opt_options Options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
var _ol_interaction_DragAndDrop_ = function(opt_options) {
|
var DragAndDrop = function(opt_options) {
|
||||||
|
|
||||||
var options = opt_options ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
Interaction.call(this, {
|
Interaction.call(this, {
|
||||||
handleEvent: _ol_interaction_DragAndDrop_.handleEvent
|
handleEvent: DragAndDrop.handleEvent
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -63,7 +63,7 @@ var _ol_interaction_DragAndDrop_ = function(opt_options) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inherits(_ol_interaction_DragAndDrop_, Interaction);
|
inherits(DragAndDrop, Interaction);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +71,7 @@ inherits(_ol_interaction_DragAndDrop_, Interaction);
|
|||||||
* @this {ol.interaction.DragAndDrop}
|
* @this {ol.interaction.DragAndDrop}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.handleDrop_ = function(event) {
|
DragAndDrop.handleDrop_ = function(event) {
|
||||||
var files = event.dataTransfer.files;
|
var files = event.dataTransfer.files;
|
||||||
var i, ii, file;
|
var i, ii, file;
|
||||||
for (i = 0, ii = files.length; i < ii; ++i) {
|
for (i = 0, ii = files.length; i < ii; ++i) {
|
||||||
@@ -88,7 +88,7 @@ _ol_interaction_DragAndDrop_.handleDrop_ = function(event) {
|
|||||||
* @param {Event} event Event.
|
* @param {Event} event Event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.handleStop_ = function(event) {
|
DragAndDrop.handleStop_ = function(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.dataTransfer.dropEffect = 'copy';
|
event.dataTransfer.dropEffect = 'copy';
|
||||||
@@ -100,7 +100,7 @@ _ol_interaction_DragAndDrop_.handleStop_ = function(event) {
|
|||||||
* @param {Event} event Load event.
|
* @param {Event} event Load event.
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.prototype.handleResult_ = function(file, event) {
|
DragAndDrop.prototype.handleResult_ = function(file, event) {
|
||||||
var result = event.target.result;
|
var result = event.target.result;
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var projection = this.projection_;
|
var projection = this.projection_;
|
||||||
@@ -134,8 +134,8 @@ _ol_interaction_DragAndDrop_.prototype.handleResult_ = function(file, event) {
|
|||||||
this.source_.addFeatures(features);
|
this.source_.addFeatures(features);
|
||||||
}
|
}
|
||||||
this.dispatchEvent(
|
this.dispatchEvent(
|
||||||
new _ol_interaction_DragAndDrop_.Event(
|
new DragAndDrop.Event(
|
||||||
_ol_interaction_DragAndDrop_.EventType_.ADD_FEATURES, file,
|
DragAndDrop.EventType_.ADD_FEATURES, file,
|
||||||
features, projection));
|
features, projection));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -148,25 +148,25 @@ _ol_interaction_DragAndDrop_.prototype.handleResult_ = function(file, event) {
|
|||||||
* @this {ol.interaction.DragAndDrop}
|
* @this {ol.interaction.DragAndDrop}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.handleEvent = TRUE;
|
DragAndDrop.handleEvent = TRUE;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.prototype.registerListeners_ = function() {
|
DragAndDrop.prototype.registerListeners_ = function() {
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
if (map) {
|
if (map) {
|
||||||
var dropArea = this.target ? this.target : map.getViewport();
|
var dropArea = this.target ? this.target : map.getViewport();
|
||||||
this.dropListenKeys_ = [
|
this.dropListenKeys_ = [
|
||||||
_ol_events_.listen(dropArea, EventType.DROP,
|
_ol_events_.listen(dropArea, EventType.DROP,
|
||||||
_ol_interaction_DragAndDrop_.handleDrop_, this),
|
DragAndDrop.handleDrop_, this),
|
||||||
_ol_events_.listen(dropArea, EventType.DRAGENTER,
|
_ol_events_.listen(dropArea, EventType.DRAGENTER,
|
||||||
_ol_interaction_DragAndDrop_.handleStop_, this),
|
DragAndDrop.handleStop_, this),
|
||||||
_ol_events_.listen(dropArea, EventType.DRAGOVER,
|
_ol_events_.listen(dropArea, EventType.DRAGOVER,
|
||||||
_ol_interaction_DragAndDrop_.handleStop_, this),
|
DragAndDrop.handleStop_, this),
|
||||||
_ol_events_.listen(dropArea, EventType.DROP,
|
_ol_events_.listen(dropArea, EventType.DROP,
|
||||||
_ol_interaction_DragAndDrop_.handleStop_, this)
|
DragAndDrop.handleStop_, this)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -175,7 +175,7 @@ _ol_interaction_DragAndDrop_.prototype.registerListeners_ = function() {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.prototype.setActive = function(active) {
|
DragAndDrop.prototype.setActive = function(active) {
|
||||||
Interaction.prototype.setActive.call(this, active);
|
Interaction.prototype.setActive.call(this, active);
|
||||||
if (active) {
|
if (active) {
|
||||||
this.registerListeners_();
|
this.registerListeners_();
|
||||||
@@ -188,7 +188,7 @@ _ol_interaction_DragAndDrop_.prototype.setActive = function(active) {
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.prototype.setMap = function(map) {
|
DragAndDrop.prototype.setMap = function(map) {
|
||||||
this.unregisterListeners_();
|
this.unregisterListeners_();
|
||||||
Interaction.prototype.setMap.call(this, map);
|
Interaction.prototype.setMap.call(this, map);
|
||||||
if (this.getActive()) {
|
if (this.getActive()) {
|
||||||
@@ -204,7 +204,7 @@ _ol_interaction_DragAndDrop_.prototype.setMap = function(map) {
|
|||||||
* @private
|
* @private
|
||||||
* @return {Array.<ol.Feature>} Features.
|
* @return {Array.<ol.Feature>} Features.
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.prototype.tryReadFeatures_ = function(format, text, options) {
|
DragAndDrop.prototype.tryReadFeatures_ = function(format, text, options) {
|
||||||
try {
|
try {
|
||||||
return format.readFeatures(text, options);
|
return format.readFeatures(text, options);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -216,7 +216,7 @@ _ol_interaction_DragAndDrop_.prototype.tryReadFeatures_ = function(format, text,
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.prototype.unregisterListeners_ = function() {
|
DragAndDrop.prototype.unregisterListeners_ = function() {
|
||||||
if (this.dropListenKeys_) {
|
if (this.dropListenKeys_) {
|
||||||
this.dropListenKeys_.forEach(_ol_events_.unlistenByKey);
|
this.dropListenKeys_.forEach(_ol_events_.unlistenByKey);
|
||||||
this.dropListenKeys_ = null;
|
this.dropListenKeys_ = null;
|
||||||
@@ -228,7 +228,7 @@ _ol_interaction_DragAndDrop_.prototype.unregisterListeners_ = function() {
|
|||||||
* @enum {string}
|
* @enum {string}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.EventType_ = {
|
DragAndDrop.EventType_ = {
|
||||||
/**
|
/**
|
||||||
* Triggered when features are added
|
* Triggered when features are added
|
||||||
* @event ol.interaction.DragAndDrop.Event#addfeatures
|
* @event ol.interaction.DragAndDrop.Event#addfeatures
|
||||||
@@ -251,7 +251,7 @@ _ol_interaction_DragAndDrop_.EventType_ = {
|
|||||||
* @param {Array.<ol.Feature>=} opt_features Features.
|
* @param {Array.<ol.Feature>=} opt_features Features.
|
||||||
* @param {ol.proj.Projection=} opt_projection Projection.
|
* @param {ol.proj.Projection=} opt_projection Projection.
|
||||||
*/
|
*/
|
||||||
_ol_interaction_DragAndDrop_.Event = function(type, file, opt_features, opt_projection) {
|
DragAndDrop.Event = function(type, file, opt_features, opt_projection) {
|
||||||
|
|
||||||
Event.call(this, type);
|
Event.call(this, type);
|
||||||
|
|
||||||
@@ -277,6 +277,6 @@ _ol_interaction_DragAndDrop_.Event = function(type, file, opt_features, opt_proj
|
|||||||
this.projection = opt_projection;
|
this.projection = opt_projection;
|
||||||
|
|
||||||
};
|
};
|
||||||
inherits(_ol_interaction_DragAndDrop_.Event, Event);
|
inherits(DragAndDrop.Event, Event);
|
||||||
|
|
||||||
export default _ol_interaction_DragAndDrop_;
|
export default DragAndDrop;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import _ol_View_ from '../../../../src/ol/View.js';
|
|||||||
import Event from '../../../../src/ol/events/Event.js';
|
import Event from '../../../../src/ol/events/Event.js';
|
||||||
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
import EventTarget from '../../../../src/ol/events/EventTarget.js';
|
||||||
import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js';
|
import _ol_format_GeoJSON_ from '../../../../src/ol/format/GeoJSON.js';
|
||||||
import _ol_interaction_DragAndDrop_ from '../../../../src/ol/interaction/DragAndDrop.js';
|
import DragAndDrop from '../../../../src/ol/interaction/DragAndDrop.js';
|
||||||
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
import _ol_source_Vector_ from '../../../../src/ol/source/Vector.js';
|
||||||
|
|
||||||
where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
||||||
@@ -19,7 +19,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
|||||||
return new _ol_View_();
|
return new _ol_View_();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
interaction = new _ol_interaction_DragAndDrop_({
|
interaction = new DragAndDrop({
|
||||||
formatConstructors: [_ol_format_GeoJSON_]
|
formatConstructors: [_ol_format_GeoJSON_]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -27,8 +27,8 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
|||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
|
|
||||||
it('can be constructed without arguments', function() {
|
it('can be constructed without arguments', function() {
|
||||||
var interaction = new _ol_interaction_DragAndDrop_();
|
var interaction = new DragAndDrop();
|
||||||
expect(interaction).to.be.an(_ol_interaction_DragAndDrop_);
|
expect(interaction).to.be.an(DragAndDrop);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sets formatConstructors on the instance', function() {
|
it('sets formatConstructors on the instance', function() {
|
||||||
@@ -37,7 +37,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
|||||||
|
|
||||||
it('accepts a source option', function() {
|
it('accepts a source option', function() {
|
||||||
var source = new _ol_source_Vector_();
|
var source = new _ol_source_Vector_();
|
||||||
var drop = new _ol_interaction_DragAndDrop_({
|
var drop = new DragAndDrop({
|
||||||
formatConstructors: [_ol_format_GeoJSON_],
|
formatConstructors: [_ol_format_GeoJSON_],
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
@@ -73,7 +73,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
|||||||
|
|
||||||
it('registers and unregisters listeners on a custom target', function() {
|
it('registers and unregisters listeners on a custom target', function() {
|
||||||
var customTarget = new EventTarget();
|
var customTarget = new EventTarget();
|
||||||
interaction = new _ol_interaction_DragAndDrop_({
|
interaction = new DragAndDrop({
|
||||||
formatConstructors: [_ol_format_GeoJSON_],
|
formatConstructors: [_ol_format_GeoJSON_],
|
||||||
target: customTarget
|
target: customTarget
|
||||||
});
|
});
|
||||||
@@ -137,7 +137,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() {
|
|||||||
|
|
||||||
it('adds dropped features to a source', function(done) {
|
it('adds dropped features to a source', function(done) {
|
||||||
var source = new _ol_source_Vector_();
|
var source = new _ol_source_Vector_();
|
||||||
var drop = new _ol_interaction_DragAndDrop_({
|
var drop = new DragAndDrop({
|
||||||
formatConstructors: [_ol_format_GeoJSON_],
|
formatConstructors: [_ol_format_GeoJSON_],
|
||||||
source: source
|
source: source
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user