From 3f6f66d09c23314b32b032a432274a447b9535b0 Mon Sep 17 00:00:00 2001 From: Jeff Nusz Date: Thu, 1 Sep 2016 14:04:35 -0700 Subject: [PATCH] fix eslint issues --- src/dat/color/interpret.js | 2 +- src/dat/controllers/ControllerFactory.js | 8 +- src/dat/controllers/NumberControllerBox.js | 2 - src/dat/controllers/NumberControllerSlider.js | 2 +- src/dat/dom/dom.js | 84 +++++++++---------- src/dat/gui/GUI.js | 12 ++- 6 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/dat/color/interpret.js b/src/dat/color/interpret.js index fd22637..451d0d8 100644 --- a/src/dat/color/interpret.js +++ b/src/dat/color/interpret.js @@ -75,7 +75,7 @@ const INTERPRETATIONS = [ CSS_RGBA: { read: function(original) { - const test = original.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\,\s*(.+)\s*\)/); + const test = original.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/); if (test === null) { return false; } diff --git a/src/dat/controllers/ControllerFactory.js b/src/dat/controllers/ControllerFactory.js index de28f21..da48026 100644 --- a/src/dat/controllers/ControllerFactory.js +++ b/src/dat/controllers/ControllerFactory.js @@ -33,7 +33,8 @@ const ControllerFactory = function(object, property) { if (common.isNumber(arguments[2]) && common.isNumber(arguments[3])) { // has step? if (common.isNumber(arguments[4])) { - return new NumberControllerSlider(object, property, arguments[2], arguments[3], arguments[4]); + return new NumberControllerSlider(object, property, + arguments[2], arguments[3], arguments[4]); } return new NumberControllerSlider(object, property, arguments[2], arguments[3]); @@ -41,7 +42,8 @@ const ControllerFactory = function(object, property) { // number box if (common.isNumber(arguments[4])) { // has step - return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3], step: arguments[4] }); + return new NumberControllerBox(object, property, + { min: arguments[2], max: arguments[3], step: arguments[4] }); } return new NumberControllerBox(object, property, { min: arguments[2], max: arguments[3] }); } @@ -57,6 +59,8 @@ const ControllerFactory = function(object, property) { if (common.isBoolean(initialValue)) { return new BooleanController(object, property); } + + return null; }; export default ControllerFactory; diff --git a/src/dat/controllers/NumberControllerBox.js b/src/dat/controllers/NumberControllerBox.js index 9bc1d78..d0cc3c6 100644 --- a/src/dat/controllers/NumberControllerBox.js +++ b/src/dat/controllers/NumberControllerBox.js @@ -114,5 +114,3 @@ class NumberControllerBox extends NumberController { } export default NumberControllerBox; - - diff --git a/src/dat/controllers/NumberControllerSlider.js b/src/dat/controllers/NumberControllerSlider.js index ec1b669..244b7c3 100644 --- a/src/dat/controllers/NumberControllerSlider.js +++ b/src/dat/controllers/NumberControllerSlider.js @@ -38,7 +38,7 @@ function map(v, i1, i2, o1, o2) { */ class NumberControllerSlider extends NumberController { constructor(object, property, min, max, step) { - super(object, property, {min: min, max: max, step: step}); + super(object, property, { min: min, max: max, step: step }); const _this = this; diff --git a/src/dat/dom/dom.js b/src/dat/dom/dom.js index 15f92f5..b802fc9 100644 --- a/src/dat/dom/dom.js +++ b/src/dat/dom/dom.js @@ -14,9 +14,9 @@ import common from '../utils/common'; const EVENT_MAP = { - 'HTMLEvents': ['change'], - 'MouseEvents': ['click', 'mousemove', 'mousedown', 'mouseup', 'mouseover'], - 'KeyboardEvents': ['keydown'] + HTMLEvents: ['change'], + MouseEvents: ['click', 'mousemove', 'mousedown', 'mouseup', 'mouseover'], + KeyboardEvents: ['keydown'] }; const EVENT_MAP_INV = {}; @@ -112,43 +112,43 @@ const dom = { } const evt = document.createEvent(className); switch (className) { - case 'MouseEvents': - { - const clientX = params.x || params.clientX || 0; - const clientY = params.y || params.clientY || 0; - evt.initMouseEvent(eventType, params.bubbles || false, - params.cancelable || true, window, params.clickCount || 1, - 0, // screen X - 0, // screen Y - clientX, // client X - clientY, // client Y - false, false, false, false, 0, null); - break; - } - case 'KeyboardEvents': - { - const init = evt.initKeyboardEvent || evt.initKeyEvent; // webkit || moz - common.defaults(params, { - cancelable: true, - ctrlKey: false, - altKey: false, - shiftKey: false, - metaKey: false, - keyCode: undefined, - charCode: undefined - }); - init(eventType, params.bubbles || false, - params.cancelable, window, - params.ctrlKey, params.altKey, - params.shiftKey, params.metaKey, - params.keyCode, params.charCode); - break; - } - default: - { - evt.initEvent(eventType, params.bubbles || false, params.cancelable || true); - break; - } + case 'MouseEvents': + { + const clientX = params.x || params.clientX || 0; + const clientY = params.y || params.clientY || 0; + evt.initMouseEvent(eventType, params.bubbles || false, + params.cancelable || true, window, params.clickCount || 1, + 0, // screen X + 0, // screen Y + clientX, // client X + clientY, // client Y + false, false, false, false, 0, null); + break; + } + case 'KeyboardEvents': + { + const init = evt.initKeyboardEvent || evt.initKeyEvent; // webkit || moz + common.defaults(params, { + cancelable: true, + ctrlKey: false, + altKey: false, + shiftKey: false, + metaKey: false, + keyCode: undefined, + charCode: undefined + }); + init(eventType, params.bubbles || false, + params.cancelable, window, + params.ctrlKey, params.altKey, + params.shiftKey, params.metaKey, + params.keyCode, params.charCode); + break; + } + default: + { + evt.initEvent(eventType, params.bubbles || false, params.cancelable || true); + break; + } } common.defaults(evt, aux); elem.dispatchEvent(evt); @@ -267,7 +267,7 @@ const dom = { */ getOffset: function(el) { let elem = el; - const offset = {left: 0, top: 0}; + const offset = { left: 0, top: 0 }; if (elem.offsetParent) { do { offset.left += elem.offsetLeft; @@ -284,7 +284,7 @@ const dom = { * @param elem */ isActive: function(elem) { - return elem === document.activeElement && ( elem.type || elem.href ); + return elem === document.activeElement && (elem.type || elem.href); } }; diff --git a/src/dat/gui/GUI.js b/src/dat/gui/GUI.js index 412bd8c..effabfc 100644 --- a/src/dat/gui/GUI.js +++ b/src/dat/gui/GUI.js @@ -45,7 +45,7 @@ const SUPPORTS_LOCAL_STORAGE = (function() { } catch (e) { return false; } -})(); +}()); let SAVE_DIALOGUE; @@ -144,7 +144,7 @@ const GUI = function(pars) { params.load.preset = params.preset; } } else { - params.load = {preset: DEFAULT_DEFAULT_PRESET_NAME}; + params.load = { preset: DEFAULT_DEFAULT_PRESET_NAME }; } if (common.isUndefined(params.parent) && params.hideable) { @@ -386,7 +386,7 @@ const GUI = function(pars) { // Make it not elastic. - if (!this.parent) { + if (!this.parent) { setWidth(_this, params.width); } } @@ -537,7 +537,7 @@ common.extend( ' name "' + name + '"'); } - const newGuiParams = {name: name, parent: this}; + const newGuiParams = { name: name, parent: this }; // We need to pass down the autoPlace trait so that we can // attach event listeners to open/close folder actions to @@ -545,11 +545,9 @@ common.extend( newGuiParams.autoPlace = this.autoPlace; // Do we have saved appearance data for this folder? - if (this.load && // Anything loaded? this.load.folders && // Was my parent a dead-end? this.load.folders[name]) { // Did daddy remember me? - // Start me closed if I was closed newGuiParams.closed = this.load.folders[name].closed; @@ -837,7 +835,7 @@ function augmentController(gui, li, controller) { // All sliders should be accompanied by a box. if (controller instanceof NumberControllerSlider) { const box = new NumberControllerBox(controller.object, controller.property, - {min: controller.__min, max: controller.__max, step: controller.__step}); + { min: controller.__min, max: controller.__max, step: controller.__step }); common.each(['updateDisplay', 'onChange', 'onFinishChange', 'step'], function(method) { const pc = controller[method];