twothumbslider.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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.TwoThumbSlider</title>
  10. <script src="../base.js"></script>
  11. <script>
  12. goog.require('goog.dom');
  13. goog.require('goog.ui.Component');
  14. goog.require('goog.ui.TwoThumbSlider');
  15. </script>
  16. <style>
  17. .goog-twothumbslider-vertical,
  18. .goog-twothumbslider-horizontal {
  19. background-color: ThreeDFace;
  20. position: relative;
  21. overflow: hidden;
  22. }
  23. .goog-twothumbslider-value-thumb {
  24. position: absolute;
  25. background-color: ThreeDShadow;
  26. overflow: hidden;
  27. }
  28. .goog-twothumbslider-extent-thumb {
  29. position: absolute;
  30. background-color: #FF0000;
  31. overflow: hidden;
  32. }
  33. .goog-twothumbslider-vertical .goog-twothumbslider-value-thumb {
  34. height: 20px;
  35. width: 100%;
  36. }
  37. .goog-twothumbslider-vertical .goog-twothumbslider-extent-thumb {
  38. height: 20px;
  39. width: 100%;
  40. }
  41. .goog-twothumbslider-horizontal .goog-twothumbslider-value-thumb {
  42. width: 20px;
  43. height: 100%;
  44. }
  45. .goog-twothumbslider-horizontal .goog-twothumbslider-extent-thumb {
  46. height: 20px;
  47. width: 20px;
  48. }
  49. #s-h {
  50. margin-bottom: 2em;
  51. }
  52. #out1, #out2 {
  53. color: #999;
  54. margin-left: 1em;
  55. }
  56. </style>
  57. </head>
  58. <body>
  59. <h1>goog.ui.TwoThumbSlider</h1>
  60. <div id="s-h">
  61. <div id="s1" class="goog-twothumbslider" style="width: 200px; height: 20px">
  62. <!-- this line is here just to show that custom content can be added -->
  63. <div style="position:absolute;width:100%;top:9px;border:1px inset white;
  64. overflow:hidden;height:0"></div>
  65. <div class="goog-twothumbslider-value-thumb"></div>
  66. <div class="goog-twothumbslider-extent-thumb"></div>
  67. </div>
  68. <label>
  69. <input type="checkbox" onclick="s.setMoveToPointEnabled(this.checked)">
  70. MoveToPointEnabled
  71. <span id="out1"></span>
  72. </label>
  73. </div>
  74. <div id="s-v">
  75. <!-- slider inserted using scripting -->
  76. <label id="s2-label">
  77. <input type="checkbox" onclick="s2.setMoveToPointEnabled(this.checked)">
  78. MoveToPointEnabled
  79. <span id="out2"></span>
  80. </label>
  81. </div>
  82. <script>
  83. var el = document.getElementById('s1');
  84. var s = new goog.ui.TwoThumbSlider;
  85. s.decorate(el);
  86. s.addEventListener(goog.ui.Component.EventType.CHANGE, function() {
  87. document.getElementById('out1').innerHTML = 'start: ' + s.getValue() +
  88. ' end: ' + (s.getValue() + s.getExtent());
  89. });
  90. var s2 = new goog.ui.TwoThumbSlider;
  91. s2.setOrientation(goog.ui.SliderBase.Orientation.VERTICAL);
  92. s2.createDom();
  93. var el = s2.getElement();
  94. el.style.width = '20px';
  95. el.style.height = '200px';
  96. s2.render(document.body);
  97. s2.setStep(null);
  98. s2.addEventListener(goog.ui.Component.EventType.CHANGE, function() {
  99. document.getElementById('out2').innerHTML = 'start: ' + s2.getValue() +
  100. ' end: ' + (s2.getValue() + s2.getExtent());
  101. });
  102. var label = document.getElementById('s2-label');
  103. label.parentNode.insertBefore(el, label);
  104. </script>
  105. </body>
  106. </html>