diff --git a/examples/drag-and-drop-image-vector.js b/examples/drag-and-drop-image-vector.js index 971f736329..44fdd05d59 100644 --- a/examples/drag-and-drop-image-vector.js +++ b/examples/drag-and-drop-image-vector.js @@ -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_TopoJSON_ from '../src/ol/format/TopoJSON.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_Tile_ from '../src/ol/layer/Tile.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: [ _ol_format_GPX_, _ol_format_GeoJSON_, diff --git a/examples/drag-and-drop.js b/examples/drag-and-drop.js index 2fdb6fe3f9..222efea03b 100644 --- a/examples/drag-and-drop.js +++ b/examples/drag-and-drop.js @@ -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_TopoJSON_ from '../src/ol/format/TopoJSON.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_Vector_ from '../src/ol/layer/Vector.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: [ _ol_format_GPX_, _ol_format_GeoJSON_, diff --git a/src/ol/interaction/DragAndDrop.js b/src/ol/interaction/DragAndDrop.js index e6f8caf98e..a9a6d8f210 100644 --- a/src/ol/interaction/DragAndDrop.js +++ b/src/ol/interaction/DragAndDrop.js @@ -21,12 +21,12 @@ import {get as getProjection} from '../proj.js'; * @param {olx.interaction.DragAndDropOptions=} opt_options Options. * @api */ -var _ol_interaction_DragAndDrop_ = function(opt_options) { +var DragAndDrop = function(opt_options) { var options = opt_options ? opt_options : {}; 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} * @private */ -_ol_interaction_DragAndDrop_.handleDrop_ = function(event) { +DragAndDrop.handleDrop_ = function(event) { var files = event.dataTransfer.files; var i, ii, file; for (i = 0, ii = files.length; i < ii; ++i) { @@ -88,7 +88,7 @@ _ol_interaction_DragAndDrop_.handleDrop_ = function(event) { * @param {Event} event Event. * @private */ -_ol_interaction_DragAndDrop_.handleStop_ = function(event) { +DragAndDrop.handleStop_ = function(event) { event.stopPropagation(); event.preventDefault(); event.dataTransfer.dropEffect = 'copy'; @@ -100,7 +100,7 @@ _ol_interaction_DragAndDrop_.handleStop_ = function(event) { * @param {Event} event Load event. * @private */ -_ol_interaction_DragAndDrop_.prototype.handleResult_ = function(file, event) { +DragAndDrop.prototype.handleResult_ = function(file, event) { var result = event.target.result; var map = this.getMap(); var projection = this.projection_; @@ -134,8 +134,8 @@ _ol_interaction_DragAndDrop_.prototype.handleResult_ = function(file, event) { this.source_.addFeatures(features); } this.dispatchEvent( - new _ol_interaction_DragAndDrop_.Event( - _ol_interaction_DragAndDrop_.EventType_.ADD_FEATURES, file, + new DragAndDrop.Event( + DragAndDrop.EventType_.ADD_FEATURES, file, features, projection)); }; @@ -148,25 +148,25 @@ _ol_interaction_DragAndDrop_.prototype.handleResult_ = function(file, event) { * @this {ol.interaction.DragAndDrop} * @api */ -_ol_interaction_DragAndDrop_.handleEvent = TRUE; +DragAndDrop.handleEvent = TRUE; /** * @private */ -_ol_interaction_DragAndDrop_.prototype.registerListeners_ = function() { +DragAndDrop.prototype.registerListeners_ = function() { var map = this.getMap(); if (map) { var dropArea = this.target ? this.target : map.getViewport(); this.dropListenKeys_ = [ _ol_events_.listen(dropArea, EventType.DROP, - _ol_interaction_DragAndDrop_.handleDrop_, this), + DragAndDrop.handleDrop_, this), _ol_events_.listen(dropArea, EventType.DRAGENTER, - _ol_interaction_DragAndDrop_.handleStop_, this), + DragAndDrop.handleStop_, this), _ol_events_.listen(dropArea, EventType.DRAGOVER, - _ol_interaction_DragAndDrop_.handleStop_, this), + DragAndDrop.handleStop_, this), _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 */ -_ol_interaction_DragAndDrop_.prototype.setActive = function(active) { +DragAndDrop.prototype.setActive = function(active) { Interaction.prototype.setActive.call(this, active); if (active) { this.registerListeners_(); @@ -188,7 +188,7 @@ _ol_interaction_DragAndDrop_.prototype.setActive = function(active) { /** * @inheritDoc */ -_ol_interaction_DragAndDrop_.prototype.setMap = function(map) { +DragAndDrop.prototype.setMap = function(map) { this.unregisterListeners_(); Interaction.prototype.setMap.call(this, map); if (this.getActive()) { @@ -204,7 +204,7 @@ _ol_interaction_DragAndDrop_.prototype.setMap = function(map) { * @private * @return {Array.} Features. */ -_ol_interaction_DragAndDrop_.prototype.tryReadFeatures_ = function(format, text, options) { +DragAndDrop.prototype.tryReadFeatures_ = function(format, text, options) { try { return format.readFeatures(text, options); } catch (e) { @@ -216,7 +216,7 @@ _ol_interaction_DragAndDrop_.prototype.tryReadFeatures_ = function(format, text, /** * @private */ -_ol_interaction_DragAndDrop_.prototype.unregisterListeners_ = function() { +DragAndDrop.prototype.unregisterListeners_ = function() { if (this.dropListenKeys_) { this.dropListenKeys_.forEach(_ol_events_.unlistenByKey); this.dropListenKeys_ = null; @@ -228,7 +228,7 @@ _ol_interaction_DragAndDrop_.prototype.unregisterListeners_ = function() { * @enum {string} * @private */ -_ol_interaction_DragAndDrop_.EventType_ = { +DragAndDrop.EventType_ = { /** * Triggered when features are added * @event ol.interaction.DragAndDrop.Event#addfeatures @@ -251,7 +251,7 @@ _ol_interaction_DragAndDrop_.EventType_ = { * @param {Array.=} opt_features Features. * @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); @@ -277,6 +277,6 @@ _ol_interaction_DragAndDrop_.Event = function(type, file, opt_features, opt_proj this.projection = opt_projection; }; -inherits(_ol_interaction_DragAndDrop_.Event, Event); +inherits(DragAndDrop.Event, Event); -export default _ol_interaction_DragAndDrop_; +export default DragAndDrop; diff --git a/test/spec/ol/interaction/draganddrop.test.js b/test/spec/ol/interaction/draganddrop.test.js index 0a1e24b024..99a3665b44 100644 --- a/test/spec/ol/interaction/draganddrop.test.js +++ b/test/spec/ol/interaction/draganddrop.test.js @@ -3,7 +3,7 @@ import _ol_View_ from '../../../../src/ol/View.js'; import Event from '../../../../src/ol/events/Event.js'; import EventTarget from '../../../../src/ol/events/EventTarget.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'; where('FileReader').describe('ol.interaction.DragAndDrop', function() { @@ -19,7 +19,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { return new _ol_View_(); } }; - interaction = new _ol_interaction_DragAndDrop_({ + interaction = new DragAndDrop({ formatConstructors: [_ol_format_GeoJSON_] }); }); @@ -27,8 +27,8 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { describe('constructor', function() { it('can be constructed without arguments', function() { - var interaction = new _ol_interaction_DragAndDrop_(); - expect(interaction).to.be.an(_ol_interaction_DragAndDrop_); + var interaction = new DragAndDrop(); + expect(interaction).to.be.an(DragAndDrop); }); it('sets formatConstructors on the instance', function() { @@ -37,7 +37,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { it('accepts a source option', function() { var source = new _ol_source_Vector_(); - var drop = new _ol_interaction_DragAndDrop_({ + var drop = new DragAndDrop({ formatConstructors: [_ol_format_GeoJSON_], source: source }); @@ -73,7 +73,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { it('registers and unregisters listeners on a custom target', function() { var customTarget = new EventTarget(); - interaction = new _ol_interaction_DragAndDrop_({ + interaction = new DragAndDrop({ formatConstructors: [_ol_format_GeoJSON_], target: customTarget }); @@ -137,7 +137,7 @@ where('FileReader').describe('ol.interaction.DragAndDrop', function() { it('adds dropped features to a source', function(done) { var source = new _ol_source_Vector_(); - var drop = new _ol_interaction_DragAndDrop_({ + var drop = new DragAndDrop({ formatConstructors: [_ol_format_GeoJSON_], source: source });