popupcolorpicker.html 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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.PopupColorPicker</title>
  10. <script src="../base.js"></script>
  11. <link rel="stylesheet" href="css/demo.css">
  12. <link rel="stylesheet" href="../css/colorpicker-simplegrid.css">
  13. <script>
  14. goog.require('goog.ui.PopupColorPicker');
  15. </script>
  16. <style>
  17. .goog-popupcolorpicker {
  18. position:absolute;
  19. -moz-outline:0;
  20. outline:0;
  21. }
  22. #button1, #button2 {
  23. display: block;
  24. width: 60px;
  25. text-align: center;
  26. margin: 10px;
  27. padding: 10px;
  28. font: normal 0.8em verdana,sans-serif;
  29. border: 1px solid #000;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <h1>goog.ui.PopupColorPicker</h1>
  35. <a href="javascript:void(0)" id="button1">Show 1</a>
  36. <a href="javascript:void(0)" id="button2">Show 2</a>
  37. <script>
  38. var picker = new goog.ui.PopupColorPicker();
  39. picker.render();
  40. picker.attach(document.getElementById('button1'));
  41. picker.attach(document.getElementById('button2'));
  42. goog.events.listen(picker, 'change', function(e) {
  43. picker.getLastTarget().style.backgroundColor = picker.getSelectedColor();
  44. });
  45. </script>
  46. </body>
  47. </html>