Skip to content

Commit 5daf4f3

Browse files
committed
Remove use of string template from js.
1 parent 796e630 commit 5daf4f3

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

js/admin.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable no-console */
1+
/* eslint-disable prefer-template, no-console */
22
(function ($) {
33
const params = window.mailchimp_sf_admin_params || {};
44
const oauthBaseUrl = 'https://woocommerce.mailchimpapp.com';
@@ -11,15 +11,23 @@
1111
* @param {string} token - Token from the Oauth service.
1212
*/
1313
function openMailChimpOauthPopup(token) {
14-
const startUrl = `${oauthBaseUrl}/auth/start/${token}`;
14+
const startUrl = oauthBaseUrl + '/auth/start/' + token;
1515
const width = 800;
1616
const height = 600;
1717
const screenSizes = window.screen || { width: 1024, height: 768 };
1818
const left = (screenSizes.width - width) / 2;
1919
const top = (screenSizes.height - height) / 4;
20-
const windowOptions = `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${
21-
width
22-
}, height=${height}, top=${top}, left=${left}, domain=${oauthBaseUrl.replace('https://', '')}`;
20+
const windowOptions =
21+
'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' +
22+
width +
23+
', height=' +
24+
height +
25+
', top=' +
26+
top +
27+
', left=' +
28+
left +
29+
', domain=' +
30+
oauthBaseUrl.replace('https://', '');
2331

2432
// Open Mailchimp OAuth popup.
2533
const popup = window.open(startUrl, params.oauth_window_name, windowOptions);
@@ -58,7 +66,8 @@
5866
window.clearInterval(oauthInterval);
5967

6068
// Check status of OAuth connection.
61-
$.post(`${oauthBaseUrl}/api/status/${token}`, function (statusData) {
69+
const statusUrl = oauthBaseUrl + '/api/status/' + token;
70+
$.post(statusUrl, function (statusData) {
6271
if (statusData && statusData.status === 'accepted') {
6372
const finishData = {
6473
action: 'mailchimp_sf_oauth_finish',
@@ -83,18 +92,20 @@
8392
}
8493
$(errorSelector).show();
8594
}
95+
$(spinner).removeClass('is-active');
8696
}).fail(function () {
8797
console.error('Error calling OAuth finish endpoint.');
8898
$(errorSelector).html(params.generic_error);
8999
$(errorSelector).show();
100+
$(spinner).removeClass('is-active');
90101
});
91102
} else {
92103
console.log(
93104
'Error calling OAuth status endpoint. No credentials provided at login popup? Data:',
94105
statusData,
95106
);
107+
$(spinner).removeClass('is-active');
96108
}
97-
$(spinner).removeClass('is-active');
98109
}).fail(function () {
99110
$(errorSelector).html(params.generic_error);
100111
$(errorSelector).show();

0 commit comments

Comments
 (0)