From 415e21f445d18adfd236166d257ed0366b50407b Mon Sep 17 00:00:00 2001 From: StorytellerCZ Date: Mon, 14 May 2018 10:39:06 +0200 Subject: [PATCH] Remove jQuery from accounts-ui-unstyled & fix typos --- .../login_buttons_dialogs.js | 11 ++++----- .../login_buttons_dropdown.js | 24 +++++++++---------- .../login_buttons_session.js | 14 +++++------ packages/accounts-ui-unstyled/package.js | 1 - packages/oauth/oauth_server.js | 2 +- 5 files changed, 25 insertions(+), 27 deletions(-) diff --git a/packages/accounts-ui-unstyled/login_buttons_dialogs.js b/packages/accounts-ui-unstyled/login_buttons_dialogs.js index 569bdcc2bb..370d9b0d27 100644 --- a/packages/accounts-ui-unstyled/login_buttons_dialogs.js +++ b/packages/accounts-ui-unstyled/login_buttons_dialogs.js @@ -75,7 +75,7 @@ Template._resetPasswordDialog.helpers({ // Template._justResetPasswordDialog.events({ - 'click #just-verified-dismiss-button': () => + 'click #just-verified-dismiss-button': () => loginButtonsSession.set('justResetPassword', false), }); @@ -133,7 +133,7 @@ Template._enrollAccountDialog.helpers({ // Template._justVerifiedEmailDialog.events({ - 'click #just-verified-dismiss-button': () => + 'click #just-verified-dismiss-button': () => loginButtonsSession.set('justVerifiedEmail', false), }); @@ -148,7 +148,7 @@ Template._justVerifiedEmailDialog.helpers({ // Template._loginButtonsMessagesDialog.events({ - 'click #messages-dialog-dismiss-button': () => + 'click #messages-dialog-dismiss-button': () => loginButtonsSession.resetMessages(), }); @@ -192,8 +192,7 @@ Template._configureLoginServiceDialog.events({ ); configuration.loginStyle = - $('#configure-login-service-dialog input[name="loginStyle"]:checked') - .val(); + document.querySelector('#configure-login-service-dialog input[name="loginStyle"]:checked').value; // Configure this login service Accounts.connection.call( @@ -253,7 +252,7 @@ Template._configureLoginServiceDialog.helpers({ configurationFields, visible: () => loginButtonsSession.get('configureLoginServiceDialogVisible'), // renders the appropriate template - configurationSteps: () => + configurationSteps: () => Template._configureLoginServiceDialog.templateForService(), saveDisabled: () => loginButtonsSession.get('configureLoginServiceDialogSaveDisabled'), diff --git a/packages/accounts-ui-unstyled/login_buttons_dropdown.js b/packages/accounts-ui-unstyled/login_buttons_dropdown.js index 13b52a25fc..3ec72f0dd8 100644 --- a/packages/accounts-ui-unstyled/login_buttons_dropdown.js +++ b/packages/accounts-ui-unstyled/login_buttons_dropdown.js @@ -147,7 +147,7 @@ const changePassword = () => { if (!matchPasswordAgainIfPresent()) return; - + Accounts.changePassword(oldPassword, password, error => { if (error) { loginButtonsSession.errorMessage(error.reason || "Unknown error"); @@ -185,12 +185,12 @@ const isInPasswordSignupFields = (fieldOrFields) => { } return signupFields.includes(fieldOrFields); -} +}; // events shared between loginButtonsLoggedOutDropdown and // loginButtonsLoggedInDropdown Template.loginButtons.events({ - 'click #login-name-link, click #login-sign-in-link': () => + 'click #login-name-link, click #login-sign-in-link': () => loginButtonsSession.set('dropdownVisible', true), 'click .login-close-text': loginButtonsSession.closeDropdown, }); @@ -377,7 +377,7 @@ Template._loginButtonsLoggedOutPasswordService.helpers({ const loginFields = [ {fieldName: 'username-or-email', fieldLabel: 'Username or Email', autocomplete: 'username email', - visible: () => isInPasswordSignupFields( + visible: () => isInPasswordSignupFields( ["USERNAME_AND_EMAIL", "USERNAME_AND_OPTIONAL_EMAIL"] ), }, @@ -402,7 +402,7 @@ Template._loginButtonsLoggedOutPasswordService.helpers({ "USERNAME_ONLY", ]), }, - {fieldName: 'email', fieldLabel: 'Email', inputType: 'email', + {fieldName: 'email', fieldLabel: 'Email', inputType: 'email', autocomplete: 'email', visible: () => isInPasswordSignupFields( ["USERNAME_AND_EMAIL", "EMAIL_ONLY"] @@ -432,8 +432,8 @@ Template._loginButtonsLoggedOutPasswordService.helpers({ inForgotPasswordFlow: () => loginButtonsSession.get('inForgotPasswordFlow'), - inLoginFlow: () => - !loginButtonsSession.get('inSignupFlow') && + inLoginFlow: () => + !loginButtonsSession.get('inSignupFlow') && !loginButtonsSession.get('inForgotPasswordFlow'), inSignupFlow: () => loginButtonsSession.get('inSignupFlow'), @@ -473,10 +473,10 @@ Template._loginButtonsChangePassword.helpers({ } return [ // The username and email fields are included here to address an - // accessibility warning in Chrome, but the fields don't actually display. - // The warning states that there should be an optionally hidden - // username/email field on password forms. - // XXX I think we should not use a CSS class here because this is the + // accessibility warning in Chrome, but the fields don't actually display. + // The warning states that there should be an optionally hidden + // username/email field on password forms. + // XXX I think we should not use a CSS class here because this is the // `unstyled` package. So instead we apply an inline style. {fieldName: 'username', fieldLabel: 'Username', autocomplete: 'username', fieldStyle: 'display: none;', fieldValue: username, @@ -486,7 +486,7 @@ Template._loginButtonsChangePassword.helpers({ "USERNAME_ONLY", ]), }, - {fieldName: 'email', fieldLabel: 'Email', inputType: 'email', + {fieldName: 'email', fieldLabel: 'Email', inputType: 'email', autocomplete: 'email', fieldStyle: 'display: none;', fieldValue: email, visible: () => isInPasswordSignupFields( ["USERNAME_AND_EMAIL", "EMAIL_ONLY"] diff --git a/packages/accounts-ui-unstyled/login_buttons_session.js b/packages/accounts-ui-unstyled/login_buttons_session.js index 817954ee99..a604ac51ab 100644 --- a/packages/accounts-ui-unstyled/login_buttons_session.js +++ b/packages/accounts-ui-unstyled/login_buttons_session.js @@ -55,26 +55,26 @@ const closeDropdown = () => { set('inMessageOnlyFlow', false); set('dropdownVisible', false); resetMessages(); -} +}; const infoMessage = message => { _set("errorMessage", null); _set("infoMessage", message); ensureMessageVisible(); -} +}; const errorMessage = message => { _set("errorMessage", message); _set("infoMessage", null); ensureMessageVisible(); -} +}; // is there a visible dialog that shows messages (info and error) const isMessageDialogVisible = () => { return get('resetPasswordToken') || get('enrollAccountToken') || get('justVerifiedEmail'); -} +}; // ensure that somethings displaying a message (info or error) is // visible. If a dialog with messages is open, do nothing; @@ -87,12 +87,12 @@ const isMessageDialogVisible = () => { const ensureMessageVisible = () => { if (!isMessageDialogVisible()) set("dropdownVisible", true); -} +}; const resetMessages = () => { _set("errorMessage", null); _set("infoMessage", null); -} +}; const configureService = name => { if (Meteor.isCordova) { @@ -102,7 +102,7 @@ const configureService = name => { set('configureLoginServiceDialogServiceName', name); set('configureLoginServiceDialogSaveDisabled', true); } -} +}; Accounts._loginButtonsSession = { set, diff --git a/packages/accounts-ui-unstyled/package.js b/packages/accounts-ui-unstyled/package.js index 2bab41c602..fb434d3b54 100644 --- a/packages/accounts-ui-unstyled/package.js +++ b/packages/accounts-ui-unstyled/package.js @@ -11,7 +11,6 @@ Package.onUse(function (api) { 'ecmascript', 'templating@1.2.13', 'session', - 'jquery', ], 'client'); // Export Accounts (etc) to packages using this one. diff --git a/packages/oauth/oauth_server.js b/packages/oauth/oauth_server.js index 9cfd44718d..c84f109c72 100644 --- a/packages/oauth/oauth_server.js +++ b/packages/oauth/oauth_server.js @@ -79,7 +79,7 @@ OAuth._stateFromQuery = query => { } }; -OAuth._loginStyleFromQuery = quer => { +OAuth._loginStyleFromQuery = query => { let style; // For backwards-compatibility for older clients, catch any errors // that result from parsing the state parameter. If we can't parse it,