From 6b4b62dd3a834307dc41980290b653c9a0cda6ef Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 10 Mar 2014 10:20:24 +0100 Subject: [PATCH] Use goog.object.get instead of ol.pointer.PointerEvent#getValueOr_ --- src/ol/pointer/pointerevent.js | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/ol/pointer/pointerevent.js b/src/ol/pointer/pointerevent.js index 720ce11c42..b55b53dd53 100644 --- a/src/ol/pointer/pointerevent.js +++ b/src/ol/pointer/pointerevent.js @@ -33,6 +33,7 @@ goog.provide('ol.pointer.PointerEvent'); goog.require('goog.events'); goog.require('goog.events.Event'); +goog.require('goog.object'); @@ -154,42 +155,42 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) { * @const * @type {number} */ - this.pointerId = this.getValueOr_('pointerId', 0, eventDict); + this.pointerId = goog.object.get(eventDict, 'pointerId', 0); /** * @type {number} */ - this.width = this.getValueOr_('width', 0, eventDict); + this.width = goog.object.get(eventDict, 'width', 0); /** * @type {number} */ - this.height = this.getValueOr_('height', 0, eventDict); + this.height = goog.object.get(eventDict, 'height', 0); /** * @type {number} */ - this.tiltX = this.getValueOr_('tiltX', 0, eventDict); + this.tiltX = goog.object.get(eventDict, 'tiltX', 0); /** * @type {number} */ - this.tiltY = this.getValueOr_('tiltY', 0, eventDict); + this.tiltY = goog.object.get(eventDict, 'tiltY', 0); /** * @type {string} */ - this.pointerType = this.getValueOr_('pointerType', '', eventDict); + this.pointerType = goog.object.get(eventDict, 'pointerType', ''); /** * @type {number} */ - this.hwTimestamp = this.getValueOr_('hwTimestamp', 0, eventDict); + this.hwTimestamp = goog.object.get(eventDict, 'hwTimestamp', 0); /** * @type {boolean} */ - this.isPrimary = this.getValueOr_('isPrimary', false, eventDict); + this.isPrimary = goog.object.get(eventDict, 'isPrimary', false); }; goog.inherits(ol.pointer.PointerEvent, goog.events.Event); @@ -208,20 +209,6 @@ ol.pointer.PointerEvent.prototype.getValue_ = function(key, eventDict) { }; -/** - * @private - * @param {string} key - * @param {*} defaultValue - * @param {Object.} eventDict - * @return {string|number|?} - */ -ol.pointer.PointerEvent.prototype.getValueOr_ = - function(key, defaultValue, eventDict) { - return goog.isDefAndNotNull(eventDict[key]) ? - eventDict[key] : defaultValue; -}; - - /** * @private * @param {Object.} eventDict