From fe94f2a123b7905bd470bc36cb375e6470cd916e Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Fri, 12 Jun 2015 16:40:20 +0930 Subject: [PATCH] Make the FormModal component more flexible --- framework/core/js/forum/src/components/change-email-modal.js | 4 ++-- .../core/js/forum/src/components/change-password-modal.js | 4 ++-- .../core/js/forum/src/components/delete-account-modal.js | 4 ++-- .../core/js/forum/src/components/forgot-password-modal.js | 4 ++-- framework/core/js/forum/src/components/form-modal.js | 4 +--- framework/core/js/forum/src/components/login-modal.js | 4 ++-- framework/core/js/forum/src/components/signup-modal.js | 4 ++-- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/framework/core/js/forum/src/components/change-email-modal.js b/framework/core/js/forum/src/components/change-email-modal.js index 99da605d2..6dd356df2 100644 --- a/framework/core/js/forum/src/components/change-email-modal.js +++ b/framework/core/js/forum/src/components/change-email-modal.js @@ -18,7 +18,7 @@ export default class ChangeEmailModal extends FormModal { return super.view({ className: 'modal-sm change-email-modal', title: 'Change Email', - body: this.success() + body: m('div.form-centered', this.success() ? [ m('p.help-text', 'We\'ve sent a confirmation email to ', m('strong', this.email()), '. If it doesn\'t arrive soon, check your spam folder.'), m('div.form-group', [ @@ -37,7 +37,7 @@ export default class ChangeEmailModal extends FormModal { m('div.form-group', [ m('button.btn.btn-primary.btn-block[type=submit]', {disabled}, 'Save Changes') ]) - ] + ]) }); } diff --git a/framework/core/js/forum/src/components/change-password-modal.js b/framework/core/js/forum/src/components/change-password-modal.js index d8103466b..76a995bf7 100644 --- a/framework/core/js/forum/src/components/change-password-modal.js +++ b/framework/core/js/forum/src/components/change-password-modal.js @@ -5,12 +5,12 @@ export default class ChangePasswordModal extends FormModal { return super.view({ className: 'modal-sm change-password-modal', title: 'Change Password', - body: [ + body: m('div.form-centered', [ m('p.help-text', 'Click the button below and check your email for a link to change your password.'), m('div.form-group', [ m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading()}, 'Send Password Reset Email') ]) - ] + ]) }); } diff --git a/framework/core/js/forum/src/components/delete-account-modal.js b/framework/core/js/forum/src/components/delete-account-modal.js index 14300a746..8c82fe252 100644 --- a/framework/core/js/forum/src/components/delete-account-modal.js +++ b/framework/core/js/forum/src/components/delete-account-modal.js @@ -11,7 +11,7 @@ export default class DeleteAccountModal extends FormModal { return super.view({ className: 'modal-sm change-password-modal', title: 'Delete Account', - body: [ + body: m('div.form-centered', [ m('p.help-text', 'Hold up there skippy! If you delete your account, there\'s no going back. All of your posts will be kept, but no longer associated with your account.'), m('div.form-group', [ m('input.form-control[name=confirm][placeholder=Type "DELETE" to proceed]', {oninput: m.withAttr('value', this.confirmation)}) @@ -19,7 +19,7 @@ export default class DeleteAccountModal extends FormModal { m('div.form-group', [ m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading() || this.confirmation() != 'DELETE'}, 'Delete Account') ]) - ] + ]) }); } diff --git a/framework/core/js/forum/src/components/forgot-password-modal.js b/framework/core/js/forum/src/components/forgot-password-modal.js index 92a7949e0..befa231e5 100644 --- a/framework/core/js/forum/src/components/forgot-password-modal.js +++ b/framework/core/js/forum/src/components/forgot-password-modal.js @@ -19,7 +19,7 @@ export default class ForgotPasswordModal extends FormModal { return super.view({ className: 'modal-sm forgot-password', title: 'Forgot Password', - body: this.success() + body: m('div.form-centered', this.success() ? [ m('p.help-text', 'We\'ve sent you an email containing a link to reset your password. Check your spam folder if you don\'t receive it within the next minute or two.'), m('div.form-group', [ @@ -34,7 +34,7 @@ export default class ForgotPasswordModal extends FormModal { m('div.form-group', [ m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading()}, 'Recover Password') ]) - ] + ]) }); } diff --git a/framework/core/js/forum/src/components/form-modal.js b/framework/core/js/forum/src/components/form-modal.js index bfae1bbf7..e2b11892b 100644 --- a/framework/core/js/forum/src/components/form-modal.js +++ b/framework/core/js/forum/src/components/form-modal.js @@ -23,9 +23,7 @@ export default class FormModal extends Component { m('form', {onsubmit: this.onsubmit.bind(this)}, [ m('div.modal-header', m('h3.title-control', options.title)), alert ? m('div.modal-alert', alert) : '', - m('div.modal-body', [ - m('div.form-centered', options.body) - ]), + m('div.modal-body', options.body), options.footer ? m('div.modal-footer', options.footer) : '' ]) ]), diff --git a/framework/core/js/forum/src/components/login-modal.js b/framework/core/js/forum/src/components/login-modal.js index 3e0897100..6a66cf60b 100644 --- a/framework/core/js/forum/src/components/login-modal.js +++ b/framework/core/js/forum/src/components/login-modal.js @@ -18,7 +18,7 @@ export default class LoginModal extends FormModal { return super.view({ className: 'modal-sm login-modal', title: 'Log In', - body: [ + body: m('div.form-centered', [ m('div.form-group', [ m('input.form-control[name=email][placeholder=Username or Email]', {value: this.email(), onchange: m.withAttr('value', this.email), disabled: this.loading()}) ]), @@ -28,7 +28,7 @@ export default class LoginModal extends FormModal { m('div.form-group', [ m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading()}, 'Log In') ]) - ], + ]), footer: [ m('p.forgot-password-link', m('a[href=javascript:;]', {onclick: () => { var email = this.email(); diff --git a/framework/core/js/forum/src/components/signup-modal.js b/framework/core/js/forum/src/components/signup-modal.js index 6b8ddd545..4884462a4 100644 --- a/framework/core/js/forum/src/components/signup-modal.js +++ b/framework/core/js/forum/src/components/signup-modal.js @@ -22,7 +22,7 @@ export default class SignupModal extends FormModal { var vdom = super.view({ className: 'modal-sm signup-modal'+(welcomeUser ? ' signup-modal-success' : ''), title: 'Sign Up', - body: [ + body: m('div.form-centered', [ m('div.form-group', [ m('input.form-control[name=username][placeholder=Username]', {value: this.username(), onchange: m.withAttr('value', this.username), disabled: this.loading()}) ]), @@ -35,7 +35,7 @@ export default class SignupModal extends FormModal { m('div.form-group', [ m('button.btn.btn-primary.btn-block[type=submit]', {disabled: this.loading()}, 'Sign Up') ]) - ], + ]), footer: [ m('p.log-in-link', [ 'Already have an account? ',