Use blocked scoped variables

In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
Tim Schaub
2018-01-11 23:32:36 -07:00
parent 0bf2b04dee
commit ad62739a6e
684 changed files with 18120 additions and 18184 deletions

View File

@@ -39,8 +39,8 @@ import _ol_pointer_EventSource_ from '../pointer/EventSource.js';
* @constructor
* @extends {ol.pointer.EventSource}
*/
var _ol_pointer_MouseSource_ = function(dispatcher) {
var mapping = {
const _ol_pointer_MouseSource_ = function(dispatcher) {
const mapping = {
'mousedown': this.mousedown,
'mousemove': this.mousemove,
'mouseup': this.mouseup,
@@ -113,11 +113,13 @@ _ol_pointer_MouseSource_.DEDUP_DIST = 25;
* @return {boolean} True, if the event was generated by a touch.
*/
_ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent) {
var lts = this.lastTouches;
var x = inEvent.clientX, y = inEvent.clientY;
for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
const lts = this.lastTouches;
const x = inEvent.clientX;
const y = inEvent.clientY;
for (let i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
// simulated mouse events will be swallowed near a primary touchend
var dx = Math.abs(x - t[0]), dy = Math.abs(y - t[1]);
const dx = Math.abs(x - t[0]);
const dy = Math.abs(y - t[1]);
if (dx <= _ol_pointer_MouseSource_.DEDUP_DIST &&
dy <= _ol_pointer_MouseSource_.DEDUP_DIST) {
return true;
@@ -136,10 +138,10 @@ _ol_pointer_MouseSource_.prototype.isEventSimulatedFromTouch_ = function(inEvent
* @return {Object} The copied event.
*/
_ol_pointer_MouseSource_.prepareEvent = function(inEvent, dispatcher) {
var e = dispatcher.cloneEvent(inEvent, inEvent);
const e = dispatcher.cloneEvent(inEvent, inEvent);
// forward mouse preventDefault
var pd = e.preventDefault;
const pd = e.preventDefault;
e.preventDefault = function() {
inEvent.preventDefault();
pd();
@@ -165,7 +167,7 @@ _ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) {
if (_ol_pointer_MouseSource_.POINTER_ID.toString() in this.pointerMap) {
this.cancel(inEvent);
}
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()] = inEvent;
this.dispatcher.down(e, inEvent);
}
@@ -179,7 +181,7 @@ _ol_pointer_MouseSource_.prototype.mousedown = function(inEvent) {
*/
_ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.move(e, inEvent);
}
};
@@ -192,10 +194,10 @@ _ol_pointer_MouseSource_.prototype.mousemove = function(inEvent) {
*/
_ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
var p = this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()];
const p = this.pointerMap[_ol_pointer_MouseSource_.POINTER_ID.toString()];
if (p && p.button === inEvent.button) {
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.up(e, inEvent);
this.cleanupMouse();
}
@@ -210,7 +212,7 @@ _ol_pointer_MouseSource_.prototype.mouseup = function(inEvent) {
*/
_ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.enterOver(e, inEvent);
}
};
@@ -223,7 +225,7 @@ _ol_pointer_MouseSource_.prototype.mouseover = function(inEvent) {
*/
_ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) {
if (!this.isEventSimulatedFromTouch_(inEvent)) {
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.leaveOut(e, inEvent);
}
};
@@ -235,7 +237,7 @@ _ol_pointer_MouseSource_.prototype.mouseout = function(inEvent) {
* @param {Event} inEvent The in event.
*/
_ol_pointer_MouseSource_.prototype.cancel = function(inEvent) {
var e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
const e = _ol_pointer_MouseSource_.prepareEvent(inEvent, this.dispatcher);
this.dispatcher.cancel(e, inEvent);
this.cleanupMouse();
};