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
+1 -1
View File
@@ -15,7 +15,7 @@
* @implements {oli.events.Event}
* @param {string} type Type.
*/
var Event = function(type) {
const Event = function(type) {
/**
* @type {boolean}
+10 -10
View File
@@ -24,7 +24,7 @@ import Event from '../events/Event.js';
* @constructor
* @extends {ol.Disposable}
*/
var EventTarget = function() {
const EventTarget = function() {
Disposable.call(this);
@@ -56,7 +56,7 @@ inherits(EventTarget, Disposable);
* @param {ol.EventsListenerFunctionType} listener Listener.
*/
EventTarget.prototype.addEventListener = function(type, listener) {
var listeners = this.listeners_[type];
let listeners = this.listeners_[type];
if (!listeners) {
listeners = this.listeners_[type] = [];
}
@@ -74,18 +74,18 @@ EventTarget.prototype.addEventListener = function(type, listener) {
* event object or if any of the listeners returned false.
*/
EventTarget.prototype.dispatchEvent = function(event) {
var evt = typeof event === 'string' ? new Event(event) : event;
var type = evt.type;
const evt = typeof event === 'string' ? new Event(event) : event;
const type = evt.type;
evt.target = this;
var listeners = this.listeners_[type];
var propagate;
const listeners = this.listeners_[type];
let propagate;
if (listeners) {
if (!(type in this.dispatching_)) {
this.dispatching_[type] = 0;
this.pendingRemovals_[type] = 0;
}
++this.dispatching_[type];
for (var i = 0, ii = listeners.length; i < ii; ++i) {
for (let i = 0, ii = listeners.length; i < ii; ++i) {
if (listeners[i].call(this, evt) === false || evt.propagationStopped) {
propagate = false;
break;
@@ -93,7 +93,7 @@ EventTarget.prototype.dispatchEvent = function(event) {
}
--this.dispatching_[type];
if (this.dispatching_[type] === 0) {
var pendingRemovals = this.pendingRemovals_[type];
let pendingRemovals = this.pendingRemovals_[type];
delete this.pendingRemovals_[type];
while (pendingRemovals--) {
this.removeEventListener(type, nullFunction);
@@ -142,9 +142,9 @@ EventTarget.prototype.hasListener = function(opt_type) {
* @param {ol.EventsListenerFunctionType} listener Listener.
*/
EventTarget.prototype.removeEventListener = function(type, listener) {
var listeners = this.listeners_[type];
const listeners = this.listeners_[type];
if (listeners) {
var index = listeners.indexOf(listener);
const index = listeners.indexOf(listener);
if (type in this.pendingRemovals_) {
// make listener a no-op, and remove later in #dispatchEvent()
listeners[index] = nullFunction;
+10 -10
View File
@@ -5,7 +5,7 @@ import MapBrowserEventType from '../MapBrowserEventType.js';
import {assert} from '../asserts.js';
import {TRUE, FALSE} from '../functions.js';
import _ol_has_ from '../has.js';
var _ol_events_condition_ = {};
const _ol_events_condition_ = {};
/**
@@ -17,7 +17,7 @@ var _ol_events_condition_ = {};
* @api
*/
_ol_events_condition_.altKeyOnly = function(mapBrowserEvent) {
var originalEvent = mapBrowserEvent.originalEvent;
const originalEvent = mapBrowserEvent.originalEvent;
return (
originalEvent.altKey &&
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
@@ -34,7 +34,7 @@ _ol_events_condition_.altKeyOnly = function(mapBrowserEvent) {
* @api
*/
_ol_events_condition_.altShiftKeysOnly = function(mapBrowserEvent) {
var originalEvent = mapBrowserEvent.originalEvent;
const originalEvent = mapBrowserEvent.originalEvent;
return (
originalEvent.altKey &&
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
@@ -75,7 +75,7 @@ _ol_events_condition_.click = function(mapBrowserEvent) {
* @return {boolean} The result.
*/
_ol_events_condition_.mouseActionButton = function(mapBrowserEvent) {
var originalEvent = mapBrowserEvent.originalEvent;
const originalEvent = mapBrowserEvent.originalEvent;
return originalEvent.button == 0 &&
!(_ol_has_.WEBKIT && _ol_has_.MAC && originalEvent.ctrlKey);
};
@@ -138,7 +138,7 @@ _ol_events_condition_.doubleClick = function(mapBrowserEvent) {
* @api
*/
_ol_events_condition_.noModifierKeys = function(mapBrowserEvent) {
var originalEvent = mapBrowserEvent.originalEvent;
const originalEvent = mapBrowserEvent.originalEvent;
return (
!originalEvent.altKey &&
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
@@ -156,7 +156,7 @@ _ol_events_condition_.noModifierKeys = function(mapBrowserEvent) {
* @api
*/
_ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) {
var originalEvent = mapBrowserEvent.originalEvent;
const originalEvent = mapBrowserEvent.originalEvent;
return !originalEvent.altKey &&
(_ol_has_.MAC ? originalEvent.metaKey : originalEvent.ctrlKey) &&
!originalEvent.shiftKey;
@@ -172,7 +172,7 @@ _ol_events_condition_.platformModifierKeyOnly = function(mapBrowserEvent) {
* @api
*/
_ol_events_condition_.shiftKeyOnly = function(mapBrowserEvent) {
var originalEvent = mapBrowserEvent.originalEvent;
const originalEvent = mapBrowserEvent.originalEvent;
return (
!originalEvent.altKey &&
!(originalEvent.metaKey || originalEvent.ctrlKey) &&
@@ -189,8 +189,8 @@ _ol_events_condition_.shiftKeyOnly = function(mapBrowserEvent) {
* @api
*/
_ol_events_condition_.targetNotEditable = function(mapBrowserEvent) {
var target = mapBrowserEvent.originalEvent.target;
var tagName = target.tagName;
const target = mapBrowserEvent.originalEvent.target;
const tagName = target.tagName;
return (
tagName !== 'INPUT' &&
tagName !== 'SELECT' &&
@@ -222,7 +222,7 @@ _ol_events_condition_.mouseOnly = function(mapBrowserEvent) {
* @api
*/
_ol_events_condition_.primaryAction = function(mapBrowserEvent) {
var pointerEvent = mapBrowserEvent.pointerEvent;
const pointerEvent = mapBrowserEvent.pointerEvent;
return pointerEvent.isPrimary && pointerEvent.button === 0;
};
export default _ol_events_condition_;