Debian Codegraph @

closure-library/closure/goog/demos/roundedpanel.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 Demo file for goog.ui.RoundedPanel component
12 -->
13 <head>
14 <title>goog.ui.RoundedPanel Demo</title>
15 <link rel="stylesheet" href="css/demo.css">
16 <link rel="stylesheet" href="../css/roundedpanel.css">
17 <script src="../base.js"></script>
18 <script>
19 goog.require('goog.dom');
20 goog.require('goog.ui.RoundedPanel');
21 </script>
22 <script>
23 var INT_BASE = 10;
24 var rp;
25
26 /**
27 * Decorates roundedPanel node through a RoundedPanel instance.
28 */
29 function decorateRoundedPanel() {
30 // Obtain the values from the 'input' and 'select' elements.
31 var panelWidth = goog.dom.getElement('panelWidth').value;
32 var panelHeight = goog.dom.getElement('panelHeight').value;
33 var borderWidth = parseInt(
34 goog.dom.getElement('borderWidth').value,
35 INT_BASE);
36 var borderColor = goog.dom.getElement('borderColor').value;
37 var radius = parseInt(goog.dom.getElement('radius').value, INT_BASE);
38 var backgroundColor = goog.dom.getElement('backgroundColor').value;
39 var cornersSelect = goog.dom.getElement('corners');
40 var corners = parseInt(
41 cornersSelect.options[cornersSelect.selectedIndex].value);
42
43 // Dispose of any existing RoundedPanel instance before creating
44 // a new one.
45 if (rp) {
46 rp.dispose();
47 rp = null;
48 }
49
50 // Set the dimensions of the panel and decorate roundedPanel.
51 var roundedPanelNode = goog.dom.getElement('roundedPanel');
52 roundedPanelNode.style.height = panelHeight;
53 roundedPanelNode.style.width = panelWidth;
54 var startTime = new Date();
55 rp = goog.ui.RoundedPanel.create(radius,
56 borderWidth,
57 borderColor,
58 backgroundColor,
59 corners);
60 rp.decorate(roundedPanelNode);
61 var endTime = new Date();
62
63 // Display the amount of time taken to render the RoundedPanel.
64 var debugNode = goog.dom.getElement('debug');
65 debugNode.innerHTML = 'Rendering time: ' +
66 (endTime - startTime) + 'ms';
67 };
68
69
70 /**
71 * Sets event handlers on the 'input' and 'select' elements containing
72 * values needed to create the rounded panel.
73 */
74 function init() {
75 // Set the event handler for the 'select' element to update the panel
76 // when onchange fires.
77 var cornersSelect = goog.dom.getElement('corners');
78 cornersSelect.onchange = decorateRoundedPanel;
79
80 // Set the event handlers for the 'input' elements to update the panel
81 // when onchange fires.
82 var inputs = goog.dom.getElementsByTagNameAndClass(null, 'rpInput');
83 for (var i = 0; i < inputs.length; i++) {
84 inputs[i].onchange = decorateRoundedPanel;
85 }
86
87 decorateRoundedPanel();
88 };
89 </script>
90 </head>
91 <body>
92 <div id="roundedPanel">
93 <div class="goog-roundedpanel-content">
94 <div>
95 Panel Width:<br>
96 <input type="text" class="rpInput" id="panelWidth">
97 </div>
98 <div>
99 Panel Height:<br>
100 <input type="text" class="rpInput" id="panelHeight">
101 </div>
102 <div>
103 Border Width:<br>
104 <input type="text" class="rpInput" value="1" id="borderWidth">
105 </div>
106 <div>
107 Border Color:<br>
108 <input type="text" class="rpInput" value="#fedcba" id="borderColor">
109 </div>
110 <div>
111 Radius:<br>
112 <input type="text" class="rpInput" value="1" id="radius">
113 </div>
114 <div>
115 Background Color:<br>
116 <input type="text" class="rpInput" value="#abcdef" id="backgroundColor">
117 </div>
118 <div>
119 Corners:<br>
120 <select id="corners">
121 <option value="15">All</option>
122 <option value="12">Top</option>
123 <option value="3">Bottom</option>
124 <option value="6">Left</option>
125 <option value="9">Right</option>
126 <option value="4">Top Left</option>
127 <option value="8">Top Right</option>
128 <option value="2">Bottom Left</option>
129 <option value="1">Bottom Right</option>
130 </select>
131 </div>
132 <div id="debug">Rendering Time:</div>
133 </div>
134 </div>
135 <script type="text/javascript">
136 init();
137 </script>
138 </body>
139 </html>