# all files / ol/pointer/ eventsource.js

100% Statements 8/8
100% Branches 0/0
100% Functions 3/3
100% Lines 8/8

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    421×

    1×

    421×

    421×

    1×
    1171×

    1×
    2990×

     goog.provide('ol.pointer.EventSource');

    /**
     * @param {ol.pointer.PointerEventHandler} dispatcher Event handler.
     * @param {!Object.<string, function(Event)>} mapping Event
     *     mapping.
     * @constructor
     */
    ol.pointer.EventSource = function(dispatcher, mapping) {
      /**
       * @type {ol.pointer.PointerEventHandler}
       */
      this.dispatcher = dispatcher;

      /**
       * @private
       * @const
       * @type {!Object.<string, function(Event)>}
       */
      this.mapping_ = mapping;
    };

    /**
     * List of events supported by this source.
     * @return {Array.<string>} Event names
     */
    ol.pointer.EventSource.prototype.getEvents = function() {
      return Object.keys(this.mapping_);
    };

    /**
     * Returns the handler that should handle a given event type.
     * @param {string} eventType The event type.
     * @return {function(Event)} Handler
     */
    ol.pointer.EventSource.prototype.getHandlerForEvent = function(eventType) {
      return this.mapping_[eventType];
    };