UNPKG

md2

Version:

Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Chips(Tags), Collapse, Colorpicker, Data Table, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.

79 lines 4.2 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; import { Injectable, InjectionToken, Optional, Inject, SkipSelf, } from '@angular/core'; import { Platform } from '../platform/platform'; export var LIVE_ANNOUNCER_ELEMENT_TOKEN = new InjectionToken('liveAnnouncerElement'); var LiveAnnouncer = (function () { function LiveAnnouncer(elementToken, platform) { // Only do anything if we're on the browser platform. if (platform.isBrowser) { // We inject the live element as `any` because the constructor signature cannot reference // browser globals (HTMLElement) on non-browser environments, since having a class decorator // causes TypeScript to preserve the constructor signature types. this._liveElement = elementToken || this._createLiveElement(); } } /** * Announces a message to screenreaders. * @param message Message to be announced to the screenreader * @param politeness The politeness of the announcer element */ LiveAnnouncer.prototype.announce = function (message, politeness) { var _this = this; if (politeness === void 0) { politeness = 'polite'; } this._liveElement.textContent = ''; // TODO: ensure changing the politeness works on all environments we support. this._liveElement.setAttribute('aria-live', politeness); // This 100ms timeout is necessary for some browser + screen-reader combinations: // - Both JAWS and NVDA over IE11 will not announce anything without a non-zero timeout. // - With Chrome and IE11 with NVDA or JAWS, a repeated (identical) message won't be read a // second time without clearing and then using a non-zero delay. // (using JAWS 17 at time of this writing). setTimeout(function () { return _this._liveElement.textContent = message; }, 100); }; /** Removes the aria-live element from the DOM. */ LiveAnnouncer.prototype._removeLiveElement = function () { if (this._liveElement && this._liveElement.parentNode) { this._liveElement.parentNode.removeChild(this._liveElement); } }; LiveAnnouncer.prototype._createLiveElement = function () { var liveEl = document.createElement('div'); liveEl.classList.add('cdk-visually-hidden'); liveEl.setAttribute('aria-atomic', 'true'); liveEl.setAttribute('aria-live', 'polite'); document.body.appendChild(liveEl); return liveEl; }; return LiveAnnouncer; }()); LiveAnnouncer = __decorate([ Injectable(), __param(0, Optional()), __param(0, Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN)), __metadata("design:paramtypes", [Object, Platform]) ], LiveAnnouncer); export { LiveAnnouncer }; export function LIVE_ANNOUNCER_PROVIDER_FACTORY(parentDispatcher, liveElement, platform) { return parentDispatcher || new LiveAnnouncer(liveElement, platform); } export var LIVE_ANNOUNCER_PROVIDER = { // If there is already a LiveAnnouncer available, use that. Otherwise, provide a new one. provide: LiveAnnouncer, deps: [ [new Optional(), new SkipSelf(), LiveAnnouncer], [new Optional(), new Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN)], Platform, ], useFactory: LIVE_ANNOUNCER_PROVIDER_FACTORY }; //# sourceMappingURL=live-announcer.js.map