Skip to content
This repository has been archived by the owner on Jul 31, 2021. It is now read-only.

Commit

Permalink
Updated the ARIA Date Picker Calendar module to support onClick for t…
Browse files Browse the repository at this point in the history
…he close icon button when openOnFocus is true.
  • Loading branch information
accdc committed Feb 18, 2019
1 parent 7258be7 commit a03ff3e
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
ARIA Calendar Module R2.6
ARIA Calendar Module R2.7
Copyright 2019 Bryan Garaventa (WhatSock.com)
Refactoring Contributions Copyright 2018 Danny Allen (dannya.com) / Wonderscore Ltd (wonderscore.co.uk)
Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under the terms of the Open Source Initiative OSI - MIT License
Expand Down Expand Up @@ -507,11 +507,22 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t
},
setWeekdaysDisabled: function(dc, dateObj, isDisabled){
// 0 = Sunday, 6 = Saturday
dc.setDayOfWeekDisabled(dc, dateObj, [1, 2, 3, 4, 5], isDisabled);
dc.setDayOfWeekDisabled(dc, dateObj,
[
1,
2,
3,
4,
5
], isDisabled);
},
setWeekendsDisabled: function(dc, dateObj, isDisabled){
// 0 = Sunday, 6 = Saturday, which are the days we are not setting
dc.setDayOfWeekDisabled(dc, dateObj, [0, 6], isDisabled);
dc.setDayOfWeekDisabled(dc, dateObj,
[
0,
6
], isDisabled);
},
clearAllDisabled: function(dc){
for (var month in dc.range){
Expand Down Expand Up @@ -554,7 +565,7 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t
isOutsideDateRange: function(dateObj){
var dateCmp = this.createDateComparisonValue(dateObj);

return ((this.minDateComparisonValue && (dateCmp < this.minDateComparisonValue))
return((this.minDateComparisonValue && (dateCmp < this.minDateComparisonValue))
|| (this.maxDateComparisonValue && (dateCmp > this.maxDateComparisonValue)));
},
createDayCell: function(i, cellDateObj, cssClasses, isDisabled, isSelected){
Expand Down Expand Up @@ -726,7 +737,11 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t
if (config.ajax && typeof config.ajax === 'function' && !dc.stopAjax && !dc.ajaxLoading){
dc.ajaxLoading = dc.cancel = true;
dc.fn.navBtn = dc.navBtn;
config.ajax.apply(dc, [dc, false]);
config.ajax.apply(dc,
[
dc,
false
]);
}

if (dc.range.current.month === 1)
Expand Down Expand Up @@ -1156,7 +1171,12 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t
if ($A.hasClass(this, 'selected') || (!commentsEnabled && !$A.hasClass(this, 'comment'))){
if ($A.getAttr(this, 'aria-disabled') !== 'true'){
$A.internal.extend(true, dc.fn.current, dc.range.current);
handleClick.apply(this, [ev, dc, targ]);
handleClick.apply(this,
[
ev,
dc,
targ
]);
}

else{
Expand All @@ -1178,7 +1198,12 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t

if ($A.getAttr(this, 'aria-disabled') !== 'true'){
$A.internal.extend(true, dc.fn.current, dc.range.current);
handleClick.apply(this, [ev, dc, targ]);
handleClick.apply(this,
[
ev,
dc,
targ
]);
}

ev.preventDefault();
Expand Down Expand Up @@ -1470,7 +1495,12 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t
$A.internal.extend(true, dc.fn.current, dc.range.current);

if (!dc.setFocus.firstOpen)
handleClick.apply(this, [ev, dc, targ]);
handleClick.apply(this,
[
ev,
dc,
targ
]);
}

ev.preventDefault();
Expand All @@ -1484,6 +1514,13 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t
if (dc.showEscBtn){
$A.bind(dc.escBtn,
{
click: function(ev){
dc.close();
onFocusInit = false;
onFocusTraverse = true;
targ.focus();
ev.preventDefault();
},
keydown: function(ev){
changePressed(ev);
var k = ev.which || ev.keyCode;
Expand Down Expand Up @@ -2142,7 +2179,11 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t
$A.unbind(window, 'resize.dateeditor');

if (config.ajax && typeof config.ajax === 'function')
config.ajax.apply(dc.parent, [dc.parent, true]);
config.ajax.apply(dc.parent,
[
dc.parent,
true
]);

dc.parent.setFocus.firstOpen = true;
},
Expand Down Expand Up @@ -2254,6 +2295,12 @@ Part of AccDC, a Cross-Browser JavaScript accessibility API, distributed under t
ev.stopPropagation();
}

else if (k === 9 && onFocusInit && !onFocusTraverse && odc.loaded && ev.shiftKey){
onFocusInit = false;
onFocusTraverse = false;
odc.close();
}

else if (k === 9 && onFocusInit && !onFocusTraverse && odc.loaded && !ev.shiftKey){
onFocusInit = false;
onFocusTraverse = true;
Expand Down
Loading

0 comments on commit a03ff3e

Please sign in to comment.