forked from verdnatura/hedera-web
43 lines
766 B
JavaScript
43 lines
766 B
JavaScript
import './style.scss';
|
|
|
|
export default new Class({
|
|
Extends: Hedera.Form,
|
|
Template: require('./ui.xml')
|
|
|
|
,activate() {
|
|
var self = this;
|
|
this.$.contactForm.onsubmit = function() {
|
|
self._onSubmit(); return false;
|
|
};
|
|
|
|
this.refreshCaptcha();
|
|
}
|
|
|
|
,refreshCaptcha() {
|
|
params = {
|
|
srv: 'rest:misc/captcha',
|
|
stamp: new Date().getTime()
|
|
};
|
|
this.$.captchaImg.src = '?'+ Vn.Url.makeUri(params);
|
|
}
|
|
|
|
,_onSubmit() {
|
|
this.conn.sendForm(this.$.contactForm,
|
|
this._onResponse.bind(this));
|
|
}
|
|
|
|
,_onResponse(json) {
|
|
var form = this.$.contactForm;
|
|
|
|
if (json) {
|
|
form.reset();
|
|
Htk.Toast.showMessage(_('DataSentSuccess'));
|
|
} else
|
|
Htk.Toast.showError(_('ErrorSendingData'));
|
|
|
|
form['captcha'].value = '';
|
|
this.refreshCaptcha();
|
|
}
|
|
});
|
|
|