| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>goog.fx.Dragger</title> |
| 5 |
<meta charset="utf-8"> |
| 6 |
<link rel="stylesheet" href="css/demo.css"> |
| 7 |
<script src="../base.js"></script> |
| 8 |
<script> |
| 9 |
goog.require('goog.fx.Dragger'); |
| 10 |
goog.require('goog.dom'); |
| 11 |
goog.require('goog.style'); |
| 12 |
</script> |
| 13 |
<style> |
| 14 |
#frame { |
| 15 |
position: absolute; |
| 16 |
left: 99px; |
| 17 |
top: 99px; |
| 18 |
width: 802px; |
| 19 |
height: 502px; |
| 20 |
border: 1px solid #999; |
| 21 |
background-color: #F0F0F0; |
| 22 |
} |
| 23 |
|
| 24 |
.window { |
| 25 |
position:absolute; |
| 26 |
left: 150px; |
| 27 |
top: 110px; |
| 28 |
width: 300px; |
| 29 |
height: 100px; |
| 30 |
background-color: rgb(200,200,250); |
| 31 |
border: 1px solid #99F; |
| 32 |
font: bold 11px/18px arial; |
| 33 |
text-indent: 10px; |
| 34 |
color: #FFF; |
| 35 |
} |
| 36 |
|
| 37 |
#win2 { |
| 38 |
top:250px; |
| 39 |
background-color: rgb(250,200,200); |
| 40 |
border: 1px solid #F99; |
| 41 |
} |
| 42 |
|
| 43 |
#win3 { |
| 44 |
left:500px; |
| 45 |
background-color: rgb(150,200,150); |
| 46 |
border: 1px solid #6A6; |
| 47 |
} |
| 48 |
|
| 49 |
.bar { |
| 50 |
position:absolute; |
| 51 |
left: 0px; |
| 52 |
top: 0px; |
| 53 |
width: 300px; |
| 54 |
height: 20px; |
| 55 |
background-color: #99F; |
| 56 |
cursor: default; |
| 57 |
} |
| 58 |
#win2 .bar { background-color: #F99; } |
| 59 |
#win3 .bar { background-color: #6A6; } |
| 60 |
|
| 61 |
#sliderback { |
| 62 |
position: absolute; |
| 63 |
left: 50px; |
| 64 |
top: 98px; |
| 65 |
height: 505px; |
| 66 |
width: 1px; |
| 67 |
font-size: 1px; |
| 68 |
background-color: #999; |
| 69 |
} |
| 70 |
|
| 71 |
#slider { |
| 72 |
position: absolute; |
| 73 |
left: 35px; |
| 74 |
top: 98px; |
| 75 |
width: 30px; |
| 76 |
height: 13px; |
| 77 |
font: normal 10px verdana; |
| 78 |
background-color: #EEE; |
| 79 |
color: #000; |
| 80 |
text-align:center; |
| 81 |
border: 1px solid #999; |
| 82 |
cursor: default; |
| 83 |
} |
| 84 |
|
| 85 |
#ghostbox { |
| 86 |
position: absolute; |
| 87 |
left: 100px; |
| 88 |
top: 625px; |
| 89 |
width: 600px; |
| 90 |
height: 20px; |
| 91 |
} |
| 92 |
|
| 93 |
.block { |
| 94 |
position: absolute; |
| 95 |
left: 0px; |
| 96 |
top: 0px; |
| 97 |
width: 125px; |
| 98 |
height: 20px; |
| 99 |
font: bold 11px/18px arial; |
| 100 |
background-color: #AAA; |
| 101 |
color: #EEE; |
| 102 |
text-align: center; |
| 103 |
border: 1px solid #666; |
| 104 |
} |
| 105 |
|
| 106 |
.ghost0 { left: 0px; } |
| 107 |
.ghost1 { left: 130px; } |
| 108 |
.ghost2 { left: 260px; } |
| 109 |
.ghost3 { left: 390px; } |
| 110 |
|
| 111 |
</style> |
| 112 |
</head> |
| 113 |
<body> |
| 114 |
<h1>goog.fx.Dragger</h1> |
| 115 |
<p><strong>Demonstrations of the drag utiities</strong>.</p> |
| 116 |
|
| 117 |
<div id="frame"></div> |
| 118 |
|
| 119 |
<div id="win1" class="window"><div class="bar">Drag Me...</div></div> |
| 120 |
<div id="win2" class="window"><div class="bar">Drag Me...</div></div> |
| 121 |
<div id="win3" class="window"><div class="bar">Drag Me...</div></div> |
| 122 |
|
| 123 |
<div id="sliderback"></div> |
| 124 |
<div id="slider">0</div> |
| 125 |
|
| 126 |
|
| 127 |
<script> |
| 128 |
|
| 129 |
var $ = goog.dom.getElement; |
| 130 |
|
| 131 |
// WINDOW EXAMPLE |
| 132 |
//================ |
| 133 |
|
| 134 |
var Z = 5; |
| 135 |
|
| 136 |
var limits = new goog.math.Rect(100, 100, 500, 400) ; |
| 137 |
|
| 138 |
var window1 = new goog.fx.Dragger($('win1'), $('win1').firstChild, limits); |
| 139 |
var window2 = new goog.fx.Dragger($('win2'), $('win2').firstChild, limits); |
| 140 |
var window3 = new goog.fx.Dragger($('win3'), $('win3').firstChild); |
| 141 |
|
| 142 |
window3.setHysteresis(6); |
| 143 |
|
| 144 |
function setZ(e) { |
| 145 |
this.target.style.zIndex = Z++; |
| 146 |
goog.style.setOpacity(this.target, 0.50); |
| 147 |
} |
| 148 |
|
| 149 |
function end(e) { |
| 150 |
goog.style.setOpacity(this.target, 1); |
| 151 |
} |
| 152 |
|
| 153 |
goog.events.listen(window1, 'start', setZ); |
| 154 |
goog.events.listen(window2, 'start', setZ); |
| 155 |
goog.events.listen(window3, 'start', setZ); |
| 156 |
|
| 157 |
goog.events.listen(window1, 'end', end); |
| 158 |
goog.events.listen(window2, 'end', end); |
| 159 |
goog.events.listen(window3, 'end', end); |
| 160 |
|
| 161 |
|
| 162 |
// SLIDER EXAMPLE |
| 163 |
//================ |
| 164 |
|
| 165 |
var slider1 = new goog.fx.Dragger($('slider'), null, |
| 166 |
new goog.math.Rect(35, 98, 0, 490)); |
| 167 |
|
| 168 |
goog.events.listen(slider1, 'drag', function(e) { |
| 169 |
var percent = Math.round(100 * (e.top - e.dragger.limits.top) / |
| 170 |
e.dragger.limits.height); |
| 171 |
$('slider').innerHTML = percent; |
| 172 |
}); |
| 173 |
|
| 174 |
|
| 175 |
goog.events.listen(window, 'unload', function(e) { |
| 176 |
window1.dispose(); |
| 177 |
window2.dispose(); |
| 178 |
window3.dispose(); |
| 179 |
|
| 180 |
slider1.dispose(); |
| 181 |
}); |
| 182 |
|
| 183 |
</script> |
| 184 |
</body> |
| 185 |
</html> |
| 186 |
<!-- |
| 187 |
Copyright 2010 The Closure Library Authors. All Rights Reserved. |
| 188 |
|
| 189 |
Use of this source code is governed by the Apache License, Version 2.0. |
| 190 |
See the COPYING file for details. |
| 191 |
--> |