//>>built
define(["dijit","dojo","dojox","dojo/require!dijit/_WidgetBase,dojo/string"],function(_1,_2,_3){
_2.provide("dojox.mobile.app.ImageThumbView");
_2.experimental("dojox.mobile.app.ImageThumbView");
_2.require("dijit._WidgetBase");
_2.require("dojo.string");
_2.declare("dojox.mobile.app.ImageThumbView",_1._WidgetBase,{items:[],urlParam:"url",labelParam:null,itemTemplate:"
",minPadding:4,maxPerRow:3,maxRows:-1,baseClass:"mblImageThumbView",thumbSize:"medium",animationEnabled:true,selectedIndex:-1,cache:null,cacheMustMatch:false,clickEvent:"onclick",cacheBust:false,disableHide:false,constructor:function(_4,_5){
},postCreate:function(){
this.inherited(arguments);
var _6=this;
var _7="mblThumbHover";
this.addThumb=_2.hitch(this,this.addThumb);
this.handleImgLoad=_2.hitch(this,this.handleImgLoad);
this.hideCached=_2.hitch(this,this.hideCached);
this._onLoadImages={};
this.cache=[];
this.visibleImages=[];
this._cacheCounter=0;
this.connect(this.domNode,this.clickEvent,function(_8){
var _9=_6._getItemNodeFromEvent(_8);
if(_9&&!_9._cached){
_6.onSelect(_9._item,_9._index,_6.items);
_2.query(".selected",this.domNode).removeClass("selected");
_2.addClass(_9,"selected");
}
});
_2.addClass(this.domNode,this.thumbSize);
this.resize();
this.render();
},onSelect:function(_a,_b,_c){
},_setAnimationEnabledAttr:function(_d){
this.animationEnabled=_d;
_2[_d?"addClass":"removeClass"](this.domNode,"animated");
},_setItemsAttr:function(_e){
this.items=_e||[];
var _f={};
var i;
for(i=0;i0){
_12=_12.touches[0];
}
return this._getItemNode(_12.target);
},resize:function(){
this._thumbSize=null;
this._size=_2.contentBox(this.domNode);
this.disableHide=true;
this.render();
this.disableHide=false;
},hideCached:function(){
for(var i=0;i0){
_14=this.visibleImages.pop();
this.cache.push(_14);
if(!this.disableHide){
_2.addClass(_14,"hidden");
}
_14._cached=true;
}
if(this.cache&&this.cache.length>0){
setTimeout(this.hideCached,1000);
}
if(!this.items||this.items.length==0){
return;
}
for(i=0;i0&&(i+1)/this.maxPerRow>=this.maxRows){
break;
}
}
if(!this._thumbSize){
return;
}
var _15=0;
var row=-1;
var _16=this._thumbSize.w+(this.padding*2);
var _17=this._thumbSize.h+(this.padding*2);
var _18=this.thumbNodes=_2.query(".mblThumb",this.domNode);
var pos=0;
_18=this.visibleImages;
for(i=0;i<_18.length;i++){
if(_18[i]._cached){
continue;
}
if(pos%this.maxPerRow==0){
row++;
}
_15=pos%this.maxPerRow;
this.place(_18[i],(_15*_16)+this.padding,(row*_17)+this.padding);
if(!_18[i]._loading){
_2.removeClass(_18[i],"hidden");
}
if(pos==this.selectedIndex){
_2[pos==this.selectedIndex?"addClass":"removeClass"](_18[i],"selected");
}
pos++;
}
var _19=Math.ceil(pos/this.maxPerRow);
this._numRows=_19;
this.setContainerHeight((_19*(this._thumbSize.h+this.padding*2)));
},setContainerHeight:function(_1a){
_2.style(this.domNode,"height",_1a+"px");
},addThumb:function(_1b,url,_1c){
var _1d;
var _1e=false;
if(this.cache.length>0){
var _1f=false;
for(var i=0;i-1?"&":"?")+"cacheBust="+(new Date()).getTime()+"_"+(this._cacheCounter++);
}
_2.query(".mblThumbSrc",img._thumbDiv).style("backgroundImage","url("+url+")");
delete this._onLoadImages[img._url];
},calcPadding:function(){
var _23=this._size.w;
var _24=this._thumbSize.w;
var _25=_24+this.minPadding;
this.maxPerRow=Math.floor(_23/_25);
this.padding=Math.floor((_23-(_24*this.maxPerRow))/(this.maxPerRow*2));
},place:function(_26,x,y){
_2.style(_26,{"-webkit-transform":"translate("+x+"px,"+y+"px)"});
},destroy:function(){
var img;
var _27=0;
for(var url in this._onLoadImages){
img=this._onLoadImages[url];
if(img){
img.src=null;
_27++;
}
}
this.inherited(arguments);
}});
});