From a9c54e0c025f1a537f2bdf62f94b2f7f1333274f Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 19 Jul 2016 15:00:05 +0200 Subject: [PATCH 1/2] Fix event type and documentation of ol.events.condition.mouseOnly --- externs/oli.js | 24 ++++++++++++++++++++++++ src/ol/events/condition.js | 9 ++++----- src/ol/mapbrowserevent.js | 3 +++ src/ol/pointer/pointerevent.js | 3 +++ 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/externs/oli.js b/externs/oli.js index 305b8fe033..6c468f460f 100644 --- a/externs/oli.js +++ b/externs/oli.js @@ -157,6 +157,30 @@ oli.MapBrowserEvent.prototype.pixel; oli.MapBrowserEvent.prototype.dragging; +/** + * @interface + */ +oli.MapBrowserPointerEvent; + + +/** + * @type {ol.pointer.PointerEvent} + */ +oli.MapBrowserPointerEvent.prototype.pointerEvent; + + +/** + * @interface + */ +oli.pointer.PointerEvent; + + +/** + * @type {Event} + */ +oli.pointer.PointerEvent.prototype.originalEvent; + + /** * @interface */ diff --git a/src/ol/events/condition.js b/src/ol/events/condition.js index 425ea769b9..df9839149d 100644 --- a/src/ol/events/condition.js +++ b/src/ol/events/condition.js @@ -199,15 +199,14 @@ ol.events.condition.targetNotEditable = function(mapBrowserEvent) { /** * Return `true` if the event originates from a mouse device. * - * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. + * @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Map browser pointer + * event. * @return {boolean} True if the event originates from a mouse device. * @api stable */ -ol.events.condition.mouseOnly = function(mapBrowserEvent) { +ol.events.condition.mouseOnly = function(mapBrowserPointerEvent) { // see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType - goog.asserts.assertInstanceof(mapBrowserEvent, ol.MapBrowserPointerEvent, - 'Requires an ol.MapBrowserPointerEvent to work.'); - return mapBrowserEvent.pointerEvent.pointerType == 'mouse'; + return mapBrowserPointerEvent.pointerEvent.pointerType == 'mouse'; }; diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index 76d671810d..f612750acd 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -91,6 +91,7 @@ ol.MapBrowserEvent.prototype.stopPropagation = function() { /** * @constructor + * @implements {oli.MapBrowserPointerEvent} * @extends {ol.MapBrowserEvent} * @param {string} type Event type. * @param {ol.Map} map Map. @@ -105,8 +106,10 @@ ol.MapBrowserPointerEvent = function(type, map, pointerEvent, opt_dragging, opt_frameState); /** + * The underlying pointer event. * @const * @type {ol.pointer.PointerEvent} + * @api */ this.pointerEvent = pointerEvent; diff --git a/src/ol/pointer/pointerevent.js b/src/ol/pointer/pointerevent.js index 6274330539..f955f39e0c 100644 --- a/src/ol/pointer/pointerevent.js +++ b/src/ol/pointer/pointerevent.js @@ -41,6 +41,7 @@ goog.require('ol.events.Event'); * touch events and even native pointer events. * * @constructor + * @implements {oli.pointer.PointerEvent} * @extends {ol.events.Event} * @param {string} type The type of the event to create. * @param {Event} originalEvent The event. @@ -51,8 +52,10 @@ ol.pointer.PointerEvent = function(type, originalEvent, opt_eventDict) { ol.events.Event.call(this, type); /** + * The original browser event. * @const * @type {Event} + * @api */ this.originalEvent = originalEvent; From 4b68df73a8b97e71118cf070a7b01bcb22c8a35c Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 9 Aug 2016 16:13:57 +0200 Subject: [PATCH 2/2] Do not expose ol.MapBrowserPointerEvent to the docs --- doc/errors/index.md | 4 ++++ externs/oli.js | 24 ------------------------ src/ol/events/condition.js | 9 ++++----- src/ol/mapbrowserevent.js | 3 --- src/ol/pointer/pointerevent.js | 3 --- 5 files changed, 8 insertions(+), 35 deletions(-) diff --git a/doc/errors/index.md b/doc/errors/index.md index 2f52e265fd..7c313ddc8a 100644 --- a/doc/errors/index.md +++ b/doc/errors/index.md @@ -224,3 +224,7 @@ Hex color should have 3 or 6 digits. ### 55 The `{-y}` placeholder requires a tile grid with extent. + +### 56 + +`mapBrowserEvent` must originate from a pointer event. diff --git a/externs/oli.js b/externs/oli.js index 6c468f460f..305b8fe033 100644 --- a/externs/oli.js +++ b/externs/oli.js @@ -157,30 +157,6 @@ oli.MapBrowserEvent.prototype.pixel; oli.MapBrowserEvent.prototype.dragging; -/** - * @interface - */ -oli.MapBrowserPointerEvent; - - -/** - * @type {ol.pointer.PointerEvent} - */ -oli.MapBrowserPointerEvent.prototype.pointerEvent; - - -/** - * @interface - */ -oli.pointer.PointerEvent; - - -/** - * @type {Event} - */ -oli.pointer.PointerEvent.prototype.originalEvent; - - /** * @interface */ diff --git a/src/ol/events/condition.js b/src/ol/events/condition.js index df9839149d..4cc07ef5d6 100644 --- a/src/ol/events/condition.js +++ b/src/ol/events/condition.js @@ -2,7 +2,6 @@ goog.provide('ol.events.condition'); goog.require('ol.functions'); goog.require('ol.MapBrowserEvent.EventType'); -goog.require('ol.MapBrowserPointerEvent'); /** @@ -199,14 +198,14 @@ ol.events.condition.targetNotEditable = function(mapBrowserEvent) { /** * Return `true` if the event originates from a mouse device. * - * @param {ol.MapBrowserPointerEvent} mapBrowserPointerEvent Map browser pointer - * event. + * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. * @return {boolean} True if the event originates from a mouse device. * @api stable */ -ol.events.condition.mouseOnly = function(mapBrowserPointerEvent) { +ol.events.condition.mouseOnly = function(mapBrowserEvent) { + ol.assert(mapBrowserEvent.pointerEvent, 56); // mapBrowserEvent must originate from a pointer event // see http://www.w3.org/TR/pointerevents/#widl-PointerEvent-pointerType - return mapBrowserPointerEvent.pointerEvent.pointerType == 'mouse'; + return /** @type {ol.MapBrowserEvent} */ (mapBrowserEvent).pointerEvent.pointerType == 'mouse'; }; diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index f612750acd..76d671810d 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -91,7 +91,6 @@ ol.MapBrowserEvent.prototype.stopPropagation = function() { /** * @constructor - * @implements {oli.MapBrowserPointerEvent} * @extends {ol.MapBrowserEvent} * @param {string} type Event type. * @param {ol.Map} map Map. @@ -106,10 +105,8 @@ ol.MapBrowserPointerEvent = function(type, map, pointerEvent, opt_dragging, opt_frameState); /** - * The underlying pointer event. * @const * @type {ol.pointer.PointerEvent} - * @api */ this.pointerEvent = pointerEvent; diff --git a/src/ol/pointer/pointerevent.js b/src/ol/pointer/pointerevent.js index f955f39e0c..6274330539 100644 --- a/src/ol/pointer/pointerevent.js +++ b/src/ol/pointer/pointerevent.js @@ -41,7 +41,6 @@ goog.require('ol.events.Event'); * touch events and even native pointer events. * * @constructor - * @implements {oli.pointer.PointerEvent} * @extends {ol.events.Event} * @param {string} type The type of the event to create. * @param {Event} originalEvent The event. @@ -52,10 +51,8 @@ ol.pointer.PointerEvent = function(type, originalEvent, opt_eventDict) { ol.events.Event.call(this, type); /** - * The original browser event. * @const * @type {Event} - * @api */ this.originalEvent = originalEvent;