bfc8ec5e744f98b2be591a65b2809b717c2da3f2.svn-base 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>dojox.layout.SizingPane</title>
  6. <script type="text/javascript" src="../../../dojo/dojo.js"></script>
  7. <script type="text/javascript">
  8. dojo.require("dijit.dijit");
  9. dojo.require("dojo.fx");
  10. </script>
  11. <style type="text/css">
  12. @import "../../../dojo/resources/dojo.css";
  13. @import "../../../dijit/themes/dijit.css";
  14. @import "../../../dijit/themes/tundra/tundra.css";
  15. @import "../../../dijit/tests/css/dijitTests.css";
  16. body { background:#ededed; color:#666; }
  17. #nav {
  18. position:absolute;
  19. top:100px;
  20. left:10px;
  21. width:200px;
  22. -moz-border-radius:8pt 8pt;
  23. background:#fff;
  24. border:2px solid #ccc;
  25. }
  26. #box1 {
  27. overflow:hidden;
  28. position:absolute;
  29. display:block;
  30. width:25px;
  31. height:25px;
  32. -moz-border-radius:8pt 8pt;
  33. radius:8pt;
  34. -webkit-border-radius:8pt 8pt;
  35. background:#fff;
  36. border:2px solid #ccc;
  37. padding:7px;
  38. }
  39. </style>
  40. <script>
  41. var animationMethod = "chain"; // || combine
  42. var _showing = false;
  43. var animG, offsetW, offsetH = null;
  44. var box1 = null;
  45. var boxMixin = {
  46. startWidth: 25,
  47. startHeight: 25,
  48. endWidth: 320,
  49. endHeight: 320,
  50. duration: 300
  51. };
  52. dojo.addOnLoad(function() {
  53. box1 = dojo.byId('box1');
  54. centerNode(box1);
  55. dojo.connect(box1,"onmouseover",null,"show");
  56. dojo.connect(box1,"onmouseout",null,"hideCheck");
  57. //dojo.connect(box1,"onmouseout",null,"hideCheck");
  58. //dojo.connect(but1,"onclick",null,"show");
  59. });
  60. function hideCheck(node) {
  61. if (_showing) {
  62. setTimeout("hide('box1')",125);
  63. }
  64. }
  65. function centerNode(node) {
  66. var viewport = dijit.getViewport();
  67. var mb = dojo.marginBox(node);
  68. var style = node.style;
  69. offsetW = mb.w - style.width;
  70. offsetH = mb.h - style.height;
  71. style.left = (viewport.l + (viewport.w - mb.w)/2) + "px";
  72. style.top = (viewport.t + (viewport.h - mb.h)/2) + "px";
  73. }
  74. function doUnderlay() {
  75. console.debug('make underlay');
  76. }
  77. function show() {
  78. if (_showing) { return; }
  79. if (animG && animG.status == "playing") { animG.stop(); }
  80. _showing = true;
  81. var viewport = dijit.getViewport();
  82. var newLeft = (viewport.l + (viewport.w - boxMixin.endWidth)/2);
  83. var newTop = (viewport.t + (viewport.h - boxMixin.endHeight)/2);
  84. var style = box1.style;
  85. var anim1 = dojo.animateProperty({
  86. node: box1,
  87. duration: boxMixin.duration/2,
  88. properties: {
  89. width: { /* start: boxMixin.startWidth, */ end: boxMixin.endWidth, unit:"px" },
  90. left: { end: newLeft, unit:"px" }
  91. },
  92. beforeBegin: doUnderlay()
  93. });
  94. var anim2 = dojo.animateProperty({
  95. node: box1,
  96. duration: boxMixin.duration/2,
  97. properties: {
  98. height: { /*start: boxMixin.startHeight, */ end: boxMixin.endHeight, unit:"px" },
  99. top: { end: newTop, unit: "px" }
  100. },
  101. onEnd: function() { _showing = true; }
  102. });
  103. animG = dojo.fx[animationMethod]([anim1,anim2]).play();
  104. // chain:
  105. // animate width / left position
  106. // animate height / top position
  107. // onend: fadeIn content?
  108. }
  109. function hide(node) {
  110. if (!_showing) return;
  111. if (animG && animG.status() == "playing") { animG.stop(); }
  112. var viewport = dijit.getViewport();
  113. var newLeft = (viewport.l + (viewport.w - boxMixin.startWidth)/2);
  114. var newTop = (viewport.t + (viewport.h - boxMixin.startHeight)/2);
  115. var style = node.style;
  116. var anim1 = dojo.animateProperty({
  117. node: box1,
  118. duration: boxMixin.duration/2,
  119. properties: {
  120. width: { end: boxMixin.startWidth, unit:"px" },
  121. left: { end: newLeft, unit:"px" }
  122. }
  123. });
  124. var anim2 = dojo.animateProperty({
  125. node: box1,
  126. duration: boxMixin.duration/2,
  127. properties: {
  128. height: { end: boxMixin.startHeight, unit:"px" },
  129. top: { end: newTop, unit: "px" }
  130. },
  131. onEnd: function() { _showing = false; }
  132. });
  133. // if we chain, do anim2 first [because height/top is how anim2 in show() ends]
  134. animG = dojo.fx[animationMethod]([anim2,anim1]).play();
  135. }
  136. </script>
  137. </head>
  138. <body class="tundra">
  139. <h1 class="testTitle">dojox.layout.SizingPane</h1>
  140. <p>This is simply a test / example. There is no <i>real</i> dojox.layout.SizingPane, but this code
  141. should/might become part of a dojox.fx.toggle class ... it's just "neat", isn't it?</p>
  142. <div id="box1">
  143. lorem. lorem. lorem.
  144. </div>
  145. </body>
  146. </html>