From 49649b1ff911f9d99fd32ffd65057c3daf446f50 Mon Sep 17 00:00:00 2001 From: Doug Fritz Date: Wed, 3 Sep 2014 21:14:36 -0700 Subject: [PATCH] update style for jshint and jscs --- .jshintrc | 2 +- elements/Gui.js | 17 ++++++++--------- elements/controller-base/controller-base.js | 7 +++---- .../controller-boolean/controller-boolean.js | 4 +++- .../controller-function.js | 3 +++ .../controller-number/controller-number.js | 19 +++++++++++-------- .../controller-string/controller-string.js | 3 +++ elements/gui-panel/gui-panel.js | 16 ++++++++-------- elements/gui-row/gui-row.js | 3 +++ 9 files changed, 43 insertions(+), 31 deletions(-) diff --git a/.jshintrc b/.jshintrc index 804f8af..1419d9f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -5,7 +5,7 @@ "camelcase": true, "curly": true, "immed": true, - "newcap": true, + "newcap": false, "noarg": true, "undef": true, "unused": "vars", diff --git a/elements/Gui.js b/elements/Gui.js index b75b083..24d30f6 100644 --- a/elements/Gui.js +++ b/elements/Gui.js @@ -1,4 +1,7 @@ +/* globals document */ + (function(scope) { + 'use strict'; var Gui = function(params) { @@ -20,7 +23,6 @@ }; - // Register custom controllers // ------------------------------- @@ -32,7 +34,6 @@ }; - // Returns a controller based on a value // ------------------------------- @@ -52,7 +53,6 @@ }; - // Gui ready handler ... * shakes fist at polymer * // ------------------------------- @@ -72,11 +72,14 @@ Gui.ready = function(fnc) { - ready ? fnc() : readyHandlers.push(fnc); + if (ready) { + fnc(); + } else { + readyHandlers.push(fnc); + } }; - // Error // ------------------------------- @@ -92,7 +95,6 @@ console.warn.apply(console, args); }; - // Old namespaces // ------------------------------- @@ -129,13 +131,10 @@ } - // Export // ------------------------------- scope.dat = dat; scope.Gui = Gui; - })(this); - diff --git a/elements/controller-base/controller-base.js b/elements/controller-base/controller-base.js index 4bcf251..9674579 100644 --- a/elements/controller-base/controller-base.js +++ b/elements/controller-base/controller-base.js @@ -1,3 +1,6 @@ +/* globals Gui, Polymer, PathObserver */ +'use strict'; + /* [ ] onChange() @@ -17,7 +20,6 @@ Polymer('controller-base', { init: function() {}, - // Observers // ------------------------------- @@ -36,7 +38,6 @@ Polymer('controller-base', { }, - // Helpers // ------------------------------- @@ -44,7 +45,6 @@ Polymer('controller-base', { return (x - a) / (b - a) * (d - c) + c; }, - // Legacy // ------------------------------- @@ -68,5 +68,4 @@ Polymer('controller-base', { } - }); diff --git a/elements/controller-boolean/controller-boolean.js b/elements/controller-boolean/controller-boolean.js index 288c03f..ae1c1f9 100644 --- a/elements/controller-boolean/controller-boolean.js +++ b/elements/controller-boolean/controller-boolean.js @@ -1,3 +1,6 @@ +/* globals Gui, Polymer */ +'use strict'; + Gui.register('controller-boolean', function(value) { return typeof value == 'boolean'; @@ -8,7 +11,6 @@ Polymer('controller-boolean', { ready: function() { - }, toggle: function() { diff --git a/elements/controller-function/controller-function.js b/elements/controller-function/controller-function.js index cdb02c8..c7fa1f6 100644 --- a/elements/controller-function/controller-function.js +++ b/elements/controller-function/controller-function.js @@ -1,3 +1,6 @@ +/* globals Gui, Polymer */ +'use strict'; + Gui.register('controller-function', function(value) { return typeof value == 'function'; diff --git a/elements/controller-number/controller-number.js b/elements/controller-number/controller-number.js index 7de74d6..28e5c94 100644 --- a/elements/controller-number/controller-number.js +++ b/elements/controller-number/controller-number.js @@ -1,3 +1,6 @@ +/* globals Gui, Polymer, window */ +'use strict'; + /* [ ] arrow keys @@ -34,11 +37,15 @@ Polymer('controller-number', { var _this = this; window.addEventListener('keydown', function(e) { - if (e.keyCode == 18) _this._alt = true; + if (e.keyCode == 18) { + _this._alt = true; + } }, false); window.addEventListener('keyup', function(e) { - if (e.keyCode == 18) _this._alt = false; + if (e.keyCode == 18) { + _this._alt = false; + } }, false); this.super(); @@ -140,7 +147,6 @@ Polymer('controller-number', { }, - // Events // ------------------------------- @@ -162,7 +168,7 @@ Polymer('controller-number', { e.preventDefault(); this._rect = this.$.track.getBoundingClientRect(); - if (!this._alt) this.value = this.valueFromX(e.x); + if (!this._alt) { this.value = this.valueFromX(e.x); } }, @@ -185,7 +191,7 @@ Polymer('controller-number', { var dv = this.valueFromDX(e.ddx); - if (this._alt) dv /= 10; + if (this._alt) { dv /= 10; } this.value += dv * this._dragFriction; @@ -213,8 +219,6 @@ Polymer('controller-number', { }, - - // Filters // ------------------------------- @@ -228,7 +232,6 @@ Polymer('controller-number', { }, - // Helpers // ------------------------------- diff --git a/elements/controller-string/controller-string.js b/elements/controller-string/controller-string.js index 094b074..b85fdd0 100644 --- a/elements/controller-string/controller-string.js +++ b/elements/controller-string/controller-string.js @@ -1,3 +1,6 @@ +/* globals Gui, Polymer */ +'use strict'; + Gui.register('controller-string', function(value) { return typeof value == 'string'; diff --git a/elements/gui-panel/gui-panel.js b/elements/gui-panel/gui-panel.js index efedc3f..c285fed 100644 --- a/elements/gui-panel/gui-panel.js +++ b/elements/gui-panel/gui-panel.js @@ -1,3 +1,6 @@ +/* globals Polymer, window, document, Path, Gui */ +'use strict'; + // [ ] scrolling when docked // [ ] scrolling when window short and not docked @@ -6,7 +9,7 @@ Polymer('gui-panel', { docked: false, open: true, touch: ('ontouchstart' in window) || - (!!window.DocumentTouch && document instanceof DocumentTouch), + (!!window.DocumentTouch && document instanceof window.DocumentTouch), ready: function() { @@ -17,14 +20,15 @@ Polymer('gui-panel', { }, anon: function() { + var name; if (arguments.length == 1) { - var name = arguments[0]; + name = arguments[0]; return this.anon.values[name]; } var initialValue = arguments[0]; - var name = arguments[1]; + name = arguments[1]; var args = [this.anon.values, name]; args = args.concat(Array.prototype.slice.call(arguments, 2)); @@ -41,7 +45,7 @@ Polymer('gui-panel', { var value = Path.get(path).getValueFrom(object); - if (value == null || value == undefined) { + if (value === null || value === undefined) { return Gui.error(object + ' doesn\'t have a value for path "' + path + '".'); } @@ -79,7 +83,6 @@ Polymer('gui-panel', { }, - // Observers // ------------------------------- @@ -101,7 +104,6 @@ Polymer('gui-panel', { } - }, dockedChanged: function() { @@ -110,7 +112,6 @@ Polymer('gui-panel', { }, - // Events // ------------------------------- @@ -128,7 +129,6 @@ Polymer('gui-panel', { // }, - // Legacy // ------------------------------- diff --git a/elements/gui-row/gui-row.js b/elements/gui-row/gui-row.js index 083ff37..5a1a8e3 100644 --- a/elements/gui-row/gui-row.js +++ b/elements/gui-row/gui-row.js @@ -1,3 +1,6 @@ +/* globals Polymer */ +'use strict'; + Polymer('gui-row', { comment: null,