2014-09-07 20:18:36 +00:00
|
|
|
Polymer( 'controller-option', {
|
|
|
|
|
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 ) {
|
|
|
|
|
|
|
|
if ( Array.isArray( options ) ){
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if ( object ) return Object.keys( object );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|