This commit is contained in:
George Michael Brower 2014-09-07 21:31:51 -04:00
parent 62dafb68f9
commit d19dc2ef40
17 changed files with 729 additions and 701 deletions

View File

@ -1,5 +0,0 @@
# 2 space indentation
[*.js]
indent_style = space
indent_size = 2

48
.jscsrc
View File

@ -1,20 +1,44 @@
{ {
"preset": "google",
"fileExtensions": [ ".js" ],
"requireParenthesesAroundIIFE": true, "fileExtensions": [".js", ".json"],
"excludeFiles": ["node_modules/**", "build/**"],
"maximumLineLength": 120, "maximumLineLength": 120,
"validateLineBreaks": "LF", "validateLineBreaks": "LF",
"validateIndentation": 2, "validateIndentation": 4,
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"return",
"try",
"catch"
],
"requireSpaceBeforeBlockStatements": true,
"requireSpacesInConditionalExpression": {
"afterTest": true,
"beforeConsequent": true,
"afterConsequent": true,
"beforeAlternate": true
},
"requireSpacesInsideParentheses": "allButNested",
"requireSpacesInsideObjectBrackets": "allButNested",
"requireSpacesInsideArrayBrackets": "allButNested",
"requireParenthesesAroundIIFE": true,
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowKeywords": ["with"], "disallowKeywords": ["with"],
"disallowSpacesInsideObjectBrackets": null, "disallowImplicitTypeConversion": ["string"]
"disallowImplicitTypeConversion": ["string"],
"disallowMultipleVarDecl": null,
"safeContextKeyword": "_this",
"excludeFiles": [
"test/data/**"
]
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,5 @@
'use strict';
Gui.ready( init ); Gui.ready( init );
function init() { function init() {
@ -119,7 +121,9 @@ function sticky( elements ) {
var body = document.body, timer; var body = document.body, timer;
window.addEventListener('scroll', function() { window.addEventListener('scroll', function() {
clearTimeout( timer ); clearTimeout( timer );
if ( !body.classList.contains('disable-hover') ) { if ( !body.classList.contains('disable-hover') ) {
body.classList.add('disable-hover') body.classList.add('disable-hover')
} }
@ -127,6 +131,7 @@ window.addEventListener('scroll', function() {
timer = setTimeout(function() { timer = setTimeout(function() {
body.classList.remove('disable-hover') body.classList.remove('disable-hover')
}, 150); }, 150);
}, false); }, false);
})(); })();

View File

@ -1,4 +1,5 @@
( function( scope ) { ( function( scope ) {
'use strict'; 'use strict';
var Gui = function( params ) { var Gui = function( params ) {
@ -21,6 +22,7 @@
}; };
// Register custom controllers // Register custom controllers
// ------------------------------- // -------------------------------
@ -32,6 +34,7 @@
}; };
// Returns a controller based on a value // Returns a controller based on a value
// ------------------------------- // -------------------------------
@ -51,6 +54,7 @@
}; };
// Gui ready handler ... * shakes fist at polymer * // Gui ready handler ... * shakes fist at polymer *
// ------------------------------- // -------------------------------
@ -70,14 +74,11 @@
Gui.ready = function( fnc ) { Gui.ready = function( fnc ) {
if (ready) { ready ? fnc() : readyHandlers.push( fnc );
fnc();
} else {
readyHandlers.push(fnc);
}
}; };
// Error // Error
// ------------------------------- // -------------------------------
@ -93,6 +94,7 @@
console.warn.apply( console, args ); console.warn.apply( console, args );
}; };
// Old namespaces // Old namespaces
// ------------------------------- // -------------------------------
@ -129,10 +131,12 @@
} }
// Export // Export
// ------------------------------- // -------------------------------
scope.dat = dat; scope.dat = dat;
scope.Gui = Gui; scope.Gui = Gui;
} )( this ); } )( this );

View File

@ -1,12 +1,8 @@
/* globals Gui, Polymer, PathObserver */ /* globals Gui, Polymer, PathObserver */
'use strict'; 'use strict';
/* // [ ] onFinishChange()
[ ] onChange()
[ ] onFinishChange()
*/
Polymer( 'controller-base', { Polymer( 'controller-base', {
ready: function() { ready: function() {
@ -19,6 +15,7 @@ Polymer('controller-base', {
init: function() {}, init: function() {},
// Observers // Observers
// ------------------------------- // -------------------------------
@ -38,6 +35,7 @@ Polymer('controller-base', {
}, },
// Helpers // Helpers
// ------------------------------- // -------------------------------
@ -50,6 +48,7 @@ Polymer('controller-base', {
return ( x - a ) / ( b - a ) * ( d - c ) + c; return ( x - a ) / ( b - a ) * ( d - c ) + c;
}, },
// Legacy // Legacy
// ------------------------------- // -------------------------------
@ -77,8 +76,11 @@ Polymer('controller-base', {
onChange: function( v ) { onChange: function( v ) {
this.addEventListener( 'change', function( e ) { this.addEventListener( 'change', function( e ) {
v( e.detail ); v( e.detail );
} ); } );
return this; return this;
}, },

View File

@ -6,14 +6,6 @@
[ ] arrow keys [ ] arrow keys
[ ] min() max() step() commands of yore [ ] min() max() step() commands of yore
[x] only validate input box on blur, not on keydown
[x] enter key blurs
[x] decimals
[x] step
[x] dy to drag friction
[x] negative slider
[x] hover behavior
*/ */
Gui.register( 'controller-number', function( value ) { Gui.register( 'controller-number', function( value ) {
@ -60,6 +52,7 @@ Polymer('controller-number', {
}, },
// Observers // Observers
// ------------------------------- // -------------------------------
@ -78,6 +71,7 @@ Polymer('controller-number', {
} }
this.super(); this.super();
}, },
minChanged: function() { minChanged: function() {
@ -147,6 +141,7 @@ Polymer('controller-number', {
}, },
// Events // Events
// ------------------------------- // -------------------------------
@ -203,12 +198,12 @@ Polymer('controller-number', {
this.value = this.valueFromX( e.pageX ); this.value = this.valueFromX( e.pageX );
} }
}, },
tracky: function( e ) { tracky: function( e ) {
this._dragFriction = Math.max(0.01, this._dragFriction = Math.max( 0.01, Math.min( 1, this.map( e.dy, 50, 300, 1, 0.1 )) );
Math.min(1, this.map(e.dy, 50, 300, 1, 0.1)));
}, },
@ -222,6 +217,7 @@ Polymer('controller-number', {
}, },
// Filters // Filters
// ------------------------------- // -------------------------------
@ -235,6 +231,7 @@ Polymer('controller-number', {
}, },
// Helpers // Helpers
// ------------------------------- // -------------------------------

View File

@ -1,3 +1,6 @@
/* globals Polymer, Object, Array */
'use strict';
Polymer( 'controller-option', { Polymer( 'controller-option', {
key: null, key: null,
@ -48,10 +51,13 @@ Polymer( 'controller-option', {
keys: function( object ) { keys: function( object ) {
if ( object ) return Object.keys( object ); if ( object ) {
return Object.keys( object );
}
} }
} ); } );

View File

@ -18,7 +18,9 @@ Polymer('controller-string', {
keydown: function( e ) { keydown: function( e ) {
if ( e.keyCode == 13 ) { if ( e.keyCode == 13 ) {
this.$.input.blur(); this.$.input.blur();
} }
} }

View File

@ -13,21 +13,25 @@ Polymer('gui-panel', {
ready: function() { ready: function() {
this.domElement = this;
this.defined = {}; this.defined = {};
}, },
define: function() { define: function() {
var name, initialValue, args;
if ( arguments.length == 1 ) { if ( arguments.length == 1 ) {
var name = arguments[ 0 ]; name = arguments[ 0 ];
return this.defined[ name ]; return this.defined[ name ];
} }
var initialValue = arguments[ 1 ]; initialValue = arguments[ 1 ];
var name = arguments[ 0 ]; name = arguments[ 0 ];
var args = [ this.defined, name ]; args = [ this.defined, name ];
args = args.concat( Array.prototype.slice.call( arguments, 2 ) ); args = args.concat( Array.prototype.slice.call( arguments, 2 ) );
this.defined[ name ] = initialValue; this.defined[ name ] = initialValue;
@ -126,21 +130,6 @@ Polymer('gui-panel', {
this.open = !this.open; this.open = !this.open;
}, },
// checkHeight: function() {
// if ( window.innerHeight < this.$.controllers.offsetHeight ) {
// this.docked = true;
// } else {
// this.docked = false;
// }
// if ( window.innerHeight < this.$.controllers.offsetHeight) {
// this.docked = true;
// } else {
// this.docked = false;
// }
// },
// Legacy // Legacy
// ------------------------------- // -------------------------------
@ -151,6 +140,5 @@ Polymer('gui-panel', {
} }
// todo: domElement
} ); } );

View File

@ -19,8 +19,7 @@ gulp.task('watch', ['default'], function() {
] ]
} ); } );
gulp.watch(['elements/**/*.styl', 'elements/**/*.html', gulp.watch( ['elements/**/*.styl', 'elements/**/*.html', 'elements/**/*.js', 'gui.html'], ['build'] );
'elements/**/*.js', 'gui.html'], ['build']);
gulp.watch( ['README.md', 'docs/*'], ['docs'] ); gulp.watch( ['README.md', 'docs/*'], ['docs'] );
@ -45,24 +44,30 @@ gulp.task('vulcanize', ['css'], function() {
dest: 'build', dest: 'build',
inline: true, inline: true,
strip: true strip: true
} ) ); } ) );
} ); } );
gulp.task( 'lint', ['jscs', 'jshint'] );
gulp.task( 'jscs', function() { gulp.task( 'jscs', function() {
return gulp.src('elements/**/*.js')
return gulp.src( 'elements/**/*.js', '*.json', '*.js' )
.pipe( $.jscs() ); .pipe( $.jscs() );
} ); } );
gulp.task( 'jshint', function() { gulp.task( 'jshint', function() {
return gulp.src('elements/**/*.js')
return gulp.src( 'elements/**/*.js', '*.json', '*.js' )
.pipe( reload( { stream: true, once: true } ) ) .pipe( reload( { stream: true, once: true } ) )
.pipe( $.jshint( '.jshintrc' ) ) .pipe( $.jshint( '.jshintrc' ) )
.pipe( $.jshint.reporter( 'jshint-stylish' ) ) .pipe( $.jshint.reporter( 'jshint-stylish' ) )
.pipe( $.if( !browserSync.active, $.jshint.reporter( 'fail' ) ) ); .pipe( $.if( !browserSync.active, $.jshint.reporter( 'fail' ) ) );
} ); } );
gulp.task('lint', ['jscs', 'jshint']);
gulp.task( 'css', function() { gulp.task( 'css', function() {