charpicker.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2010 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <head>
  9. <title>goog.ui.CharPicker</title>
  10. <meta charset=utf-8>
  11. <!-- common css used by all closure demos; not required for char picker -->
  12. <link rel="stylesheet" href="css/demo.css">
  13. <!-- used only for button in this page; not required for char picker-->
  14. <link rel="stylesheet" href="../css/menubutton.css">
  15. <!-- only required css for char picker -->
  16. <link rel="stylesheet" href="../css/charpicker.css">
  17. <script src="../base.js"></script>
  18. <script>
  19. goog.require('goog.i18n.CharPickerData');
  20. goog.require('goog.i18n.uChar.LocalNameFetcher');
  21. goog.require('goog.ui.CharPicker');
  22. </script>
  23. <style>
  24. #p1_value {
  25. color: red;
  26. font-weight: bold;
  27. font-size: large;
  28. }
  29. p {
  30. height: 2em;
  31. }
  32. </style>
  33. </head>
  34. <body>
  35. <h1>goog.ui.CharPicker</h1>
  36. <p>You have selected: <span id="p1_value">none</span>
  37. <div id="char-picker"></div>
  38. <script>
  39. var picker = new goog.ui.CharPicker(new goog.i18n.CharPickerData(),
  40. new goog.i18n.uChar.LocalNameFetcher(),
  41. ["\uD869\uDED6", "a", "b", "c"], 10, 1);
  42. var el = goog.dom.getElement('char-picker');
  43. picker.decorate(el);
  44. // Action on selection
  45. var selectionAction = function() {
  46. goog.dom.setTextContent(goog.dom.getElement('p1_value'),
  47. picker.getSelectedChar());
  48. };
  49. // Get selected locale from the char picker.
  50. goog.events.listen(picker, 'action', function(e) { selectionAction(); });
  51. </script>
  52. <p>
  53. <input type="button" value="Dispose" onclick="picker.dispose()">
  54. </p>
  55. </body>
  56. </html>