mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
63 lines
919 B
JavaScript
63 lines
919 B
JavaScript
/* globals Polymer, Object, Array */
|
|
|
|
|
|
Polymer( 'controller-option', {
|
|
|
|
key: null,
|
|
|
|
ready: function() {
|
|
|
|
this.options = {};
|
|
|
|
},
|
|
|
|
init: function( options ) {
|
|
|
|
if ( Array.isArray( options ) ) {
|
|
|
|
options.forEach( function( opt ) {
|
|
|
|
this.options[ opt ] = opt;
|
|
|
|
}, this );
|
|
|
|
} else {
|
|
|
|
this.options = options;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
valueChanged: function() {
|
|
|
|
for ( var i in this.options ) {
|
|
if ( this.options[ i ] === this.value ) {
|
|
this.key = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
this.super();
|
|
|
|
},
|
|
|
|
keyChanged: function() {
|
|
|
|
this.value = this.options[ this.key ];
|
|
|
|
},
|
|
|
|
keys: function( object ) {
|
|
|
|
if ( object ) {
|
|
|
|
return Object.keys( object );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
} );
|