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,
"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"],
"disallowSpacesInsideObjectBrackets": null,
"disallowImplicitTypeConversion": ["string"],
"disallowMultipleVarDecl": null,
"disallowImplicitTypeConversion": ["string"]
"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 );
function init() {
@ -119,7 +121,9 @@ function sticky( elements ) {
var body = document.body, timer;
window.addEventListener('scroll', function() {
clearTimeout( timer );
if ( !body.classList.contains('disable-hover') ) {
body.classList.add('disable-hover')
}
@ -127,6 +131,7 @@ window.addEventListener('scroll', function() {
timer = setTimeout(function() {
body.classList.remove('disable-hover')
}, 150);
}, false);
})();

View File

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

View File

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

View File

@ -6,14 +6,6 @@
[ ] arrow keys
[ ] 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 ) {
@ -60,6 +52,7 @@ Polymer('controller-number', {
},
// Observers
// -------------------------------
@ -78,6 +71,7 @@ Polymer('controller-number', {
}
this.super();
},
minChanged: function() {
@ -147,6 +141,7 @@ Polymer('controller-number', {
},
// Events
// -------------------------------
@ -203,12 +198,12 @@ Polymer('controller-number', {
this.value = this.valueFromX( e.pageX );
}
},
tracky: function( e ) {
this._dragFriction = Math.max(0.01,
Math.min(1, this.map(e.dy, 50, 300, 1, 0.1)));
this._dragFriction = Math.max( 0.01, Math.min( 1, this.map( e.dy, 50, 300, 1, 0.1 )) );
},
@ -222,6 +217,7 @@ Polymer('controller-number', {
},
// Filters
// -------------------------------
@ -235,6 +231,7 @@ Polymer('controller-number', {
},
// Helpers
// -------------------------------

View File

@ -1,3 +1,6 @@
/* globals Polymer, Object, Array */
'use strict';
Polymer( 'controller-option', {
key: null,
@ -48,10 +51,13 @@ Polymer( 'controller-option', {
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 ) {
if ( e.keyCode == 13 ) {
this.$.input.blur();
}
}

View File

@ -13,21 +13,25 @@ Polymer('gui-panel', {
ready: function() {
this.domElement = this;
this.defined = {};
},
define: function() {
var name, initialValue, args;
if ( arguments.length == 1 ) {
var name = arguments[ 0 ];
name = arguments[ 0 ];
return this.defined[ name ];
}
var initialValue = arguments[ 1 ];
var name = arguments[ 0 ];
initialValue = arguments[ 1 ];
name = arguments[ 0 ];
var args = [ this.defined, name ];
args = [ this.defined, name ];
args = args.concat( Array.prototype.slice.call( arguments, 2 ) );
this.defined[ name ] = initialValue;
@ -126,21 +130,6 @@ Polymer('gui-panel', {
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
// -------------------------------
@ -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',
'elements/**/*.js', 'gui.html'], ['build']);
gulp.watch( ['elements/**/*.styl', 'elements/**/*.html', 'elements/**/*.js', 'gui.html'], ['build'] );
gulp.watch( ['README.md', 'docs/*'], ['docs'] );
@ -45,24 +44,30 @@ gulp.task('vulcanize', ['css'], function() {
dest: 'build',
inline: true,
strip: true
} ) );
} );
gulp.task( 'lint', ['jscs', 'jshint'] );
gulp.task( 'jscs', function() {
return gulp.src('elements/**/*.js')
return gulp.src( 'elements/**/*.js', '*.json', '*.js' )
.pipe( $.jscs() );
} );
gulp.task( 'jshint', function() {
return gulp.src('elements/**/*.js')
return gulp.src( 'elements/**/*.js', '*.json', '*.js' )
.pipe( reload( { stream: true, once: true } ) )
.pipe( $.jshint( '.jshintrc' ) )
.pipe( $.jshint.reporter( 'jshint-stylish' ) )
.pipe( $.if( !browserSync.active, $.jshint.reporter( 'fail' ) ) );
} );
gulp.task('lint', ['jscs', 'jshint']);
gulp.task( 'css', function() {