if(typeof console==="undefined"){console={};console.log=function(){}}Meetup.DomDeco.PhotoSoloGallery=function(){bindMethods(this)};Meetup.DomDeco.PhotoSoloGallery.prototype.buffers=null;Meetup.DomDeco.PhotoSoloGallery.prototype.elements=null;Meetup.DomDeco.PhotoSoloGallery.prototype.evPointers=null;Meetup.DomDeco.PhotoSoloGallery.prototype.dimensions=null;Meetup.DomDeco.PhotoSoloGallery.prototype.photoKeys=null;Meetup.DomDeco.PhotoSoloGallery.prototype.photos=null;Meetup.DomDeco.PhotoSoloGallery.prototype.copies=null;Meetup.DomDeco.PhotoSoloGallery.prototype.isAccessing=false;Meetup.DomDeco.PhotoSoloGallery.prototype.isInAnimation=false;Meetup.DomDeco.PhotoSoloGallery.prototype.index=0;Meetup.DomDeco.PhotoSoloGallery.prototype.stack=0;Meetup.DomDeco.PhotoSoloGallery.prototype.photoSizeToken="";Meetup.DomDeco.PhotoSoloGallery.prototype.urlApi="";Meetup.DomDeco.PhotoSoloGallery.prototype.urlGroup="";Meetup.DomDeco.PhotoSoloGallery.PHOTO_SIZES={six00:600,event:360,global:180,highres:null,thumb:80};Meetup.DomDeco.PhotoSoloGallery.SEC_FADING=0.5;Meetup.DomDeco.PhotoSoloGallery.TRANS_FADING="easeInCubic";Meetup.DomDeco.PhotoSoloGallery.REGEX_NUM=new RegExp(/__MM__/);Meetup.DomDeco.PhotoSoloGallery.IND_BUF_FADEOUT=0;Meetup.DomDeco.PhotoSoloGallery.IND_BUF_FADEIN=1;Meetup.DomDeco.PhotoSoloGallery.prototype.__repr__=function(){return"Meetup.DomDeco.PhotoSoloGallery"};Meetup.DomDeco.PhotoSoloGallery.prototype.decorate=function(el){if(!el){throw new Error("No elements has passed")}if(!Meetup.Data.grouphome.photos||Meetup.Data.grouphome.photos.length===0){LOG.error("No photos for this group...");return false}this.buffers={};this.elements={};this.evPointers={};this.dimensions={};this.photoKeys=[];this.photos={};this.copies={};this.photoSizeToken="event";this.urlGroup=Meetup.Data.grouphome.baseUrl;this.urlApi=this.urlGroup+"api/";var ROOT,ELMS=this.elements,DIMS=this.dimensions,COPY=this.copies,MKD=MochiKit.DOM,G1=MKD.getFirstElementByTagAndClassName,MKSC=MochiKit.Signal.connect;ELMS.root=el;ROOT=ELMS.root;ELMS.mainPhoto=G1("div","mainPhoto",ROOT);ELMS.arrowNext=G1("div","navNext",ROOT);ELMS.arrowPrev=G1("div","navPrev",ROOT);ELMS.meta=G1("div","meta",ROOT);ELMS.uploader=G1("div","uploader",ELMS.meta);ELMS.counts=G1("ul","counts",ELMS.meta);ELMS.comments=G1("li","comments",ELMS.counts);ELMS.tags=G1("li","tags",ELMS.counts);ELMS.quay=Meetup.DomDeco.PhotoSoloGallery.buildQuay();COPY.uploadedBy=Meetup.Copy.uploadedBy;COPY.comment=Meetup.Copy.commentsCountSingle;COPY.comments=Meetup.Copy.commentsCount;COPY.tag=Meetup.Copy.tagsCountSingle;COPY.tags=Meetup.Copy.tagsCount;this.buffers.fadein=G1("div","fadein",ELMS.mainPhoto);this.buffers.fadeout=G1("div","fadeout",ELMS.mainPhoto);this.resetDimensions();if(Meetup.Data.grouphome.photos.length===1){ELMS.arrowNext.style.display="none";ELMS.arrowPrev.style.display="none";return false}this.evPointers.onNextClick=MKSC(ELMS.arrowNext,"onclick",this.onNextClick);this.evPointers.onPrevClick=MKSC(ELMS.arrowPrev,"onclick",this.onPrevClick);this.evPointers.onWindowResize=MKSC(window,"onresize",this.onWindowResize);this.initializeOthers()};Meetup.DomDeco.PhotoSoloGallery.prototype.initializeOthers=function(){var photo,photoId;var MDGP=Meetup.Data.grouphome.photos;for(var i=0,len=MDGP.length;i<len;++i){photo=MDGP[i];photoId=photo.photoId;this.photos[photoId]=photo;this.photoKeys[this.photoKeys.length]=photoId}var a_photo=MochiKit.DOM.getFirstElementByTagAndClassName("a",undefined,this.buffers.fadein);var a_photo_id=Meetup.DomDeco.PhotoSoloGallery.getPhotoIdByHref(a_photo);var img_src=Meetup.DomDeco.PhotoSoloGallery.getUrlFrombackgroundImage(MochiKit.Style.getStyle(this.buffers.fadein,"background-image"));if(img_src===null){throw new Error("Something really goes wrong.")}Meetup.DomDeco.PhotoSoloGallery.loadImgAsync(img_src,partial(this.cacheImgForInit,a_photo_id),undefined,undefined,undefined,partial(this.onImgLoadError,true));delete Meetup.DomDeco.PhotoSoloGallery.prototype.initializeOthers};Meetup.DomDeco.PhotoSoloGallery.prototype.cacheImgForInit=function(id,img){this.elements.quay.appendChild(img);var dim=Meetup.DomDeco.PhotoSoloGallery.getActualDimension(img);var photo=this.photos[id];if(photo===undefined){return false}photo.w=dim.width;photo.h=dim.height;photo.cache=img;this.elements.quay.removeChild(img)};Meetup.DomDeco.PhotoSoloGallery.getUrlFrombackgroundImage=function(backgroundImage){var r=/url\((\'|\")*(.+)(\'|\")*\)/;var result=backgroundImage.match(r);if(result){result=result[2]}return result};Meetup.DomDeco.PhotoSoloGallery.getPhotoIdByHref=function(obj){var href=""+obj.getAttribute("href");var arr=href.split("/");return arr[arr.length-1]};Meetup.DomDeco.PhotoSoloGallery.prototype.onAccessFail=function(evaled){this.isAccessing=false;for(var i=0,len=arguments.length;i<len;++i){}};Meetup.DomDeco.PhotoSoloGallery.prototype.onAccessGetPhotos=function(evaled){this.isAccessing=false;if(!evaled||parseInt(evaled.count,10)<1){LOG.error("no member found");return null}var i,len,photo;for(i=0,len=evaled.length;i<len;++i){this.pushPhoto(evaled[i])}if(i===0){this.elements.mainPhoto.innerHTML="No photo has uploaded yet.";this.hideSpinner();this.hideNavArrows();return}else{if(i===1){this.hideNavArrows()}}this.onNextClick()};Meetup.DomDeco.PhotoSoloGallery.prototype.onNextClick=function(ev){if(ev){ev.stop()}this.animationDirection=true;if(this.isInAnimation){++this.stack;return}this.isInAnimation=true;var photo=this.getNextPhoto();try{if(photo===undefined){LOG.error("You seem to have a network problem.");return}if(photo.cache){this.animateSlide(photo.photoId)}else{var url=photo.urls[this.photoSizeToken];Meetup.DomDeco.PhotoSoloGallery.loadImgAsync(url,partial(this.cacheImg,photo.photoId),undefined,undefined,undefined,partial(this.onImgLoadError,true))}}catch(er){LOG.error("You seem to have a network problem:"+serializeJSON(er));return false}};Meetup.DomDeco.PhotoSoloGallery.prototype.onImgLoadError=function(direction){var photo_key=this.photoKeys[this.index];delete this.photos[photo_key];this.photoKeys.splice(this.index,1);this.isInAnimation=false;if(direction){--this.index;this.onNextClick()}else{++this.index;this.onPrevClick()}};Meetup.DomDeco.PhotoSoloGallery.prototype.onPrevClick=function(ev){if(ev){ev.preventDefault();ev.stopPropagation()}this.animationDirection=false;if(this.isInAnimation){--this.stack;return}this.isInAnimation=true;var photo=this.getPrevPhoto();try{if(photo===undefined){LOG.error("You seem to have a network problem.");return}if(photo.cache){this.animateSlide(photo.photoId)}else{Meetup.DomDeco.PhotoSoloGallery.loadImgAsync(photo.urls[this.photoSizeToken],partial(this.cacheImg,photo.photoId),undefined,undefined,undefined,partial(this.onImgLoadError,false))}}catch(er){LOG.error("You seem to have a network problem: "+serializeJSON(er))}};Meetup.DomDeco.PhotoSoloGallery.prototype.onWindowResize=function(){this.resetDimensions()};Meetup.DomDeco.PhotoSoloGallery.prototype.updateMeta=function(){var photo=this.photos[this.photoKeys[this.index]];var ELMS=this.elements;var wrap=DIV();if(photo===undefined){LOG.error("You seem to have a network problem");return}if(photo.memberId!==null){var a=A({href:this.makeMemberUrl(photo)});a.innerHTML=photo.memberName;wrap.appendChild(a)}else{wrap.innerHTML=photo.memberName}ELMS.uploader.innerHTML=this.copies.uploadedBy.replace(Meetup.DomDeco.PhotoSoloGallery.REGEX_NUM,wrap.innerHTML);ELMS.tags.innerHTML="";var a_tag;var url=this.makePhotoUrl(photo);if(photo.tags===1){a_tag=A({href:url},this.copies.tag.replace(Meetup.DomDeco.PhotoSoloGallery.REGEX_NUM,photo.tags))}else{a_tag=A({href:url},this.copies.tags.replace(Meetup.DomDeco.PhotoSoloGallery.REGEX_NUM,photo.tags))}ELMS.tags.appendChild(a_tag);var a_com;ELMS.comments.innerHTML="";if(photo.comments===1){a_com=A({href:url},this.copies.comment.replace(Meetup.DomDeco.PhotoSoloGallery.REGEX_NUM,photo.comments))}else{a_com=A({href:url},this.copies.comments.replace(Meetup.DomDeco.PhotoSoloGallery.REGEX_NUM,photo.comments))}ELMS.comments.appendChild(a_com)};Meetup.DomDeco.PhotoSoloGallery.prototype.finishAnimation=function(){this.isInAnimation=false;this.buffers.fadeout.innerHTML="";this.updateMeta();if(this.stack===0){return}if(this.animationDirection){--this.stack}else{++this.stack}if(this.stack>0){this.onNextClick()}else{this.onPrevClick()}};Meetup.DomDeco.PhotoSoloGallery.prototype.accessGetPhotos=function(){var def,opt,mid=Member.id||0,cid=Chapter.id;opt={method:"getLatestChapterPhotos",arg_chapterId:cid,arg_memberId:mid,arg_begin:0,arg_limit:25};this.isAccessing=true;def=Meetup.Http.post(this.urlApi,MochiKit.Base.queryString(opt));def.addCallbacks(this.onAccessGetPhotos,this.onAccessFail)};Meetup.DomDeco.PhotoSoloGallery.prototype.makePhotoUrl=function(photo){return this.urlGroup+"photos/"+photo.photoAlbumId+"/"+photo.photoId};Meetup.DomDeco.PhotoSoloGallery.prototype.makeMemberUrl=function(photo){return this.urlGroup+"members/"+photo.memberId+"/"};Meetup.DomDeco.PhotoSoloGallery.prototype.makeMarginLeft=function(photo){var result=0;if((photo.w!==0)&&(this.dimensions.mainPhoto.w<photo.w)){result=Math.round((this.dimensions.mainPhoto.w-photo.w)/2)}return result};Meetup.DomDeco.PhotoSoloGallery.prototype.makeMarginTop=function(photo){var result=Math.round((this.dimensions.mainPhoto.h-photo.h)/2);if(photo.h===0){result=0}return result};Meetup.DomDeco.PhotoSoloGallery.prototype.animateSlide=function(photoId){var elm,fadeout=this.buffers.fadeout,fadein=this.buffers.fadein,photo=this.photos[photoId],MKSS=MochiKit.Style.setStyle,TIME=Meetup.DomDeco.PhotoSoloGallery.SEC_FADING,TRANS=Meetup.DomDeco.PhotoSoloGallery.TRANS_FADING;var curFadeinBg=MochiKit.Style.getStyle(fadein,"background-image");if(curFadeinBg){fadeout.style.backgroundImage=curFadeinBg}if(fadein.childNodes.length>0){fadeout.appendChild(fadein.firstChild)}MKSS(fadeout,{display:"block",visibility:"visible",opacity:1});MKSS(fadein,{display:"block",visibility:"visible",opacity:0});var futFadeinBg=Meetup.DomDeco.PhotoSoloGallery.buildBGImageString(photo.cache.src);fadein.style.backgroundImage=futFadeinBg;fadein.appendChild(A({href:this.makePhotoUrl(photo)}," "));Meetup.Tweener.addTween(fadeout,{opacity:0,time:TIME,transition:TRANS});Meetup.Tweener.addTween(fadein,{opacity:1,time:TIME,transition:TRANS});window.setTimeout(this.finishAnimation,(TIME*1010))};Meetup.DomDeco.PhotoSoloGallery.prototype.cacheImg=function(id,img){this.elements.quay.appendChild(img);var dim=Meetup.DomDeco.PhotoSoloGallery.getActualDimension(img);var photo=this.photos[id];if(photo===undefined){return false}photo.w=dim.width;photo.h=dim.height;photo.cache=img;img.alt="";img.title=photo.caption;this.animateSlide(id);this.elements.quay.removeChild(img)};Meetup.DomDeco.PhotoSoloGallery.prototype.getBuffer=function(index){throw new Error("obsolete")};Meetup.DomDeco.PhotoSoloGallery.prototype.getNextPhoto=function(incr){incr=incr||1;var photo,next_index=this.index+incr;if(next_index>=this.photoKeys.length){this.index=next_index%this.photoKeys.length}else{this.index=next_index}return this.photos[this.photoKeys[this.index]]};Meetup.DomDeco.PhotoSoloGallery.prototype.getPrevPhoto=function(incr){incr=incr||1;if(this.index===-1){this.index=0}var photo,mod,next_index=this.index-incr;if(next_index<0){this.index=this.photoKeys.length+(next_index%this.photoKeys.length)}else{this.index=next_index}return this.photos[this.photoKeys[this.index]]};Meetup.DomDeco.PhotoSoloGallery.prototype.hideNavArrows=function(){MochiKit.Signal.disconnect(this.evPointers.onNextClick);MochiKit.Signal.disconnect(this.evPointers.onPrevClick);this.elements.arrowNext.style.display="none";this.elements.arrowPrev.style.display="none"};Meetup.DomDeco.PhotoSoloGallery.prototype.hideSpinner=function(){this.elements.mainPhoto.style.backgroundImage="none"};Meetup.DomDeco.PhotoSoloGallery.prototype.pushPhoto=function(photo){var id=photo.photoId;if(id&&this.photos[id]===undefined){this.photos[id]=photo;this.photoKeys[this.photoKeys.length]=id}};Meetup.DomDeco.PhotoSoloGallery.prototype.resetDimensions=function(){this.dimensions.mainPhoto=MochiKit.Style.getElementDimensions(this.elements.mainPhoto)};Meetup.DomDeco.PhotoSoloGallery.buildBGImageString=function(url){return["url(",url,")"].join("")};Meetup.DomDeco.PhotoSoloGallery.buildPhoto=function(img,url,ml,mt){var a=A({href:url});a.appendChild(img);a.style.marginLeft=ml+"px";a.style.marginTop=mt+"px";return a};Meetup.DomDeco.PhotoSoloGallery.buildQuay=function(){var div=DIV();div.style.visibility="hidden";div.style.display="block";div.style.position="absolute";div.style.top="1px";div.style.left="1px";div.style.width="360px";div.style.height="360px";div.style.zoom="1";document.body.appendChild(div);return div};Meetup.DomDeco.PhotoSoloGallery.buildUrlForGroupBase=function(){LOG.error("buildUrlForGroupBase is deprecated");var i,arr_original=window.location.href.split("/"),arr=[];for(i=0;i<4;++i){arr[arr.length]=arr_original[i]}arr[arr.length]="";return arr.join("/")};Meetup.DomDeco.PhotoSoloGallery.getActualDimension=function(image){if("naturalWidth" in image){return{width:image.naturalWidth,height:image.naturalHeight}}var run,mem,w=0,h=0,key="actual";if("src" in image){if(image[key]&&image[key].src===image.src){return image[key]}if(document.uniqueID){w=image.width;h=image.height}else{var fn=function(){w=image.width;h=image.height};mem={w:image.width,h:image.height};image.removeAttribute("width");image.addEventListener("DOMAttrModified",fn,false);image.removeAttribute("height");image.removeEventListener("DOMAttrModified",fn,false);image.width=mem.w;image.height=mem.h}image[key]={width:w,height:h,src:image.src};return image[key]}return{width:image.width,height:image.height}};Meetup.DomDeco.PhotoSoloGallery.loadImgAsync=function(abspath,onLoad,tick,delay,timeout,funcError){tick=tick||0;delay=delay||72;timeout=timeout||10000;if(!funcError){funcError=function(ev){if(img.finish){return}img.finish=true;throw new Error("The given file path doesn't seem to exist")}}var img=new Image();img.finish=false;img.onabort=funcError;img.onerror=funcError;img.onload=function(ev){img.finish=true;if(window.opera&&!img.complete){LOG.error("Opera specific problem")}onLoad(img)};img.src=abspath;if(!img.finish&&timeout){window.setTimeout(function(){if(img.finish){return}if(img.complete){img.finish=true;if(img.width){return}funcError()}if((tick+=delay)>timeout){img.finish=true;funcError()}setTimeout(arguments.callee,delay)},5)}};