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 * Returns a function that console.log's its arguments, prefixed by |msg|. | 10 * Returns a function that console.log's its arguments, prefixed by |msg|. |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 for (var i = 2; i < arguments.length; i++) { | 467 for (var i = 2; i < arguments.length; i++) { |
468 var arg = arguments[i]; | 468 var arg = arguments[i]; |
469 if (typeof(arg) == 'string') { | 469 if (typeof(arg) == 'string') { |
470 element.appendChild(document.createTextNode(arg)); | 470 element.appendChild(document.createTextNode(arg)); |
471 } else { | 471 } else { |
472 element.appendChild(arg); | 472 element.appendChild(arg); |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
476 return element; | 476 return element; |
| 477 }, |
| 478 |
| 479 /** |
| 480 * Returns a string '[Ctrl-][Alt-][Shift-][Meta-]' depending on the event |
| 481 * modifiers. Convenient for writing out conditions in keyboard handlers. |
| 482 * |
| 483 * @param {Event} event |
| 484 * @return {string} |
| 485 */ |
| 486 getKeyModifiers: function(event) { |
| 487 return (event.ctrlKey ? 'Ctrl-' : '') + |
| 488 (event.altKey ? 'Alt-' : '') + |
| 489 (event.shiftKey ? 'Shift-' : '') + |
| 490 (event.metaKey ? 'Meta-' : ''); |
477 } | 491 } |
478 }; | 492 }; |
OLD | NEW |