2 name: 'blerg.EmailForm',
4 {name: 'emailRegisterForm', components: [
5 {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'},
6 {tag: 'form', onsubmit: 'registerEmail', components: [
7 {kind: 'onyx.InputDecorator', classes: 'recovery', components: [
8 {kind: 'onyx.Input', name: 'email'}
10 {kind: 'onyx.Button', content: 'Register', onclick: 'registerEmail'}
13 {name: 'emailStatus', showing: false, components: [
14 {tag: 'p', components: [
15 {content: 'Registered email: ', tag: null},
16 {name: 'emailOutput', tag: 'span', classes: 'email-address'},
18 {kind: 'onyx.Button', content: 'Deregister', onclick: 'deregisterEmail'}
20 {name: 'emailSent', showing: false, components: [
21 {content: 'An email has been sent to ', tag: null},
22 {name: 'emailSentAddress', tag: 'span', classes: 'email-address'},
23 {content: '.', tag: null}
28 this.inherited(arguments);
30 this.fetchEmailStatus();
32 registerEmail: function(inSender, inEvent) {
33 var email = this.$.email.getValue();
34 this.$.email.setValue('');
35 this.$.email.node.blur();
37 var req = new enyo.Ajax({
38 url: '/aux/email/register',
45 req.response(this, function(inSender, inResponse) {
46 this.$.emailSentAddress.setContent(email);
47 this.$.emailRegisterForm.hide();
48 this.$.emailSent.show();
51 req.error(this, function(inSender, inResponse) {
52 alert('Failed to register email.');
57 fetchEmailStatus: function() {
58 var req = new enyo.Ajax({
59 url: '/aux/email/status'
62 req.response(this, function(inSender, inResponse) {
63 if (inResponse.email) {
64 this.$.emailRegisterForm.hide();
65 this.$.emailStatus.show();
66 this.$.emailOutput.setContent(inResponse.email);
68 this.$.emailRegisterForm.show();
74 deregisterEmail: function(inSender, inEvent) {
75 var req = new enyo.Ajax({
76 url: '/aux/email/cancel'
79 req.response(this, function(inSender, inResponse) {
80 if (inResponse.status == 'success') {
81 this.$.emailStatus.hide();
82 this.$.emailRegisterForm.show();
83 alert('Email notifications deregistered');
85 alert('Failed to deregister');
89 req.error(this, function(inSender, inResponse) {
90 alert('Failed to deregister');