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 /** | 5 /** |
6 * Namespace for utility functions. | 6 * Namespace for utility functions. |
7 */ | 7 */ |
8 var util = {}; | 8 var util = {}; |
9 | 9 |
10 /** | 10 /** |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 * suffix like "x86-mario-something". | 1240 * suffix like "x86-mario-something". |
1241 * @return {boolean} True if the board of the device matches the given prefix. | 1241 * @return {boolean} True if the board of the device matches the given prefix. |
1242 */ | 1242 */ |
1243 util.boardIs = function(boardPrefix) { | 1243 util.boardIs = function(boardPrefix) { |
1244 // The board name should be lower-cased, but making it case-insensitive for | 1244 // The board name should be lower-cased, but making it case-insensitive for |
1245 // backward compatibility just in case. | 1245 // backward compatibility just in case. |
1246 var board = str('CHROMEOS_RELEASE_BOARD'); | 1246 var board = str('CHROMEOS_RELEASE_BOARD'); |
1247 var pattern = new RegExp('^' + boardPrefix, 'i'); | 1247 var pattern = new RegExp('^' + boardPrefix, 'i'); |
1248 return board.match(pattern) != null; | 1248 return board.match(pattern) != null; |
1249 }; | 1249 }; |
| 1250 |
| 1251 /** |
| 1252 * Disabled browser shortcus key events on the given document. |
| 1253 * @param {Element} element Element to be disabled browser shortcut keys on. |
| 1254 */ |
| 1255 util.disableBrowserShortcutKeys = function(element) { |
| 1256 element.addEventListener('keydown', function(e) { |
| 1257 switch (util.getKeyModifiers(e) + e.keyCode) { |
| 1258 case 'Ctrl-79': // Disable native Ctrl-O (open file). |
| 1259 case 'Ctrl-83': // Disable native Ctrl-S (save as). |
| 1260 case 'Ctrl-85': // Disable native Ctrl-U (view source). |
| 1261 e.preventDefault(); |
| 1262 } |
| 1263 }); |
| 1264 }; |
OLD | NEW |