Skip to content

Instantly share code, notes, and snippets.

@imehesz
Last active August 29, 2015 14:14
Show Gist options
  • Save imehesz/f8c493802b2f6b33174a to your computer and use it in GitHub Desktop.
Save imehesz/f8c493802b2f6b33174a to your computer and use it in GitHub Desktop.
designer
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../paper-item/paper-item.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
box-sizing: border-box;
}
#topeka_app {
width: 300px;
height: 300px;
min-height: 450px;
left: 1430px;
top: 580px;
}
#core_card {
position: absolute;
width: 300px;
height: 300px;
border-radius: 2px;
box-shadow: rgba(0, 0, 0, 0.0980392) 0px 2px 4px, rgba(0, 0, 0, 0.0980392) 0px 0px 3px;
left: 500px;
top: 190px;
background-color: rgb(255, 255, 255);
}
#core_drawer_panel {
position: absolute;
top: 600px;
right: 0px;
bottom: 0px;
left: 1440px;
}
#core_header_panel {
width: 300px;
height: 400px;
left: 1420px;
top: 530px;
}
#core_item {
left: 1530px;
top: 610px;
}
#core_toolbar {
right: 0px;
left: 1440px;
color: rgb(255, 255, 255);
fill: rgb(255, 255, 255);
top: 560px;
background-color: rgb(79, 125, 201);
}
#core_icon_button {
left: 1540px;
top: 640px;
}
#paper_fab {
left: 1600px;
top: 640px;
}
</style>
<core-card id="core_card" layout vertical>
<paper-item id="userQuestion_item" icon="settings" label="Item">Question</paper-item>
<paper-button id="answer1" on-click="{{ checkAnswer }}" value="answer1">answer 1</paper-button>
<paper-button id="answer2" on-click="{{ checkAnswer }}" value="answer2">answer 2</paper-button>
<paper-button id="answer3" on-click="{{ checkAnswer }}" value="answer3">answer 3</paper-button>
<paper-item id="userAnswer_item">{{ userAnswer }}</paper-item>
</core-card>
</template>
<script>
Polymer({
items: [
{
"country": "Hungary",
"capital": "Budapest"
},
{
"country": "Romania",
"capital": "Bukarest"
},
{
"country": "France",
"capital": "Paris"
},
{
"country": "Italy",
"capital": "Rome"
},
{
"country": "Spain",
"capital": "Madrid"
}
],
question: null,
answers: [],
ready: function () {
this.startGame();
},
startGame: function () {
this.setAnswers();
this.setQuestion();
},
setQuestion: function () {
this.question = shuffle(this.answers)[0];
this.$.userQuestion_item.textContent = this.question.country;
},
setAnswers: function () {
var randArr = shuffle(this.items);
this.answers = randArr.slice(0,3);
this.$.answer1.textContent = this.answers[0].capital;
this.$.answer2.textContent = this.answers[1].capital;
this.$.answer3.textContent = this.answers[2].capital;
},
checkAnswer: function (event,detail,target) {
var answer = target.attributes["value"];
this.userAnswer = answer.value;
}
});
</script>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment