| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview Introduces users to ChromeVox. |
| 7 */ |
| 8 |
| 9 goog.provide('Tutorial'); |
| 10 |
| 11 goog.require('Msgs'); |
| 12 |
| 13 /** |
| 14 * @constructor |
| 15 */ |
| 16 Tutorial = function() { |
| 17 /** |
| 18 * The 0-based index of the current page of the tutorial. |
| 19 * @type {number} |
| 20 * @private |
| 21 */ |
| 22 this.page_ = 0; |
| 23 }; |
| 24 |
| 25 /** |
| 26 * Data for the ChromeVox tutorial consisting of a list of pages, |
| 27 * each one of which contains a list of objects, where each object has |
| 28 * a message ID for some text, and optional attributes indicating if it's |
| 29 * a heading, link, text for only one platform, etc. |
| 30 * |
| 31 * @type Array<Object> |
| 32 */ |
| 33 Tutorial.PAGES = [ |
| 34 [ |
| 35 { msgid: 'tutorial_welcome_heading', heading: true }, |
| 36 { msgid: 'tutorial_welcome_text' }, |
| 37 { msgid: 'tutorial_enter_to_advance', repeat: true }, |
| 38 ], |
| 39 [ |
| 40 { msgid: 'tutorial_on_off_heading', heading: true }, |
| 41 { msgid: 'tutorial_control' }, |
| 42 { msgid: 'tutorial_on_off' }, |
| 43 { msgid: 'tutorial_enter_to_advance', repeat: true }, |
| 44 ], |
| 45 [ |
| 46 { msgid: 'tutorial_modifier_heading', heading: true }, |
| 47 { msgid: 'tutorial_modifier' }, |
| 48 { msgid: 'tutorial_chromebook_search', chromebookOnly: true }, |
| 49 { msgid: 'tutorial_any_key' }, |
| 50 { msgid: 'tutorial_enter_to_advance', repeat: true }, |
| 51 ], |
| 52 [ |
| 53 { msgid: 'tutorial_basic_navigation_heading', heading: true }, |
| 54 { msgid: 'tutorial_basic_navigation' }, |
| 55 { msgid: 'tutorial_click_next' }, |
| 56 ], |
| 57 [ |
| 58 { msgid: 'tutorial_jump_heading', heading: true }, |
| 59 { msgid: 'tutorial_jump' }, |
| 60 { msgid: 'tutorial_click_next' }, |
| 61 ], |
| 62 [ |
| 63 { msgid: 'tutorial_menus_heading', heading: true }, |
| 64 { msgid: 'tutorial_menus' }, |
| 65 { msgid: 'tutorial_click_next' }, |
| 66 ], |
| 67 [ |
| 68 { msgid: 'tutorial_chrome_shortcuts_heading', heading: true }, |
| 69 { msgid: 'tutorial_chrome_shortcuts' }, |
| 70 { msgid: 'tutorial_chromebook_ctrl_forward', chromebookOnly: true }, |
| 71 { msgid: 'tutorial_chromeos_ctrl_f2', chromebookOnly: false }, |
| 72 ], |
| 73 [ |
| 74 { msgid: 'tutorial_learn_more_heading', heading: true }, |
| 75 { msgid: 'tutorial_learn_more' }, |
| 76 { msgid: 'next_command_reference', |
| 77 link: 'http://www.chromevox.com/next_keyboard_shortcuts.html' }, |
| 78 { msgid: 'chrome_keyboard_shortcuts', |
| 79 link: 'https://support.google.com/chromebook/answer/183101?hl=en' }, |
| 80 { msgid: 'touchscreen_accessibility', |
| 81 link: 'https://support.google.com/chromebook/answer/6103702?hl=en' }, |
| 82 ], |
| 83 ]; |
| 84 |
| 85 Tutorial.prototype = { |
| 86 /** Open the first page in the tutorial. */ |
| 87 firstPage: function() { |
| 88 this.page_ = 0; |
| 89 this.showPage_(); |
| 90 }, |
| 91 |
| 92 /** Move to the next page in the tutorial. */ |
| 93 nextPage: function() { |
| 94 if (this.page_ < Tutorial.PAGES.length - 1) { |
| 95 this.page_++; |
| 96 this.showPage_(); |
| 97 } |
| 98 }, |
| 99 |
| 100 /** Move to the previous page in the tutorial. */ |
| 101 previousPage: function() { |
| 102 if (this.page_ > 0) { |
| 103 this.page_--; |
| 104 this.showPage_(); |
| 105 } |
| 106 }, |
| 107 |
| 108 /** |
| 109 * Recreate the tutorial DOM for page |this.page_|. |
| 110 * @private |
| 111 */ |
| 112 showPage_: function() { |
| 113 var tutorialContainer = $('tutorial_main'); |
| 114 tutorialContainer.innerHTML = ''; |
| 115 |
| 116 var pageElements = Tutorial.PAGES[this.page_]; |
| 117 for (var i = 0; i < pageElements.length; ++i) { |
| 118 var pageElement = pageElements[i]; |
| 119 var msgid = pageElement.msgid; |
| 120 var text = Msgs.getMsg(msgid); |
| 121 var element; |
| 122 if (pageElement.heading) { |
| 123 element = document.createElement('h2'); |
| 124 } else if (pageElement.link) { |
| 125 element = document.createElement('a'); |
| 126 element.href = pageElement.link; |
| 127 element.target = '_blank'; |
| 128 } else { |
| 129 element = document.createElement('p'); |
| 130 } |
| 131 element.innerText = text; |
| 132 tutorialContainer.appendChild(element); |
| 133 } |
| 134 } |
| 135 }; |
| OLD | NEW |