progressbar.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.ProgressBar</title>
  10. <link rel="stylesheet" href="css/demo.css">
  11. <style>
  12. .progress-bar-vertical,
  13. .progress-bar-horizontal {
  14. position: relative;
  15. border: 1px solid #949dad;
  16. background: white;
  17. padding: 1px;
  18. overflow: hidden;
  19. margin: 2px;
  20. }
  21. .progress-bar-horizontal {
  22. width: 80%;
  23. height: 14px;
  24. }
  25. .progress-bar-vertical {
  26. width: 14px;
  27. height: 200px;
  28. }
  29. .progress-bar-thumb {
  30. position: relative;
  31. background: #d4e4ff;
  32. overflow: hidden;
  33. width: 100%;
  34. height: 100%;
  35. }
  36. #pb2 {
  37. height: 1.3em;
  38. }
  39. </style>
  40. <script src="../base.js"></script>
  41. <script>
  42. goog.require('goog.ui.Component');
  43. goog.require('goog.ui.ProgressBar');
  44. goog.require('goog.dom');
  45. goog.require('goog.Timer');
  46. </script>
  47. </head>
  48. <body>
  49. <h1>goog.ui.ProgressBar</h1>
  50. <div id=out></div>
  51. <div id=d></div>
  52. <div id=pb2>
  53. <div class="progress-bar-thumb"></div>
  54. <div style='position:absolute;top:0;text-align:center;width:100%;
  55. font:statusbar;padding:2px'>
  56. Decorated element
  57. </div>
  58. </div>
  59. <script>
  60. var $ = goog.dom.getElement;
  61. var pb = new goog.ui.ProgressBar;
  62. pb.setOrientation(goog.ui.ProgressBar.Orientation.VERTICAL);
  63. pb.render($('d'));
  64. var pb2 = new goog.ui.ProgressBar;
  65. pb2.decorate($('pb2'));
  66. var last = 0;
  67. var delta = 1;
  68. var t = new goog.Timer(20);
  69. t.addEventListener('tick', function(e) {
  70. if (last > 100 || last < 0) {
  71. delta = -delta;
  72. }
  73. last += delta;
  74. pb.setValue(last);
  75. pb2.setValue(last);
  76. });
  77. t.start();
  78. pb.addEventListener(goog.ui.Component.EventType.CHANGE, function() {
  79. goog.dom.setTextContent($('out'), this.getValue() + '%');
  80. });
  81. </script>
  82. </body>
  83. </html>