@nice-digital/global-nav 5.0.940 → 7.0.930
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -55
- package/lib/Footer/Footer.js +31 -55
- package/lib/Footer/Legal/Legal.js +76 -71
- package/lib/Footer/Legal/index.js +10 -7
- package/lib/Footer/Pages/Pages.js +34 -54
- package/lib/Footer/Pages/Pages.module.scss +1 -1
- package/lib/Footer/Pages/index.js +10 -7
- package/lib/Footer/Pages/links.json +2 -5
- package/lib/Footer/Services/Services.js +65 -86
- package/lib/Footer/Services/Services.module.scss +1 -1
- package/lib/Footer/Services/index.js +10 -7
- package/lib/Footer/Social/Social.js +46 -57
- package/lib/Footer/Social/index.js +10 -7
- package/lib/Footer/index.js +10 -7
- package/lib/Header/Account/Account.js +87 -109
- package/lib/Header/Account/index.js +10 -7
- package/lib/Header/Account/nice-accounts.js +7 -12
- package/lib/Header/Header.js +345 -171
- package/lib/Header/Header.module.scss +2 -2
- package/lib/Header/Nav/Dropdown/Components/AboutUs.js +216 -105
- package/lib/Header/Nav/Dropdown/Components/BNF.js +120 -75
- package/lib/Header/Nav/Dropdown/Components/BNFc.js +115 -73
- package/lib/Header/Nav/Dropdown/Components/Button.js +11 -14
- package/lib/Header/Nav/Dropdown/Components/CKS.js +115 -73
- package/lib/Header/Nav/Dropdown/Components/Grid.js +16 -22
- package/lib/Header/Nav/Dropdown/Components/Guidance.js +244 -128
- package/lib/Header/Nav/Dropdown/Components/LifeSciences.js +169 -108
- package/lib/Header/Nav/Dropdown/Components/StandardsAndIndicators.js +83 -45
- package/lib/Header/Nav/Dropdown/Components/index.js +46 -24
- package/lib/Header/Nav/Dropdown/Dropdown.js +48 -63
- package/lib/Header/Nav/Dropdown/Dropdown.module.scss +1 -1
- package/lib/Header/Nav/Dropdown/index.js +10 -7
- package/lib/Header/Nav/Nav.js +84 -102
- package/lib/Header/Nav/Nav.module.scss +2 -4
- package/lib/Header/Nav/NavLinks/NavLinks.js +118 -137
- package/lib/Header/Nav/NavLinks/NavLinks.module.scss +1 -1
- package/lib/Header/Nav/NavLinks/index.js +10 -7
- package/lib/Header/Nav/SubNav/SubNav.js +54 -90
- package/lib/Header/Nav/SubNav/index.js +10 -7
- package/lib/Header/Nav/__mocks__/services.json +3 -3
- package/lib/Header/Nav/index.js +10 -7
- package/lib/Header/OldIEMessage/OldIEMessage.js +65 -67
- package/lib/Header/OldIEMessage/ie.js +14 -0
- package/lib/Header/OldIEMessage/index.js +10 -7
- package/lib/Header/Search/Autocomplete/Autocomplete.js +169 -194
- package/lib/Header/Search/Autocomplete/Autocomplete.module.scss +9 -1
- package/lib/Header/Search/Autocomplete/index.js +10 -7
- package/lib/Header/Search/Autocomplete/suggester/index.js +21 -28
- package/lib/Header/Search/Autocomplete/suggester/phrase-finder.js +13 -14
- package/lib/Header/Search/Autocomplete/suggester/term-finder.js +18 -21
- package/lib/Header/Search/Autocomplete/suggester/tokenizer.js +12 -17
- package/lib/Header/Search/Search.js +73 -90
- package/lib/Header/Search/index.js +10 -7
- package/lib/Header/SkipLink/SkipLink.js +24 -62
- package/lib/Header/SkipLink/SkipLink.module.scss +5 -1
- package/lib/Header/SkipLink/index.js +10 -7
- package/lib/Header/_header-settings.scss +0 -2
- package/lib/Header/context/HeaderContext.js +28 -54
- package/lib/Header/index.js +10 -7
- package/lib/Main/BackToTop/BackToTop.js +22 -25
- package/lib/Main/BackToTop/BackToTop.module.scss +1 -4
- package/lib/Main/Main.js +22 -26
- package/lib/Main/index.js +10 -7
- package/lib/TrackedLink/TrackedLink.js +48 -74
- package/lib/TrackedLink/index.js +10 -7
- package/lib/hooks/useEscapeKeydown.js +8 -21
- package/lib/hooks/useIsClient.js +20 -0
- package/lib/index.js +22 -12
- package/lib/renderer.js +21 -30
- package/lib/tracker/index.js +8 -25
- package/lib/utils.js +4 -7
- package/package.json +68 -65
- package/types.d.ts +1 -0
- package/lib/Header/Account/AccountOld.js +0 -227
|
@@ -1,70 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
exports
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
12
|
var _HeaderContext = require("../context/HeaderContext");
|
|
15
|
-
|
|
16
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
19
|
-
|
|
20
15
|
var _niceAccounts = require("./nice-accounts");
|
|
21
|
-
|
|
22
16
|
var _AccountModule = _interopRequireDefault(require("./Account.module.scss"));
|
|
23
|
-
|
|
24
17
|
var _tracker = require("../../tracker");
|
|
25
|
-
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
26
19
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
|
-
function
|
|
29
|
-
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
30
23
|
function Account(props) {
|
|
31
|
-
var
|
|
32
|
-
|
|
24
|
+
var _props$provider = props.provider,
|
|
25
|
+
provider = _props$provider === void 0 ? "niceAccounts" : _props$provider;
|
|
33
26
|
// We've left this is state as per the pre-hook implementation
|
|
34
|
-
var _useState = (0, _react.useState)(
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
var _useState = (0, _react.useState)(provider == Account.providers.idam),
|
|
28
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
|
29
|
+
doesUseIdAM = _useState2[0];
|
|
37
30
|
var _useContext = (0, _react.useContext)(_HeaderContext.HeaderContext),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
accountMenuIsExpanded = _useContext.accountMenuIsExpanded,
|
|
32
|
+
setAccountMenuIsExpanded = _useContext.setAccountMenuIsExpanded;
|
|
41
33
|
var keypress = (0, _react.useRef)(),
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
myAccountButton = (0, _react.useRef)(),
|
|
35
|
+
myAccountMenu = (0, _react.useRef)();
|
|
44
36
|
var handleMyAccountButtonClick = (0, _react.useCallback)(function (e) {
|
|
45
|
-
var _this2 = this;
|
|
46
|
-
|
|
47
|
-
(0, _newArrowCheck2["default"])(this, _this);
|
|
48
37
|
keypress.current = e.pageX;
|
|
49
38
|
setAccountMenuIsExpanded(function (prevState) {
|
|
50
|
-
(0, _newArrowCheck2["default"])(this, _this2);
|
|
51
39
|
return !prevState;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
40
|
+
});
|
|
41
|
+
}, []);
|
|
55
42
|
function focusAccount() {
|
|
56
43
|
myAccountMenu && myAccountMenu.current.setAttribute("tabIndex", -1);
|
|
57
44
|
myAccountMenu && myAccountMenu.current.focus();
|
|
58
45
|
}
|
|
59
|
-
|
|
60
46
|
(0, _react.useEffect)(function () {
|
|
61
|
-
(0, _newArrowCheck2["default"])(this, _this);
|
|
62
|
-
|
|
63
47
|
if (!keypress.current && accountMenuIsExpanded) {
|
|
64
48
|
focusAccount();
|
|
65
49
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
50
|
+
}, [accountMenuIsExpanded]);
|
|
68
51
|
function handleKeyDown(e) {
|
|
69
52
|
if (e.key === "Escape" || e.key === "Esc") {
|
|
70
53
|
e.preventDefault();
|
|
@@ -72,11 +55,9 @@ function Account(props) {
|
|
|
72
55
|
myAccountButton && myAccountButton.current.focus();
|
|
73
56
|
}
|
|
74
57
|
}
|
|
75
|
-
|
|
76
58
|
function handleMenuItemClick(e) {
|
|
77
59
|
var href = e.currentTarget.getAttribute("href");
|
|
78
60
|
var eventLabel;
|
|
79
|
-
|
|
80
61
|
if (href.indexOf("editprofile") > -1) {
|
|
81
62
|
eventLabel = "Edit profile";
|
|
82
63
|
} else if (href.indexOf("signout") > -1) {
|
|
@@ -84,41 +65,35 @@ function Account(props) {
|
|
|
84
65
|
} else if (href.indexOf("signin") > -1) {
|
|
85
66
|
eventLabel = "Sign in";
|
|
86
67
|
}
|
|
87
|
-
|
|
88
68
|
if (eventLabel) {
|
|
89
69
|
e.preventDefault();
|
|
90
70
|
(0, _tracker.trackEvent)(_tracker.defaultEventCategory, _tracker.headerClickEventAction, eventLabel, null, href, function () {
|
|
91
|
-
window.location.href
|
|
71
|
+
window.location.assign(href);
|
|
92
72
|
});
|
|
93
73
|
}
|
|
94
74
|
}
|
|
95
|
-
|
|
96
75
|
(0, _react.useEffect)(function () {
|
|
97
|
-
(0, _newArrowCheck2["default"])(this, _this);
|
|
98
76
|
var consultationsResponsesLink = {
|
|
99
77
|
"Consultation responses": "https://www.nice.org.uk/consultations/"
|
|
100
78
|
};
|
|
101
|
-
|
|
102
79
|
if (doesUseIdAM) {
|
|
103
80
|
//nice accounts supplies links like: {"John Holland":"https://accounts.nice.org.uk/users/143980/editprofile","Sign out":"https://accounts.nice.org.uk/signout"}
|
|
104
81
|
//idam supplies links like:[{ key: "My profile", value: "/Account/todo" },{ key: "Sign out", value: "/Account/Logout" }]
|
|
105
82
|
//the following just converts the idam format to the nice accounts format.
|
|
83
|
+
|
|
106
84
|
var displayName = props.displayName;
|
|
107
85
|
var isLoggedIn = !!displayName;
|
|
108
86
|
var links = props.links.reduce(function (links, link) {
|
|
109
87
|
links[link.text] = link.url;
|
|
110
88
|
return links;
|
|
111
89
|
}, {});
|
|
112
|
-
|
|
113
90
|
if (isLoggedIn) {
|
|
114
|
-
links = (
|
|
91
|
+
links = _objectSpread(_objectSpread({}, consultationsResponsesLink), links);
|
|
115
92
|
}
|
|
116
|
-
|
|
117
93
|
var convertedData = {
|
|
118
94
|
display_name: displayName,
|
|
119
95
|
links: links
|
|
120
96
|
};
|
|
121
|
-
|
|
122
97
|
if (props.onLoginStatusChecked) {
|
|
123
98
|
props.onLoginStatusChecked(convertedData);
|
|
124
99
|
}
|
|
@@ -126,87 +101,90 @@ function Account(props) {
|
|
|
126
101
|
//NICE accounts
|
|
127
102
|
(0, _niceAccounts.checkIsLoggedIn)(props.environment).then(function (data) {
|
|
128
103
|
if (props.onLoginStatusChecked) {
|
|
129
|
-
data.links = (
|
|
104
|
+
data.links = _objectSpread(_objectSpread({}, consultationsResponsesLink), data.links);
|
|
130
105
|
props.onLoginStatusChecked(data);
|
|
131
106
|
}
|
|
132
|
-
})
|
|
107
|
+
}).catch(function (e) {
|
|
133
108
|
console.warn("Couldn't load account data from NICE accounts", e);
|
|
134
109
|
});
|
|
135
110
|
}
|
|
136
|
-
}
|
|
111
|
+
}, []);
|
|
137
112
|
var accountsData = props.accountsData,
|
|
138
|
-
|
|
113
|
+
_props$environment = props.environment,
|
|
114
|
+
environment = _props$environment === void 0 ? "live" : _props$environment;
|
|
139
115
|
var signInLink = {};
|
|
140
|
-
|
|
141
116
|
if (doesUseIdAM) {
|
|
142
117
|
signInLink = props.links[0];
|
|
143
118
|
} else {
|
|
144
119
|
signInLink["text"] = "Sign in";
|
|
145
120
|
signInLink["url"] = (0, _niceAccounts.getDomainBaseUrl)(environment) + "signin";
|
|
146
121
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
onKeyDown: handleKeyDown,
|
|
167
|
-
ref: myAccountMenu
|
|
168
|
-
}, doesUseIdAM && accountsData.display_name && /*#__PURE__*/_react["default"].createElement("li", null, /*#__PURE__*/_react["default"].createElement("span", null, accountsData.display_name)), accountsData.links && Object.keys(accountsData.links).map(function (text, i) {
|
|
169
|
-
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
170
|
-
key: i,
|
|
171
|
-
role: "presentation"
|
|
172
|
-
}, /*#__PURE__*/_react["default"].createElement("a", {
|
|
173
|
-
href: accountsData.links[text],
|
|
174
|
-
role: "menuitem",
|
|
175
|
-
onClick: handleMenuItemClick,
|
|
122
|
+
return props.isLoggedIn ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
123
|
+
className: _AccountModule.default.account,
|
|
124
|
+
"data-tracking": "Account panel",
|
|
125
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
126
|
+
className: (0, _classnames.default)(_AccountModule.default.button, _AccountModule.default.myAccount),
|
|
127
|
+
id: "my-account-button",
|
|
128
|
+
"aria-controls": "my-account",
|
|
129
|
+
"aria-haspopup": "menu",
|
|
130
|
+
"aria-expanded": accountMenuIsExpanded,
|
|
131
|
+
onClick: handleMyAccountButtonClick,
|
|
132
|
+
onKeyDown: handleKeyDown,
|
|
133
|
+
ref: myAccountButton,
|
|
134
|
+
children: "My account"
|
|
135
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
136
|
+
className: _AccountModule.default.menu,
|
|
137
|
+
id: "my-account",
|
|
138
|
+
role: "menu",
|
|
139
|
+
"aria-hidden": !accountMenuIsExpanded,
|
|
140
|
+
"aria-labelledby": "my-account-button",
|
|
176
141
|
onKeyDown: handleKeyDown,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
142
|
+
ref: myAccountMenu,
|
|
143
|
+
children: [doesUseIdAM && accountsData.display_name && /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
144
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
145
|
+
children: accountsData.display_name
|
|
146
|
+
})
|
|
147
|
+
}), accountsData.links && Object.keys(accountsData.links).map(function (text, i) {
|
|
148
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("li", {
|
|
149
|
+
role: "presentation",
|
|
150
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
151
|
+
href: accountsData.links[text],
|
|
152
|
+
role: "menuitem",
|
|
153
|
+
onClick: handleMenuItemClick,
|
|
154
|
+
onKeyDown: handleKeyDown,
|
|
155
|
+
"data-hj-suppress": accountsData.links[text].indexOf("profile") > -1 ? "" : null,
|
|
156
|
+
children: text
|
|
157
|
+
})
|
|
158
|
+
}, i);
|
|
159
|
+
})]
|
|
160
|
+
})]
|
|
161
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
180
162
|
"data-tracking": "Sign in",
|
|
181
163
|
href: signInLink.url,
|
|
182
|
-
className: _AccountModule
|
|
183
|
-
onClick: handleMenuItemClick
|
|
184
|
-
|
|
164
|
+
className: _AccountModule.default.button,
|
|
165
|
+
onClick: handleMenuItemClick,
|
|
166
|
+
children: signInLink.text
|
|
167
|
+
});
|
|
185
168
|
}
|
|
186
|
-
|
|
187
169
|
var _default = Account;
|
|
188
|
-
exports
|
|
170
|
+
exports.default = _default;
|
|
189
171
|
Account.providers = {
|
|
190
172
|
idam: "idam",
|
|
191
173
|
niceAccounts: "niceAccounts"
|
|
192
174
|
};
|
|
193
175
|
Account.propTypes = {
|
|
194
|
-
isLoggedIn: _propTypes
|
|
195
|
-
onLoginStatusChecked: _propTypes
|
|
196
|
-
accountsData: _propTypes
|
|
197
|
-
display_name: _propTypes
|
|
198
|
-
thumbnail: _propTypes
|
|
199
|
-
links: _propTypes
|
|
176
|
+
isLoggedIn: _propTypes.default.bool.isRequired,
|
|
177
|
+
onLoginStatusChecked: _propTypes.default.func,
|
|
178
|
+
accountsData: _propTypes.default.shape({
|
|
179
|
+
display_name: _propTypes.default.string,
|
|
180
|
+
thumbnail: _propTypes.default.string,
|
|
181
|
+
links: _propTypes.default.object
|
|
200
182
|
}),
|
|
201
|
-
environment: _propTypes
|
|
202
|
-
provider: _propTypes
|
|
203
|
-
links: _propTypes
|
|
204
|
-
text: _propTypes
|
|
205
|
-
url: _propTypes
|
|
183
|
+
environment: _propTypes.default.oneOf(["live", "test", "beta", "local"]),
|
|
184
|
+
provider: _propTypes.default.oneOf([Account.providers.niceAccounts, Account.providers.idam]),
|
|
185
|
+
links: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
186
|
+
text: _propTypes.default.string.isRequired,
|
|
187
|
+
url: _propTypes.default.string.isRequired
|
|
206
188
|
})),
|
|
207
|
-
displayName: _propTypes
|
|
208
|
-
};
|
|
209
|
-
Account.defaultProps = {
|
|
210
|
-
environment: "live",
|
|
211
|
-
provider: "niceAccounts"
|
|
189
|
+
displayName: _propTypes.default.string
|
|
212
190
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "default", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _Account.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _Account = _interopRequireDefault(require("./Account"));
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
exports
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
4
6
|
exports.getDomainBaseUrl = exports.checkIsLoggedIn = void 0;
|
|
5
|
-
|
|
6
7
|
// Checks if you are logged in via NICE Accounts
|
|
7
8
|
// Returns a promise that resolves with the data from NICE Accounts.
|
|
8
9
|
// Returns a promise that rejects if the data could not be loaded.
|
|
10
|
+
|
|
9
11
|
var checkIsLoggedIn = function checkIsLoggedIn(environment) {
|
|
10
12
|
return new Promise(function (resolve, reject) {
|
|
11
13
|
var url = getDomainBaseUrl(environment) + "tophat";
|
|
@@ -13,30 +15,23 @@ var checkIsLoggedIn = function checkIsLoggedIn(environment) {
|
|
|
13
15
|
var script = document.createElement("script");
|
|
14
16
|
script.src = url + (~url.indexOf("?") ? "&" : "?") + Math.floor(Math.random() * 10000000000);
|
|
15
17
|
var done = false;
|
|
16
|
-
|
|
17
18
|
script.onload = script.onreadystatechange = function () {
|
|
18
19
|
if (!done && (!script.readyState || script.readyState === "loaded" || script.readyState === "complete")) {
|
|
19
|
-
done = true;
|
|
20
|
-
|
|
20
|
+
done = true;
|
|
21
|
+
// Handle memory leak in IE
|
|
21
22
|
script.onload = script.onreadystatechange = null;
|
|
22
|
-
|
|
23
23
|
if (body && script.parentNode) {
|
|
24
24
|
body.removeChild(script);
|
|
25
25
|
}
|
|
26
|
-
|
|
27
26
|
resolve(window._na);
|
|
28
27
|
}
|
|
29
28
|
};
|
|
30
|
-
|
|
31
29
|
script.onerror = reject;
|
|
32
30
|
body.insertBefore(script, body.firstChild);
|
|
33
31
|
});
|
|
34
32
|
};
|
|
35
|
-
|
|
36
33
|
exports.checkIsLoggedIn = checkIsLoggedIn;
|
|
37
|
-
|
|
38
34
|
var getDomainBaseUrl = function getDomainBaseUrl(environment) {
|
|
39
|
-
return "https://"
|
|
35
|
+
return "https://".concat(environment !== "live" ? environment + "-" : "", "accounts.nice.org.uk/");
|
|
40
36
|
};
|
|
41
|
-
|
|
42
37
|
exports.getDomainBaseUrl = getDomainBaseUrl;
|