Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Introduces users to ChromeVox. | 6 * @fileoverview Introduces users to ChromeVox. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('Tutorial'); | 9 goog.provide('Tutorial'); |
| 10 | 10 |
| 11 goog.require('Msgs'); | 11 goog.require('Msgs'); |
| 12 goog.require('cvox.AbstractEarcons'); | |
| 12 | 13 |
| 13 /** | 14 /** |
| 14 * @constructor | 15 * @constructor |
| 15 */ | 16 */ |
| 16 Tutorial = function() { | 17 Tutorial = function() { |
| 17 /** | 18 /** |
| 18 * The 0-based index of the current page of the tutorial. | 19 * The 0-based index of the current page of the tutorial. |
| 19 * @type {number} | 20 * @type {number} |
| 20 * @private | 21 * @private |
| 21 */ | 22 */ |
| 22 this.page_; | 23 this.page_; |
| 23 | 24 |
| 24 this.page = sessionStorage['tutorial_page_pos'] !== undefined ? | 25 this.page = sessionStorage['tutorial_page_pos'] !== undefined ? |
| 25 sessionStorage['tutorial_page_pos'] : 0; | 26 sessionStorage['tutorial_page_pos'] : 0; |
| 26 }; | 27 }; |
| 28 /** | |
| 29 * @param {Node} container | |
| 30 * @private | |
| 31 */ | |
| 32 Tutorial.buildEarconPage_ = function(container) { | |
| 33 for (var earconId in cvox.EarconDescription) { | |
| 34 var msgid = cvox.EarconDescription[earconId]; | |
| 35 var earconElement = document.createElement('p'); | |
| 36 earconElement.innerText = Msgs.getMsg(msgid); | |
| 37 earconElement.setAttribute('tabindex', 0); | |
| 38 var prevEarcon; | |
| 39 var playEarcon = function(earcon) { | |
| 40 if (prevEarcon) { | |
| 41 chrome.extension.getBackgroundPage()['cvox']['ChromeVox'][ | |
|
dmazzoni
2016/11/12 00:03:59
note: at some point we should probably come up wit
David Tseng
2016/11/13 07:32:56
Acknowledged.
| |
| 42 'earcons']['cancelEarcon'](prevEarcon); | |
|
dmazzoni
2016/11/12 00:03:59
nit: indent by 4
David Tseng
2016/11/13 07:32:56
Done.
| |
| 43 } | |
| 44 chrome.extension.getBackgroundPage()['cvox']['ChromeVox'][ | |
| 45 'earcons']['playEarcon'](earcon); | |
|
dmazzoni
2016/11/12 00:03:59
nit: indent by 4
David Tseng
2016/11/13 07:32:56
Done.
| |
| 46 prevEarcon = earcon; | |
| 47 }.bind(this, earconId); | |
| 48 earconElement.addEventListener('focus', playEarcon, false); | |
| 49 container.appendChild(earconElement); | |
| 50 } | |
| 51 }; | |
| 27 | 52 |
| 28 /** | 53 /** |
| 29 * Data for the ChromeVox tutorial consisting of a list of pages, | 54 * Data for the ChromeVox tutorial consisting of a list of pages, |
| 30 * each one of which contains a list of objects, where each object has | 55 * each one of which contains a list of objects, where each object has |
| 31 * a message ID for some text, and optional attributes indicating if it's | 56 * a message ID for some text, and optional attributes indicating if it's |
| 32 * a heading, link, text for only one platform, etc. | 57 * a heading, link, text for only one platform, etc. |
| 33 * | 58 * |
| 34 * @type Array<Array<Object>> | 59 * @type Array<Array<Object>> |
| 35 */ | 60 */ |
| 36 Tutorial.PAGES = [ | 61 Tutorial.PAGES = [ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 { msgid: 'tutorial_menus_heading', heading: true }, | 93 { msgid: 'tutorial_menus_heading', heading: true }, |
| 69 { msgid: 'tutorial_menus' }, | 94 { msgid: 'tutorial_menus' }, |
| 70 { msgid: 'tutorial_click_next' }, | 95 { msgid: 'tutorial_click_next' }, |
| 71 ], | 96 ], |
| 72 [ | 97 [ |
| 73 { msgid: 'tutorial_chrome_shortcuts_heading', heading: true }, | 98 { msgid: 'tutorial_chrome_shortcuts_heading', heading: true }, |
| 74 { msgid: 'tutorial_chrome_shortcuts' }, | 99 { msgid: 'tutorial_chrome_shortcuts' }, |
| 75 { msgid: 'tutorial_chromebook_ctrl_forward', chromebookOnly: true } | 100 { msgid: 'tutorial_chromebook_ctrl_forward', chromebookOnly: true } |
| 76 ], | 101 ], |
| 77 [ | 102 [ |
| 103 { msgid: 'tutorial_earcon_page_title', heading: true }, | |
| 104 { msgid: 'tutorial_earcon_page_body' }, | |
| 105 { custom: Tutorial.buildEarconPage_ } | |
| 106 ], | |
| 107 [ | |
| 78 { msgid: 'tutorial_learn_more_heading', heading: true }, | 108 { msgid: 'tutorial_learn_more_heading', heading: true }, |
| 79 { msgid: 'tutorial_learn_more' }, | 109 { msgid: 'tutorial_learn_more' }, |
| 80 { msgid: 'next_command_reference', | 110 { msgid: 'next_command_reference', |
| 81 link: 'http://www.chromevox.com/next_keyboard_shortcuts.html' }, | 111 link: 'http://www.chromevox.com/next_keyboard_shortcuts.html' }, |
| 82 { msgid: 'chrome_keyboard_shortcuts', | 112 { msgid: 'chrome_keyboard_shortcuts', |
| 83 link: 'https://support.google.com/chromebook/answer/183101?hl=en' }, | 113 link: 'https://support.google.com/chromebook/answer/183101?hl=en' }, |
| 84 { msgid: 'touchscreen_accessibility', | 114 { msgid: 'touchscreen_accessibility', |
| 85 link: 'https://support.google.com/chromebook/answer/6103702?hl=en' }, | 115 link: 'https://support.google.com/chromebook/answer/6103702?hl=en' }, |
| 86 ], | 116 ], |
| 87 ]; | 117 ]; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 element = document.createElement('li'); | 208 element = document.createElement('li'); |
| 179 } else if (pageElement.link) { | 209 } else if (pageElement.link) { |
| 180 element = document.createElement('a'); | 210 element = document.createElement('a'); |
| 181 element.href = pageElement.link; | 211 element.href = pageElement.link; |
| 182 element.setAttribute('tabindex', 0); | 212 element.setAttribute('tabindex', 0); |
| 183 element.addEventListener('click', function(evt) { | 213 element.addEventListener('click', function(evt) { |
| 184 Panel.closeMenusAndRestoreFocus(); | 214 Panel.closeMenusAndRestoreFocus(); |
| 185 chrome.windows.create({url: evt.target.href}); | 215 chrome.windows.create({url: evt.target.href}); |
| 186 return false; | 216 return false; |
| 187 }, false); | 217 }, false); |
| 218 } else if (pageElement.custom) { | |
| 219 element = document.createElement('div'); | |
| 220 pageElement.custom(element); | |
| 188 } else { | 221 } else { |
| 189 element = document.createElement('p'); | 222 element = document.createElement('p'); |
| 190 } | 223 } |
| 191 if (text) | 224 if (text) |
| 192 element.innerText = text; | 225 element.innerText = text; |
| 193 container.appendChild(element); | 226 container.appendChild(element); |
| 194 } | 227 } |
| 195 if (focus) | 228 if (focus) |
| 196 focus.focus(); | 229 focus.focus(); |
| 197 }, | 230 }, |
| 198 | 231 |
| 199 /** @private */ | 232 /** @private */ |
| 200 finalizeDom_: function() { | 233 finalizeDom_: function() { |
| 201 var disableNext = this.page == (Tutorial.PAGES.length - 1); | 234 var disableNext = this.page == (Tutorial.PAGES.length - 1); |
| 202 var disablePrevious = this.page == 0; | 235 var disablePrevious = this.page == 0; |
| 203 $('tutorial_next').setAttribute('aria-disabled', disableNext); | 236 $('tutorial_next').setAttribute('aria-disabled', disableNext); |
| 204 $('tutorial_previous').setAttribute('aria-disabled', disablePrevious); | 237 $('tutorial_previous').setAttribute('aria-disabled', disablePrevious); |
| 205 }, | 238 }, |
| 206 | 239 |
| 207 get page() { | 240 get page() { |
| 208 return this.page_; | 241 return this.page_; |
| 209 }, | 242 }, |
| 210 | 243 |
| 211 set page(val) { | 244 set page(val) { |
| 212 this.page_ = val; | 245 this.page_ = val; |
| 213 sessionStorage['tutorial_page_pos'] = this.page_; | 246 sessionStorage['tutorial_page_pos'] = this.page_; |
| 214 } | 247 } |
| 215 }; | 248 }; |
| OLD | NEW |