dojox.image.ThumbnailPicker._loadImage
dojo.require("dojox.image.ThumbnailPicker");
defined in dojox/image/ThumbnailPicker.js
Usage
function (data, index, callback) (view source)
var url = this.imageStore.getValue(data,this.imageThumbAttr); var img = document.createElement("img"); var imgContainer = document.createElement("div"); imgContainer.setAttribute("id","img_" + this.widgetid+"_"+index); imgContainer.appendChild(img); img._index = index; img._data = data; this._thumbs[index] = imgContainer; var loadingDiv; if(this.useLoadNotifier){ loadingDiv = document.createElement("div"); loadingDiv.setAttribute("id","loadingDiv_" + this.widgetid+"_"+index); //If this widget was previously told that the main image for this //thumb has been loaded, make the loading indicator transparent. this._setThumbClass(loadingDiv, this._loadedImages[index] ? "thumbLoaded":"thumbNotifier"); imgContainer.appendChild(loadingDiv); } var size = dojo.marginBox(this.thumbsNode); var defaultSize; var sizeParam; if(this.isHorizontal){ defaultSize = this.thumbWidth; sizeParam = 'w'; } else{ defaultSize = this.thumbHeight; sizeParam = 'h'; } size = size[sizeParam]; var sl = this.thumbScroller.scrollLeft, st = this.thumbScroller.scrollTop; dojo.style(this.thumbsNode, this._sizeProperty, (size + defaultSize + 20) + "px"); //Remember the scroll values, as changing the size can alter them this.thumbScroller.scrollLeft = sl; this.thumbScroller.scrollTop = st; this.thumbsNode.appendChild(imgContainer); dojo.connect(img, "onload", this, function(){ var realSize = dojo.marginBox(img)[sizeParam]; this._totalSize += (Number(realSize) + 4); dojo.style(this.thumbsNode, this._sizeProperty, this._totalSize + "px"); if(this.useLoadNotifier){dojo.style(loadingDiv, "width", (img.width - 4) + "px"); } callback(); return false; }); dojo.connect(img, "onclick", this, function(evt){ dojo.publish(this.getClickTopicName(), [{ index: evt.target._index, data: evt.target._data, url: img.getAttribute("src"), largeUrl: this.imageStore.getValue(data,this.imageLargeAttr), title: this.imageStore.getValue(data,this.titleAttr), link: this.imageStore.getValue(data,this.linkAttr) }]); return false; }); dojo.addClass(img, "imageGalleryThumb"); img.setAttribute("src", url); var title = this.imageStore.getValue(data, this.titleAttr); if(title){ img.setAttribute("title",title); } this._updateNavControls();
parameter | type | description |
---|---|---|
data | ||
index | ||
callback |