Skip to content

Instantly share code, notes, and snippets.

@Gordi90
Last active August 29, 2015 14:06
Show Gist options
  • Save Gordi90/cb61e0dc1a1f396b614d to your computer and use it in GitHub Desktop.
Save Gordi90/cb61e0dc1a1f396b614d to your computer and use it in GitHub Desktop.
designer
<link rel="import" href="../paper-input/paper-input.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../core-ajax/core-ajax.html">
<polymer-element name="login-box">
<template>
<style>
:host {
box-sizing: border-box;
width: 100%;
height: 100%;
}
#login_button {
width: 200px;
}
#registration_button {
width: 200px;
}
</style>
<div id="div" vertical layout center on-favorite-tap="{{ handleLogin }}">
<paper-input label="Felhasználónév" willvalidate id="loginInput" layout vertical></paper-input>
<paper-input label="Jelszó" willvalidate type="password" id="passwordInput" layout vertical></paper-input>
<paper-button label="Belépés" id="loginButton" on-tap="{{ loginClicked }}"></paper-button>
<paper-button label="Regisztráció" id="registrationButton" on-tap="{{ registerClicked }}"></paper-button>
</div>
<core-ajax url="http://noisyman.aut.bme.hu/qa/index.php?p=login" handleas="json" id="loginAjax" on-core-response="{{ handleLoginResponse }}" hidden></core-ajax>
<core-ajax url="http://noisyman.aut.bme.hu/qa/index.php?p=register" handleas="json" id="registerAjax" on-core-response="{{ handleRegisterResponse }}" on-core-error="{{ handleRegisterResponse }}" on-core-complete="{{ handleRegisterResponse }}" hidden></core-ajax>
</template>
<script>
Polymer('login-box', {
publish: {
"login": {
"value": "",
"reflect": true
}
},
registerClicked: function (event, detail, sender) {
this.login = this.$.loginInput.value;
this.$.registerAjax.params='{"username":"' + this.$.loginInput.value + '", "password":"' + this.$.passwordInput.value + '"}'
this.$.registerAjax.go();
},
handleRegisterResponse: function (e) {
console.log(e.type, e.detail.msg)
console.log(this.$.registerAjax.response)
}
});
</script>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment