diff --git a/example.json b/example.json
index 5162019..eab6e34 100644
--- a/example.json
+++ b/example.json
@@ -1,24 +1,33 @@
- // Configuration options must be added and amended for all json files where required
+// Configuration options must be added and amended for all JSON files where required
- // config.json - to disable globally
- "_homeButton": {
- "_isEnabled": false
- }
+// config.json - Used to disable globally
+"_homeButton": {
+ "_isEnabled": false
+}
- // course.json
- "_homeButton": {
- "_isEnabled": true,
- "_hideHomeButton": false,
- "_comment": "Amend co-00 to match the ID of the start / landing page",
- "_redirectToId": "co-00",
- "alt": "Introduction"
+// course.json - Use for global settings and navigation order
+"_extensions": {
+ "_homeButton": {
+ "_navOrder": -1,
+ "_showLabel": true,
+ "navLabel": "Home",
+ "_navTooltip": {
+ "_isEnabled": false,
+ "text": "Home"
}
+ }
+}
- // contentObjects.json
- "_homeButton": {
- "_isEnabled": true,
- "_hideHomeButton": false,
- "_hideBackButton": true,
- "_redirectToId": "",
- "alt": "Home"
- }
+// course.json or contentObjects - Use to configure at the menu or content object level
+"_homeButton": {
+ "_isEnabled": true,
+ "_hideHomeButton": false,
+ "_comment": "Amend _redirectToId to match the ID of the start / landing page",
+ "_redirectToId": "",
+ "_comment": "Option to override navigation button label and tooltip",
+ "navLabel": "Introduction",
+ "_navTooltip": {
+ "_isEnabled": true,
+ "text": "Introduction"
+ }
+}
diff --git a/js/HomeNavigationButtonView.js b/js/HomeNavigationButtonView.js
new file mode 100644
index 0000000..269ce16
--- /dev/null
+++ b/js/HomeNavigationButtonView.js
@@ -0,0 +1,36 @@
+import Adapt from 'core/js/adapt';
+import NavigationButtonView from 'core/js/views/NavigationButtonView';
+import tooltips from 'core/js/tooltips';
+
+class HomeNavigationButtonView extends NavigationButtonView {
+
+ attributes() {
+ return {
+ ...super.attributes(),
+ 'data-tooltip-id': this.model.get('_id')
+ };
+ }
+
+ initialize(options) {
+ super.initialize(options);
+ this.setupEventListeners();
+ this.render();
+ tooltips.register({
+ _id: this.model.get('_id'),
+ ...this.model.get('_navTooltip') || {}
+ });
+ }
+
+ setupEventListeners() {
+ this.listenTo(Adapt, {
+ remove: this.remove
+ });
+ }
+
+ static get template() {
+ return 'HomeNavigationButton.jsx';
+ }
+
+}
+
+export default HomeNavigationButtonView;
diff --git a/js/adapt-homeButton.js b/js/adapt-homeButton.js
index 0f8ddc6..608dc08 100644
--- a/js/adapt-homeButton.js
+++ b/js/adapt-homeButton.js
@@ -3,6 +3,9 @@ import Adapt from 'core/js/adapt';
import data from 'core/js/data';
import location from 'core/js/location';
import router from 'core/js/router';
+import navigation from 'core/js/navigation';
+import NavigationButtonModel from 'core/js/models/NavigationButtonModel';
+import HomeNavigationButtonView from './HomeNavigationButtonView';
class HomeButton extends Backbone.Controller {
@@ -11,8 +14,10 @@ class HomeButton extends Backbone.Controller {
}
onDataReady() {
+ // Do not render if turned off at config level
const config = Adapt.config.get('_homeButton');
if (config?._isEnabled === false) return;
+
this.$html = $('html');
this.stopListening();
this.listenTo(Adapt, {
@@ -22,11 +27,15 @@ class HomeButton extends Backbone.Controller {
});
}
+ static get globalsConfig() {
+ return Adapt.course.get('_globals')?._extensions?._homeButton;
+ }
+
get currentModelConfig() {
return location._currentModel?.get('_homeButton');
}
- get courseConfig() {
+ static get courseConfig() {
return Adapt.course?.get('_homeButton');
}
@@ -43,30 +52,44 @@ class HomeButton extends Backbone.Controller {
enable() {
const currentModelConfig = this.currentModelConfig;
- const courseConfig = this.courseConfig;
+
+ // Update classes
this.$html.toggleClass('hide-nav-home-btn', Boolean(currentModelConfig?._hideHomeButton));
// extend functionality to toggle back button display
this.$html.toggleClass('hide-nav-back-btn', Boolean(currentModelConfig?._hideBackButton));
- const altText = (currentModelConfig?.alt || courseConfig?.alt || '');
- const $backButton = $('button[data-event="backButton"]');
- const $icon = $('
', { class: 'icon', 'aria-hidden': true });
- const $homeButton = $('