Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <include src="keyboard_overlay_data.js"/> | 5 <include src="keyboard_overlay_data.js"/> |
| 6 <include src="keyboard_overlay_accessibility_helper.js"/> | 6 <include src="keyboard_overlay_accessibility_helper.js"/> |
| 7 | 7 |
| 8 var BASE_KEYBOARD = { | 8 var BASE_KEYBOARD = { |
| 9 top: 0, | 9 top: 0, |
| 10 left: 0, | 10 left: 0, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 var identifierMap = {}; | 111 var identifierMap = {}; |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * Returns layouts data. | 114 * Returns layouts data. |
| 115 * @return {Object} Keyboard layout data. | 115 * @return {Object} Keyboard layout data. |
| 116 */ | 116 */ |
| 117 function getLayouts() { | 117 function getLayouts() { |
| 118 return keyboardOverlayData['layouts']; | 118 return keyboardOverlayData['layouts']; |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Cache the shortcut data after it is constructed. | |
| 122 var shortcutDataCache; | |
| 123 | |
| 124 /** | 121 /** |
| 125 * Returns shortcut data. | 122 * Returns shortcut data. |
| 126 * @return {Object} Keyboard shortcut data. | 123 * @return {Object} Keyboard shortcut data. |
| 127 */ | 124 */ |
| 128 function getShortcutData() { | 125 function getShortcutData() { |
| 129 if (shortcutDataCache) | 126 return keyboardOverlayData['shortcut']; |
| 130 return shortcutDataCache; | |
| 131 | |
| 132 shortcutDataCache = keyboardOverlayData['shortcut']; | |
| 133 | |
| 134 var searchKeyIsModifier = | |
| 135 loadTimeData.getString('keyboardSearchKeyActsAsFunctionKey') == 'true'; | |
| 136 if (searchKeyIsModifier) { | |
| 137 // TODO(mazda): Clean this up and move these out to the data js. | |
| 138 var searchModifierRemoveShortcuts = { | |
| 139 'backspace<>ALT': 'keyboardOverlayDelete', | |
| 140 'down<>ALT': 'keyboardOverlayPageDown', | |
| 141 'down<>ALT<>CTRL': 'keyboardOverlayEnd', | |
| 142 'up<>ALT': 'keyboardOverlayPageUp', | |
| 143 'up<>ALT<>CTRL': 'keyboardOverlayHome' | |
| 144 }; | |
| 145 var searchModifierAddShortcuts = { | |
|
mazda
2012/12/17 18:27:51
Could you keep these shortcuts data separated from
danakj
2012/12/17 18:30:48
Ah, right ok! I'll move them back here and just ha
danakj
2012/12/17 20:01:29
Done.
| |
| 146 '1<>SEARCH': 'keyboardOverlayF1', | |
| 147 '2<>SEARCH': 'keyboardOverlayF2', | |
| 148 '3<>SEARCH': 'keyboardOverlayF3', | |
| 149 '4<>SEARCH': 'keyboardOverlayF4', | |
| 150 '5<>SEARCH': 'keyboardOverlayF5', | |
| 151 '6<>SEARCH': 'keyboardOverlayF6', | |
| 152 '7<>SEARCH': 'keyboardOverlayF7', | |
| 153 '8<>SEARCH': 'keyboardOverlayF8', | |
| 154 '9<>SEARCH': 'keyboardOverlayF9', | |
| 155 '0<>SEARCH': 'keyboardOverlayF10', | |
| 156 '-<>SEARCH': 'keyboardOverlayF11', | |
| 157 '=<>SEARCH': 'keyboardOverlayF12', | |
| 158 'F1<>SEARCH': 'keyboardOverlayF1', | |
| 159 'F2<>SEARCH': 'keyboardOverlayF2', | |
| 160 'F3<>SEARCH': 'keyboardOverlayF3', | |
| 161 'F4<>SEARCH': 'keyboardOverlayF4', | |
| 162 'F5<>SEARCH': 'keyboardOverlayF5', | |
| 163 'F6<>SEARCH': 'keyboardOverlayF6', | |
| 164 'F7<>SEARCH': 'keyboardOverlayF7', | |
| 165 'F8<>SEARCH': 'keyboardOverlayF8', | |
| 166 'F9<>SEARCH': 'keyboardOverlayF9', | |
| 167 'F10<>SEARCH': 'keyboardOverlayF10', | |
| 168 'F11<>SEARCH': 'keyboardOverlayF11', | |
| 169 'F12<>SEARCH': 'keyboardOverlayF12', | |
| 170 'back<>SEARCH': 'keyboardOverlayF1', | |
| 171 'forward<>SEARCH': 'keyboardOverlayF2', | |
| 172 'reload<>SEARCH': 'keyboardOverlayF3', | |
| 173 'maximize<>SEARCH': 'keyboardOverlayF4', | |
| 174 'switch window<>SEARCH': 'keyboardOverlayF5', | |
| 175 'bright down<>SEARCH': 'keyboardOverlayF6', | |
| 176 'bright up<>SEARCH': 'keyboardOverlayF7', | |
| 177 'mute<>SEARCH': 'keyboardOverlayF8', | |
| 178 'vol. down<>SEARCH': 'keyboardOverlayF9', | |
| 179 'vol. up<>SEARCH': 'keyboardOverlayF10', | |
| 180 'backspace<>SEARCH': 'keyboardOverlayDelete', | |
| 181 'down<>SEARCH': 'keyboardOverlayPageDown', | |
| 182 'right<>SEARCH': 'keyboardOverlayEnd', | |
| 183 'up<>SEARCH': 'keyboardOverlayPageUp', | |
| 184 'left<>SEARCH': 'keyboardOverlayHome', | |
| 185 '.<>SEARCH': 'keyboardOverlayInsert' | |
| 186 }; | |
| 187 | |
| 188 for (var key in searchModifierRemoveShortcuts) | |
| 189 delete shortcutDataCache[key]; | |
| 190 for (var key in searchModifierAddShortcuts) | |
| 191 shortcutDataCache[key] = searchModifierAddShortcuts[key]; | |
| 192 } | |
| 193 | |
| 194 return shortcutDataCache; | |
| 195 } | 127 } |
| 196 | 128 |
| 197 /** | 129 /** |
| 198 * Returns the keyboard overlay ID. | 130 * Returns the keyboard overlay ID. |
| 199 * @return {string} Keyboard overlay ID. | 131 * @return {string} Keyboard overlay ID. |
| 200 */ | 132 */ |
| 201 function getKeyboardOverlayId() { | 133 function getKeyboardOverlayId() { |
| 202 return keyboardOverlayId; | 134 return keyboardOverlayId; |
| 203 } | 135 } |
| 204 | 136 |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 instructions.style.top = ((BASE_INSTRUCTIONS.top - BASE_KEYBOARD.top) * | 518 instructions.style.top = ((BASE_INSTRUCTIONS.top - BASE_KEYBOARD.top) * |
| 587 height / BASE_KEYBOARD.height + minY) + 'px'; | 519 height / BASE_KEYBOARD.height + minY) + 'px'; |
| 588 instructions.style.width = (width * BASE_INSTRUCTIONS.width / | 520 instructions.style.width = (width * BASE_INSTRUCTIONS.width / |
| 589 BASE_KEYBOARD.width) + 'px'; | 521 BASE_KEYBOARD.width) + 'px'; |
| 590 instructions.style.height = (height * BASE_INSTRUCTIONS.height / | 522 instructions.style.height = (height * BASE_INSTRUCTIONS.height / |
| 591 BASE_KEYBOARD.height) + 'px'; | 523 BASE_KEYBOARD.height) + 'px'; |
| 592 | 524 |
| 593 var instructionsText = document.createElement('div'); | 525 var instructionsText = document.createElement('div'); |
| 594 instructionsText.id = 'instructions-text'; | 526 instructionsText.id = 'instructions-text'; |
| 595 instructionsText.className = 'keyboard-overlay-instructions-text'; | 527 instructionsText.className = 'keyboard-overlay-instructions-text'; |
| 596 var searchKeyIsModifier = | 528 instructionsText.innerHTML = |
| 597 loadTimeData.getString('keyboardSearchKeyActsAsFunctionKey') == 'true'; | 529 loadTimeData.getString('keyboardOverlayInstructions'); |
| 598 if (searchKeyIsModifier) { | |
| 599 instructionsText.innerHTML = | |
| 600 loadTimeData.getString('keyboardOverlayInstructionsWithSearch'); | |
| 601 } else { | |
| 602 instructionsText.innerHTML = | |
| 603 loadTimeData.getString('keyboardOverlayInstructions'); | |
| 604 } | |
| 605 instructions.appendChild(instructionsText); | 530 instructions.appendChild(instructionsText); |
| 606 var instructionsHideText = document.createElement('div'); | 531 var instructionsHideText = document.createElement('div'); |
| 607 instructionsHideText.id = 'instructions-hide-text'; | 532 instructionsHideText.id = 'instructions-hide-text'; |
| 608 instructionsHideText.className = 'keyboard-overlay-instructions-hide-text'; | 533 instructionsHideText.className = 'keyboard-overlay-instructions-hide-text'; |
| 609 instructionsHideText.innerHTML = | 534 instructionsHideText.innerHTML = |
| 610 loadTimeData.getString('keyboardOverlayInstructionsHide'); | 535 loadTimeData.getString('keyboardOverlayInstructionsHide'); |
| 611 instructions.appendChild(instructionsHideText); | 536 instructions.appendChild(instructionsHideText); |
| 612 var learnMoreLinkText = document.createElement('div'); | 537 var learnMoreLinkText = document.createElement('div'); |
| 613 learnMoreLinkText.id = 'learn-more-text'; | 538 learnMoreLinkText.id = 'learn-more-text'; |
| 614 learnMoreLinkText.className = 'keyboard-overlay-learn-more-text'; | 539 learnMoreLinkText.className = 'keyboard-overlay-learn-more-text'; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 * Handles click events of the learn more link. | 609 * Handles click events of the learn more link. |
| 685 * @param {Event} e Mouse click event. | 610 * @param {Event} e Mouse click event. |
| 686 */ | 611 */ |
| 687 function learnMoreClicked(e) { | 612 function learnMoreClicked(e) { |
| 688 chrome.send('openLearnMorePage'); | 613 chrome.send('openLearnMorePage'); |
| 689 chrome.send('DialogClose'); | 614 chrome.send('DialogClose'); |
| 690 e.preventDefault(); | 615 e.preventDefault(); |
| 691 } | 616 } |
| 692 | 617 |
| 693 document.addEventListener('DOMContentLoaded', init); | 618 document.addEventListener('DOMContentLoaded', init); |
| OLD | NEW |