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