YUI.add("flickr-people-getPhotosOf-fetcher",function(e,o){"use strict";e.namespace("ListFetchers")["flickr-people-getPhotosOf"]={run:function(t,s){var r=this;return e.Promise.all([s.callAPI("flickr.people.getPhotosOf",this._processParams(t),!0),s.getModelRegistry("photo-models"),s.getModelRegistry("person-models"),s.getModelRegistry("photosof-models"),s.getModelRegistry("photo-engagement-models"),s.getModelRegistry("photo-stats-models")]).then(function(e){return r._processResponse(e,t)},e.FetcherErrorLogger(o))},_processParams:function(o){var t;if(t={extras:e.APIHelper.request.getRebootPhotoExtras(),per_page:o.perPage||20,page:o.page||1,get_user_info:1},o.id)t.user_id=o.id;else{if(!o.pathAlias)throw new Error("[flickr-people-getPhotosOf-fetcher] `id` or `pathAlias` is required.");t.path_alias=o.pathAlias}return t},_processResponse:function(o,t){var s,r,p=o[0],a=o[1],i=o[2],l=o[3],h=o[4],n=o[5];return s={id:p.user.nsid,pathAlias:p.user.pathAlias,totalItems:parseInt(p.photos.total,10)},r=e.APIHelper.response.parsePerson(p.user),s.owner=i.addOrUpdate(r),s.photoPageList=e.APIHelper.response.parsePhotos({photos:p.photos.photo,personModelRegistry:i,photoModelRegistry:a,photoEngagementModelRegistry:h,photoStatsModelRegistry:n}),l.addOrUpdate(s),s.photoPageList}}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["photo-models","person-models","photosof-models","photo-engagement-models","photo-stats-models"]});YUI.add("hermes-template-profile-photosof",function(e,a){var l=e.Template.Handlebars.revive({1:function(e,a,l,t,n){var s,r=e.escapeExpression,i=null!=a?a:{},o=l.helperMissing;return'\t
\n\t\t
'+r((l.intlMessage||a&&a.intlMessage||o).call(i,{name:"intlMessage",hash:{intlName:"profile.VIEW_ALL"},data:n}))+"\n\t\t
"+r((l.intlMessage||a&&a.intlMessage||o).call(i,{name:"intlMessage",hash:{username:null!=(s=null!=a?a.person:a)?s.displayname:s,intlName:"profile.PHOTOS_OF"},data:n}))+"
\n\t\t"+r((l.outlet||a&&a.outlet||o).call(i,null!=a?a["photo-list-view"]:a,{name:"outlet",hash:{},data:n}))+"\n\t
\n"},compiler:[7,">= 4.0.0"],main:function(e,a,l,t,n){var s;return null!=(s=l.if.call(null!=a?a:{},null!=a?a.photosOf:a,{name:"if",hash:{},fn:e.program(1,n,0),inverse:e.noop,data:n}))?s:""},useData:!0}),t={};e.Array.each([],function(a){var l=e.Template.get("hermes/"+a);l&&(t[a]=l)}),e.Template.register("hermes/profile-photosof",function(a,n){return n=n||{},n.partials=n.partials?e.merge(t,n.partials):t,l(a,n)})},"@VERSION@",{requires:["template-base","handlebars-base"]});YUI.add("profile-photosof-view",function(t){t.namespace("Views")[this.name]=t.Base.create("profile-photosof-view",t.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(t){var e="photosof-";return this.nsid=t.nsid,this.pathAlias=t.pathAlias,this.isViewingSelf=t.isViewingSelf,this.pathAlias?e+=this.pathAlias:e+=this.nsid,t.modelRegistryName="photosof-models",t.photoListConfig={parentName:"photosof-container",measureAFT:!0,contextSuffix:e,paginateOnScroll:!1,maintainScrollPosition:!1,pageParams:{page:1,nominalPage:1,viewPageSize:10,perPage:10},subviewMapping:{"photo-models":{name:"photo-list-photo-view",params:{removePhotosOfYou:this.isViewingSelf&&!this.isMobile}}}},t.photoListConfig.modelParams={registryName:"photosof-models",modelIdOrAttributes:this.nsid,collectionAttributeName:"photoPageList",fetchParams:{page:1,nominalPage:1,viewPageSize:10,perPage:10}},t.photoListConfig.layout={targetRowHeight:140,targetRowHeightTolerance:.5,maxNumRows:1,alwaysDisplayOrphans:!0,containerPadding:{top:0,right:0,bottom:8,left:0},itemSpacing:{horizontal:4,vertical:4}},this.photoListConfig=t.photoListConfig,this},subviewConfig:{"photo-list-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!0}},loadState:function(){return t.Promise.all([this.appContext.getModel("photosof-models",this.nsid),this.appContext.getModel("person-models",this.nsid)]).then(function(t){this.set("photosOfModel",t[0]),this.set("personModel",t[1])}.bind(this))},buildContainer:function(){var e=t.URLHelper.generatePersonUrls(this.get("personModel"));return this.setContainerWithTemplate("profile-photosof",{person:this.get("personModel").toJSON(),urls:e,photosOf:this.get("photosOfModel").getValue("photoPageList").getList().length>0,showProfileOnboardingTooltip:this.isViewingSelf}),this},activate:function(){return this},onSubviewEvent:function(e,o){if(o&&"photosofyou:remove"===o[0]){var i,s=o[1];(i=new t.Views.FluidModal({actionButtonLabel:this.intlMessage({intlName:"common.CONFIRM"}),title:this.intlMessage({intlName:"profile.PROFILE_PHOTOSOF_MODAL_TITLE"}),appContext:this.appContext,dismissOnOverlayClick:!0,dismissOnActionClick:!0,actionButtonDisabled:!1,actionButtonIsDangerous:!0,showCancelButton:!0,hideModalOverlay:!1,showCancelX:!0})).on("actionClick",function(){return this.appContext.callAPI("flickr.photos.people.delete",{photo_id:s.getValue("id"),user_id:this.appContext.getViewer().nsid}).then(function(e){e&&"ok"===e.stat&&(new t.Views.FluidModal({appContext:this.appContext,message:this.intlMessage({intlName:"common.ALMOST_DONE"}),showButtons:!1}).show(),t.config.win.location.reload())}.bind(this),function(e){t.config.win.location.reload()})}.bind(this)),i.show()}}})},"@VERSION@",{requires:["flutil","flickr-view","fluid-modal-view","url-helper","photosof-models","hermes-template-profile-photosof","hermes-template-profile-tooltip"],langBundles:["common","profile"]});YUI.add("profile-popular-photos-models",function(e){function t(e){t.superclass.constructor.call(this,e)}e.Models[this.name]=t,e.extend(t,e.FlickrModelRegistry,{name:this.name,remote:{read:function(t){return e.ListFetchers["flickr-photos-getPopular"].run(t,this.appContext)}},attributes:{photos:{isCollection:!0,pageFetch:{listFetcher:e.ListFetchers["flickr-photos-getPopular"]}},totalItems:{validator:function(t,r){return e.AttributeHelpers.validateInteger(t)},setter:function(t){return e.AttributeHelpers.coerceInteger(t)},defaultValue:0}}})},"@VERSION@",{requires:["flickr-model-registry","flickr-promise","flickr-photos-getPopular-fetcher"]});YUI.add("flickr-photos-getPopular-fetcher",function(e,o){"use strict";require("hermes-core/flog")(o);e.namespace("ListFetchers")["flickr-photos-getPopular"]={run:function(o,t,s){var r=this,p=this._processParams(o);return new e.FlickrPromise({apiResponse:t.callAPI("flickr.photos.getPopular",p),modelRegistry:t.getModelRegistry("profile-popular-photos-models"),personModelRegistry:t.getModelRegistry("person-models"),photoModelRegistry:t.getModelRegistry("photo-models"),photoEngagementModelRegistry:t.getModelRegistry("photo-engagement-models"),photoStatsModelRegistry:t.getModelRegistry("photo-stats-models")}).then(function(e){return r._processResponse(e,p,t)},function(e){return r._processResponse(e,p,t)}.bind(this))},_processResponse:function(o,t,s){var r,p,n,i,g,l=o.apiResponse,a=o.modelRegistry,d=o.personModelRegistry,h=o.photoModelRegistry,m=o.photoEngagementModelRegistry,u=o.photoStatsModelRegistry,R=[];return g=t.nsid+"-"+t.sort,l?(p=l.photos.photo.length,n=l.photos.perpage,i=l.photos.page,r={id:g,totalItems:p},l&&l.photos&&l.photos.photo.length&&(R=e.Array.map(l.photos.photo,function(o,t){return e.APIHelper.response.parsePhotos({photos:[o],personModelRegistry:d,photoModelRegistry:h,photoEngagementModelRegistry:m,photoStatsModelRegistry:u})[0]})),r.photos={perPage:n,page:i,pageContent:R,totalItems:p},a.addOrUpdate(r),r):(r={id:g,totalItems:[]},r.photos={perPage:t.per_page,page:1,pageContent:[],totalItems:0},s.getModelRegistry("profile-popular-photos-models").then(function(e){return e.addOrUpdate(r),r}))},_processParams:function(o){return{extras:e.APIHelper.request.getRebootPhotoExtras(),per_page:o.perPage||50,page:o.page||1,sort:o.sort||"interesting",view_as:"ff",user_id:o.nsid,nsid:o.nsid}}}},"@VERSION@",{requires:["flickr-promise","api-helper"],optional:["profile-popular-photos-models","person-models","photo-models","photo-engagement-models"]});YUI.add("hermes-template-profile-popular-photos",function(a,e){var t=a.Template.Handlebars.revive({1:function(a,e,t,n,l){var s,i,r=null!=e?e:{},p=t.helperMissing,o=a.escapeExpression;return'\t\n\t\t
'+o((t.intlMessage||e&&e.intlMessage||p).call(r,{name:"intlMessage",hash:{intlName:"profile.MOST_POPULAR_PHOTOS"},data:l}))+"
\n"+(null!=(s=t.if.call(r,null!=e?e.isViewingSelf:e,{name:"if",hash:{},fn:a.program(2,l,0),inverse:a.noop,data:l}))?s:"")+'\n\t\t
\n\n'+(null!=(s=t.if.call(r,null!=e?e.photos:e,{name:"if",hash:{},fn:a.program(4,l,0),inverse:a.noop,data:l}))?s:"")+"\t
\n"},2:function(a,e,t,n,l){var s;return'\t\t\n\t\t\t\n'+(null!=(s=a.invokePartial(n["profile-bio-privacy"],e,{name:"profile-bio-privacy",hash:{loading:!0},data:l,indent:"\t\t\t\t",helpers:t,partials:n,decorators:a.decorators}))?s:"")+"\t\t\t\n\t\t
\n"},4:function(a,e,t,n,l){return"\t\t\t"+a.escapeExpression((t.outlet||e&&e.outlet||t.helperMissing).call(null!=e?e:{},null!=e?e["photo-list-view"]:e,{name:"outlet",hash:{},data:l}))+"\n"},6:function(a,e,t,n,l){var s;return null!=(s=t.if.call(null!=e?e:{},null!=e?e.isViewingSelf:e,{name:"if",hash:{},fn:a.program(7,l,0),inverse:a.noop,data:l}))?s:""},7:function(a,e,t,n,l){var s=null!=e?e:{},i=t.helperMissing,r=a.escapeExpression;return'\t\t\n\t\t\t
'+r((t.intlMessage||e&&e.intlMessage||i).call(s,{name:"intlMessage",hash:{intlName:"profile.MOST_POPULAR_PHOTOS"},data:l}))+'
\n\n\t\t\t
\n\t\t\t\t
'+r((t.intlMessage||e&&e.intlMessage||i).call(s,{name:"intlMessage",hash:{intlName:"profile.MOST_POPULAR_PHOTOS_EMPTY_TITLE"},data:l}))+"
\n\t\t\t\t
"+r((t.intlMessage||e&&e.intlMessage||i).call(s,{name:"intlMessage",hash:{intlName:"profile.MOST_POPULAR_PHOTOS_EMPTY_TEXT"},data:l}))+"
\n\t\t\t\t
"+r((t.intlMessage||e&&e.intlMessage||i).call(s,{name:"intlMessage",hash:{intlName:"profile.MOST_POPULAR_PHOTOS_EMPTY_TEXT_2"},data:l}))+'
\n\t\t\t\t
'+r((t.intlMessage||e&&e.intlMessage||i).call(s,{name:"intlMessage",hash:{intlName:"profile.MOST_POPULAR_PHOTOS_GO_TO_CR"},data:l}))+"
\n\t\t\t
\n\t\t
\n"},compiler:[7,">= 4.0.0"],main:function(a,e,t,n,l){var s;return null!=(s=t.if.call(null!=e?e:{},null!=e?e.popularPhotos:e,{name:"if",hash:{},fn:a.program(1,l,0),inverse:a.program(6,l,0),data:l}))?s:""},usePartial:!0,useData:!0}),n={};a.Array.each(["profile-bio-privacy"],function(e){var t=a.Template.get("hermes/"+e);t&&(n[e]=t)}),a.Template.register("hermes/profile-popular-photos",function(e,l){return l=l||{},l.partials=l.partials?a.merge(n,l.partials):n,t(e,l)})},"@VERSION@",{requires:["template-base","handlebars-base","hermes-template-profile-bio-privacy"]});YUI.add("popular-photos-view",function(t){var e={interesting:"profile.FILTER_INTERESTING",views:"profile.FILTER_VIEWS",comments:"profile.FILTER_COMMENTS",faves:"profile.FILTER_FAVES"};t.namespace("Views")[this.name]=t.Base.create("popular-photos-view",t.FlickrView,[],{langBundles:this.details.langBundles,initializer:function(t){return this.nsid=t.nsid,this.pathAlias=t.pathAlias,this.isViewingSelf=t.isViewingSelf,this.profilePage=t.profilePage,this.sort=t.sort||"faves",this.pathAlias?this.pathAlias:this.nsid,t.modelRegistryName="profile-popular-photos-models",t.photoListConfig={parentName:"profile-container",measureAFT:!0,paginateOnScroll:!1,maintainScrollPosition:!1,pageParams:{id:this.nsid+"-"+this.sort,nsid:this.nsid,perPage:25,page:1,sort:this.sort}},t.photoListConfig.modelParams={registryName:"profile-popular-photos-models",modelIdOrAttributes:this.nsid+"-"+this.sort,collectionAttributeName:"photos",fetchParams:{id:this.nsid+"-"+this.sort,nsid:this.nsid,perPage:25,page:1,sort:this.sort}},t.photoListConfig.layout={targetRowHeight:140,targetRowHeightTolerance:.5,containerPadding:{top:0,right:0,bottom:8,left:0},itemSpacing:{horizontal:4,vertical:4}},t.profilePage&&(t.photoListConfig.layout.maxNumRows=4),this.photoListConfig=t.photoListConfig,this.params=t,this},subviewConfig:{"photo-list-view":{requiredToShowOnClient:!0,requiredToShowOnServer:!0}},loadState:function(){var e={id:this.nsid+"-"+this.sort,nsid:this.nsid,perPage:25,page:1,sort:this.sort};return t.Promise.all([this.appContext.getModel("profile-popular-photos-models",e),this.appContext.getModel("person-models",this.nsid)]).then(function(e){this.set("popularModel",e[0]),this.set("personModel",e[1]),this.set("personURLs",t.URLHelper.generatePersonUrls(e[1]))}.bind(this))},buildContainer:function(){return this.setContainerWithTemplate("profile-popular-photos",{popularPhotos:this.get("popularModel").getValue("photos").getList().length>0,urls:this.get("personURLs"),photos:this.get("popularModel").getValue("photos").size(),isViewingSelf:this.isViewingSelf,sortValue:this.sort,sortIntl:this.intlMessage({intlName:e[this.sort]}),person:this.get("personModel").toJSON()}),this},activate:function(){var e=this.get("container"),i=e.one(".filter-sort"),o=e.one("span.privacy");return i&&(this.registerEventHandler(i.on("click",this.onFilterClick,this)),t.Accessibility.makeDroparoundAnchorAccessible({view:this,getDroparound:this.getFilterDroparound.bind(this),anchor:i,handler:this.onFilterClick.bind(this)})),o&&this.isViewingSelf&&(this.registerEventHandler(o.on("click",this.openPrivacyDropdown.bind(this))),t.Accessibility.makeDroparoundAnchorAccessible({view:this,getDroparound:this.getPrivacyDroparound.bind(this),anchor:o,handler:this.openPrivacyDropdown.bind(this)}),this.getPopularPhotosPrivacySetting()),this},getFilterDroparound:function(){return this.dropdown},getPrivacyDroparound:function(){return this.privacyDropdown},onFilterClick:function(i){i.halt(),this.dropdown=new t.Views.FluidDroparound({appContext:this.appContext,showDropArrow:!0,observePageResize:!0,anchorElement:i.target,keyboardAnchorElement:i.target,minVerticalSpace:400,positionFixed:!0,preferLeft:!0,closeOnScroll:!0,anchorOffsetHorizontal:16,menuItems:[{text:this.intlMessage({intlName:"profile.FILTER_FAVES"}),url:this.get("personURLs").popularFaves,sortKey:"faves",isSelected:"faves"===this.sort},{text:this.intlMessage({intlName:"profile.FILTER_INTERESTING"}),url:this.get("personURLs").popular,sortKey:"interesting",isSelected:"interesting"===this.sort},{text:this.intlMessage({intlName:"profile.FILTER_VIEWS"}),url:this.get("personURLs").popularViews,sortKey:"views",isSelected:"views"===this.sort},{text:this.intlMessage({intlName:"profile.FILTER_COMMENTS"}),url:this.get("personURLs").popularComments,sortKey:"comments",isSelected:"comments"===this.sort}]}),this.dropdown.show(),this.registerEventHandler(this.dropdown.on("selected",function(i){if(i&&i.menuItem){var o=i.menuItem.sortKey,s=(i.menuItem.url,this.intlMessage({intlName:e[o]})),r=this.get("container").one(".dropdown-text");this.sort=o,r&&r.set("text",s),t.loaderBar.start(),this.updatePopularView(this.sort)}this.dropdown.close()}.bind(this)),this)},updatePopularView:function(e){this.loadState().then(function(){t.loaderBar.progress();var e=this.subviews["photo-list-view"],i=this.get("popularModel").getValue("photos").getList();i&&i.length?e.setItems(i):this.buildContainer(),t.loaderBar.finish()}.bind(this))},openPrivacyDropdown:function(e){e.halt();var i=e.target;i.getAttribute("data-privacy")&&(this.privacyDropdown&&this.privacyDropdown.destroy({remove:!0}),this.privacyDropdown=new t.Views.FluidDroparound({appContext:this.appContext,showDropArrow:!0,observePageResize:!0,anchorElement:i,keyboardAnchorElement:i,minVerticalSpace:400,positionFixed:!0,preferLeft:!0,closeOnScroll:!0,anchorOffsetHorizontal:0,anchorOffsetVertical:0,menuItems:[{text:this.intlMessage({intlName:"profile.EVERYONE"}),privacy:0,isSelected:0===this.get("popularPrivacy")},{text:this.intlMessage({intlName:"profile.ONLY_ME"}),privacy:5,isSelected:5===this.get("popularPrivacy")}]}),this.privacyDropdown.show(),this.registerEventHandler(this.privacyDropdown.on("selected",this.onNewPrivacySelected.bind(this)),this))},onNewPrivacySelected:function(t){if(t&&t.menuItem){var e=t.menuItem.privacy;return this.privacyDropdown&&this.privacyDropdown.close(),this.updatePrivacyIcon(!0),this.set("popularPrivacy",e),this.appContext.callAPI("flickr.account.setProfilePrivacy",{popular:e}).then(function(t){this.updatePrivacyIcon(!1)}.bind(this))}},updatePrivacyIcon:function(t){this.get("container").one('span[data-privacy="popular"]').setHTML(this.templates("profile-bio-privacy")({loading:t,private:5===this.get("popularPrivacy")}))},getPopularPhotosPrivacySetting:function(){return this.appContext.callAPI("flickr.account.getProfilePrivacy",{timestamp:(new Date).getTime()}).then(function(t){var e=t.privacy;e&&(this.set("popularPrivacy",e.popular),this.updatePrivacyIcon())}.bind(this),function(t){this.updatePrivacyIcon()}.bind(this))}})},"@VERSION@",{requires:["flutil","flickr-view","url-helper","profile-popular-photos-models","hermes-template-profile-popular-photos","hermes-template-profile-tooltip"],langBundles:["common","profile"]});