Skip to content

Commit

Permalink
Switch from AirBnb to JavaScript standard
Browse files Browse the repository at this point in the history
Since we're using Standard in other projects, it makes sense to switch
the eslint ruleset from AirBnb to Standard. All of these changes were
made with the `--fix` autocorrect option to eslint.
  • Loading branch information
ijdickinson committed Nov 18, 2019
1 parent f7b5602 commit db5f25d
Show file tree
Hide file tree
Showing 23 changed files with 1,219 additions and 1,194 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
env: {
browser: true,
},
extends: 'airbnb-base',
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
Expand Down
898 changes: 449 additions & 449 deletions app/javascript/data/locations-data.js

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions app/javascript/lib/bind-external-events.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
/* Handle events for components outside the Vue component tree */
/* eslint-disable no-param-reassign */

import bus from './event-bus';
import safeForEach from './safe-foreach';
import bus from './event-bus'
import safeForEach from './safe-foreach'

/** Prevent default behaviour of event, with support for IE which just has to be different! */
function eventPreventDefault(event) {
function eventPreventDefault (event) {
if (event.preventDefault) {
event.preventDefault();
event.preventDefault()
} else {
event.returnValue = false;
event.returnValue = false
}
}

function handleShowHideClick(event) {
eventPreventDefault(event);
function handleShowHideClick (event) {
eventPreventDefault(event)
// notify Vue
let node = event.target;
let node = event.target
while (!node.id) {
node = node.parentElement;
node = node.parentElement
}

const closing = node.classList.contains('o-data-view--open');
bus.$emit('open-close-data-view', { id: node.id, closing });
const closing = node.classList.contains('o-data-view--open')
bus.$emit('open-close-data-view', { id: node.id, closing })

return false;
return false
}

function bindShowHideDataView() {
const nodes = document.querySelectorAll('.o-data-view__hide-action');
function bindShowHideDataView () {
const nodes = document.querySelectorAll('.o-data-view__hide-action')

// this weirdness with slice is because IE11 doesn't do forEach on the return
// value from querySelectorAll
safeForEach(nodes, (node) => {
node.setAttribute('href', '#');
node.addEventListener('click', handleShowHideClick, false);
});
node.setAttribute('href', '#')
node.addEventListener('click', handleShowHideClick, false)
})
}

function handleLocationClick(event) {
function handleLocationClick (event) {
// notify Vue
bus.$emit('change-location');
bus.$emit('change-location')

eventPreventDefault(event);
return false;
eventPreventDefault(event)
return false
}

function bindChangeLocationLink() {
const nodes = document.querySelectorAll('.o-data-view__location');
function bindChangeLocationLink () {
const nodes = document.querySelectorAll('.o-data-view__location')

safeForEach(nodes, (node) => {
node.setAttribute('href', '#');
node.addEventListener('click', handleLocationClick, false);
});
node.setAttribute('href', '#')
node.addEventListener('click', handleLocationClick, false)
})
}

export default function bindExternalEvents() {
bindShowHideDataView();
bindChangeLocationLink();
export default function bindExternalEvents () {
bindShowHideDataView()
bindChangeLocationLink()
}
6 changes: 3 additions & 3 deletions app/javascript/lib/event-bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* ```
*/

import Vue from 'vue';
import Vue from 'vue'

const bus = new Vue();
export default bus;
const bus = new Vue()
export default bus
10 changes: 5 additions & 5 deletions app/javascript/lib/ie-d3-fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
This proposed fix via: https://github.com/Microsoft/ChakraCore/issues/1415#issuecomment-287888807
*/
import * as Sentry from '@sentry/browser';
import * as Sentry from '@sentry/browser'

if (window && window.navigator && window.navigator.userAgent && /Edge\/1[0-4]\./.test(window.navigator.userAgent)) {
// Fix for bug in Microsoft Edge: https://github.com/Microsoft/ChakraCore/issues/1415#issuecomment-246424339
Sentry.captureMessage('Applying function.call fix for Microsoft Edge <= 14');
Sentry.captureMessage('Applying function.call fix for Microsoft Edge <= 14')
/* eslint-disable no-extend-native */
Function.prototype.call = function ieEdgeCallFix(t, ...args) {
return this.apply(t, Array.prototype.slice.apply(args, [1]));
};
Function.prototype.call = function ieEdgeCallFix (t, ...args) {
return this.apply(t, Array.prototype.slice.apply(args, [1]))
}
}
92 changes: 46 additions & 46 deletions app/javascript/lib/leaflet-rrose.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,107 +20,107 @@
* IN THE SOFTWARE.
*/

import L from 'leaflet';
import L from 'leaflet'

L.Rrose = L.Popup.extend({

/* eslint-disable no-underscore-dangle */
_initLayout() {
const prefix = 'leaflet-rrose';
const container = L.DomUtil.create('div', `${prefix} ${this.options.className} leaflet-zoom-animated`);
this.rrose = {};
this._container = container;
_initLayout () {
const prefix = 'leaflet-rrose'
const container = L.DomUtil.create('div', `${prefix} ${this.options.className} leaflet-zoom-animated`)
this.rrose = {}
this._container = container

let closeButton;
let wrapper;
let closeButton
let wrapper

// Set the pixel distances from the map edges at which popups are too close and
// need to be re-oriented.
const xBound = 80;
const yBound = 80;
const xBound = 80
const yBound = 80

// Determine the alternate direction to pop up; north mimics Leaflet's
// default behavior, so we initialize to that.
this.options.position = 'n';
this.options.position = 'n'

// Then see if the point is too far north...
const yDiff = yBound - this._map.latLngToContainerPoint(this._latlng).y;
const yDiff = yBound - this._map.latLngToContainerPoint(this._latlng).y
if (yDiff > 0) {
this.options.position = 's';
this.options.position = 's'
}
// or too far east...
let xDiff = this._map.latLngToContainerPoint(this._latlng).x -
(this._map.getSize().x - xBound);
(this._map.getSize().x - xBound)
if (xDiff > 0) {
this.options.position += 'w';
this.options.position += 'w'
} else {
// or too far west.
xDiff = xBound - this._map.latLngToContainerPoint(this._latlng).x;
xDiff = xBound - this._map.latLngToContainerPoint(this._latlng).x
if (xDiff > 0) {
this.options.position += 'e';
this.options.position += 'e'
}
}

// Create the necessary DOM elements in the correct order. Pure 'n' and 's'
// conditions need only one class for styling, others need two.
if (/s/.test(this.options.position)) {
this._tipContainer = L.DomUtil.create('div', `${prefix}-tip-container` +
` ${prefix}-tip-container-${this.options.position}`, container);
` ${prefix}-tip-container-${this.options.position}`, container)
wrapper = L.DomUtil.create('div', `${prefix}-content-wrapper` +
` ${prefix}-content-wrapper-${this.options.position}`, container);
this._wrapper = wrapper;
` ${prefix}-content-wrapper-${this.options.position}`, container)
this._wrapper = wrapper
} else {
wrapper = L.DomUtil.create('div', `${prefix}-content-wrapper` +
` ${prefix}-content-wrapper-${this.options.position}`, container);
this._wrapper = wrapper;
` ${prefix}-content-wrapper-${this.options.position}`, container)
this._wrapper = wrapper
this._tipContainer = L.DomUtil.create('div', `${prefix}-tip-container` +
` ${prefix}-tip-container-${this.options.position}`, container);
` ${prefix}-tip-container-${this.options.position}`, container)
}

this._tip = L.DomUtil.create('div', `${prefix}-tip` +
` ${prefix}-tip-${this.options.position}`, this._tipContainer);
L.DomEvent.disableClickPropagation(wrapper);
this._contentNode = L.DomUtil.create('div', `${prefix}-content`, wrapper);
L.DomEvent.on(this._contentNode, 'mousewheel', L.DomEvent.stopPropagation);
` ${prefix}-tip-${this.options.position}`, this._tipContainer)
L.DomEvent.disableClickPropagation(wrapper)
this._contentNode = L.DomUtil.create('div', `${prefix}-content`, wrapper)
L.DomEvent.on(this._contentNode, 'mousewheel', L.DomEvent.stopPropagation)

if (this.options.closeButton) {
closeButton = L.DomUtil.create('a', `${prefix}-close-button`, this._wrapper);
this._closeButton = closeButton;
closeButton.href = '#close';
closeButton.innerHTML = '&#215;';
closeButton = L.DomUtil.create('a', `${prefix}-close-button`, this._wrapper)
this._closeButton = closeButton
closeButton.href = '#close'
closeButton.innerHTML = '&#215;'

L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this);
L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this)
}
},

_updatePosition() {
const pos = this._map.latLngToLayerPoint(this._latlng);
const is3d = L.Browser.any3d;
const { offset } = this.options;
_updatePosition () {
const pos = this._map.latLngToLayerPoint(this._latlng)
const is3d = L.Browser.any3d
const { offset } = this.options

if (is3d) {
L.DomUtil.setPosition(this._container, pos);
L.DomUtil.setPosition(this._container, pos)
}

if (/s/.test(this.options.position)) {
this._containerBottom = (-this._container.offsetHeight + offset.y) -
(is3d ? 0 : pos.y);
(is3d ? 0 : pos.y)
} else {
this._containerBottom = -offset.y - (is3d ? 0 : pos.y);
this._containerBottom = -offset.y - (is3d ? 0 : pos.y)
}

if (/e/.test(this.options.position)) {
this._containerLeft = offset.x + (is3d ? 0 : pos.x);
this._containerLeft = offset.x + (is3d ? 0 : pos.x)
} else if (/w/.test(this.options.position)) {
this._containerLeft = -Math.round(this._containerWidth) + offset.x +
(is3d ? 0 : pos.x);
(is3d ? 0 : pos.x)
} else {
this._containerLeft = -Math.round(this._containerWidth / 2) +
offset.x + (is3d ? 0 : pos.x);
offset.x + (is3d ? 0 : pos.x)
}

this._container.style.bottom = `${this._containerBottom}px`;
this._container.style.left = `${this._containerLeft}px`;
},
this._container.style.bottom = `${this._containerBottom}px`
this._container.style.left = `${this._containerLeft}px`
}

});
})
Loading

0 comments on commit db5f25d

Please sign in to comment.