pastehandler.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <!--
  5. Copyright 2010 The Closure Library Authors. All Rights Reserved.
  6. Use of this source code is governed by the Apache License, Version 2.0.
  7. See the COPYING file for details.
  8. -->
  9. <head>
  10. <title>PasteHandler Test</title>
  11. <link rel="stylesheet" href="css/demo.css">
  12. <script src="../base.js"></script>
  13. <script>
  14. goog.require('goog.debug.DivConsole');
  15. goog.require('goog.debug.LogManager');
  16. goog.require('goog.dom');
  17. goog.require('goog.events.PasteHandler');
  18. goog.require('goog.log');
  19. goog.require('goog.ui.KeyboardShortcutEvent');
  20. </script>
  21. </head>
  22. <body>
  23. <h2>Demo of goog.events.PasteHandler</h2>
  24. <fieldset>
  25. <legend>Demo of the <strong>goog.events.PasteHandler</strong>:</legend>
  26. <label>goog.events.PasteHandler detects paste events in textareas.
  27. Try pasting text in the textarea below and watch the event log at the
  28. bottom of the page.<br></label>
  29. <textarea id="foo" rows="10" cols="100"></textarea>
  30. </fieldset>
  31. <fieldset class="goog-debug-panel">
  32. <legend>Event Log</legend>
  33. <div id="log" style="height: 200px;"></div>
  34. </fieldset>
  35. <script type="text/javascript">
  36. var textarea = goog.dom.getElement('foo');
  37. var pasteHandler = new goog.events.PasteHandler(textarea);
  38. var logger = goog.log.getLogger('demo')
  39. goog.events.listen(pasteHandler, goog.events.PasteHandler.EventType.PASTE,
  40. function(e) {
  41. goog.log.log(logger, goog.log.Level.SHOUT, 'pasted!');
  42. });
  43. goog.debug.LogManager.getRoot().setLevel(goog.log.Level.SEVERE);
  44. var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log'));
  45. logconsole.setCapturing(true);
  46. </script>
  47. </body>
  48. </html>