Commit 68e9c69e authored by Valentin Hervieu's avatar Valentin Hervieu

test(keyboardSupport): Complete full test coverage for keyboard controls

parent efcacbe9
...@@ -418,6 +418,7 @@ ...@@ -418,6 +418,7 @@
*/ */
resetSlider: function() { resetSlider: function() {
this.manageElementsStyle(); this.manageElementsStyle();
this.addAccessibility();
this.setMinAndMax(); this.setMinAndMax();
this.updateCeilLab(); this.updateCeilLab();
this.updateFloorLab(); this.updateFloorLab();
...@@ -645,15 +646,19 @@ ...@@ -645,15 +646,19 @@
addAccessibility: function() { addAccessibility: function() {
this.minH.attr('role', 'slider'); this.minH.attr('role', 'slider');
this.updateAriaAttributes(); this.updateAriaAttributes();
if (this.options.keyboardSupport) if (this.options.keyboardSupport && !(this.options.readOnly || this.options.disabled))
this.minH.attr('tabindex', '0'); this.minH.attr('tabindex', '0');
else
this.minH.attr('tabindex', '');
if (this.options.vertical) if (this.options.vertical)
this.minH.attr('aria-orientation', 'vertical'); this.minH.attr('aria-orientation', 'vertical');
if (this.range) { if (this.range) {
this.maxH.attr('role', 'slider'); this.maxH.attr('role', 'slider');
if (this.options.keyboardSupport) if (this.options.keyboardSupport && !(this.options.readOnly || this.options.disabled))
this.maxH.attr('tabindex', '0'); this.maxH.attr('tabindex', '0');
else
this.maxH.attr('tabindex', '');
if (this.options.vertical) if (this.options.vertical)
this.maxH.attr('aria-orientation', 'vertical'); this.maxH.attr('aria-orientation', 'vertical');
} }
...@@ -1370,13 +1375,21 @@ ...@@ -1370,13 +1375,21 @@
newMinValue = newValue; newMinValue = newValue;
newMinOffset = newOffset; newMinOffset = newOffset;
newMaxValue = newValue + difference; newMaxValue = newValue + difference;
if (newMaxValue > this.maxValue) return; if (newMaxValue > this.maxValue) {
newMaxValue = this.maxValue;
newMinValue = newMaxValue - difference;
newMinOffset = this.valueToOffset(newMinValue);
}
newMaxOffset = this.valueToOffset(newMaxValue); newMaxOffset = this.valueToOffset(newMaxValue);
} else { } else {
newMaxValue = newValue; newMaxValue = newValue;
newMaxOffset = newOffset; newMaxOffset = newOffset;
newMinValue = newValue - difference; newMinValue = newValue - difference;
if (newMinValue < this.minValue) return; if (newMinValue < this.minValue) {
newMinValue = this.minValue;
newMaxValue = newMinValue + difference;
newMaxOffset = this.valueToOffset(newMaxValue);
}
newMinOffset = this.valueToOffset(newMinValue); newMinOffset = this.valueToOffset(newMinValue);
} }
this.positionTrackingBar(newMinValue, newMaxValue, newMinOffset, newMaxOffset); this.positionTrackingBar(newMinValue, newMaxValue, newMinOffset, newMaxOffset);
......
This diff is collapsed.
...@@ -422,6 +422,7 @@ ...@@ -422,6 +422,7 @@
*/ */
resetSlider: function() { resetSlider: function() {
this.manageElementsStyle(); this.manageElementsStyle();
this.addAccessibility();
this.setMinAndMax(); this.setMinAndMax();
this.updateCeilLab(); this.updateCeilLab();
this.updateFloorLab(); this.updateFloorLab();
...@@ -532,7 +533,7 @@ ...@@ -532,7 +533,7 @@
manageEventsBindings: function() { manageEventsBindings: function() {
if (this.options.disabled || this.options.readOnly) if (this.options.disabled || this.options.readOnly)
this.unbindEvents(); this.unbindEvents();
else if (!this.options.disabled || !this.options.readOnly) else
this.bindEvents(); this.bindEvents();
}, },
...@@ -649,15 +650,19 @@ ...@@ -649,15 +650,19 @@
addAccessibility: function() { addAccessibility: function() {
this.minH.attr('role', 'slider'); this.minH.attr('role', 'slider');
this.updateAriaAttributes(); this.updateAriaAttributes();
if (this.options.keyboardSupport) if (this.options.keyboardSupport && !(this.options.readOnly || this.options.disabled))
this.minH.attr('tabindex', '0'); this.minH.attr('tabindex', '0');
else
this.minH.attr('tabindex', '');
if (this.options.vertical) if (this.options.vertical)
this.minH.attr('aria-orientation', 'vertical'); this.minH.attr('aria-orientation', 'vertical');
if (this.range) { if (this.range) {
this.maxH.attr('role', 'slider'); this.maxH.attr('role', 'slider');
if (this.options.keyboardSupport) if (this.options.keyboardSupport && !(this.options.readOnly || this.options.disabled))
this.maxH.attr('tabindex', '0'); this.maxH.attr('tabindex', '0');
else
this.maxH.attr('tabindex', '');
if (this.options.vertical) if (this.options.vertical)
this.maxH.attr('aria-orientation', 'vertical'); this.maxH.attr('aria-orientation', 'vertical');
} }
...@@ -1374,13 +1379,21 @@ ...@@ -1374,13 +1379,21 @@
newMinValue = newValue; newMinValue = newValue;
newMinOffset = newOffset; newMinOffset = newOffset;
newMaxValue = newValue + difference; newMaxValue = newValue + difference;
if (newMaxValue > this.maxValue) return; if (newMaxValue > this.maxValue) {
newMaxValue = this.maxValue;
newMinValue = newMaxValue - difference;
newMinOffset = this.valueToOffset(newMinValue);
}
newMaxOffset = this.valueToOffset(newMaxValue); newMaxOffset = this.valueToOffset(newMaxValue);
} else { } else {
newMaxValue = newValue; newMaxValue = newValue;
newMaxOffset = newOffset; newMaxOffset = newOffset;
newMinValue = newValue - difference; newMinValue = newValue - difference;
if (newMinValue < this.minValue) return; if (newMinValue < this.minValue) {
newMinValue = this.minValue;
newMaxValue = newMinValue + difference;
newMaxOffset = this.valueToOffset(newMaxValue);
}
newMinOffset = this.valueToOffset(newMinValue); newMinOffset = this.valueToOffset(newMinValue);
} }
this.positionTrackingBar(newMinValue, newMaxValue, newMinOffset, newMaxOffset); this.positionTrackingBar(newMinValue, newMaxValue, newMinOffset, newMaxOffset);
......
This diff is collapsed.
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