Skip to content

Commit

Permalink
Notify changes and Version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertPeek committed Mar 4, 2016
1 parent 92fb887 commit dd351c2
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 78 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
131 changes: 122 additions & 9 deletions js/adapt-hotgrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
Expand All @@ -140,15 +150,43 @@ define(function(require) {
popupObject_body = itemModel.bodyReduced;
}

Adapt.trigger("notify:popup", {
title: popupObject_title,
body: "<div class='hotgrid-notify-container'><div class='hotgrid-notify-body'>" + popupObject_body + "</div>" +
"<img class='hotgrid-notify-graphic' src='" +
itemModel._itemGraphic.src + "' alt='" +
itemModel._itemGraphic.alt + "'/></div>"
});
// Trigger which type of notify based on the '_canCycleThroughPagination' setting
if(this.model.get('_canCycleThroughPagination')) {
var interactionObject = {
title: popupObject_title,
body: "<div class='notify-container'><div class='notify-body'>" + popupObject_body + "</div>" +
"<img class='notify-graphic' src='" +
itemModel._itemGraphic.src + "' alt='" +
itemModel._itemGraphic.alt + "'/></div>",
_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: "<div class='notify-container'><div class='notify-body'>" + popupObject_body + "</div>" +
"<img class='notify-graphic' src='" +
itemModel._itemGraphic.src + "' alt='" +
itemModel._itemGraphic.alt + "'/></div>"
}
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) {
Expand All @@ -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));
},

Expand All @@ -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("<div class='notify-container'><div class='notify-body'>" + popupObject_body + "</div>" +
"<img class='notify-graphic' src='" +
itemModel._itemGraphic.src + "' alt='" +
itemModel._itemGraphic.alt + "'/></div>");

///// 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
Expand Down
99 changes: 32 additions & 67 deletions less/hotgrid.less
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}
}
}

0 comments on commit dd351c2

Please sign in to comment.