| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<title>dijit/place on clipped nodes unit test</title> |
| 6 |
|
| 7 |
<script src="boilerplate.js"></script> |
| 8 |
|
| 9 |
<style type="text/css"> |
| 10 |
html, body, div { |
| 11 |
border: none; |
| 12 |
margin: 0px; |
| 13 |
padding: 0px; |
| 14 |
} |
| 15 |
|
| 16 |
.around { |
| 17 |
/* the around-node (ex: a ComboBox or TextBox) */ |
| 18 |
color: white; |
| 19 |
background: blue; |
| 20 |
} |
| 21 |
|
| 22 |
.clip { |
| 23 |
/* ancestor of an around-node that clips the around-node */ |
| 24 |
display: inline-block; |
| 25 |
#display: inline; |
| 26 |
overflow: hidden; |
| 27 |
background: gray; |
| 28 |
|
| 29 |
padding: 10px 0px; |
| 30 |
margin: 0px 100px; |
| 31 |
width: 100px; |
| 32 |
} |
| 33 |
|
| 34 |
#popup { |
| 35 |
position: absolute; |
| 36 |
width: 25px; |
| 37 |
background: red; |
| 38 |
color: white; |
| 39 |
} |
| 40 |
</style> |
| 41 |
|
| 42 |
<script type="text/javascript"> |
| 43 |
require([ |
| 44 |
"doh/runner", |
| 45 |
"dojo/dom", "dojo/dom-geometry", "dojo/window", |
| 46 |
"dijit/place", "dojo/parser", "dojo/domReady!" |
| 47 |
], function(doh, dom, domGeometry, winUtils, place, parser){ |
| 48 |
|
| 49 |
parser.parse(); |
| 50 |
|
| 51 |
// The around nodes |
| 52 |
var aroundOne = dom.byId("around1"), |
| 53 |
aroundTwo = dom.byId("around2"), |
| 54 |
aroundThree = dom.byId("around3"), |
| 55 |
abs1 = dom.byId("absAround1"), |
| 56 |
abs2 = dom.byId("absAround2"), |
| 57 |
abs3 = dom.byId("absAround3"); |
| 58 |
|
| 59 |
// The popup (aka dropdown) |
| 60 |
var popup = dom.byId("popup"), |
| 61 |
pp, |
| 62 |
ret; |
| 63 |
|
| 64 |
doh.register("aroundOne", [ |
| 65 |
function plain(t){ |
| 66 |
ret = place.around(popup, aroundOne, [ |
| 67 |
"before-centered" |
| 68 |
], true); |
| 69 |
|
| 70 |
pp = domGeometry.position(popup); |
| 71 |
doh.is(100, pp.x + pp.w, "popup hugs left side of clipping div"); |
| 72 |
|
| 73 |
ret = place.around(popup, aroundOne, [ |
| 74 |
"after-centered" |
| 75 |
], true); |
| 76 |
|
| 77 |
pp = domGeometry.position(popup); |
| 78 |
doh.is(200, pp.x, "popup hugs right side of clipping div"); |
| 79 |
}, |
| 80 |
function aroundOneScrolled(t){ |
| 81 |
// Programatically scroll to the right |
| 82 |
dom.byId("clip1").scrollLeft = 50; |
| 83 |
|
| 84 |
// Same tests as before |
| 85 |
ret = place.around(popup, aroundOne, [ |
| 86 |
"before-centered" |
| 87 |
], true); |
| 88 |
|
| 89 |
pp = domGeometry.position(popup); |
| 90 |
doh.is(100, pp.x + pp.w, "popup hugs left side of clipping div"); |
| 91 |
|
| 92 |
ret = place.around(popup, aroundOne, [ |
| 93 |
"after-centered" |
| 94 |
], true); |
| 95 |
|
| 96 |
pp = domGeometry.position(popup); |
| 97 |
doh.is(200, pp.x, "popup hugs right side of clipping div"); |
| 98 |
}, |
| 99 |
function aroundOneScrollbar(t){ |
| 100 |
// Show scroll bar |
| 101 |
dom.byId("clip1").style.overflow = "scroll"; |
| 102 |
|
| 103 |
// Same tests as before |
| 104 |
ret = place.around(popup, aroundOne, [ |
| 105 |
"before-centered" |
| 106 |
], true); |
| 107 |
|
| 108 |
pp = domGeometry.position(popup); |
| 109 |
doh.is(100, pp.x + pp.w, "popup hugs left side of clipping div"); |
| 110 |
|
| 111 |
ret = place.around(popup, aroundOne, [ |
| 112 |
"after-centered" |
| 113 |
], true); |
| 114 |
|
| 115 |
pp = domGeometry.position(popup); |
| 116 |
doh.is(200, pp.x, "popup hugs right side of clipping div"); |
| 117 |
} |
| 118 |
|
| 119 |
]); |
| 120 |
|
| 121 |
doh.register("aroundTwo", [ |
| 122 |
function plain(t){ |
| 123 |
ret = place.around(popup, aroundTwo, [ |
| 124 |
"before-centered" |
| 125 |
], true); |
| 126 |
|
| 127 |
pp = domGeometry.position(popup); |
| 128 |
doh.is(100, pp.x + pp.w, "popup hugs left side of outer clipping div"); |
| 129 |
|
| 130 |
ret = place.around(popup, aroundTwo, [ |
| 131 |
"after-centered" |
| 132 |
], true); |
| 133 |
|
| 134 |
pp = domGeometry.position(popup); |
| 135 |
doh.is(200, pp.x, "popup hugs right side of outer clipping div"); |
| 136 |
} |
| 137 |
]); |
| 138 |
|
| 139 |
doh.register("aroundThree", [ |
| 140 |
function plain(t){ |
| 141 |
ret = place.around(popup, aroundThree, [ |
| 142 |
"before-centered" |
| 143 |
], true); |
| 144 |
|
| 145 |
pp = domGeometry.position(popup); |
| 146 |
doh.is(150, pp.x + pp.w, "popup hugs left side of inner clipping div"); |
| 147 |
|
| 148 |
ret = place.around(popup, aroundThree, [ |
| 149 |
"after-centered" |
| 150 |
], true); |
| 151 |
|
| 152 |
pp = domGeometry.position(popup); |
| 153 |
doh.is(250, pp.x, "popup hugs right side of inner clipping div"); |
| 154 |
} |
| 155 |
]); |
| 156 |
|
| 157 |
doh.register("absolutely positioned nodes", [ |
| 158 |
function aroundNodeAbsolute(t){ |
| 159 |
ret = place.around(popup, abs1, [ |
| 160 |
"before-centered" |
| 161 |
], true); |
| 162 |
|
| 163 |
pp = domGeometry.position(popup); |
| 164 |
doh.is(50, pp.x + pp.w, "popup hugs left side of absolutely positioned around node"); |
| 165 |
|
| 166 |
ret = place.around(popup, abs1, [ |
| 167 |
"after-centered" |
| 168 |
], true); |
| 169 |
|
| 170 |
pp = domGeometry.position(popup); |
| 171 |
doh.is(350, pp.x, "popup hugs right side of absolutely positioned around node"); |
| 172 |
}, |
| 173 |
function aroundNodeParentAbsolute(t){ |
| 174 |
ret = place.around(popup, abs2, [ |
| 175 |
"before-centered" |
| 176 |
], true); |
| 177 |
|
| 178 |
pp = domGeometry.position(popup); |
| 179 |
doh.is(60, pp.x + pp.w, "popup hugs left side of absolutely positioned around node wrapper"); |
| 180 |
|
| 181 |
ret = place.around(popup, abs2, [ |
| 182 |
"after-centered" |
| 183 |
], true); |
| 184 |
|
| 185 |
pp = domGeometry.position(popup); |
| 186 |
doh.is(120, pp.x, "popup hugs right side of absolutely positioned around node wrapper"); |
| 187 |
}, |
| 188 |
function absoluteInRelative(t){ |
| 189 |
ret = place.around(popup, abs3, [ |
| 190 |
"before-centered" |
| 191 |
], true); |
| 192 |
|
| 193 |
pp = domGeometry.position(popup); |
| 194 |
doh.is(110, pp.x + pp.w, "popup hugs left side of position:absolute parent"); |
| 195 |
|
| 196 |
ret = place.around(popup, abs3, [ |
| 197 |
"after-centered" |
| 198 |
], true); |
| 199 |
|
| 200 |
pp = domGeometry.position(popup); |
| 201 |
doh.is(170, pp.x, "popup hugs right side of position:relative grandparent (which clips parent)"); |
| 202 |
} |
| 203 |
]); |
| 204 |
doh.run(); |
| 205 |
}); |
| 206 |
|
| 207 |
</script> |
| 208 |
</head> |
| 209 |
<body class="claro" dir="ltr"> |
| 210 |
<h1>Dijit Place Clipping Unit Test</h1> |
| 211 |
|
| 212 |
|
| 213 |
<div id="popup"> |
| 214 |
p |
| 215 |
</div> |
| 216 |
|
| 217 |
|
| 218 |
<div id="clip1" class="clip"> |
| 219 |
<div id="around1" class="around" style="width: 500px; height: 50px;">123456789abcdef</div> |
| 220 |
</div> |
| 221 |
|
| 222 |
|
| 223 |
<br/> |
| 224 |
<div id="clip2a" class="clip"> |
| 225 |
<div id="clip2b" style="width: 200px; margin: 0px; background: white" class="clip"> |
| 226 |
<div id="noclip2"> |
| 227 |
<div id="around2" class="around" style="width: 500px; height: 50px;">123456789abcdef</div> |
| 228 |
</div> |
| 229 |
</div> |
| 230 |
</div> |
| 231 |
|
| 232 |
|
| 233 |
<br/> |
| 234 |
<div id="clip3a" style="width: 200px; background: yellow; padding: 10px 50px;" class="clip"> |
| 235 |
<div id="clip3b" style="margin: 0px" class="clip"> |
| 236 |
<div id="noclip3"> |
| 237 |
<div id="around3" class="around" style="width: 500px; height: 50px;">123456789abcdef</div> |
| 238 |
</div> |
| 239 |
</div> |
| 240 |
</div> |
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
<br/> |
| 245 |
<div id="clip4" class="clip"> |
| 246 |
<div id="absAround1" class="around" style="width: 300px; height: 50px; position: absolute; left: 50px; top:500px;">absolute</div> |
| 247 |
</div> |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
<br/> |
| 252 |
<div id="clip5a" style="width: 50px; background: yellow; padding: 10px 50px;" class="clip"> |
| 253 |
<div id="clip5b" style="position: absolute; left: 60px; top: 600px; width: 60px; background: navy; margin: 0px;" class="clip"> |
| 254 |
<div id="absAround2" class="around" style="width: 500px; height: 50px;">parent absolute</div> |
| 255 |
</div> |
| 256 |
</div> |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
<br/> |
| 261 |
<div id="clip6a" style="width: 70px; height: 70px; background: #adff2f; padding: 0px; position: relative;" class="clip"> |
| 262 |
<div id="clip6b" style="position: absolute; left: 10px; top: 0px; width: 150px; background: navy; margin: 0px;" class="clip"> |
| 263 |
<div id="absAround3" class="around" style="width: 500px; height: 50px;">grandparent relative</div> |
| 264 |
</div> |
| 265 |
</div> |
| 266 |
</body> |
| 267 |
</html> |