Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: adaptlearning/adapt_framework
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v5.7.0
Choose a base ref
...
head repository: adaptlearning/adapt_framework
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v5.7.1
Choose a head ref

Commits on Sep 2, 2020

  1. add missing space

    moloko authored Sep 2, 2020
    Copy the full SHA
    a0b9f87 View commit details

Commits on Sep 3, 2020

  1. Copy the full SHA
    db4e511 View commit details

Commits on Sep 8, 2020

  1. Less tidy up (#2893)

    guywillis authored Sep 8, 2020
    Copy the full SHA
    41a9657 View commit details

Commits on Sep 9, 2020

  1. swap logic in ternary

    should only be calling getStartHash if start page is enabled
    fixes #2907
    moloko authored Sep 9, 2020
    Copy the full SHA
    f6caafb View commit details

Commits on Sep 11, 2020

  1. Merge pull request #2909 from adaptlearning/issue/2907

    fix bug in triggerDataReady
    tomgreenfield authored Sep 11, 2020
    Copy the full SHA
    a462501 View commit details

Commits on Sep 15, 2020

  1. Copy the full SHA
    14bd95f View commit details

Commits on Sep 22, 2020

  1. Copy the full SHA
    89a6163 View commit details

Commits on Sep 23, 2020

  1. Copy the full SHA
    676a2da View commit details
  2. Copy the full SHA
    44817f3 View commit details
  3. Copy the full SHA
    2b684d5 View commit details

Commits on Sep 29, 2020

  1. Copy the full SHA
    99f30d1 View commit details
  2. Copy the full SHA
    9064fff View commit details
  3. Copy the full SHA
    7d6a8f2 View commit details
  4. Copy the full SHA
    aa04520 View commit details

Commits on Sep 30, 2020

  1. Copy the full SHA
    5fbf470 View commit details
  2. Copy the full SHA
    a178e43 View commit details
  3. Copy the full SHA
    809f3b0 View commit details

Commits on Oct 5, 2020

  1. issue/2928 Typo

    oliverfoster authored Oct 5, 2020
    Copy the full SHA
    f316618 View commit details

Commits on Oct 6, 2020

  1. Merge pull request #2931 from adaptlearning/issue/2928

    issue/2928 Fixes navigateToElement, deprecates scrollTo
    tomgreenfield authored Oct 6, 2020
    Copy the full SHA
    b15b3ee View commit details

Commits on Oct 8, 2020

  1. Copy the full SHA
    8944991 View commit details
  2. Copy the full SHA
    f93c173 View commit details
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [5.7.1] - 2020-10-09

### Fixed
* Page Level Progress indicators disrupting container outlines in Firefox - now fixed for article/block/page level indicators as well ([#2619](https://github.com/adaptlearning/adapt_framework/issues/2619))
* `Adapt.navigateToElement('.pageId')` errors ([#2901](https://github.com/adaptlearning/adapt_framework/issues/2901))
* `"view:requestChild"` event life-cycle never closes ([#2903](https://github.com/adaptlearning/adapt_framework/issues/2903))
* Switching language forces the 'start page' config to be enabled ([#2907](https://github.com/adaptlearning/adapt_framework/issues/2907))
* Firefox display of `*-title-inner` elements when using outline ([#2912](https://github.com/adaptlearning/adapt_framework/issues/2912))
* IE11 broken display of .svg in `<img>` ([#2916](https://github.com/adaptlearning/adapt_framework/issues/2916))
* `Adapt.scrollTo` assumes the selector parameter will always refer to an 'Adapt Element' ([#2928](https://github.com/adaptlearning/adapt_framework/issues/2928))

### Changed
* General clean up of Less code ([#2891](https://github.com/adaptlearning/adapt_framework/issues/2891))

## [5.7.0] - 2020-08-25
### Added
* New `AttemptStates` API ([#2747](https://github.com/adaptlearning/adapt_framework/issues/2747))
@@ -920,6 +934,7 @@ The initial version of the Adapt framework.
### Added
- Everything!

[5.7.1]: https://github.com/adaptlearning/adapt_framework/compare/v5.7.0...v5.7.1
[5.7.0]: https://github.com/adaptlearning/adapt_framework/compare/v5.6.1...v5.7.0
[5.6.1]: https://github.com/adaptlearning/adapt_framework/compare/v5.6.0...v5.6.1
[5.6.0]: https://github.com/adaptlearning/adapt_framework/compare/v5.5.1...v5.6.0
2 changes: 1 addition & 1 deletion GRUNT.md
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ Compiles all files in `src` to create a production-ready minified/compressed ver
`--menu` If more than one menu is present in the */src/menu* folder, specifies the name of the menu to include in the build.
`--theme` If more than one theme is present in the */src/theme* folder, specifies the name of the theme to include in the build.
`--sourcedir` Specifies the absolute path to parent folder of the code to be processed. Defaults to the path to */src*.
`--outputdir` Specifies the absolute path to parent folder where the build will be written. Defaults to the path to */build*.
`--outputdir` Specifies the absolute path to parent folder where the build will be written. Defaults to the path to */build*.
`--jsonext` Specifies the file extension your JSON files use. Defaults to *json*. If the server your content is hosted on doesn't support the JSON mime-type you can use *txt* here to use the .txt file extension instead. You will need to manually amend the extension of all your JSON files to .txt initially.

**dev**
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapt_framework",
"version": "5.7.0",
"version": "5.7.1",
"description": "Adapt Learning output framework",
"repository": {
"type": "git",
4 changes: 2 additions & 2 deletions src/core/js/adapt.js
Original file line number Diff line number Diff line change
@@ -140,9 +140,9 @@ define([
}

/**
* Allows a selector to be passed in and Adapt will navigate to this element. Resolves
* Allows a selector or id to be passed in and Adapt will navigate to this element. Resolves
* asynchronously when the element has been navigated to.
* @param {string} selector CSS selector of the Adapt element you want to navigate to e.g. `".co-05"`
* @param {string} selector CSS selector or id of the Adapt element you want to navigate to e.g. `".co-05"` or `"co-05"`
* @param {Object} [settings] The settings for the `$.scrollTo` function (See https://github.com/flesler/jquery.scrollTo#settings).
* @param {Object} [settings.replace=false] Set to `true` if you want to update the URL without creating an entry in the browser's history.
*/
4 changes: 1 addition & 3 deletions src/core/js/data.js
Original file line number Diff line number Diff line change
@@ -164,9 +164,7 @@ define([
Adapt.trigger('app:languageChanged', newLanguage);
_.defer(() => {
Adapt.startController.loadCourseData();
const hash = Adapt.startController.isEnabled() ?
'#/' :
Adapt.startController.getStartHash(true);
const hash = Adapt.startController.isEnabled() ? Adapt.startController.getStartHash(true) : '#/';
Adapt.router.navigate(hash, { trigger: true, replace: true });
});
}
108 changes: 76 additions & 32 deletions src/core/js/router.js
Original file line number Diff line number Diff line change
@@ -130,24 +130,21 @@ define([

async handleId(id) {
const rootModel = Adapt.router.rootModel;
const model = (!id) ? rootModel : Adapt.findById(id);
let model = (!id) ? rootModel : Adapt.findById(id);

if (!model) {
// Bad id
this.model.set('_canNavigate', true, { pluginName: 'adapt' });
return;
}

id = model.get('_id');

// Keep the routed id incase it needs to be scrolled to later
const isContentObject = (model instanceof ContentObjectModel);
if (!isContentObject) {
// Allow navigation.
this.model.set('_canNavigate', true, { pluginName: 'adapt' });
// Scroll to element
Adapt.navigateToElement('.' + id, { replace: true, duration: 400 });
return;
}
const navigateToId = model.get('_id');

// Ensure that the router is rendering a contentobject
model = isContentObject ? model : model.findAncestor('contentobject');
id = model.get('_id');

const isRoot = (model === rootModel);
if (isRoot && Adapt.course.has('_start')) {
@@ -199,6 +196,12 @@ define([
return;
}
this.$wrapper.append(new ViewClass({ model }).$el);

if (!isContentObject && !this.isScrolling) {
// Scroll to element if not a content object or not already trying to
await Adapt.navigateToElement('.' + navigateToId, { replace: true, duration: 400 });
}

}

async updateLocation(currentLocation, type, id, currentModel) {
@@ -319,40 +322,81 @@ define([
}

/**
* Allows a selector to be passed in and Adapt will navigate to this element. Resolves
* Allows a selector or id to be passed in and Adapt will navigate to this element. Resolves
* asynchronously when the element has been navigated to.
* Backend for Adapt.navigateToElement
* @param {string} selector CSS selector of the Adapt element you want to navigate to e.g. `".co-05"`
* @param {string} selector CSS selector or id of the Adapt element you want to navigate to e.g. `".co-05"` or `"co-05"`
* @param {Object} [settings] The settings for the `$.scrollTo` function (See https://github.com/flesler/jquery.scrollTo#settings).
* @param {Object} [settings.replace=false] Set to `true` if you want to update the URL without creating an entry in the browser's history.
*/
async navigateToElement(selector, settings = {}) {
// Removes . symbol from the selector to find the model
const currentModelId = selector.replace(/\./g, '');
const currentModelId = selector.replace(/\./g, '').split(' ')[0];
const currentModel = Adapt.findById(currentModelId);
if (!currentModel) return;

// Get current page to check whether this is the current page
const currentPage = currentModel instanceof ContentObjectModel ? currentModel : currentModel.findAncestor('contentObjects');
const pageId = currentPage.get('_id');
// If current page - scrollTo element
if (pageId === Adapt.location._currentId) {
return Adapt.scrollTo(selector, settings);

if (currentModel && (!currentModel.get('_isRendered') || !currentModel.get('_isReady'))) {
const shouldReplace = settings.replace || false;
const contentObject = (currentModel instanceof ContentObjectModel) ? currentModel : currentModel.findAncestor('contentobject');
const contentObjectId = contentObject.get('_id');
const isInCurrentContentObject = (contentObjectId !== Adapt.location._currentId);
if (isInCurrentContentObject) {
this.isScrolling = true;
this.navigate(`#/id/${currentModelId}`, { trigger: true, replace: shouldReplace });
this.model.set('_shouldNavigateFocus', false, { pluginName: 'adapt' });
await new Promise(resolve => Adapt.once('contentObjectView:ready', _.debounce(() => {
this.model.set('_shouldNavigateFocus', true, { pluginName: 'adapt' });
resolve();
}, 1)));
this.isScrolling = false;
}
await Adapt.parentView.renderTo(currentModelId);
}

// Correct selector when passed a pure id
if (currentModel && selector === currentModel.get('_id')) {
selector = `.${selector}`;
}

// Get the current location - this is set in the router
const location = (Adapt.location._contentType) ?
Adapt.location._contentType : Adapt.location._currentLocation;
// Trigger initial scrollTo event
Adapt.trigger(`${location}:scrollTo`, selector);
// Setup duration variable
const disableScrollToAnimation = Adapt.config.has('_disableAnimation') ? Adapt.config.get('_disableAnimation') : false;
if (disableScrollToAnimation) {
settings.duration = 0;
} else if (!settings.duration) {
settings.duration = $.scrollTo.defaults.duration;
}

let offsetTop = 0;
if (Adapt.scrolling.isLegacyScrolling) {
offsetTop = -$('.nav').outerHeight();
// prevent scroll issue when component description aria-label coincident with top of component
if ($(selector).hasClass('component')) {
offsetTop -= $(selector).find('.aria-label').height() || 0;
}
}

const shouldReplaceRoute = settings.replace || false;
if (!settings.offset) settings.offset = { top: offsetTop, left: 0 };
if (settings.offset.top === undefined) settings.offset.top = offsetTop;
if (settings.offset.left === undefined) settings.offset.left = 0;

if (settings.offset.left === 0) settings.axis = 'y';

if (Adapt.get('_canScroll') !== false) {
// Trigger scrollTo plugin
$.scrollTo(selector, settings);
}

// Trigger an event after animation
// 300 milliseconds added to make sure queue has finished
await new Promise(resolve => {
// If the element is on another page navigate and wait until pageView:ready is fired
// Then scrollTo element
Adapt.once('contentObjectView:ready', _.debounce(async () => {
this.model.set('_shouldNavigateFocus', true, { pluginName: 'adapt' });
await Adapt.scrollTo(selector, settings);
_.delay(() => {
Adapt.a11y.focusNext(selector);
Adapt.trigger(`${location}:scrolledTo`, selector);
resolve();
}, 1));

this.model.set('_shouldNavigateFocus', false, { pluginName: 'adapt' });
this.navigate('#/id/' + pageId, { trigger: true, replace: shouldReplaceRoute });
}, settings.duration + 300);
});
}

53 changes: 2 additions & 51 deletions src/core/js/scrolling.js
Original file line number Diff line number Diff line change
@@ -109,57 +109,8 @@ define([
* @param {Object} [settings.replace=false] Set to `true` if you want to update the URL without creating an entry in the browser's history.
*/
async scrollTo(selector, settings = {}) {

const currentModelId = selector.replace(/\./g, '');
const currentModel = Adapt.findById(currentModelId);
if (!currentModel) return;

if (!currentModel.get('_isRendered') || !currentModel.get('_isRendered')) {
await Adapt.parentView.renderTo(currentModelId);
}

// Get the current location - this is set in the router
const location = (Adapt.location._contentType) ?
Adapt.location._contentType : Adapt.location._currentLocation;
// Trigger initial scrollTo event
Adapt.trigger(`${location}:scrollTo`, selector);
// Setup duration variable passed upon argumentsß
const disableScrollToAnimation = Adapt.config.has('_disableAnimation') ? Adapt.config.get('_disableAnimation') : false;
if (disableScrollToAnimation) {
settings.duration = 0;
} else if (!settings.duration) {
settings.duration = $.scrollTo.defaults.duration;
}

let offsetTop = 0;
if (Adapt.scrolling.isLegacyScrolling) {
offsetTop = -$('.nav').outerHeight();
// prevent scroll issue when component description aria-label coincident with top of component
if ($(selector).hasClass('component')) {
offsetTop -= $(selector).find('.aria-label').height() || 0;
}
}

if (!settings.offset) settings.offset = { top: offsetTop, left: 0 };
if (settings.offset.top === undefined) settings.offset.top = offsetTop;
if (settings.offset.left === undefined) settings.offset.left = 0;

if (settings.offset.left === 0) settings.axis = 'y';

if (Adapt.get('_canScroll') !== false) {
// Trigger scrollTo plugin
$.scrollTo(selector, settings);
}

// Trigger an event after animation
// 300 milliseconds added to make sure queue has finished
await new Promise(resolve => {
_.delay(() => {
Adapt.a11y.focusNext(selector);
Adapt.trigger(`${location}:scrolledTo`, selector);
resolve();
}, settings.duration + 300);
});
Adapt.log.deprecated('Adapt.scrollTo and Adapt.scrolling.scrollTo, use Adapt.navigateToElement instead.');
return Adapt.router.navigateToElement(selector, settings);
}

}
2 changes: 2 additions & 0 deletions src/core/js/views/adaptView.js
Original file line number Diff line number Diff line change
@@ -224,6 +224,8 @@ define([
Adapt.trigger('view:requestChild', event);
if (!event.hasRequestChild) {
// No new model was supplied
// Close the event so that the final state can be scrutinized
event.close();
return;
}
// A new model has been supplied for the end of the list.
2 changes: 2 additions & 0 deletions src/core/js/views/contentObjectView.js
Original file line number Diff line number Diff line change
@@ -95,6 +95,8 @@ define([
* @param {string} id
*/
async renderTo(id) {
const isRenderToSelf = (id === this.model.get('_id'));
if (isRenderToSelf) return;
let models = this.model.getAllDescendantModels(true).filter(model => model.get('_isAvailable'));
const index = models.findIndex(model => model.get('_id') === id);
if (index === -1) {
27 changes: 3 additions & 24 deletions src/core/less/_defaults/_variables.less
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@
// -webkit-transform: translateZ(0);
// }


// --------------------------------------------------
// Screen sizings
// --------------------------------------------------
// html = 16px
@@ -27,35 +25,25 @@
@device-width-large: unit(@adapt-device-large, rem);

@max-width: 90rem;
// --------------------------------------------------

// --------------------------------------------------
// Icons
// --------------------------------------------------
@icon-size: 1.5rem;
@icon-padding: 1rem;
// --------------------------------------------------

// --------------------------------------------------
// Spacings
// --------------------------------------------------
@item-margin: 0.5rem;
@item-padding: 1rem;
// --------------------------------------------------

// --------------------------------------------------
// Button padding
// --------------------------------------------------
@btn-padding: 1rem;
// --------------------------------------------------

// --------------------------------------------------
// Duration
// --------------------------------------------------
@duration: 0.2s;
// --------------------------------------------------

// --------------------------------------------------
// Colours
// --------------------------------------------------
@white: #fff;
@@ -76,33 +64,24 @@
@validation-error: @red;
@validation-error-inverted: @white;

// --------------------------------------------------
// Block padding
// --------------------------------------------------
@block-padding-ver: 4rem;
@block-padding-hoz: 0.5rem;
// --------------------------------------------------

// --------------------------------------------------
// Component padding
// --------------------------------------------------
@component-padding-hoz: 0.5rem;
// --------------------------------------------------

// --------------------------------------------------
// Navigation height
// --------------------------------------------------
@navigation-height: @icon-size + (@icon-padding * 2);
// --------------------------------------------------

// Focus outline
// Deprecated - reverting to browser outline
// --------------------------------------------------
//
// --------------------------------------------------
@focus-outline: 0; // deprecated - reverting to browser outline
// --------------------------------------------------
@focus-outline: 0;

// --------------------------------------------------
// Drawer width
// --------------------------------------------------
@drawer-width: 20rem;
// --------------------------------------------------
Loading
Oops, something went wrong.