2014-09-08 01:31:51 +00:00
|
|
|
/* globals Polymer, Object, Array */
|
2014-09-08 02:43:10 +00:00
|
|
|
|
2014-09-08 01:31:51 +00:00
|
|
|
|
2014-09-09 19:53:30 +00:00
|
|
|
Polymer( 'dat-gui-option', {
|
2014-09-07 20:18:36 +00:00
|
|
|
|
2014-09-07 23:55:40 +00:00
|
|
|
key: null,
|
|
|
|
|
2014-09-07 20:18:36 +00:00
|
|
|
ready: function() {
|
|
|
|
|
|
|
|
this.options = {};
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
init: function( options ) {
|
|
|
|
|
2014-09-08 01:31:51 +00:00
|
|
|
if ( Array.isArray( options ) ) {
|
2014-09-07 20:18:36 +00:00
|
|
|
|
|
|
|
options.forEach( function( opt ) {
|
|
|
|
|
|
|
|
this.options[ opt ] = opt;
|
|
|
|
|
|
|
|
}, this );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.options = options;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2014-09-07 23:55:40 +00:00
|
|
|
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 ) {
|
2014-09-07 20:18:36 +00:00
|
|
|
|
2014-09-08 01:31:51 +00:00
|
|
|
if ( object ) {
|
|
|
|
|
|
|
|
return Object.keys( object );
|
|
|
|
|
|
|
|
}
|
2014-09-07 20:18:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-09-08 01:38:29 +00:00
|
|
|
} );
|