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

@ -2,10 +2,10 @@
( function( scope ) { ( function( scope ) {
'use strict'; 'use strict';
var Gui = function() { var Gui = function() {
this.defined = {}; this.vars = {};
}; };
@ -15,15 +15,15 @@
}; };
Gui.prototype.define = function( name, value ) { Gui.prototype.var = function( name, value ) {
this.defined[ name ] = value; this.vars[ name ] = value;
return controllerShim; return controllerShim;
}; };
Gui.prototype.add = function( object, path ) { Gui.prototype.add = function( object, path ) {
return controllerShim; return controllerShim;
}; };
@ -36,4 +36,4 @@
scope.Gui = Gui; scope.Gui = Gui;
} )( this ); } )( this );

View File

@ -4,13 +4,13 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>dat-gui kitchen sink</title> <title>dat-gui kitchen sink</title>
<script src="../build/gui.js"></script> <script src="../build/gui.js"></script>
<!-- <link rel="import" href="../gui.html"> --> <!-- <link rel="import" href="../gui.html"> -->
<meta name="viewport" content="width=device-width, user-scalable=no"> <meta name="viewport" content="width=device-width, user-scalable=no">
<style type="text/css"> <style type="text/css">
body { body {
background: #aaa; background: #aaa;
@ -24,7 +24,7 @@
<script> <script>
var object = { var object = {
"boolean": false, "boolean": false,
"listen4Free": 332, "listen4Free": 332,
"zeroTo1": 0, "zeroTo1": 0,
@ -35,9 +35,9 @@
"optionController": 'a' "optionController": 'a'
}; };
// How do we kill polymer-ready ... // How do we kill polymer-ready ...
Gui.ready( function() { Gui.ready( function() {
gui = new Gui(); gui = new Gui();
gui.panel.docked = true; gui.panel.docked = true;
@ -48,13 +48,13 @@
gui.add( r.row, 'name' ); gui.add( r.row, 'name' );
gui.add( object, 'boolean' ); gui.add( object, 'boolean' );
gui.add( object, 'listen4Free' ); gui.add( object, 'listen4Free' );
gui.add( object, 'listen4Free' ); gui.add( object, 'listen4Free' );
gui.add( object, 'listen4Free', 0, 1000 ); gui.add( object, 'listen4Free', 0, 1000 );
gui.add( object, 'zeroTo1', 0, 1 ); gui.add( object, 'zeroTo1', 0, 1 );
gui.add( object, 'hasComment' ).comment( 'Hi there.' ); gui.add( object, 'hasComment' ).comment( 'Hi there.' );
gui.add( object, 'listen4Free' ).name( 'customName' ) gui.add( object, 'listen4Free' ).name( 'customName' )
@ -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' ] )
@ -78,4 +78,4 @@
</script> </script>
</body> </body>
</html> </html>

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' ] );
@ -51,7 +51,7 @@ describe( 'Gui', function() {
function expectController( controllerType, value ) { function expectController( controllerType, value ) {
var gui = new Gui(); var gui = new Gui();
// test using gui.add // test using gui.add
@ -66,7 +66,7 @@ describe( 'Gui', function() {
var controller = gui.add.apply( gui, args ); var controller = gui.add.apply( gui, args );
expect( controller.nodeName.toLowerCase() ).toBe( controllerType ); expect( controller.nodeName.toLowerCase() ).toBe( controllerType );
// test using gui.anon // test using gui.anon
var gui = new Gui(); var gui = new Gui();
@ -75,9 +75,9 @@ 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 );
} }
} ); } );