|
51 | 51 | ticksValuesTooltip: null,
|
52 | 52 | vertical: false,
|
53 | 53 | selectionBarColor: null,
|
| 54 | + keyboardSupport: true, |
54 | 55 | scale: 1,
|
55 | 56 | onStart: null,
|
56 | 57 | onChange: null,
|
|
310 | 311 | self.updateLowHandle(self.valueToOffset(self.scope.rzSliderModel));
|
311 | 312 | self.updateSelectionBar();
|
312 | 313 | self.updateTicksScale();
|
| 314 | + self.updateAriaAttributes(); |
313 | 315 |
|
314 | 316 | if (self.range) {
|
315 | 317 | self.updateCmbLabel();
|
|
323 | 325 | self.updateSelectionBar();
|
324 | 326 | self.updateTicksScale();
|
325 | 327 | self.updateCmbLabel();
|
| 328 | + self.updateAriaAttributes(); |
326 | 329 | }, self.options.interval);
|
327 | 330 |
|
328 | 331 | this.scope.$on('rzSliderForceRender', function() {
|
|
614 | 617 | },
|
615 | 618 |
|
616 | 619 | /**
|
617 |
| - * Adds accessibility atributes |
| 620 | + * Adds accessibility attributes |
618 | 621 | *
|
619 | 622 | * Run only once during initialization
|
620 | 623 | *
|
621 | 624 | * @returns {undefined}
|
622 | 625 | */
|
623 | 626 | addAccessibility: function() {
|
624 |
| - this.sliderElem.attr("role", "slider"); |
| 627 | + this.minH.attr('role', 'slider'); |
| 628 | + this.updateAriaAttributes(); |
| 629 | + if (this.options.keyboardSupport) |
| 630 | + this.minH.attr('tabindex', '0'); |
| 631 | + if (this.options.vertical) |
| 632 | + this.minH.attr('aria-orientation', 'vertical'); |
| 633 | + |
| 634 | + if (this.range) { |
| 635 | + this.maxH.attr('role', 'slider'); |
| 636 | + if (this.options.keyboardSupport) |
| 637 | + this.maxH.attr('tabindex', '0'); |
| 638 | + if (this.options.vertical) |
| 639 | + this.maxH.attr('aria-orientation', 'vertical'); |
| 640 | + } |
| 641 | + }, |
| 642 | + |
| 643 | + /** |
| 644 | + * Updates aria attributes according to current values |
| 645 | + */ |
| 646 | + updateAriaAttributes: function() { |
| 647 | + this.minH.attr('aria-valuenow', this.scope.rzSliderModel); |
| 648 | + this.minH.attr('aria-valuetext', this.customTrFn(this.scope.rzSliderModel)); |
| 649 | + this.minH.attr('aria-valuemin', this.minValue); |
| 650 | + this.minH.attr('aria-valuemax', this.maxValue); |
| 651 | + if (this.range) { |
| 652 | + this.maxH.attr('aria-valuenow', this.scope.rzSliderHigh); |
| 653 | + this.maxH.attr('aria-valuetext', this.customTrFn(this.scope.rzSliderHigh)); |
| 654 | + this.maxH.attr('aria-valuemin', this.minValue); |
| 655 | + this.maxH.attr('aria-valuemax', this.maxValue); |
| 656 | + } |
625 | 657 | },
|
626 | 658 |
|
627 | 659 | /**
|
|
1126 | 1158 | this.ticks.on('touchstart', angular.bind(this, this.onStart, null, null));
|
1127 | 1159 | this.ticks.on('touchstart', angular.bind(this, this.onMove, this.ticks));
|
1128 | 1160 |
|
1129 |
| - this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'rzSliderModel')) |
1130 |
| - if (this.range) { |
1131 |
| - this.maxH.on('focus', angular.bind(this, this.onPointerFocus, this.maxH, 'rzSliderHigh')); |
| 1161 | + if (this.options.keyboardSupport) { |
| 1162 | + this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'rzSliderModel')) |
| 1163 | + if (this.range) { |
| 1164 | + this.maxH.on('focus', angular.bind(this, this.onPointerFocus, this.maxH, 'rzSliderHigh')); |
| 1165 | + } |
1132 | 1166 | }
|
1133 | 1167 | },
|
1134 | 1168 |
|
|
1172 | 1206 | }
|
1173 | 1207 |
|
1174 | 1208 | pointer.addClass('rz-active');
|
1175 |
| - pointer[0].focus(); |
| 1209 | + |
| 1210 | + if (this.options.keyboardSupport) |
| 1211 | + pointer[0].focus(); |
1176 | 1212 |
|
1177 | 1213 | ehMove = angular.bind(this, this.dragging.active ? this.onDragMove : this.onMove, pointer);
|
1178 | 1214 | ehEnd = angular.bind(this, this.onEnd, ehMove);
|
|
1221 | 1257 | onEnd: function(ehMove, event) {
|
1222 | 1258 | var moveEventName = this.getEventNames(event).moveEvent;
|
1223 | 1259 |
|
1224 |
| - //this.minH.removeClass('rz-active'); |
1225 |
| - //this.maxH.removeClass('rz-active'); |
| 1260 | + if (!this.options.keyboardSupport) { |
| 1261 | + this.minH.removeClass('rz-active'); |
| 1262 | + this.maxH.removeClass('rz-active'); |
| 1263 | + this.tracking = ''; |
| 1264 | + } |
| 1265 | + this.dragging.active = false; |
1226 | 1266 |
|
1227 | 1267 | $document.off(moveEventName, ehMove);
|
1228 |
| - |
1229 | 1268 | this.scope.$emit('slideEnded');
|
1230 |
| - //this.tracking = ''; |
1231 |
| - |
1232 |
| - this.dragging.active = false; |
1233 | 1269 | this.callOnEnd();
|
1234 | 1270 | },
|
1235 | 1271 |
|
1236 | 1272 | onPointerFocus: function(pointer, ref, event) {
|
1237 |
| - //if (this.tracking === ref) return; |
1238 | 1273 | this.tracking = ref;
|
1239 |
| - console.info('focused', ref); |
1240 | 1274 | pointer.one('blur', angular.bind(this, this.onPointerBlur, pointer));
|
1241 | 1275 | pointer.on('keydown', angular.bind(this, this.onKeyboardEvent));
|
1242 | 1276 | pointer.addClass('rz-active');
|
1243 | 1277 | },
|
1244 | 1278 |
|
1245 | 1279 | onPointerBlur: function(pointer, event) {
|
1246 |
| - console.info('blured', this.tracking); |
1247 | 1280 | pointer.off('keydown');
|
1248 | 1281 | this.tracking = '';
|
1249 | 1282 | pointer.removeClass('rz-active');
|
|
1386 | 1419 | switched = true;
|
1387 | 1420 | this.scope[this.tracking] = this.scope.rzSliderHigh;
|
1388 | 1421 | this.updateHandles(this.tracking, this.maxH.rzsp);
|
| 1422 | + this.updateAriaAttributes(); |
1389 | 1423 | this.tracking = 'rzSliderHigh';
|
1390 | 1424 | this.minH.removeClass('rz-active');
|
1391 | 1425 | this.maxH.addClass('rz-active');
|
|
1394 | 1428 | switched = true;
|
1395 | 1429 | this.scope[this.tracking] = this.scope.rzSliderModel;
|
1396 | 1430 | this.updateHandles(this.tracking, this.minH.rzsp);
|
| 1431 | + this.updateAriaAttributes(); |
1397 | 1432 | this.tracking = 'rzSliderModel';
|
1398 | 1433 | this.maxH.removeClass('rz-active');
|
1399 | 1434 | this.minH.addClass('rz-active');
|
|
1404 | 1439 | if (this.scope[this.tracking] !== newValue) {
|
1405 | 1440 | this.scope[this.tracking] = newValue;
|
1406 | 1441 | this.updateHandles(this.tracking, newOffset);
|
| 1442 | + this.updateAriaAttributes(); |
1407 | 1443 | valueChanged = true;
|
1408 | 1444 | }
|
1409 | 1445 |
|
|
0 commit comments