Skip to content

Commit

Permalink
feature/#1983: add ability to hide pages from the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Mar 20, 2018
2 parents adccf49 + 304af0c commit d3f942f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ The attributes listed below are used in *contentObjects.json* to configure **Box

**_classes** (string): CSS class name to be applied to menu item's `page` element (*src/core/js/views/pageView.js*). The class must be predefined in one of the Less files. Separate multiple classes with a space.

**_isHidden** (boolean): If you want to hide a content object from the menu, set this to `true`. This can be useful if, for example, you have a content object defined as a 'start page' for the course which you therefore don't want to be listed on the menu since the user will have already seen it.

**title** (string): This text is a reference title for the content object.

**displayTitle** (string): This text is displayed on the menu item.
Expand Down Expand Up @@ -75,9 +77,9 @@ Several menu-related elements are assigned a label using the [aria-label](https:
No known limitations.

----------------------------
**Version number:** 2.0.7 <a href="https://community.adaptlearning.org/" target="_blank"><img src="https://github.com/adaptlearning/documentation/blob/master/04_wiki_assets/plug-ins/images/adapt-logo-mrgn-lft.jpg" alt="adapt learning logo" align="right"></a>
**Version number:** 2.1.0 <a href="https://community.adaptlearning.org/" target="_blank"><img src="https://github.com/adaptlearning/documentation/blob/master/04_wiki_assets/plug-ins/images/adapt-logo-mrgn-lft.jpg" alt="adapt learning logo" align="right"></a>
**Framework versions:** 2.1+
**Author / maintainer:** Adapt Core Team with [contributors](https://github.com/adaptlearning/adapt-contrib-boxmenu/graphs/contributors)
**Accessibility support:** WAI AA
**RTL support:** yes
**Cross-platform coverage:** Chrome, Chrome for Android, Firefox (ESR + latest version), Edge 12, IE 11, IE10, IE9, IE8, IE Mobile 11, Safari iOS 9+10, Safari OS X 9+10, Opera
**Cross-platform coverage:** Chrome, Chrome for Android, Firefox (ESR + latest version), Edge, IE11, IE10, IE9, IE8, IE Mobile 11, Safari 10+11 for macOS+iOS, Opera
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapt-contrib-boxMenu",
"version": "2.0.7",
"version": "2.1.0",
"framework": ">=2.1",
"homepage": "https://github.com/adaptlearning/adapt-contrib-boxmenu",
"issues": "https://github.com/adaptlearning/adapt_framework/issues/new?title=contrib-boxmenu%3A%20please%20enter%20a%20brief%20summary%20of%20the%20issue%20here&body=please%20provide%20a%20full%20description%20of%20the%20problem,%20including%20steps%20on%20how%20to%20replicate,%20what%20browser(s)/device(s)%20the%20problem%20occurs%20on%20and,%20where%20helpful,%20screenshots.",
Expand Down
19 changes: 10 additions & 9 deletions example.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"_id":"co-05",
"_parentId":"course",
"_type":"page",
"_classes":"",
"title":"Welcome to Adapt Learning",
"displayTitle":"Welcome to Adapt Learning",
"body":"This page contains a working Adapt page with all core bundled components and plugins working.",
"_id": "co-05",
"_parentId": "course",
"_type": "page",
"_classes": "",
"_isHidden": false,
"title": "Welcome to Adapt Learning",
"displayTitle": "Welcome to Adapt Learning",
"body": "This page contains a working Adapt page with all core bundled components and plugins working.",
"_graphic": {
"alt": "Welcome to Adapt Learning",
"src": "course/en/images/origami-menu-one.jpg"
},
"linkText":"View",
"duration":"2 mins"
"linkText": "View",
"duration": "2 mins"
}
15 changes: 9 additions & 6 deletions js/adapt-contrib-boxmenu.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define([
'coreJS/adapt',
'coreViews/menuView'
'core/js/adapt',
'core/js/views/menuView'
], function(Adapt, MenuView) {

var BoxMenuView = MenuView.extend({
Expand All @@ -12,11 +12,14 @@ define([
postRender: function() {
var nthChild = 0;
this.model.getChildren().each(function(item) {
if (item.get('_isAvailable')) {
nthChild++;
item.set("_nthChild", nthChild);
if (item.get('_isAvailable') && !item.get('_isHidden')) {
item.set('_nthChild', ++nthChild);
this.$('.menu-container-inner').append(new BoxMenuItemView({model: item}).$el);
}

if(item.get('_isHidden')) {
item.set('_isReady', true);
}
});
}

Expand All @@ -31,7 +34,7 @@ define([
},

className: function() {
var nthChild = this.model.get("_nthChild");
var nthChild = this.model.get('_nthChild');
return [
'menu-item',
'menu-item-' + this.model.get('_id') ,
Expand Down

0 comments on commit d3f942f

Please sign in to comment.