| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<!-- |
| 4 |
Copyright 2010 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 |
<head> |
| 10 |
<title>goog.ui.SplitPane</title> |
| 11 |
<script src="../base.js"></script> |
| 12 |
|
| 13 |
<script> |
| 14 |
goog.require('goog.dom'); |
| 15 |
goog.require('goog.events'); |
| 16 |
goog.require('goog.ui.Component'); |
| 17 |
goog.require('goog.ui.Ratings'); |
| 18 |
goog.require('goog.ui.ServerChart'); |
| 19 |
goog.require('goog.ui.SplitPane'); |
| 20 |
goog.require('goog.ui.SplitPane.Orientation'); |
| 21 |
</script> |
| 22 |
<link rel="stylesheet" href="css/demo.css"> |
| 23 |
<style class="text/css"> |
| 24 |
|
| 25 |
/* NOTE: A bug in Safari 3 requires these css definitions to be in here. |
| 26 |
Do not move these to a separate file without testing safari 3! */ |
| 27 |
|
| 28 |
/* These are recommended styles for the default splitpane */ |
| 29 |
.goog-splitpane { |
| 30 |
height: 200px; |
| 31 |
width: 300px; |
| 32 |
} |
| 33 |
|
| 34 |
.goog-splitpane-handle { |
| 35 |
border-left: 1px solid gray; |
| 36 |
border-right: 1px solid gray; |
| 37 |
background: #ccc; |
| 38 |
position: absolute; |
| 39 |
} |
| 40 |
|
| 41 |
.goog-splitpane-handle-horizontal { |
| 42 |
cursor: col-resize; |
| 43 |
} |
| 44 |
|
| 45 |
.goog-splitpane-handle-vertical { |
| 46 |
cursor: row-resize; |
| 47 |
} |
| 48 |
|
| 49 |
.goog-splitpane-first-container, |
| 50 |
.goog-splitpane-second-container { |
| 51 |
border: 5px solid black; |
| 52 |
overflow: auto; |
| 53 |
position: absolute; |
| 54 |
} |
| 55 |
|
| 56 |
/* The rest of these styles are for the splitpane demo, splitpane.html */ |
| 57 |
|
| 58 |
/* Example of styling a particular handle */ |
| 59 |
#another-splitpane .goog-splitpane-handle { |
| 60 |
background: gray; |
| 61 |
} |
| 62 |
|
| 63 |
/* The following styles are for the rating widget, which is used in the splipane |
| 64 |
example. These have nothing to do with the splitpane! */ |
| 65 |
.goog-ratings { |
| 66 |
display: block; |
| 67 |
float: left; |
| 68 |
height: 20px; |
| 69 |
height: 20px; |
| 70 |
} |
| 71 |
|
| 72 |
.goog-ratings-star { |
| 73 |
display: block; |
| 74 |
float: left; |
| 75 |
padding-left: 13px; |
| 76 |
height: 19px; |
| 77 |
cursor: pointer; |
| 78 |
background-image: url('../images/ratingstars.gif'); |
| 79 |
background-repeat: no-repeat; |
| 80 |
} |
| 81 |
|
| 82 |
.goog-ratings-firststar-off { |
| 83 |
padding-left: 20px; |
| 84 |
background-position: 0px 0px; |
| 85 |
} |
| 86 |
|
| 87 |
.goog-ratings-firststar-on { |
| 88 |
padding-left: 20px; |
| 89 |
background-position: 0px -20px; |
| 90 |
} |
| 91 |
|
| 92 |
.goog-ratings-midstar-off { |
| 93 |
background-position: 0px -40px; |
| 94 |
} |
| 95 |
|
| 96 |
.goog-ratings-midstar-on { |
| 97 |
background-position: 0px -60px; |
| 98 |
} |
| 99 |
|
| 100 |
.goog-ratings-laststar-off { |
| 101 |
padding-left: 18px; |
| 102 |
background-position: 0px -80px; |
| 103 |
} |
| 104 |
|
| 105 |
.goog-ratings-laststar-on { |
| 106 |
padding-left: 18px; |
| 107 |
background-position: 0px -100px; |
| 108 |
} |
| 109 |
</style> |
| 110 |
</head> |
| 111 |
<body> |
| 112 |
<h1>goog.ui.SplitPane</h1> |
| 113 |
Left Component Size: <input type='text' id='firstComponentSize' size='4' value=''> |
| 114 |
Width: <input type='text' id='newWidth' size='5' value='300'> |
| 115 |
Height: <input type='text' id='newHeight' size='5' value='200'> |
| 116 |
<br> |
| 117 |
<input type='radio' id='select1' name='selectSplitter' checked='true' value='first'>First One |
| 118 |
<input type='radio' id='select2' name='selectSplitter' value='second'>Second One |
| 119 |
<input type='button' value='Update Splitter' onclick='updatePane_()'> |
| 120 |
<input type='button' value='Change Orientation' onclick='changeOrientation_()'> |
| 121 |
<p> |
| 122 |
<div class='goog-splitpane' id='anotherSplitter'> |
| 123 |
<div class='goog-splitpane-first-container'> |
| 124 |
Left Frame |
| 125 |
</div> |
| 126 |
<div class='goog-splitpane-second-container'> |
| 127 |
<iframe style='z-index:10; width:100%; height:100%' src='http://www.google.com/'></iframe> |
| 128 |
</div> |
| 129 |
<div class='goog-splitpane-handle'></div> |
| 130 |
</div> |
| 131 |
First Component Width: <span id='componentOneWidth'></span> |
| 132 |
|
| 133 |
<div id="test1"> |
| 134 |
<select name="sel"> |
| 135 |
<option>Aweful</option> |
| 136 |
<option>Bad</option> |
| 137 |
<option selected>Ok</option> |
| 138 |
<option>Good</option> |
| 139 |
<option>Excellent</option> |
| 140 |
</select> |
| 141 |
</div> |
| 142 |
<p/> |
| 143 |
|
| 144 |
|
| 145 |
<p/> |
| 146 |
<div id="chart"></div> |
| 147 |
|
| 148 |
<script> |
| 149 |
|
| 150 |
/** |
| 151 |
* Show the width of the first splitpane on event changes. |
| 152 |
* @param {goog.events.Event} e The event |
| 153 |
*/ |
| 154 |
var showWidth_ = function(e) { |
| 155 |
var el = document.getElementById('componentOneWidth'); |
| 156 |
if (el) { |
| 157 |
goog.dom.setTextContent(el, e.target.getFirstComponentSize()); |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
var lhs = new goog.ui.Component(); |
| 162 |
var rhs = new goog.ui.Component(); |
| 163 |
|
| 164 |
// Set up splitpane with already existing DOM. |
| 165 |
var splitpane1 = new goog.ui.SplitPane(lhs, rhs, |
| 166 |
goog.ui.SplitPane.Orientation.HORIZONTAL); |
| 167 |
|
| 168 |
// Listen for change events and call showWidth. |
| 169 |
goog.events.listen(splitpane1, goog.ui.Component.EventType.CHANGE, |
| 170 |
showWidth_); |
| 171 |
|
| 172 |
|
| 173 |
splitpane1.setInitialSize(100); |
| 174 |
splitpane1.setHandleSize(10); |
| 175 |
splitpane1.decorate(document.getElementById('anotherSplitter')); |
| 176 |
splitpane1.setSize(new goog.math.Size(600,300)); |
| 177 |
|
| 178 |
var rw1 = new goog.ui.Ratings(); |
| 179 |
rw1.decorate(document.getElementById('test1')); |
| 180 |
|
| 181 |
// Create a barchart to put in a splitpane |
| 182 |
bar = new goog.ui.ServerChart(goog.ui.ServerChart.ChartType.BAR, 180, 104); |
| 183 |
bar.addDataSet([8,23,7], '008000'); |
| 184 |
bar.addDataSet([31,11,7], 'ffcc33'); |
| 185 |
bar.addDataSet([2,43,70,3,43,74], '3072f3'); |
| 186 |
bar.setLeftLabels(['','20K','','60K','','100K']); |
| 187 |
bar.setXLabels(['O','N','D']); |
| 188 |
bar.setMaxValue(100); |
| 189 |
|
| 190 |
var splitpane2 = new goog.ui.SplitPane(rw1, bar, |
| 191 |
goog.ui.SplitPane.Orientation.HORIZONTAL); |
| 192 |
splitpane2.render(); |
| 193 |
|
| 194 |
splitpane2.setContinuousResize(false); |
| 195 |
|
| 196 |
/** |
| 197 |
* Change the left splitter size or size a split pane. |
| 198 |
* This method reads the form fields to choose the splitter |
| 199 |
* and get the new values. |
| 200 |
*/ |
| 201 |
var updatePane_ = function() { |
| 202 |
var componentSizeValue = |
| 203 |
document.getElementById('firstComponentSize').value; |
| 204 |
var width = document.getElementById('newWidth').value; |
| 205 |
var height = document.getElementById('newHeight').value; |
| 206 |
var s1Checked = document.getElementById('select1').checked; |
| 207 |
// Which splitter to update. |
| 208 |
var whichSplitter = (s1Checked) ? splitpane1 : splitpane2; |
| 209 |
|
| 210 |
var componentSize; |
| 211 |
if ('' != componentSizeValue) { |
| 212 |
componentSize = parseInt(componentSizeValue, 10); |
| 213 |
} |
| 214 |
else { |
| 215 |
componentSize = whichSplitter.getFirstComponentSize(); |
| 216 |
} |
| 217 |
whichSplitter.setFirstComponentSize(componentSize); |
| 218 |
whichSplitter.setSize(new goog.math.Size(width, height)); |
| 219 |
|
| 220 |
// If the first pane height is changed, force the second one to update |
| 221 |
// so it moves up or down the page. |
| 222 |
splitpane2.setFirstComponentSize(); |
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* Change the orientation of the splitter pane. |
| 227 |
*/ |
| 228 |
var changeOrientation_ = function() { |
| 229 |
var s1Checked = document.getElementById('select1').checked; |
| 230 |
// Which splitter to update. |
| 231 |
var whichSplitter = s1Checked ? splitpane1 : splitpane2; |
| 232 |
var orientation = whichSplitter.getOrientation(); |
| 233 |
if (orientation == goog.ui.SplitPane.Orientation.VERTICAL) { |
| 234 |
whichSplitter.setOrientation(goog.ui.SplitPane.Orientation.HORIZONTAL); |
| 235 |
} else { |
| 236 |
whichSplitter.setOrientation(goog.ui.SplitPane.Orientation.VERTICAL); |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
</script> |
| 241 |
|
| 242 |
</body> |
| 243 |
</html> |