@financial-times/n-myft-ui 28.3.1 → 28.3.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@
|
|
20
20
|
{{#if isSaved}}
|
21
21
|
{{!-- The value of alternate label needs to be the opposite of label / the current saved state. This allows the client side JS to toggle the labels on state changes --}}
|
22
22
|
title="{{#if title}}{{title}} is{{/if}} Saved to myFT"
|
23
|
-
aria-label="{{#if title}}{{title}} is{{/if}} Saved to myFT"
|
23
|
+
aria-label="{{#if title}}{{title}} is{{/if}} Saved to myFT - Unsave"
|
24
24
|
data-alternate-label="{{#if title}}Save {{title}} to myFT for later{{else}}Save this article to myFT for later{{/if}}"
|
25
25
|
aria-pressed="true"
|
26
26
|
{{else}}
|
@@ -21,10 +21,10 @@ export default async function openSaveArticleToListVariant (contentId, options =
|
|
21
21
|
return restoreContent();
|
22
22
|
}
|
23
23
|
|
24
|
-
myFtClient.add('user', null, 'created', 'list', uuid(), { name: newList.name, token: csrfToken })
|
24
|
+
myFtClient.add('user', null, 'created', 'list', uuid(), { name: newList.name, token: csrfToken, isPublic: newList.isPublic })
|
25
25
|
.then(detail => {
|
26
26
|
myFtClient.add('list', detail.subject, 'contained', 'content', contentId, { token: csrfToken }).then((data) => {
|
27
|
-
const createdList = { name: newList.name, uuid: data.actorId, checked: true,
|
27
|
+
const createdList = { name: newList.name, uuid: data.actorId, checked: true, isPublic: !!newList.isPublic };
|
28
28
|
lists.unshift(createdList);
|
29
29
|
const announceListContainer = document.querySelector('.myft-ui-create-list-variant-announcement');
|
30
30
|
announceListContainer.textContent = `${newList.name} created`;
|
@@ -116,7 +116,6 @@ export default async function openSaveArticleToListVariant (contentId, options =
|
|
116
116
|
const overlayContent = document.querySelector('.o-overlay__content');
|
117
117
|
removeDescription();
|
118
118
|
overlayContent.insertAdjacentElement('beforeend', formElement);
|
119
|
-
formElement.elements[0].focus();
|
120
119
|
}
|
121
120
|
|
122
121
|
createListOverlay.open();
|
@@ -153,44 +152,6 @@ export default async function openSaveArticleToListVariant (contentId, options =
|
|
153
152
|
});
|
154
153
|
}
|
155
154
|
|
156
|
-
function showMessageOverlay () {
|
157
|
-
function onContinue () {
|
158
|
-
messageOverlay.destroy();
|
159
|
-
createListOverlay.show();
|
160
|
-
triggerAcknowledgeMessageEvent();
|
161
|
-
}
|
162
|
-
|
163
|
-
const messageElement = MessageElement(onContinue);
|
164
|
-
|
165
|
-
const messageOverlay = new Overlay('myft-ui-create-list-variant-message', {
|
166
|
-
html: messageElement,
|
167
|
-
modal: false,
|
168
|
-
parentnode: isMobile() ? '.o-share--horizontal' : '.o-share--vertical',
|
169
|
-
class: 'myft-ui-create-list-variant-message',
|
170
|
-
});
|
171
|
-
|
172
|
-
const scrollHandler = getScrollHandler(messageOverlay.wrapper);
|
173
|
-
const resizeHandler = getResizeHandler(messageOverlay.wrapper);
|
174
|
-
|
175
|
-
messageOverlay.open();
|
176
|
-
|
177
|
-
messageOverlay.wrapper.addEventListener('oOverlay.ready', (data) => {
|
178
|
-
positionOverlay(data.currentTarget);
|
179
|
-
|
180
|
-
window.addEventListener('scroll', scrollHandler);
|
181
|
-
|
182
|
-
window.addEventListener('oViewport.resize', resizeHandler);
|
183
|
-
});
|
184
|
-
|
185
|
-
messageOverlay.wrapper.addEventListener('oOverlay.destroy', () => {
|
186
|
-
window.removeEventListener('scroll', scrollHandler);
|
187
|
-
|
188
|
-
window.removeEventListener('oViewport.resize', resizeHandler);
|
189
|
-
});
|
190
|
-
|
191
|
-
return messageOverlay;
|
192
|
-
}
|
193
|
-
|
194
155
|
function getScrollHandler (target) {
|
195
156
|
return realignOverlay(window.scrollY, target);
|
196
157
|
}
|
@@ -206,7 +167,8 @@ function FormElement (createList, showPublicToggle, attachDescription, onListCre
|
|
206
167
|
<form class="myft-ui-create-list-variant-form">
|
207
168
|
<label class="myft-ui-create-list-variant-form-name o-forms-field">
|
208
169
|
<span class="o-forms-input o-forms-input--text">
|
209
|
-
<input class="myft-ui-create-list-variant-text" type="text" name="list-name"
|
170
|
+
<input class="myft-ui-create-list-variant-text" type="text" name="list-name">
|
171
|
+
List name
|
210
172
|
</span>
|
211
173
|
</label>
|
212
174
|
|
@@ -214,7 +176,7 @@ function FormElement (createList, showPublicToggle, attachDescription, onListCre
|
|
214
176
|
`<div class="myft-ui-create-list-variant-form-public o-forms-field" role="group">
|
215
177
|
<span class="o-forms-input o-forms-input--toggle">
|
216
178
|
<label>
|
217
|
-
<input class="myft-ui-create-list-variant-form-toggle" type="checkbox" name="is-
|
179
|
+
<input class="myft-ui-create-list-variant-form-toggle" type="checkbox" name="is-public" value="public" checked data-trackable="private-link" text="private">
|
218
180
|
<span class="myft-ui-create-list-variant-form-toggle-label o-forms-input__label">
|
219
181
|
<span class="o-forms-input__label__main">
|
220
182
|
Public
|
@@ -246,23 +208,17 @@ function FormElement (createList, showPublicToggle, attachDescription, onListCre
|
|
246
208
|
event.preventDefault();
|
247
209
|
event.stopPropagation();
|
248
210
|
const inputListName = formElement.querySelector('input[name="list-name"]');
|
249
|
-
const
|
211
|
+
const inputIsPublic = formElement.querySelector('input[name="is-public"]');
|
250
212
|
|
251
213
|
const newList = {
|
252
214
|
name: inputListName.value,
|
253
|
-
|
215
|
+
isPublic: inputIsPublic ? inputIsPublic.checked : false
|
254
216
|
};
|
255
217
|
|
256
218
|
createList(newList, ((contentId, createdList) => {
|
257
219
|
triggerCreateListEvent(contentId, createdList.uuid);
|
258
220
|
triggerAddToListEvent(contentId, createdList.uuid);
|
259
221
|
positionOverlay(createListOverlay.wrapper);
|
260
|
-
|
261
|
-
if (createdList.isShareable) {
|
262
|
-
createListOverlay.close();
|
263
|
-
showMessageOverlay();
|
264
|
-
}
|
265
|
-
|
266
222
|
onListCreated();
|
267
223
|
}));
|
268
224
|
formElement.remove();
|
@@ -294,7 +250,7 @@ function addPublicToggleListener (formElement) {
|
|
294
250
|
triggerPublicToggleEvent(event.target.checked);
|
295
251
|
}
|
296
252
|
|
297
|
-
formElement.querySelector('input[name="is-
|
253
|
+
formElement.querySelector('input[name="is-public"]').addEventListener('click', onPublicToggleClick);
|
298
254
|
}
|
299
255
|
|
300
256
|
function ContentElement (hasDescription, onClick) {
|
@@ -302,7 +258,7 @@ function ContentElement (hasDescription, onClick) {
|
|
302
258
|
|
303
259
|
const content = `
|
304
260
|
<div class="myft-ui-create-list-variant-footer">
|
305
|
-
<button class="myft-ui-create-list-variant-add myft-ui-create-list-variant-add-collapsed" data-trackable="add-to-new-list" text="add to new list">Add to a new list</button>
|
261
|
+
<button class="myft-ui-create-list-variant-add myft-ui-create-list-variant-add-collapsed" aria-expanded=false data-trackable="add-to-new-list" text="add to new list">Add to a new list</button>
|
306
262
|
${hasDescription ? `
|
307
263
|
${description}
|
308
264
|
` : ''}
|
@@ -328,11 +284,13 @@ function ContentElement (hasDescription, onClick) {
|
|
328
284
|
|
329
285
|
function restoreFormHandler () {
|
330
286
|
contentElement.querySelector('.myft-ui-create-list-variant-add').classList.add('myft-ui-create-list-variant-add-collapsed');
|
287
|
+
contentElement.querySelector('.myft-ui-create-list-variant-add').setAttribute('aria-expanded', false);
|
331
288
|
return contentElement.addEventListener('click', clickHandler, { once: true });
|
332
289
|
}
|
333
290
|
|
334
291
|
function clickHandler (event) {
|
335
292
|
contentElement.querySelector('.myft-ui-create-list-variant-add').classList.remove('myft-ui-create-list-variant-add-collapsed');
|
293
|
+
contentElement.querySelector('.myft-ui-create-list-variant-add').setAttribute('aria-expanded', true);
|
336
294
|
onClick(event);
|
337
295
|
}
|
338
296
|
|
@@ -420,28 +378,6 @@ function ListCheckboxElement (addToList, removeFromList) {
|
|
420
378
|
};
|
421
379
|
}
|
422
380
|
|
423
|
-
function MessageElement (onContinue) {
|
424
|
-
const message = `
|
425
|
-
<div class="myft-ui-create-list-variant-message-content" >
|
426
|
-
<div class="myft-ui-create-list-variant-message-text" aria-live="polite">
|
427
|
-
<h3>Thank you for your interest in making a public list</h3>
|
428
|
-
<p>We're currently testing this feature. For now, your list remains private and isn't visible to others.</p>
|
429
|
-
</div>
|
430
|
-
<div class="myft-ui-create-list-variant-message-buttons">
|
431
|
-
<button class="o-buttons o-buttons--big o-buttons--secondary" data-trackable="continue-link" text="continue">
|
432
|
-
Continue
|
433
|
-
</button>
|
434
|
-
</div>
|
435
|
-
</div>
|
436
|
-
`;
|
437
|
-
|
438
|
-
const messageElement = stringToHTMLElement(message);
|
439
|
-
|
440
|
-
messageElement.querySelector('button').addEventListener('click', onContinue);
|
441
|
-
|
442
|
-
return messageElement;
|
443
|
-
}
|
444
|
-
|
445
381
|
function realignOverlay (originalScrollPosition, target) {
|
446
382
|
return function () {
|
447
383
|
const currentScrollPosition = window.scrollY;
|
@@ -495,7 +431,7 @@ async function getLists (contentId) {
|
|
495
431
|
return myFtClient.getListsContent()
|
496
432
|
.then(results => results.items.map(list => {
|
497
433
|
const isChecked = Array.isArray(list.content) && list.content.some(content => content.uuid === contentId);
|
498
|
-
return { name: list.name, uuid: list.uuid, checked: isChecked, content: list.content,
|
434
|
+
return { name: list.name, uuid: list.uuid, checked: isChecked, content: list.content, isPublic: list.isPublic };
|
499
435
|
}));
|
500
436
|
}
|
501
437
|
|
@@ -569,20 +505,6 @@ function triggerAddToNewListEvent () {
|
|
569
505
|
}));
|
570
506
|
}
|
571
507
|
|
572
|
-
// Temporary event on the public toggle feature.
|
573
|
-
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
574
|
-
function triggerAcknowledgeMessageEvent () {
|
575
|
-
document.body.dispatchEvent(new CustomEvent('oTracking.event', {
|
576
|
-
detail: {
|
577
|
-
category: 'publicToggle',
|
578
|
-
action: 'acknowledgeMessage',
|
579
|
-
teamName: 'customer-products-us-growth',
|
580
|
-
amplitudeExploratory: true
|
581
|
-
},
|
582
|
-
bubbles: true
|
583
|
-
}));
|
584
|
-
}
|
585
|
-
|
586
508
|
// Temporary event on the public toggle feature.
|
587
509
|
// These will be used to build a sanity check dashboard, and will be removed after we get clean-up this test.
|
588
510
|
function triggerCancelEvent () {
|