zippy.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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.Zippy</title>
  10. <meta charset="utf-8">
  11. <script src="../base.js"></script>
  12. <script>
  13. goog.require('goog.debug.DivConsole');
  14. goog.require('goog.debug.LogManager');
  15. goog.require('goog.events');
  16. goog.require('goog.log');
  17. goog.require('goog.ui.AnimatedZippy');
  18. goog.require('goog.ui.Zippy');
  19. goog.require('goog.ui.ZippyEvent');
  20. </script>
  21. <link rel="stylesheet" href="css/demo.css">
  22. <style>
  23. h2 {
  24. background: #C0C0FF;
  25. margin-top: 10px;
  26. margin-bottom: 0px;
  27. cursor: pointer;
  28. padding: 1px 3px;
  29. }
  30. div {
  31. margin: 0px;
  32. padding: 0px;
  33. }
  34. p {
  35. background: #DEDEFF;
  36. border: solid #C0C0FF;
  37. border-width: 0px 3px 3px 3px;
  38. margin-top: 0px;
  39. padding: 3px;
  40. text-align: justify;
  41. overflow: hidden;
  42. }
  43. img {
  44. width: 19px;
  45. height: 16px;
  46. }
  47. .goog-zippy-expanded img {
  48. background-image: url('../images/minus.png');
  49. }
  50. .goog-zippy-collapsed img {
  51. background-image: url('../images/plus.png');
  52. }
  53. </style>
  54. </head>
  55. <body>
  56. <h1>goog.ui.Zippy</h1>
  57. <h2 id="header1">Zippy 1</h2>
  58. <p id="content1">
  59. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cras et nisi id
  60. lorem tempor semper. Suspendisse ante. Integer ligula urna, venenatis quis,
  61. placerat vitae, commodo quis, sapien. Quisque nec lectus. Sed non dolor. Sed
  62. congue, nisi in pharetra consequat, odio diam pulvinar arcu, in laoreet elit
  63. risus id ipsum. Class aptent taciti sociosqu ad litora torquent per conubia
  64. nostra, per inceptos hymenaeos. Praesent tellus enim, imperdiet a, sagittis
  65. id, pulvinar vel, tortor. Integer nulla. Sed nulla augue, lacinia id,
  66. vulputate eu, rhoncus non, ante. Integer lobortis eros vitae quam. Phasellus
  67. sagittis, ipsum sollicitudin bibendum laoreet, arcu erat luctus lacus, vel
  68. pharetra felis metus tincidunt diam. Cras ac augue in enim ultricies aliquam.
  69. </p>
  70. <div style="width: 400px; float: left;">
  71. <h2 id="header2"><img src="../images/blank.gif" />Zippy 2</h2>
  72. <p id="content2">
  73. Nunc et eros. Aliquam felis lectus, sagittis ac, sagittis eu, accumsan
  74. vitae, leo. Maecenas suscipit, arcu eget elementum tincidunt, erat ligula
  75. porttitor dui, quis ornare nisi turpis at ipsum. Vivamus magna tortor,
  76. porttitor eu, cursus ut, vulputate in, nulla. Quisque nonummy feugiat
  77. turpis. Cras lobortis lobortis elit. Aliquam congue, pede suscipit
  78. condimentum convallis, diam purus dictum lacus, eu scelerisque mi est
  79. molestie libero. Duis luctus dapibus nibh. Sed condimentum iaculis metus.
  80. Pellentesque habitant morbi tristique senectus et netus et malesuada fames
  81. ac turpis egestas. In pharetra dolor porta eros facilisis pellentesque.
  82. Proin quam mi, sodales vel, tincidunt sit amet, convallis vel, eros.
  83. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere
  84. cubilia Curae; Phasellus velit augue, rutrum sit amet, posuere nec, euismod
  85. ac, elit. Etiam nisi.
  86. </p>
  87. </div>
  88. <div style="width: 400px; float: left; margin-left: 5px; ">
  89. <h2 id="header3"><img src="../images/blank.gif" />Zippy 3</h2>
  90. <p id="content3">
  91. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas commodo
  92. convallis nisi. Cras rhoncus elit non dolor. Vivamus gravida ultricies arcu.
  93. Praesent ipsum erat, vehicula et, ultrices at, dignissim at, ipsum. Aenean
  94. venenatis. Fusce blandit laoreet urna. Aliquam et pede condimentum lorem
  95. posuere molestie. Pellentesque habitant morbi tristique senectus et netus et
  96. malesuada fames ac turpis egestas. Fusce euismod, justo in feugiat feugiat,
  97. urna metus sagittis felis, in varius neque mauris vitae dui. Nunc vel sapien
  98. in diam laoreet euismod. Mauris quis felis ut ipsum auctor feugiat. Nulla
  99. facilisi. Proin vitae urna. Quisque dignissim commodo nisl. Curabitur
  100. bibendum.
  101. </p>
  102. </div>
  103. <div style="clear: both;">
  104. Zippy 2 sets the expanded state of zippy 3 to the inverted expanded state of
  105. itself. Hence expanding zippy 2 collapses zippy 3 and vice verse.
  106. </div>
  107. <div>
  108. Zippy 2 and 3 are animated, zippy 1 is not.
  109. </div>
  110. <hr>
  111. <div id="log"></div>
  112. <script>
  113. // Set up a logger.
  114. goog.debug.LogManager.getRoot().setLevel(goog.log.Level.ALL);
  115. var logger = goog.log.getLogger('zippy');
  116. var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log'));
  117. logconsole.setCapturing(true);
  118. var EVENTS = goog.object.getValues(goog.ui.Zippy.Events);
  119. goog.log.fine(logger, 'Listening for: ' + EVENTS.join(', ') + '.');
  120. function logEvent(e) {
  121. var caption = e.target.elHeader_.id;
  122. goog.log.info(logger, '"' + caption + '" dispatched: ' + e.type);
  123. }
  124. var z1 = new goog.ui.Zippy('header1', 'content1');
  125. goog.events.listen(z1, EVENTS, logEvent);
  126. var z2 = new goog.ui.AnimatedZippy('header2', 'content2', true);
  127. goog.events.listen(z2, EVENTS, logEvent);
  128. var z3 = new goog.ui.AnimatedZippy('header3', 'content3', false);
  129. goog.events.listen(z3, EVENTS, logEvent);
  130. z1.expand();
  131. function zippyToggle(event) {
  132. z3.setExpanded(!event.expanded);
  133. }
  134. goog.events.listen(z2, goog.ui.Zippy.Events.TOGGLE, zippyToggle);
  135. </script>
  136. </body>
  137. </html>