Skip to content

Instantly share code, notes, and snippets.

@DaveVoyles
Created March 10, 2015 01:28
Show Gist options
  • Save DaveVoyles/6ab1a8aae38b7c9b0879 to your computer and use it in GitHub Desktop.
Save DaveVoyles/6ab1a8aae38b7c9b0879 to your computer and use it in GitHub Desktop.
x-radial-buttons Polymer
<link href="bower_components/polymer/polymer.html" rel="import">
<link rel="import" href="../paper-radio-group/paper-radio-group.html">
<link rel="import" href="../paper-radio-button/paper-radio-button.html">
<polymer-element name="x-radial-buttons">
<!-- Shadow DOM -->
<template>
<style>
#paper_radio_group {
position: relative;
width: 440px;
height: 50px;
}
</style>
<paper-radio-group selected="English-GB" valueattr="label" selectedindex="1" id="paper_radio_group">
<paper-radio-button label="English-US" id="paper_radio_btn_en-US" on-click="{{ changeAccentUS }}"></paper-radio-button>
<paper-radio-button checked label="English-GB" id="paper_radio_btn_en-GB" on-click="{{ changeAccentGB }}"></paper-radio-button>
<paper-radio-button label="Spanish" id="paper_radio_btn_es-ES" on-click="{{ changeAccentES }}"></paper-radio-button>
</paper-radio-group>
</template> <!-- /Shadow DOM -->
<script>
Polymer('x-radial-buttons', {
/* -- Attributes ------------------------------------------------ */
currentAccent: 'en-US',
//accentArr: ['en-US', 'en-GB, es-ES'],
created: function() {
accentArr = ['en-US', 'en-GB', 'es-ES'];
},
/* -- Methods --------------------------------------------------- */
getCurrentAccent: function() {
return currentAccent;
},
getFirstElement: function () {
console.log(this.$.paper_radio_group.querySelector("#paper_radio_btn_en-US"));
return this.$.paper_radio_group.querySelector("#paper_radio_btn_en-US");
},
getSecondElement: function () {
return this.$.paper_radio_group.querySelector("#paper_radio_btn_en-GB");
},
getThirdElement: function () {
return this.$.paper_radio_group.querySelector("#paper_radio_btn_es-ES");
},
changeAccentUS: function(event, detail, sender) {
console.log("Changed accent to American " + this.currentAccent);
currentAccent = accentArr[0];
//pokemonApp.changeAccent();
},
changeAccentGB: function() {
console.log("Changed accent to British " + this.currentAccent);
//currentAccent = accentArr[1];
pokemonApp.changeAccent();
},
changeAccentES: function () {
console.log("Changed accent to Spanish " + this.currentAccent);
currentAccent = accentArr[2];
pokemonApp.changeAccent();
}
});
</script>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment