Debian Codegraph @

closure-library/closure/goog/demos/scrollfloater.html

raw
1 <!DOCTYPE html>
2 <html>
3 <!--
4 Copyright 2008 The Closure Library Authors. All Rights Reserved.
5
6 Use of this source code is governed by the Apache License, Version 2.0.
7 See the COPYING file for details.
8 -->
9 <!--
10 -->
11 <head>
12 <title>ScrollFloater</title>
13 <script src="../base.js"></script>
14
15 <script>
16 goog.require('goog.dom');
17 goog.require('goog.events');
18 goog.require('goog.ui.ScrollFloater');
19 goog.require('goog.ui.ToggleButton');
20 </script>
21 <link rel="stylesheet" href="../css/button.css">
22 <style>
23 table {
24 border: 1px solid black;
25 width: 100%;
26 height: 1500px;
27 }
28
29 .left-cell {
30 color: black;
31 background-color: lightgray;
32 width: 33%;
33 vertical-align: top;
34 }
35
36 .cell {
37 background-color: lightblue;
38 width: 33%;
39 vertical-align: top;
40 }
41
42 .spacer {
43 border: 1px solid black;
44 height: 200px;
45 }
46
47 .goog-scrollfloater {
48 border: 1px solid black;
49 height: 150px;
50 width: 90%;
51 color: black;
52 background-color: blue;
53 background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a4e7fc), color-stop(100%,#00aadd));
54 background: gradient(linear, left top, left bottom, color-stop(0%,#a4e7fc), color-stop(100%,#00aadd));
55 }
56
57 #floater3 {
58 padding-top: 500px;
59 }
60 </style>
61 </head>
62 <body>
63 <form action="javascript:void(0)">
64 <table style="border: 1px solid black">
65 <tr>
66 <td class="left-cell">
67 <div class="spacer">
68 This content does not float.
69 </div>
70 <div class="spacer">
71 This content does not float.
72 </div>
73 <div id="floater1">
74 This floater is constrained within a container and has a top offset of 50px.
75 </div>
76 </td>
77 <td class="cell">
78 <div class="spacer">
79 This content does not float.
80 </div>
81 <div id="floater2container">
82 </div>
83 </td>
84 <td class="cell">
85 <div class="spacer">
86 This content does not float.
87 </div>
88 <!-- The purpose of this position:relative element is to ensure that
89 we're checking more than just the offsetTop of the floating
90 child. -->
91 <div style="position: relative">
92 <div id="floater3">
93 This floater is very tall.
94 <p>
95 This tall floater is pinned to the bottom of the window when
96 your window is shorter and floats at the top when it is taller.
97 </div>
98 </div>
99 </td>
100 </tr>
101 </table>
102 <div style="height:1500px"></div>
103 <p>This is the bottom of the page.</p>
104 </form>
105
106 <script>
107 var parentForm = document.getElementsByTagName('form')[0];
108
109 var scrollfloater1 = new goog.ui.ScrollFloater();
110 var button1 = new goog.ui.ToggleButton("Enable Floater 1");
111 button1.render(goog.dom.getElement('floater1'));
112 scrollfloater1.setViewportTopOffset(50);
113 scrollfloater1.setContainerElement(goog.dom.getElement('floater1').parentElement);
114 scrollfloater1.decorate(goog.dom.getElement('floater1'));
115
116 var scrollfloater2 = new goog.ui.ScrollFloater();
117
118 var button2 = new goog.ui.ToggleButton("Enable Floater 2");
119 scrollfloater2.addChild(button2, true);
120 scrollfloater2.render(goog.dom.getElement('floater2container'));
121
122 var scrollfloater3 = new goog.ui.ScrollFloater();
123 scrollfloater3.decorate(goog.dom.getElement('floater3'));
124
125 function setupClickHandler(ctrl, floater) {
126 goog.events.listen(ctrl, goog.ui.Component.EventType.ACTION,
127 function() {
128 floater.setScrollingEnabled(ctrl.isChecked());
129 });
130 }
131
132 button1.setState(goog.ui.Component.State.CHECKED, true);
133 button2.setState(goog.ui.Component.State.CHECKED, true);
134 setupClickHandler(button1, scrollfloater1);
135 setupClickHandler(button2, scrollfloater2);
136 </script>
137 </body>
138 </html>