2 name: 'blerg.EmailForm',
4 onLogin: "loginStatusChange"
7 {name: 'emailRegisterForm', components: [
8 {content: "Register an email address to get daily digest updates of your feed. We can also use this address to send you a password recovery link if you forget your password.", tag: 'p'},
9 {tag: 'form', onsubmit: 'registerEmail', components: [
10 {kind: 'onyx.InputDecorator', classes: 'recovery', components: [
11 {kind: 'onyx.Input', name: 'email'}
13 {kind: 'onyx.Button', content: 'Register', onclick: 'registerEmail'}
16 {name: 'emailStatus', showing: false, components: [
17 {tag: 'p', components: [
18 {content: 'Registered email: ', tag: null},
19 {name: 'emailOutput', tag: 'span', classes: 'email-address'},
21 {kind: 'onyx.Button', content: 'Deregister', onclick: 'deregisterEmail'}
23 {name: 'emailSent', showing: false, components: [
24 {content: 'An email has been sent to ', tag: null},
25 {name: 'emailSentAddress', tag: 'span', classes: 'email-address'},
26 {content: '.', tag: null}
31 this.inherited(arguments);
33 this.fetchEmailStatus();
35 registerEmail: function(inSender, inEvent) {
36 var email = this.$.email.getValue();
37 this.$.email.setValue('');
38 this.$.email.node.blur();
40 var req = new enyo.Ajax({
41 url: '/aux/email/register',
48 req.response(this, function(inSender, inResponse) {
49 this.$.emailSentAddress.setContent(email);
50 this.$.emailRegisterForm.hide();
51 this.$.emailSent.show();
54 req.error(this, function(inSender, inResponse) {
55 alert('Failed to register email.');
60 fetchEmailStatus: function() {
61 var req = new enyo.Ajax({
62 url: '/aux/email/status'
65 req.response(this, function(inSender, inResponse) {
66 if (inResponse.email) {
67 this.$.emailRegisterForm.hide();
68 this.$.emailStatus.show();
69 this.$.emailOutput.setContent(inResponse.email);
71 this.$.emailRegisterForm.show();
77 deregisterEmail: function(inSender, inEvent) {
78 var req = new enyo.Ajax({
79 url: '/aux/email/cancel'
82 req.response(this, function(inSender, inResponse) {
83 if (inResponse.status == 'success') {
84 this.$.emailStatus.hide();
85 this.$.emailRegisterForm.show();
86 alert('Email notifications deregistered');
88 alert('Failed to deregister');
92 req.error(this, function(inSender, inResponse) {
93 alert('Failed to deregister');
98 loginStatusChange: function(inSender, inEvent) {
99 this.fetchEmailStatus();