Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* A sentence describing each fix

### Update
* A sentence describing each udpate
* A sentence describing each update

### New
* A sentence describing each new feature
Expand Down
18 changes: 9 additions & 9 deletions js/TrickleButtonModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,18 @@ export default class TrickleButtonModel extends ComponentModel {
const text = (isDisabled && trickleConfig._button.disabledText) ?
trickleConfig._button.disabledText :
(isStart && trickleConfig._button.startText) ?
trickleConfig._button.startText :
(isFinal && trickleConfig._button.finalText) ?
trickleConfig._button.finalText :
trickleConfig._button.text;
trickleConfig._button.startText :
(isFinal && trickleConfig._button.finalText) ?
trickleConfig._button.finalText :
trickleConfig._button.text;

const ariaLabel = (isDisabled && trickleConfig._button.disabledAriaLabel) ?
trickleConfig._button.disabledAriaLabel :
trickleConfig._button.disabledAriaLabel :
(isStart && trickleConfig._button.startAriaLabel) ?
trickleConfig._button.startAriaLabel :
(isFinal && trickleConfig._button.finalAriaLabel) ?
trickleConfig._button.finalAriaLabel :
trickleConfig._button.ariaLabel;
trickleConfig._button.startAriaLabel :
(isFinal && trickleConfig._button.finalAriaLabel) ?
trickleConfig._button.finalAriaLabel :
trickleConfig._button.ariaLabel;

this.set({
buttonText: text,
Expand Down
25 changes: 23 additions & 2 deletions js/TrickleButtonView.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Adapt from 'core/js/adapt';
import a11y from 'core/js/a11y';
import notify from 'core/js/notify';
import ComponentView from 'core/js/views/componentView';
import controller from './controller';
import {
Expand Down Expand Up @@ -118,7 +119,7 @@ class TrickleButtonView extends ComponentView {
this.$('.js-trickle-btn-container').toggleClass('u-display-none', isButtonHidden);
const isButtonDisabled = this.model.get('_isButtonDisabled');
const $button = this.$('.js-trickle-btn');
const $ariaLabel = this.$('.aria-label');
const $ariaLabel = this.$('.aria-label:not(.trickle__status)');
Comment thread
swashbuck marked this conversation as resolved.
Outdated
a11y.toggleEnabled($button, !isButtonDisabled);
if (!isButtonDisabled) {
// move focus forward if it's on the aria-label
Expand Down Expand Up @@ -202,10 +203,30 @@ class TrickleButtonView extends ComponentView {
*/
async continue() {
const parent = this.model.getParent();
await controller.continue();
const childrenAdded = await controller.continue();
if (!childrenAdded) return;
Comment thread
swashbuck marked this conversation as resolved.
Outdated
await this.announceContentLoaded();
await controller.scroll(parent);
}

/**
* Announce a message to screenreaders letting them know that additional
* content has been loaded on the page.
*/
async announceContentLoaded() {
const globals = Adapt.course.get('_globals');
const message = globals?._extensions?._trickle?.additionalContentLoaded;
if (!message) return;

notify.create({ _type: 'a11y-push', body: message });

// Rough estimate: 200ms per word + buffer
const words = message.split(' ').length;
const delay = (words * 200) + 300;
Comment thread
oliverfoster marked this conversation as resolved.
Outdated

return new Promise(resolve => setTimeout(resolve, delay));
}
Comment thread
swashbuck marked this conversation as resolved.

tryButtonAutoHide() {
if (!this.model.get('_isButtonVisible')) return;
const trickleConfig = getModelConfig(this.model.getParent());
Expand Down
7 changes: 4 additions & 3 deletions js/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ class TrickleController extends Backbone.Controller {
*/
async continue() {
applyLocks();
await Adapt.parentView.addChildren();
const addedCount = await Adapt.parentView.addChildren();
await Adapt.parentView.whenReady();
return addedCount;
}

/**
Expand Down Expand Up @@ -160,8 +161,8 @@ class TrickleController extends Backbone.Controller {

let scrollToId = getScrollToId();
if (!scrollToId) {
logging.error(`Cannot scroll to the next id as none was found at id: "${fromModel.get('_id')}" with _scrollTo: "${trickleConfig._scrollTo}". Suggestion: Set _showEndOfPage to false.`)
return
logging.error(`Cannot scroll to the next id as none was found at id: "${fromModel.get('_id')}" with _scrollTo: "${trickleConfig._scrollTo}". Suggestion: Set _showEndOfPage to false.`);
return;
}

const isDescendant = Adapt.parentView.model.getAllDescendantModels().some(model => {
Expand Down
10 changes: 10 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
"inputType": "Text",
"validators": [],
"translatable": true
},
"additionalContentLoaded": {
"type": "string",
"required": true,
"title": "Additional content loaded.",
"default": "Loading.",
"inputType": "Text",
"help": "Announced to screen readers when additional content is loaded. Recommend keeping this short.",
"validators": [],
"translatable": true
}
},
"properties": {
Expand Down
9 changes: 9 additions & 0 deletions schema/course.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
"_adapt": {
"translatable": true
}
},
"additionalContentLoaded": {
"type": "string",
"title": "Additional content loaded",
"default": "Loading.",
"description": "Announced to screen readers when additional content is loaded. Recommend keeping this short.",
"_adapt": {
"translatable": true
}
}
}
}
Expand Down