diff --git a/README.md b/README.md
index 9d72cdc..1c494bc 100755
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@ Hotgrid automatically switches to 2 columns in mobile mode for the best user exp
----------------------------
-**Version number:** 2.0
+**Version number:** 2.0.2
**Framework versions:** 2.0
**Author / maintainer:**
**Accessibility support:** WAI AA
diff --git a/bower.json b/bower.json
index 83cc057..893aeb7 100755
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "adapt-hotgrid-audio",
- "version": "2.0.1",
+ "version": "2.0.2",
"framework": "2.0.4",
"homepage": "https://github.com/deltanet/adapt-hotgrid-audio",
"displayName": "Hotgrid",
diff --git a/js/adapt-hotgrid.js b/js/adapt-hotgrid.js
index eb2fc6d..d1ea4c9 100755
--- a/js/adapt-hotgrid.js
+++ b/js/adapt-hotgrid.js
@@ -24,6 +24,9 @@ define(function(require) {
// Listen for text change on audio extension
this.listenTo(Adapt, "audio:changeText", this.replaceText);
+
+ this.listenTo(Adapt, 'hotgridNotify:back', this.previousItem);
+ this.listenTo(Adapt, 'hotgridNotify:next', this.nextItem);
this.setDeviceSize();
},
@@ -47,6 +50,8 @@ define(function(require) {
if (this.model.get('_reducedText') && this.model.get('_reducedText')._isEnabled) {
this.replaceText(Adapt.audio.textSize);
}
+
+ var activeItem = 0;
},
resizeControl: function() {
@@ -114,6 +119,11 @@ define(function(require) {
var $item = $link.parent();
var itemModel = this.model.get('_items')[$item.index()];
+ this.$('.hotgrid-grid-item.active').removeClass('active');
+ $item.addClass('active');
+
+ activeItem = $item.index();
+
if(!itemModel.visited) {
$item.addClass("visited");
itemModel.visited = true;
@@ -140,15 +150,43 @@ define(function(require) {
popupObject_body = itemModel.bodyReduced;
}
- Adapt.trigger("notify:popup", {
- title: popupObject_title,
- body: "
" + popupObject_body + "
" +
- "
"
- });
+ // Trigger which type of notify based on the '_canCycleThroughPagination' setting
+ if(this.model.get('_canCycleThroughPagination')) {
+ var interactionObject = {
+ title: popupObject_title,
+ body: "" + popupObject_body + "
" +
+ "
",
+ _back:[
+ {
+ _callbackEvent: "hotgridNotify:back"
+ }
+ ],
+ _next:[
+ {
+ _callbackEvent: "hotgridNotify:next"
+ }
+ ],
+ _showIcon: false
+ }
+ Adapt.trigger('notify:interaction', interactionObject);
+ // Delay showing the nav arrows until notify has faded in
+ _.delay(_.bind(function() {
+ this.updateNotifyNav(activeItem);
+ }, this), 600);
- this.isPopupOpen = true;
+ } else {
+ var popupObject = {
+ title: popupObject_title,
+ body: "" + popupObject_body + "
" +
+ "
"
+ }
+ Adapt.trigger('notify:popup', popupObject);
+ }
+
///// Audio /////
if (this.model.has('_audio') && this.model.get('_audio')._isEnabled && Adapt.audio.audioClip[this.model.get('_audio')._channel].status==1) {
@@ -158,12 +196,14 @@ define(function(require) {
///// End of Audio /////
Adapt.once("notify:closed", _.bind(function() {
- this.isPopupOpen = false;
+ //this.isPopupOpen = false;
///// Audio /////
if (this.model.has('_audio') && this.model.get('_audio')._isEnabled) {
Adapt.trigger('audio:pauseAudio', this.model.get('_audio')._channel);
}
///// End of Audio /////
+ this.$('.hotgrid-grid-item.active').removeClass('active');
+ //
}, this));
},
@@ -183,6 +223,79 @@ define(function(require) {
}
},
+ previousItem: function (event) {
+ activeItem--;
+ this.updateNotifyContent(activeItem);
+ },
+
+ nextItem: function (event) {
+ activeItem++;
+ this.updateNotifyContent(activeItem);
+ },
+
+ updateNotifyContent: function(index) {
+
+ this.$('.hotgrid-grid-item.active').removeClass('active');
+
+ var notifyItems = this.$(".hotgrid-grid-inner").children();
+ this.$(notifyItems[index]).addClass('active');
+
+ var itemModel = this.model.get('_items')[index];
+
+ if(!itemModel.visited) {
+ this.$(notifyItems[index]).addClass("visited");
+ itemModel.visited = true;
+ }
+
+ // Set popup text to default full size
+ var popupObject_title = itemModel.title;
+ var popupObject_body = itemModel.body;
+
+ // If reduced text is enabled and selected
+ if (this.model.get('_reducedText') && this.model.get('_reducedText')._isEnabled && Adapt.audio.textSize == 1) {
+ popupObject_title = itemModel.titleReduced;
+ popupObject_body = itemModel.bodyReduced;
+ }
+
+ $('.notify-popup-title-inner').html(popupObject_title);
+ $('.notify-popup-body-inner').html("" + popupObject_body + "
" +
+ "
");
+
+ ///// Audio /////
+ if (this.model.has('_audio') && this.model.get('_audio')._isEnabled && Adapt.audio.audioClip[this.model.get('_audio')._channel].status==1) {
+ // Trigger audio
+ Adapt.trigger('audio:playAudio', itemModel._audio.src, this.model.get('_id'), this.model.get('_audio')._channel);
+ }
+ ///// End of Audio /////
+
+ this.updateNotifyNav(activeItem);
+ this.evaluateCompletion();
+
+ },
+
+ updateNotifyNav: function (index) {
+ // Hide buttons
+ if(index === 0) {
+ $('#notify-arrow-back').css('visibility','hidden');
+ $('notify-popup-arrow-l').css('visibility','hidden');
+ }
+ if(index === (this.model.get('_items').length)-1) {
+ $('#notify-arrow-next').css('visibility','hidden');
+ $('notify-popup-arrow-r').css('visibility','hidden');
+ }
+ // Show buttons
+ if(index > 0) {
+ $('#notify-arrow-back').css('visibility','visible');
+ $('notify-popup-arrow-l').css('visibility','visible');
+ }
+ if(index < (this.model.get('_items').length)-1) {
+ $('#notify-arrow-next').css('visibility','visible');
+ $('notify-popup-arrow-r').css('visibility','visible');
+ }
+ },
+
// Reduced text
replaceText: function(value) {
// If enabled
diff --git a/less/hotgrid.less b/less/hotgrid.less
index 7c3240b..951bd7c 100755
--- a/less/hotgrid.less
+++ b/less/hotgrid.less
@@ -7,6 +7,9 @@
float: left;
text-align: center;
width: 50%;
+ @media all and (max-width:(@device-width-medium - 1)) {
+ width: 100%;
+ }
&.visited {
.hotgrid-item-states-image {
@@ -42,78 +45,40 @@
margin: 5px;
}
}
-}
-
-.hotgrid-notify-container {
- text-align: center;
-}
-
-.hotgrid-notify-body {
- float: left;
- padding-bottom: @notify-padding-bottom;
- text-align: left;
- width: 58%;
-
- .dir-rtl & {
- float: right;
- }
-
- @media (max-width: @device-width-medium) {
- padding-bottom: (@notify-padding-bottom / 3);
- width: 100%;
- }
-}
-
-.hotgrid-notify-graphic {
- float: right;
- margin-top: -@notify-title-padding-bottom;
- padding-bottom: @notify-padding-bottom;
- width: 40%;
-
- .dir-rtl & {
- float: left;
- }
-
- @media (max-width: @device-width-medium) {
- float: none;
- margin-top: 0;
- padding-bottom: 0;
- width: 75%;
- }
-}
-.item-states-image {
- .default {
- img.hotgrid-item-image-hover {
- display: none;
- }
+ .item-states-image {
+ .default {
+ img.hotgrid-item-image-hover {
+ display: none;
+ }
- img.hotgrid-item-image-visited {
- display: none;
- }
- }
-
- .hover {
- > img {
- display:none;
- }
- img.hotgrid-item-image-hover {
- display: block;
- }
- img.hotgrid-item-image-visited {
- display: none;
+ img.hotgrid-item-image-visited {
+ display: none;
+ }
}
- }
- .visited {
- > img {
- display: none;
+ .hover {
+ > img {
+ display:none;
+ }
+ img.hotgrid-item-image-hover {
+ display: block;
+ }
+ img.hotgrid-item-image-visited {
+ display: none;
+ }
}
- img.hotgrid-item-image-hover {
- display: none !important;
- }
- img.hotgrid-item-image-visited {
- display: block !important;
+
+ .visited {
+ > img {
+ display: none;
+ }
+ img.hotgrid-item-image-hover {
+ display: none !important;
+ }
+ img.hotgrid-item-image-visited {
+ display: block !important;
+ }
}
}
}