| 1 |
dojo.provide("dojox.image.Gallery"); |
| 2 |
dojo.experimental("dojox.image.Gallery"); |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
dojo.require("dojo.fx"); |
| 12 |
dojo.require("dijit._Widget"); |
| 13 |
dojo.require("dijit._Templated"); |
| 14 |
dojo.require("dojox.image.ThumbnailPicker"); |
| 15 |
dojo.require("dojox.image.SlideShow"); |
| 16 |
|
| 17 |
dojo.declare("dojox.image.Gallery", |
| 18 |
[dijit._Widget, dijit._Templated], |
| 19 |
{ |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
imageHeight: 375, |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
imageWidth: 500, |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
pageSize: dojox.image.SlideShow.prototype.pageSize, |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
autoLoad: true, |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
linkAttr: "link", |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
imageThumbAttr: "imageUrlThumb", |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
imageLargeAttr: "imageUrl", |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
titleAttr: "title", |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
slideshowInterval: 3, |
| 63 |
|
| 64 |
templateString: dojo.cache("dojox.image", "resources/Gallery.html"), |
| 65 |
|
| 66 |
postCreate: function(){ |
| 67 |
|
| 68 |
|
| 69 |
this.widgetid = this.id; |
| 70 |
this.inherited(arguments) |
| 71 |
|
| 72 |
this.thumbPicker = new dojox.image.ThumbnailPicker({ |
| 73 |
linkAttr: this.linkAttr, |
| 74 |
imageLargeAttr: this.imageLargeAttr, |
| 75 |
imageThumbAttr: this.imageThumbAttr, |
| 76 |
titleAttr: this.titleAttr, |
| 77 |
useLoadNotifier: true, |
| 78 |
size: this.imageWidth |
| 79 |
}, this.thumbPickerNode); |
| 80 |
|
| 81 |
|
| 82 |
this.slideShow = new dojox.image.SlideShow({ |
| 83 |
imageHeight: this.imageHeight, |
| 84 |
imageWidth: this.imageWidth, |
| 85 |
autoLoad: this.autoLoad, |
| 86 |
linkAttr: this.linkAttr, |
| 87 |
imageLargeAttr: this.imageLargeAttr, |
| 88 |
titleAttr: this.titleAttr, |
| 89 |
slideshowInterval: this.slideshowInterval, |
| 90 |
pageSize: this.pageSize |
| 91 |
}, this.slideShowNode); |
| 92 |
|
| 93 |
var _this = this; |
| 94 |
|
| 95 |
|
| 96 |
dojo.subscribe(this.slideShow.getShowTopicName(), function(packet){ |
| 97 |
_this.thumbPicker._showThumbs(packet.index); |
| 98 |
}); |
| 99 |
|
| 100 |
dojo.subscribe(this.thumbPicker.getClickTopicName(), function(evt){ |
| 101 |
_this.slideShow.showImage(evt.index); |
| 102 |
}); |
| 103 |
|
| 104 |
|
| 105 |
dojo.subscribe(this.thumbPicker.getShowTopicName(), function(evt){ |
| 106 |
_this.slideShow.moveImageLoadingPointer(evt.index); |
| 107 |
}); |
| 108 |
|
| 109 |
|
| 110 |
dojo.subscribe(this.slideShow.getLoadTopicName(), function(index){ |
| 111 |
_this.thumbPicker.markImageLoaded(index); |
| 112 |
}); |
| 113 |
this._centerChildren(); |
| 114 |
}, |
| 115 |
|
| 116 |
setDataStore: function(dataStore, request, paramNames){ |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
this.thumbPicker.setDataStore(dataStore, request, paramNames); |
| 130 |
this.slideShow.setDataStore(dataStore, request, paramNames); |
| 131 |
}, |
| 132 |
|
| 133 |
reset: function(){ |
| 134 |
|
| 135 |
|
| 136 |
this.slideShow.reset(); |
| 137 |
this.thumbPicker.reset(); |
| 138 |
}, |
| 139 |
|
| 140 |
showNextImage: function(inTimer){ |
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
this.slideShow.showNextImage(); |
| 147 |
}, |
| 148 |
|
| 149 |
toggleSlideshow: function(){ |
| 150 |
dojo.deprecated("dojox.widget.Gallery.toggleSlideshow is deprecated. Use toggleSlideShow instead.", "", "2.0"); |
| 151 |
this.toggleSlideShow(); |
| 152 |
}, |
| 153 |
|
| 154 |
toggleSlideShow: function(){ |
| 155 |
|
| 156 |
|
| 157 |
this.slideShow.toggleSlideShow(); |
| 158 |
}, |
| 159 |
|
| 160 |
showImage: function(index, callback){ |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
this.slideShow.showImage(index, callback); |
| 168 |
}, |
| 169 |
|
| 170 |
resize: function(dim){ |
| 171 |
this.thumbPicker.resize(dim); |
| 172 |
}, |
| 173 |
|
| 174 |
_centerChildren: function() { |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
var thumbSize = dojo.marginBox(this.thumbPicker.outerNode); |
| 179 |
var slideSize = dojo.marginBox(this.slideShow.outerNode); |
| 180 |
|
| 181 |
var diff = (thumbSize.w - slideSize.w) / 2; |
| 182 |
|
| 183 |
if(diff > 0) { |
| 184 |
dojo.style(this.slideShow.outerNode, "marginLeft", diff + "px"); |
| 185 |
} else if(diff < 0) { |
| 186 |
dojo.style(this.thumbPicker.outerNode, "marginLeft", (diff * -1) + "px"); |
| 187 |
} |
| 188 |
} |
| 189 |
}); |