Commit 232df30b by Dave St.Germain

support aria-grabbed and aria-dropeffect

parent f4391b5e
<div id="inputtype_${id}" class="capa_inputtype" role="application"> <div id="inputtype_${id}" class="capa_inputtype">
<div class="drag_and_drop_problem_div" id="drag_and_drop_div_${id}" <div class="drag_and_drop_problem_div" id="drag_and_drop_div_${id}"
data-plain-id="${id}"> data-plain-id="${id}">
</div> </div>
......
...@@ -17,7 +17,7 @@ define([], function () { ...@@ -17,7 +17,7 @@ define([], function () {
'></div>' '></div>'
); );
state.baseImageEl = $('<img alt="drop target" />'); state.baseImageEl = $('<img alt="drop target image" />');
state.baseImageEl.attr('src', state.config.baseImage); state.baseImageEl.attr('src', state.config.baseImage);
state.baseImageEl.load(function () { state.baseImageEl.load(function () {
......
...@@ -28,7 +28,6 @@ return { ...@@ -28,7 +28,6 @@ return {
if (this.numDraggablesOnMe > 0) { if (this.numDraggablesOnMe > 0) {
return; return;
} }
this.containerEl.attr('aria-grabbed', 'true');
// If this draggable is just being dragged out of the // If this draggable is just being dragged out of the
// container, we must perform some additional tasks. // container, we must perform some additional tasks.
...@@ -84,6 +83,9 @@ return { ...@@ -84,6 +83,9 @@ return {
if (this.isOriginal === true) { if (this.isOriginal === true) {
this.state.numDraggablesInSlider -= 1; this.state.numDraggablesInSlider -= 1;
} }
SR.readText(gettext('dragging out of slider'));
} else {
SR.readText(gettext('dragging'));
} }
this.zIndex = 1000; this.zIndex = 1000;
...@@ -91,7 +93,8 @@ return { ...@@ -91,7 +93,8 @@ return {
if (this.labelEl !== null) { if (this.labelEl !== null) {
this.labelEl.css('z-index', '1000'); this.labelEl.css('z-index', '1000');
} }
this.iconEl.attr('aria-grabbed', 'true').focus();
this.toggleTargets(true);
this.mousePressed = true; this.mousePressed = true;
this.state.currentMovingDraggable = this; this.state.currentMovingDraggable = this;
} }
...@@ -100,9 +103,15 @@ return { ...@@ -100,9 +103,15 @@ return {
'mouseUp': function () { 'mouseUp': function () {
if (this.mousePressed === true) { if (this.mousePressed === true) {
this.state.currentMovingDraggable = null; this.state.currentMovingDraggable = null;
this.containerEl.attr('aria-grabbed', 'false'); this.iconEl.attr('aria-grabbed', 'false');
this.checkLandingElement(); this.checkLandingElement();
if (this.inContainer === true) {
SR.readText(gettext('dropped in slider'));
} else {
SR.readText(gettext('dropped on target'));
}
this.toggleTargets(false);
} }
}, },
......
...@@ -236,6 +236,17 @@ return { ...@@ -236,6 +236,17 @@ return {
return false; return false;
}, },
'toggleTargets': function (onoff) {
var c1, target, effect;
effect = (onoff ? 'move' : undefined);
this.state.baseImageEl.attr('aria-dropeffect', effect);
for (c1 = 0; c1 < this.state.targets.length; c1 += 1) {
target = this.state.targets[c1];
target.targetEl.attr('aria-dropeffect', effect);
}
},
'snapToTarget': function (target) { 'snapToTarget': function (target) {
var offset; var offset;
......
...@@ -153,8 +153,6 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab ...@@ -153,8 +153,6 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab
'mouseDown': draggableEvents.mouseDown, 'mouseDown': draggableEvents.mouseDown,
'mouseUp': draggableEvents.mouseUp, 'mouseUp': draggableEvents.mouseUp,
'mouseMove': draggableEvents.mouseMove, 'mouseMove': draggableEvents.mouseMove,
'keydown': draggableEvents.keyDown,
'keyup': draggableEvents.keyDown,
'checkLandingElement': draggableLogic.checkLandingElement, 'checkLandingElement': draggableLogic.checkLandingElement,
'checkIfOnTarget': draggableLogic.checkIfOnTarget, 'checkIfOnTarget': draggableLogic.checkIfOnTarget,
...@@ -162,6 +160,7 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab ...@@ -162,6 +160,7 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab
'correctZIndexes': draggableLogic.correctZIndexes, 'correctZIndexes': draggableLogic.correctZIndexes,
'moveBackToSlider': draggableLogic.moveBackToSlider, 'moveBackToSlider': draggableLogic.moveBackToSlider,
'moveDraggableTo': draggableLogic.moveDraggableTo, 'moveDraggableTo': draggableLogic.moveDraggableTo,
'toggleTargets': draggableLogic.toggleTargets,
'makeDraggableCopy': makeDraggableCopy, 'makeDraggableCopy': makeDraggableCopy,
...@@ -183,9 +182,9 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab ...@@ -183,9 +182,9 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab
'border-right: 1px solid #CCC; ' + 'border-right: 1px solid #CCC; ' +
'text-align: center; ' + 'text-align: center; ' +
'position: relative; ' + 'position: relative; ' +
'cursor: pointer; ' + 'cursor: move; ' +
'" ' + '" ' +
'tabindex="0" aria-grabbed="false" role="listitem"></div>' 'role="listitem"></div>'
); );
draggableObj.containerEl.appendTo(state.sliderEl); draggableObj.containerEl.appendTo(state.sliderEl);
...@@ -240,6 +239,7 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab ...@@ -240,6 +239,7 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab
'position: absolute; ' + 'position: absolute; ' +
'color: black; ' + 'color: black; ' +
'font-size: 0.95em; ' + 'font-size: 0.95em; ' +
'cursor: move; ' +
'" ' + '" ' +
'>' + '>' +
obj.label + obj.label +
...@@ -279,7 +279,9 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab ...@@ -279,7 +279,9 @@ define(['js/capa/drag_and_drop/draggable_events', 'js/capa/drag_and_drop/draggab
'position: absolute; ' + 'position: absolute; ' +
'color: black; ' + 'color: black; ' +
'font-size: 0.95em; ' + 'font-size: 0.95em; ' +
'cursor: move; ' +
'" ' + '" ' +
'tabindex="0" aria-grabbed="false" role="listitem"' +
'>' + '>' +
obj.label + obj.label +
'</div>' '</div>'
......
...@@ -86,9 +86,8 @@ define([], function () { ...@@ -86,9 +86,8 @@ define([], function () {
'left: ' + obj.x + 'px; ' + 'left: ' + obj.x + 'px; ' +
borderCss + borderCss +
'" ' + '" ' +
'></div>' 'aria-dropeffect=""></div>'
); );
if (fromTargetField === true) { if (fromTargetField === true) {
targetEl.appendTo(draggableObj.iconEl); targetEl.appendTo(draggableObj.iconEl);
} else { } else {
...@@ -115,9 +114,8 @@ define([], function () { ...@@ -115,9 +114,8 @@ define([], function () {
'background-color: white; ' + 'background-color: white; ' +
'font-size: 0.95em; ' + 'font-size: 0.95em; ' +
'color: #009fe2; ' + 'color: #009fe2; ' +
'cursor: pointer; ' +
'" ' + '" ' +
'aria-dropeffect="move">0</div>' '>0</div>'
); );
} else { } else {
numTextEl = null; numTextEl = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment