| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>dojox.image.Lightbox Tests | The Dojo Toolkit</title> |
| 5 |
|
| 6 |
|
| 7 |
<link rel="stylesheet" id="themeStyles" href="../../../dijit/themes/claro/claro.css"> |
| 8 |
<link rel="stylesheet" href="../resources/image.css"> |
| 9 |
|
| 10 |
<style type="text/css"> |
| 11 |
@import "../../../dojo/resources/dojo.css"; |
| 12 |
@import "../../../dijit/tests/css/dijitTests.css"; |
| 13 |
body, html { width:100%; height:100%; margin:0; padding:0; } |
| 14 |
|
| 15 |
#customTitleThing { |
| 16 |
height:75px; |
| 17 |
border:1px solid #ededed; |
| 18 |
overflow:auto; |
| 19 |
width:92%; |
| 20 |
} |
| 21 |
</style> |
| 22 |
|
| 23 |
|
| 24 |
<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug:true, parseOnLoad: true"></script> |
| 25 |
|
| 26 |
|
| 27 |
<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script> |
| 28 |
|
| 29 |
|
| 30 |
<script type="text/javascript"> |
| 31 |
require(["dojo", "dijit/form/Button", "dojox/image/Lightbox", "dojox/data/FlickrStore", "dojo/parser", "dojo/domReady!"], function(){ |
| 32 |
|
| 33 |
// sample with super-rich text content (no widgets or undelegated events please). |
| 34 |
|
| 35 |
var title = dojo.byId("customExample").innerHTML; |
| 36 |
dojo.empty("customExample"); |
| 37 |
|
| 38 |
var lb = new dojox.image.Lightbox({ |
| 39 |
href:"images/square.jpg", |
| 40 |
title: title |
| 41 |
}); |
| 42 |
lb.startup(); |
| 43 |
|
| 44 |
new dijit.form.Button({ |
| 45 |
onClick: function(){ |
| 46 |
lb.show(); |
| 47 |
}, |
| 48 |
label:"Custom HTML" |
| 49 |
}).placeAt("container"); |
| 50 |
|
| 51 |
// and example that has events: |
| 52 |
var elb = new dojox.image.LightboxDialog({}); |
| 53 |
elb.connect(elb.textNode, "onclick", function(e){ |
| 54 |
e.preventDefault(); |
| 55 |
elb.show({ |
| 56 |
leaveTitle:true, |
| 57 |
href: dojo.attr(e.target, "href") |
| 58 |
}); |
| 59 |
}) |
| 60 |
elb.startup(); |
| 61 |
|
| 62 |
var content = "<a href='images/chris1_lg.jpg'>chris1<a/>" |
| 63 |
+ " | <a href='images/chris2_lg.jpg'>chris2</a>" |
| 64 |
+ " | <a href='images/chris3_lg.jpg'>chris3</a>" |
| 65 |
; |
| 66 |
|
| 67 |
new dijit.form.Button({ |
| 68 |
onClick:function(){ |
| 69 |
elb.show({ |
| 70 |
title:content, |
| 71 |
href:"images/chris1_lg.jpg" |
| 72 |
}); |
| 73 |
}, |
| 74 |
label:"Custom Links" |
| 75 |
}).placeAt("container"); |
| 76 |
|
| 77 |
// and example of onClick for the image (to hide the lightbox); |
| 78 |
var clb = new dojox.image.Lightbox({ |
| 79 |
title:"fun fun fun fun", |
| 80 |
href:"images/chris1_lg.jpg", |
| 81 |
onClick: function(){ |
| 82 |
this.hide(); |
| 83 |
} |
| 84 |
}); |
| 85 |
clb.startup(); |
| 86 |
|
| 87 |
new dijit.form.Button({ |
| 88 |
label:"Custom Click", |
| 89 |
onClick: function(){ |
| 90 |
clb.show() |
| 91 |
} |
| 92 |
}).placeAt("container"); |
| 93 |
|
| 94 |
// and example of onClick for the image (to toggle between large/small); |
| 95 |
var clb2 = new dojox.image.Lightbox({ |
| 96 |
title:"fun fun fun fun", // friday, friday! |
| 97 |
href:"images/chris1_sm.jpg", |
| 98 |
onClick: function(info){ |
| 99 |
|
| 100 |
this.href = info.href == "images/chris1_lg.jpg" ? "images/chris1_sm.jpg" : "images/chris1_lg.jpg"; |
| 101 |
this.show({ |
| 102 |
leaveTitle:true, |
| 103 |
href: this.href |
| 104 |
}); |
| 105 |
} |
| 106 |
}); |
| 107 |
clb2.startup(); |
| 108 |
|
| 109 |
new dijit.form.Button({ |
| 110 |
label:"Zoomish Click", |
| 111 |
onClick: function(){ |
| 112 |
clb2.show() |
| 113 |
} |
| 114 |
}).placeAt("container"); |
| 115 |
|
| 116 |
dojo.query("#groupremover").onclick(function(e){ |
| 117 |
e.preventDefault(); |
| 118 |
var g = dijit.byId("targetremover"); |
| 119 |
console.warn(g); |
| 120 |
if(g){ |
| 121 |
// destroying a dojox.image.Lightbox will remove itself from |
| 122 |
// the LightboxDialog |
| 123 |
g.destroy(); |
| 124 |
} |
| 125 |
|
| 126 |
// test showing group 3 after removal: |
| 127 |
var lbd = dijit.byId("dojoxLightboxDialog"); // the master |
| 128 |
lbd.show({ |
| 129 |
title:"Should Only be three remaining", |
| 130 |
group:"group3" |
| 131 |
}); |
| 132 |
}) |
| 133 |
|
| 134 |
dojo.query("#groupkiller").onclick(function(e){ |
| 135 |
e.preventDefault(); |
| 136 |
var lbd = dijit.byId("dojoxLightboxDialog"); |
| 137 |
lbd.removeGroup("group3"); |
| 138 |
}); |
| 139 |
|
| 140 |
}); |
| 141 |
|
| 142 |
// programatic flickrstore implementation [basic] |
| 143 |
function onComplete(items,request){ |
| 144 |
if(items.length > 0){ |
| 145 |
var lightbox = dijit.byId("fromStore"); |
| 146 |
dojo.forEach(items, function(item){ |
| 147 |
var part = { |
| 148 |
title: flickrStore.getValue(item,"title"), |
| 149 |
href: flickrStore.getValue(item,"imageUrl") |
| 150 |
}; |
| 151 |
this.addImage(part, "flickrStore"); |
| 152 |
}, lightbox); |
| 153 |
dijit.byId('flickrButton').set("disabled", false); |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
function onError(error,request){ |
| 158 |
console.warn(error,request); |
| 159 |
} |
| 160 |
|
| 161 |
function init(){ |
| 162 |
var flickrRequest = { |
| 163 |
query: {}, |
| 164 |
onComplete: onComplete, |
| 165 |
onError: onError, |
| 166 |
userid: "jetstreet", |
| 167 |
tags: "jetstreet", |
| 168 |
count: 10 |
| 169 |
}; |
| 170 |
flickrStore.fetch(flickrRequest); |
| 171 |
} |
| 172 |
dojo.ready(init); |
| 173 |
</script> |
| 174 |
|
| 175 |
</head> |
| 176 |
<body class="claro"> |
| 177 |
|
| 178 |
<div id="container" style="padding:20px;"> |
| 179 |
<h1 class="testTitle">a Dojo based Lightbox implementation:</h1> |
| 180 |
|
| 181 |
<h3>Individual</h3> |
| 182 |
<p> |
| 183 |
<a href="images/imageVert.jpg" dojoType="dojox.image.Lightbox" title="More Guatemala...">tall</a> |
| 184 |
<a href="images/imageHoriz.jpg" dojoType="dojox.image.Lightbox" title="Antigua, Guatemala">4:3 image</a> |
| 185 |
<a href="images/broken.jpg" dojoType="dojox.image.Lightbox" title="broken href example">Broken link</a> |
| 186 |
</p> |
| 187 |
|
| 188 |
<h3>Oversized</h3> |
| 189 |
<p> |
| 190 |
<a href="images/supertall.gif" dojoType="dojox.image.Lightbox" title="a large image">super tall image</a> |
| 191 |
<a href="images/superwide.gif" dojoType="dojox.image.Lightbox" title="a large image">super wide image</a> |
| 192 |
<a href="images/huuuge.png" modal="true" dojoType="dojox.image.Lightbox" title="a large image">large than viewport?</a> (also modal, no click on underlay) |
| 193 |
<a href="images/huuuge.png" dojoType="dojox.image.Lightbox" title="a large image with a really really long multi-line-title because I can. Okay, this title has to be really really supremely long in order to occupy the full width of the viewport provided. yymv.">large than viewport, long title</a> |
| 194 |
</p> |
| 195 |
|
| 196 |
<h3>Grouped:</h3> |
| 197 |
<p> |
| 198 |
<a href="images/imageHoriz2.jpg" dojoType="dojox.image.Lightbox" group="group1" title="Amsterdam Train Depot but this title is going to be really really really really long just because">wide image, multiline title</a> |
| 199 |
<a href="images/square.jpg" dojoType="dojox.image.Lightbox" group="group1" title="1:1 aspect">square</a> |
| 200 |
<a href="images/extraWide.jpg" dojoType="dojox.image.Lightbox" group="group1" title="Greeneville, TN">wide image</a> |
| 201 |
<a href="images/broken.jpg" dojoType="dojox.image.Lightbox" group="group1" title="broken href example">Broken link</a> |
| 202 |
</p> |
| 203 |
|
| 204 |
<h3>Alternate Group:</h3> |
| 205 |
<p> |
| 206 |
<a href="images/imageHoriz2.jpg" dojoType="dojox.image.Lightbox" group="group2" title="hmm <em>right</em> there is <b>rich text</b> here">Rich Text Title</a> |
| 207 |
<a href="images/square.jpg" dojoType="dojox.image.Lightbox" group="group2" title="1:1 aspect">square</a> |
| 208 |
<a href="images/imageHoriz.jpg" dojoType="dojox.image.Lightbox" group="group2" title="Antigua, Guatemala">4:3 image</a> |
| 209 |
<a href="images/imageVert.jpg" dojoType="dojox.image.Lightbox" group="group2" title="More Guatemala...">tall</a> |
| 210 |
</p> |
| 211 |
|
| 212 |
<h3>RemoveGroup Group3:</h3> |
| 213 |
<p> |
| 214 |
<a id="targetremover" href="images/imageHoriz2.jpg" dojoType="dojox.image.Lightbox" group="group3" title="hmm <em>right</em> there is <b>rich text</b> here">Rich Text Title</a> |
| 215 |
<a href="images/square.jpg" dojoType="dojox.image.Lightbox" group="group3" title="1:1 aspect">square</a> |
| 216 |
<a href="images/imageHoriz.jpg" dojoType="dojox.image.Lightbox" group="group3" title="Antigua, Guatemala">4:3 image</a> |
| 217 |
<a href="images/imageVert.jpg" dojoType="dojox.image.Lightbox" group="group3" title="More Guatemala...">tall</a> |
| 218 |
</p> |
| 219 |
<p> |
| 220 |
<a href='#' id="groupremover">remove one from group3, then show group</a> | <a href="#" id="groupkiller">remove group3</a> |
| 221 |
</p> |
| 222 |
|
| 223 |
<h3>From dojox.data.FlickrStore:</h3> |
| 224 |
|
| 225 |
<div dojoType="dojox.data.FlickrStore" data-dojo-id="flickrStore" label="title"></div> |
| 226 |
<div id="fromStore" dojoType="dojox.image.LightboxDialog" store="flickrStore" group="flickrStore"></div> |
| 227 |
|
| 228 |
<button dojoType="dijit.form.Button" id="flickrButton" disabled="disabled"> |
| 229 |
Show Flickr lightbox |
| 230 |
<script type="dojo/connect" data-dojo-event="onClick"> |
| 231 |
dijit.byId('fromStore').show({ group:"flickrStore" }); |
| 232 |
</script> |
| 233 |
</button> |
| 234 |
|
| 235 |
</div> |
| 236 |
|
| 237 |
<div id="customExample"> |
| 238 |
<div id="customTitleThing"> |
| 239 |
<p>lorem ipsum dolor amit</p> |
| 240 |
<p>lorem ipsum dolor amit</p> |
| 241 |
<p>lorem ipsum dolor amit</p> |
| 242 |
<p>lorem ipsum dolor amit</p> |
| 243 |
<p>lorem ipsum dolor amit</p> |
| 244 |
<p>lorem ipsum dolor amit</p> |
| 245 |
</div> |
| 246 |
</div> |
| 247 |
|
| 248 |
</body> |
| 249 |
</html> |