gui.define* => gui.var*

This commit is contained in:
Doug Fritz 2014-09-09 13:18:15 -07:00
parent 64a7d0b630
commit f98ac9b462
5 changed files with 27 additions and 28 deletions

View File

@ -6,7 +6,7 @@ BUILD
REFACTOR REFACTOR
- [ ] controller-* => gui-* - [ ] controller-* => gui-*
- [ ] gui.define* => gui.var* - [x] gui.define* => gui.var*
- [ ] Gui.js => gui-panel => dat-gui - [ ] Gui.js => gui-panel => dat-gui
PARITY PARITY
@ -30,7 +30,6 @@ DOCS
- [ ] Auto generatated polymer docs - [ ] Auto generatated polymer docs
STYLE STYLE
- [x] touch styles: bigger please! - [x] touch styles: bigger please!
- [x] kill hover behavior if touch - [x] kill hover behavior if touch
- [x] sharing more styles - [x] sharing more styles

View File

@ -13,7 +13,7 @@
// Properties // Properties
this.defined = {}; this.vars = {};
this.localStorage = params.localStorage || false; this.localStorage = params.localStorage || false;
// Make domElement // Make domElement
@ -84,22 +84,22 @@
}; };
Gui.prototype.define = function() { Gui.prototype.var = function() {
var name, initialValue, args; var name, initialValue, args;
if ( arguments.length == 1 ) { if ( arguments.length == 1 ) {
name = arguments[ 0 ]; name = arguments[ 0 ];
return this.defined[ name ]; return this.vars[ name ];
} }
initialValue = arguments[ 1 ]; initialValue = arguments[ 1 ];
name = arguments[ 0 ]; name = arguments[ 0 ];
args = [ this.defined, name ]; args = [ this.vars, name ];
args = args.concat( Array.prototype.slice.call( arguments, 2 ) ); args = args.concat( Array.prototype.slice.call( arguments, 2 ) );
this.defined[ name ] = initialValue; this.vars[ name ] = initialValue;
return this.add.apply( this, args ); return this.add.apply( this, args );

View File

@ -5,7 +5,7 @@
var Gui = function() { var Gui = function() {
this.defined = {}; this.vars = {};
}; };
@ -15,9 +15,9 @@
}; };
Gui.prototype.define = function( name, value ) { Gui.prototype.var = function( name, value ) {
this.defined[ name ] = value; this.vars[ name ] = value;
return controllerShim; return controllerShim;
}; };

View File

@ -65,7 +65,7 @@
gui.add( object, 'maxIsNegative', -5, -2 ); gui.add( object, 'maxIsNegative', -5, -2 );
gui.define( 'anonymousSlider', 0, -1, 1 ).comment( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam semper dui metus'); gui.var( 'anonymousSlider', 0, -1, 1 ).comment( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam semper dui metus');
gui.add( object, 'optionController', { A: 'a', B: 'b', C: 'c'} ); gui.add( object, 'optionController', { A: 'a', B: 'b', C: 'c'} );
gui.add( object, 'optionController', [ 'a', 'b', 'c' ] ) gui.add( object, 'optionController', [ 'a', 'b', 'c' ] )

View File

@ -32,7 +32,7 @@ describe( 'Gui', function() {
expectController( 'controller-number', 1234 ); expectController( 'controller-number', 1234 );
expectController( 'controller-string', 'string value' ); expectController( 'controller-string', 'string value' );
expectController( 'controller-function', function(){} ); expectController( 'controller-function', function() {} );
expectController( 'controller-boolean', true ); expectController( 'controller-boolean', true );
expectController( 'controller-option', 'hey', [ 'hey', 'hi', 'ho' ] ); expectController( 'controller-option', 'hey', [ 'hey', 'hi', 'ho' ] );
@ -75,7 +75,7 @@ describe( 'Gui', function() {
args.unshift( value ); args.unshift( value );
args.unshift( 'name' ); args.unshift( 'name' );
controller = gui.define.apply( gui, args ); controller = gui.var.apply( gui, args );
expect( controller.nodeName.toLowerCase() ).toBe( controllerType ); expect( controller.nodeName.toLowerCase() ).toBe( controllerType );
} }