Skip to content

Commit

Permalink
Fixes #47
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertPeek committed Feb 17, 2022
1 parent cfc92e9 commit 5ce1b7c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions js/hotgridPopupView.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@ define([
var itemCount = this.model.get('_items').length;
var canCycleThroughPagination = this.model.get('_canCycleThroughPagination');

var shouldEnableBack = index > 0 && canCycleThroughPagination;
var shouldEnableNext = index < itemCount - 1 && canCycleThroughPagination;
var shouldEnableBack = (canCycleThroughPagination && index > 0) || false;
var shouldEnableNext = (canCycleThroughPagination && index < itemCount - 1) || false;
var $controls = this.$('.hotgrid-popup-controls');

this.$('hotgrid-popup-nav').filter('.back').toggleClass('is-disabled', shouldEnableBack);
this.$('hotgrid-popup-nav').filter('.next').toggleClass('is-disabled', shouldEnableNext);
this.$('hotgrid-popup-controls')
.toggleClass('.back', !shouldEnableBack)
.toggleClass('.next', !shouldEnableNext);

$controls.filter('.back').a11y_cntrl_enabled(shouldEnableBack);
$controls.filter('.next').a11y_cntrl_enabled(shouldEnableNext);
Adapt.a11y.toggleAccessibleEnabled($controls.filter('.back'), shouldEnableBack);
Adapt.a11y.toggleAccessibleEnabled($controls.filter('.next'), shouldEnableNext);
},

handleTabs: function() {
this.$('.hotgrid-item:not(.is-active) *').a11y_on(false);
this.$('.hotgrid-item.is-active *').a11y_on(true);
Adapt.a11y.toggleHidden(this.$('.hotgrid-item:not(.is-active)'), true);
Adapt.a11y.toggleHidden(this.$('.hotgrid-item.is-active'), false);
},

onItemsActiveChange: function(item, _isActive) {
Expand All @@ -65,8 +66,8 @@ define([
},

handleFocus: function(index) {
this.$('.hotgrid-popup-inner .is-active').a11y_focus();
this.applyNavigationClasses(index);
Adapt.a11y.focusFirst(this.$('.hotgrid-popup-inner .is-active'));
this.applyNavigationClasses(index);
},

onItemsVisitedChange: function(item, _isVisited) {
Expand Down

0 comments on commit 5ce1b7c

Please sign in to comment.