| OLD | NEW |
| (Empty) |
| 1 | |
| 2 | |
| 3 (function() { | |
| 4 'use strict'; | |
| 5 | |
| 6 Polymer.IronA11yAnnouncer = Polymer({ | |
| 7 is: 'iron-a11y-announcer', | |
| 8 | |
| 9 properties: { | |
| 10 | |
| 11 /** | |
| 12 * The value of mode is used to set the `aria-live` attribute | |
| 13 * for the element that will be announced. Valid values are: `off`, | |
| 14 * `polite` and `assertive`. | |
| 15 */ | |
| 16 mode: { | |
| 17 type: String, | |
| 18 value: 'polite' | |
| 19 }, | |
| 20 | |
| 21 _text: { | |
| 22 type: String, | |
| 23 value: '' | |
| 24 } | |
| 25 }, | |
| 26 | |
| 27 created: function() { | |
| 28 if (!Polymer.IronA11yAnnouncer.instance) { | |
| 29 Polymer.IronA11yAnnouncer.instance = this; | |
| 30 } | |
| 31 | |
| 32 document.body.addEventListener('iron-announce', this._onIronAnnounce.b
ind(this)); | |
| 33 }, | |
| 34 | |
| 35 /** | |
| 36 * Cause a text string to be announced by screen readers. | |
| 37 * | |
| 38 * @param {string} text The text that should be announced. | |
| 39 */ | |
| 40 announce: function(text) { | |
| 41 this._text = ''; | |
| 42 this.async(function() { | |
| 43 this._text = text; | |
| 44 }, 100); | |
| 45 }, | |
| 46 | |
| 47 _onIronAnnounce: function(event) { | |
| 48 if (event.detail && event.detail.text) { | |
| 49 this.announce(event.detail.text); | |
| 50 } | |
| 51 } | |
| 52 }); | |
| 53 | |
| 54 Polymer.IronA11yAnnouncer.instance = null; | |
| 55 | |
| 56 Polymer.IronA11yAnnouncer.requestAvailability = function() { | |
| 57 if (!Polymer.IronA11yAnnouncer.instance) { | |
| 58 document.createElement('iron-a11y-announcer'); | |
| 59 } | |
| 60 | |
| 61 document.body.appendChild(Polymer.IronA11yAnnouncer.instance); | |
| 62 }; | |
| 63 })(); | |
| 64 | |
| 65 | |
| OLD | NEW |