|
309 | 309 | self.updateLowHandle(self.valueToOffset(self.scope.rzSliderModel));
|
310 | 310 | self.updateSelectionBar();
|
311 | 311 | self.updateTicksScale();
|
| 312 | + self.updateAriaAttributes(); |
312 | 313 |
|
313 | 314 | if (self.range) {
|
314 | 315 | self.updateCmbLabel();
|
|
322 | 323 | self.updateSelectionBar();
|
323 | 324 | self.updateTicksScale();
|
324 | 325 | self.updateCmbLabel();
|
| 326 | + self.updateAriaAttributes(); |
325 | 327 | }, self.options.interval);
|
326 | 328 |
|
327 | 329 | this.scope.$on('rzSliderForceRender', function() {
|
|
614 | 616 | },
|
615 | 617 |
|
616 | 618 | /**
|
617 |
| - * Adds accessibility atributes |
| 619 | + * Adds accessibility attributes |
618 | 620 | *
|
619 | 621 | * Run only once during initialization
|
620 | 622 | *
|
621 | 623 | * @returns {undefined}
|
622 | 624 | */
|
623 | 625 | addAccessibility: function() {
|
624 |
| - this.sliderElem.attr("role", "slider"); |
| 626 | + this.minH.attr('role', 'slider'); |
| 627 | + this.updateAriaAttributes(); |
| 628 | + if (this.options.keyboardSupport) |
| 629 | + this.minH.attr('tabindex', '0'); |
| 630 | + if (this.options.vertical) |
| 631 | + this.minH.attr('aria-orientation', 'vertical'); |
| 632 | + |
| 633 | + if (this.range) { |
| 634 | + this.maxH.attr('role', 'slider'); |
| 635 | + if (this.options.keyboardSupport) |
| 636 | + this.maxH.attr('tabindex', '0'); |
| 637 | + if (this.options.vertical) |
| 638 | + this.maxH.attr('aria-orientation', 'vertical'); |
| 639 | + } |
| 640 | + }, |
| 641 | + |
| 642 | + /** |
| 643 | + * Updates aria attributes according to current values |
| 644 | + */ |
| 645 | + updateAriaAttributes: function() { |
| 646 | + this.minH.attr('aria-valuenow', this.scope.rzSliderModel); |
| 647 | + this.minH.attr('aria-valuetext', this.customTrFn(this.scope.rzSliderModel)); |
| 648 | + this.minH.attr('aria-valuemin', this.minValue); |
| 649 | + this.minH.attr('aria-valuemax', this.maxValue); |
| 650 | + if (this.range) { |
| 651 | + this.maxH.attr('aria-valuenow', this.scope.rzSliderHigh); |
| 652 | + this.maxH.attr('aria-valuetext', this.customTrFn(this.scope.rzSliderHigh)); |
| 653 | + this.maxH.attr('aria-valuemin', this.minValue); |
| 654 | + this.maxH.attr('aria-valuemax', this.maxValue); |
| 655 | + } |
625 | 656 | },
|
626 | 657 |
|
627 | 658 | /**
|
|
1111 | 1142 | this.ticks.on('touchstart', angular.bind(this, this.onStart, null, null));
|
1112 | 1143 | this.ticks.on('touchstart', angular.bind(this, this.onMove, this.ticks));
|
1113 | 1144 |
|
1114 |
| - this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'rzSliderModel')) |
1115 |
| - if (this.range) { |
1116 |
| - this.maxH.on('focus', angular.bind(this, this.onPointerFocus, this.maxH, 'rzSliderHigh')); |
| 1145 | + if (this.options.keyboardSupport) { |
| 1146 | + this.minH.on('focus', angular.bind(this, this.onPointerFocus, this.minH, 'rzSliderModel')) |
| 1147 | + if (this.range) { |
| 1148 | + this.maxH.on('focus', angular.bind(this, this.onPointerFocus, this.maxH, 'rzSliderHigh')); |
| 1149 | + } |
1117 | 1150 | }
|
1118 | 1151 | },
|
1119 | 1152 |
|
|
1157 | 1190 | }
|
1158 | 1191 |
|
1159 | 1192 | pointer.addClass('rz-active');
|
1160 |
| - pointer[0].focus(); |
| 1193 | + |
| 1194 | + if (this.options.keyboardSupport) |
| 1195 | + pointer[0].focus(); |
1161 | 1196 |
|
1162 | 1197 | ehMove = angular.bind(this, this.dragging.active ? this.onDragMove : this.onMove, pointer);
|
1163 | 1198 | ehEnd = angular.bind(this, this.onEnd, ehMove);
|
|
1206 | 1241 | onEnd: function(ehMove, event) {
|
1207 | 1242 | var moveEventName = this.getEventNames(event).moveEvent;
|
1208 | 1243 |
|
1209 |
| - //this.minH.removeClass('rz-active'); |
1210 |
| - //this.maxH.removeClass('rz-active'); |
| 1244 | + if (!this.options.keyboardSupport) { |
| 1245 | + this.minH.removeClass('rz-active'); |
| 1246 | + this.maxH.removeClass('rz-active'); |
| 1247 | + this.tracking = ''; |
| 1248 | + } |
| 1249 | + this.dragging.active = false; |
1211 | 1250 |
|
1212 | 1251 | $document.off(moveEventName, ehMove);
|
1213 |
| - |
1214 | 1252 | this.scope.$emit('slideEnded');
|
1215 |
| - //this.tracking = ''; |
1216 |
| - |
1217 |
| - this.dragging.active = false; |
1218 | 1253 | this.callOnEnd();
|
1219 | 1254 | },
|
1220 | 1255 |
|
1221 | 1256 | onPointerFocus: function(pointer, ref, event) {
|
1222 |
| - //if (this.tracking === ref) return; |
1223 | 1257 | this.tracking = ref;
|
1224 |
| - console.info('focused', ref); |
1225 | 1258 | pointer.one('blur', angular.bind(this, this.onPointerBlur, pointer));
|
1226 | 1259 | pointer.on('keydown', angular.bind(this, this.onKeyboardEvent));
|
1227 | 1260 | pointer.addClass('rz-active');
|
1228 | 1261 | },
|
1229 | 1262 |
|
1230 | 1263 | onPointerBlur: function(pointer, event) {
|
1231 |
| - console.info('blured', this.tracking); |
1232 | 1264 | pointer.off('keydown');
|
1233 | 1265 | this.tracking = '';
|
1234 | 1266 | pointer.removeClass('rz-active');
|
|
1370 | 1402 | switched = true;
|
1371 | 1403 | this.scope[this.tracking] = this.scope.rzSliderHigh;
|
1372 | 1404 | this.updateHandles(this.tracking, this.maxH.rzsp);
|
| 1405 | + this.updateAriaAttributes(); |
1373 | 1406 | this.tracking = 'rzSliderHigh';
|
1374 | 1407 | this.minH.removeClass('rz-active');
|
1375 | 1408 | this.maxH.addClass('rz-active');
|
|
1380 | 1413 | switched = true;
|
1381 | 1414 | this.scope[this.tracking] = this.scope.rzSliderModel;
|
1382 | 1415 | this.updateHandles(this.tracking, this.minH.rzsp);
|
| 1416 | + this.updateAriaAttributes(); |
1383 | 1417 | this.tracking = 'rzSliderModel';
|
1384 | 1418 | this.maxH.removeClass('rz-active');
|
1385 | 1419 | this.minH.addClass('rz-active');
|
|
1392 | 1426 | if (this.scope[this.tracking] !== newValue) {
|
1393 | 1427 | this.scope[this.tracking] = newValue;
|
1394 | 1428 | this.updateHandles(this.tracking, newOffset);
|
| 1429 | + this.updateAriaAttributes(); |
1395 | 1430 | this.scope.$apply();
|
1396 | 1431 | this.callOnChange();
|
1397 | 1432 | }
|
|
1493 | 1528 | 'use strict';
|
1494 | 1529 |
|
1495 | 1530 | $templateCache.put('rzSliderTpl.html',
|
1496 |
| - "<span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class=\"rz-bar rz-selection\"></span></span> <span class=rz-pointer tabindex=0></span> <span class=rz-pointer tabindex=0></span> <span class=\"rz-bubble rz-limit\"></span> <span class=\"rz-bubble rz-limit\"></span> <span class=rz-bubble></span> <span class=rz-bubble></span> <span class=rz-bubble></span><ul class=rz-ticks></ul>" |
| 1531 | + "<span class=rz-bar-wrapper><span class=rz-bar></span></span> <span class=rz-bar-wrapper><span class=\"rz-bar rz-selection\"></span></span> <span class=rz-pointer></span> <span class=rz-pointer></span> <span class=\"rz-bubble rz-limit\"></span> <span class=\"rz-bubble rz-limit\"></span> <span class=rz-bubble></span> <span class=rz-bubble></span> <span class=rz-bubble></span><ul class=rz-ticks></ul>" |
1497 | 1532 | );
|
1498 | 1533 |
|
1499 | 1534 | }]);
|
|
0 commit comments