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

View File

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

View File

@ -2,10 +2,10 @@
( function( scope ) {
'use strict';
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;
};
Gui.prototype.add = function( object, path ) {
return controllerShim;
};
@ -36,4 +36,4 @@
scope.Gui = Gui;
} )( this );
} )( this );

View File

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

View File

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