| 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.fx.DragListGroup</title> |
| 11 |
<meta charset="utf-8"> |
| 12 |
<script src="../base.js"></script> |
| 13 |
<script> |
| 14 |
goog.require('goog.dom'); |
| 15 |
goog.require('goog.fx.DragListDirection'); |
| 16 |
goog.require('goog.fx.DragListGroup'); |
| 17 |
</script> |
| 18 |
<link rel="stylesheet" href="css/demo.css"> |
| 19 |
<style> |
| 20 |
body { |
| 21 |
font-family: verdana, sans-serif; |
| 22 |
} |
| 23 |
|
| 24 |
.hr_clear { |
| 25 |
float: none; |
| 26 |
clear: both; |
| 27 |
height: 0px; |
| 28 |
padding: 10px 0px 0px 0px; |
| 29 |
border: 0px; |
| 30 |
margin: 0px; |
| 31 |
visibility: hidden; |
| 32 |
} |
| 33 |
|
| 34 |
.bug { |
| 35 |
color: red; |
| 36 |
font-style: italic; |
| 37 |
} |
| 38 |
|
| 39 |
.horiz1_class, |
| 40 |
.horiz3_class, |
| 41 |
.horiz5_class { |
| 42 |
padding: 8px 12px; |
| 43 |
/* box_height + 2 * (padding + border + margin) = |
| 44 |
50 + 2 * (5 + 2 + 4) = 72px */ |
| 45 |
height: 72px; |
| 46 |
border: 2px solid #000000; |
| 47 |
} |
| 48 |
.horiz1_class { float: left; } |
| 49 |
.horiz3_class { float: left; } |
| 50 |
.horiz5_class { float: left; } |
| 51 |
|
| 52 |
.horiz1_class div { float: left; } |
| 53 |
.horiz3_class div { float: right; } |
| 54 |
.horiz5_class div { float: left; } |
| 55 |
|
| 56 |
.horiz5_class { |
| 57 |
width: 288px; |
| 58 |
height: 216px; |
| 59 |
} |
| 60 |
|
| 61 |
.vert_table td { |
| 62 |
vertical-align: top; |
| 63 |
padding: 0px 20px; |
| 64 |
} |
| 65 |
|
| 66 |
.vert1_class, |
| 67 |
.vert2_class { |
| 68 |
padding: 12px 8px; |
| 69 |
/* box_width + 2 * (padding + border + margin) = |
| 70 |
50 + 2 * (5 + 2 + 2) = 68px */ |
| 71 |
width: 68px; |
| 72 |
border: 2px solid #000000; |
| 73 |
} |
| 74 |
|
| 75 |
div.red_box, |
| 76 |
div.yellow_box, |
| 77 |
div.blue_box, |
| 78 |
div.purple_box { |
| 79 |
width: 50px; |
| 80 |
height: 50px; |
| 81 |
padding: 5px; |
| 82 |
margin: 4px 2px; |
| 83 |
font-family: verdana, sans-serif; |
| 84 |
font-size: 36px; |
| 85 |
font-weight: bold; |
| 86 |
text-align: center; |
| 87 |
} |
| 88 |
div.red_box { |
| 89 |
border: 2px solid #CC0000; |
| 90 |
color: #CC0000; |
| 91 |
} |
| 92 |
div.yellow_box { |
| 93 |
border: 2px solid #CCCC00; |
| 94 |
color: #CCCC00; |
| 95 |
} |
| 96 |
div.blue_box { |
| 97 |
border: 2px solid #0000CC; |
| 98 |
color: #0000CC; |
| 99 |
} |
| 100 |
div.purple_box { |
| 101 |
border: 2px solid #993399; |
| 102 |
color: #993399; |
| 103 |
} |
| 104 |
|
| 105 |
#test { |
| 106 |
background-color: #CCFFCC; |
| 107 |
width: 100px; |
| 108 |
height: 100px; |
| 109 |
padding: 13px; |
| 110 |
border: 11px solid #339933; |
| 111 |
margin: 15px; |
| 112 |
} |
| 113 |
|
| 114 |
/* The following styles are used in the JS. */ |
| 115 |
|
| 116 |
.cursor_pointer { |
| 117 |
cursor: pointer; |
| 118 |
} |
| 119 |
|
| 120 |
.cursor_move { |
| 121 |
cursor: move; |
| 122 |
-moz-user-select: none; |
| 123 |
} |
| 124 |
|
| 125 |
.opacity_40 { |
| 126 |
opacity: 0.4; |
| 127 |
-moz-opacity: 0.4; |
| 128 |
filter: alpha(opacity=40); |
| 129 |
} |
| 130 |
|
| 131 |
.drag_hover_class { |
| 132 |
border-color: #009900; |
| 133 |
background-color: #CCFFCC; |
| 134 |
} |
| 135 |
</style> |
| 136 |
</head> |
| 137 |
<body> |
| 138 |
|
| 139 |
<h1>goog.fx.DragListGroup</h1> |
| 140 |
<h2>You can drag any squares into any of the first 4 lists.</h2> |
| 141 |
<hr class="hr_clear"> |
| 142 |
|
| 143 |
<h4>Horizontal list 1 (grows right):</h4> |
| 144 |
<div id="horiz1_div" class="horiz1_class"> |
| 145 |
<div class="red_box">1</div> |
| 146 |
<div class="red_box">2</div> |
| 147 |
<div class="red_box">3</div> |
| 148 |
<div class="red_box">4</div> |
| 149 |
</div> |
| 150 |
<hr class="hr_clear"> |
| 151 |
|
| 152 |
<table class="vert_table"> |
| 153 |
<tr> |
| 154 |
|
| 155 |
<td> |
| 156 |
<h4>Vertical list 1:</h4> |
| 157 |
<div id="vert1_div" class="vert1_class"> |
| 158 |
<div class="blue_box">1</div> |
| 159 |
<div class="blue_box">2</div> |
| 160 |
<div class="blue_box">3</div> |
| 161 |
<div class="blue_box">4</div> |
| 162 |
</div> |
| 163 |
</td> |
| 164 |
|
| 165 |
<td> |
| 166 |
<h4>Vertical list 2 (style changes on drag hover):</h4> |
| 167 |
<div id="vert2_div" class="vert2_class"> |
| 168 |
<div class="purple_box">1</div> |
| 169 |
<div class="purple_box">2</div> |
| 170 |
<div class="purple_box">3</div> |
| 171 |
<div class="purple_box">4</div> |
| 172 |
</div> |
| 173 |
</td> |
| 174 |
|
| 175 |
</tr> |
| 176 |
</table> |
| 177 |
<hr class="hr_clear"> |
| 178 |
<h4>Horizontal list 3 (grows left):</h4> |
| 179 |
<p class="bug">Bug: drop position is off by one.</p> |
| 180 |
<div id="horiz3_div" class="horiz3_class"> |
| 181 |
<div class="yellow_box">1</div> |
| 182 |
<div class="yellow_box">2</div> |
| 183 |
<div class="yellow_box">3</div> |
| 184 |
<div class="yellow_box">4</div> |
| 185 |
</div> |
| 186 |
<hr class="hr_clear"> |
| 187 |
|
| 188 |
<h4>Horizontal list 5 (grows right, has multiple rows, hysteresis is enabled):</h4> |
| 189 |
<p class="bug">Bug: can't drop into the last row.</p> |
| 190 |
<div id="horiz5_div" class="horiz5_class"> |
| 191 |
<div class="blue_box">11</div> |
| 192 |
<div class="blue_box">22</div> |
| 193 |
<div class="blue_box">33</div> |
| 194 |
<div class="blue_box">44</div> |
| 195 |
<div class="blue_box">55</div> |
| 196 |
<div class="blue_box">66</div> |
| 197 |
<div class="blue_box">77</div> |
| 198 |
<div class="blue_box">88</div> |
| 199 |
<div class="blue_box">99</div> |
| 200 |
</div> |
| 201 |
<hr class="hr_clear"> |
| 202 |
|
| 203 |
<h4>The items in this list can be moved around with shift-dragging:</h4> |
| 204 |
<div id="horiz6_div" class="horiz1_class"> |
| 205 |
<div class="red_box">1</div> |
| 206 |
<div class="red_box">2</div> |
| 207 |
<div class="red_box">3</div> |
| 208 |
<div class="red_box">4</div> |
| 209 |
</div> |
| 210 |
<hr class="hr_clear"> |
| 211 |
|
| 212 |
<h4>The items have different width:</h4> |
| 213 |
<p class="bug"> |
| 214 |
Bug: the drop positions are off. |
| 215 |
For example try moving box 1 a bit to the left. |
| 216 |
</p> |
| 217 |
<div id="horiz7_div" class="horiz1_class"> |
| 218 |
<div class="red_box" style="width: 200px">1</div> |
| 219 |
<div class="red_box">2</div> |
| 220 |
<div class="red_box" style="width: 200px">3</div> |
| 221 |
<div class="red_box">4</div> |
| 222 |
</div> |
| 223 |
<hr class="hr_clear"> |
| 224 |
<script> |
| 225 |
|
| 226 |
var dlg = new goog.fx.DragListGroup(); |
| 227 |
dlg.setDragItemHoverClass('cursor_move'); |
| 228 |
dlg.setDraggerElClass('cursor_move opacity_40'); |
| 229 |
|
| 230 |
dlg.addDragList(goog.dom.getElement('horiz1_div'), |
| 231 |
goog.fx.DragListDirection.RIGHT); |
| 232 |
dlg.addDragList(goog.dom.getElement('horiz3_div'), |
| 233 |
goog.fx.DragListDirection.LEFT); |
| 234 |
dlg.addDragList(goog.dom.getElement('vert1_div'), |
| 235 |
goog.fx.DragListDirection.DOWN); |
| 236 |
dlg.addDragList(goog.dom.getElement('vert2_div'), |
| 237 |
goog.fx.DragListDirection.DOWN, true, 'drag_hover_class'); |
| 238 |
|
| 239 |
dlg.init(); |
| 240 |
|
| 241 |
var dlg2 = new goog.fx.DragListGroup(); |
| 242 |
dlg2.setDragItemHoverClass('cursor_move'); |
| 243 |
dlg2.setDraggerElClass('cursor_move opacity_40'); |
| 244 |
dlg2.setCurrDragItemClass('opacity_40'); |
| 245 |
dlg2.setIsCurrDragItemAlwaysDisplayed(); |
| 246 |
dlg2.addDragList(goog.dom.getElement('horiz5_div'), |
| 247 |
goog.fx.DragListDirection.RIGHT_2D); |
| 248 |
dlg2.setHysteresis(5); |
| 249 |
dlg2.init(); |
| 250 |
|
| 251 |
var dlg3 = new goog.fx.DragListGroup(); |
| 252 |
dlg3.setDragItemHoverClass('cursor_move'); |
| 253 |
dlg3.setDraggerElClass('cursor_move opacity_40'); |
| 254 |
dlg3.addDragList(goog.dom.getElement('horiz6_div'), |
| 255 |
goog.fx.DragListDirection.RIGHT); |
| 256 |
goog.events.listen(dlg3, goog.fx.DragListGroup.EventType.BEFOREDRAGSTART, |
| 257 |
function(e) { |
| 258 |
if (!e.event.shiftKey) { |
| 259 |
e.preventDefault(); |
| 260 |
} |
| 261 |
}); |
| 262 |
dlg3.init(); |
| 263 |
|
| 264 |
var dlg4 = new goog.fx.DragListGroup(); |
| 265 |
dlg4.setDragItemHoverClass('cursor_move'); |
| 266 |
dlg4.setDraggerElClass('cursor_move opacity_40'); |
| 267 |
dlg4.setIsCurrDragItemAlwaysDisplayed(); |
| 268 |
dlg4.addDragList(goog.dom.getElement('horiz7_div'), |
| 269 |
goog.fx.DragListDirection.RIGHT); |
| 270 |
dlg4.init(); |
| 271 |
</script> |
| 272 |
</body> |
| 273 |
</html> |