(function(){var t,i,r,f,u,e={}.hasOwnProperty,n=function(n,t){function r(){this.constructor=n}for(var i in t)e.call(t,i)&&(n[i]=t[i]);return r.prototype=t.prototype,n.prototype=new r,n.__super__=t.prototype,n};window.Glipho!=null||(window.Glipho={}),window.Glipho.Publications!=null||(window.Glipho.Publications={}),i=function(t){function i(){return i.__super__.constructor.apply(this,arguments)}return n(i,t),i.name="Publications",i.prototype.parse=function(n){return this.currentPage=n.Page,this.pageSize=n.PageSize,this.totalPages=n.TotalPages,n.Items},i}(Backbone.Collection),t=function(t){function i(){return i.__super__.constructor.apply(this,arguments)}return n(i,t),i.name="PublicationView",i.prototype.tagName="div",i.prototype.className="pub",i.prototype.template=Handlebars.compile($("#publication-template").html()),i.prototype.initialize=function(n){return this.showTopic=n.showTopic!=null?n.showTopic:!0,this.showProfile=n.showProfile!=null?n.showProfile:!0,this.showCounters=n.showCounters!=null?n.showCounters:!1},i.prototype.render=function(){var n;return n=this.model.toJSON(),n.showTopic=this.showTopic,n.showProfile=this.showProfile,n.showCounters=this.showCounters,$(this.el).html(this.template(n)),this},i}(Backbone.View),r=function(t){function i(){return i.__super__.constructor.apply(this,arguments)}return n(i,t),i.name="ScrollTopButton",i.prototype.tagName="div",i.prototype.className="scroll-top-button",i.prototype.template=Handlebars.compile($("#scroll-button-template").html()),i.prototype.events={click:"scroll"},i.prototype.render=function(){return this.$el.html(this.template()),this.$el.css("z-index","9991"),this.onPage=!0,this.$el.click(function(){return $("html, body").animate({scrollTop:"0px"},1500,"easeInOutExpo")}),this},i.prototype.remove=function(){return this.$el.remove(),this.onPage=!1,this},i.prototype.scroll=function(){},i}(Backbone.View),Glipho.Publications.ListingView=function(f){function e(){return e.__super__.constructor.apply(this,arguments)}return n(e,f),e.name="ListingView",e.prototype.tagName="div",e.prototype.initialize=function(n){return this.showTopics=n.showTopics!=null?n.showTopics:!0,this.showProfiles=n.showProfiles!=null?n.showProfiles:!0,this.scrollable=n.scrollable!=null?n.scrollable:!0,this.showCounters=n.showCounters!=null?n.showCounters:!1,this.noPublicationMessage=n.noPublicationMessage!=null?'<h2 class="message">'+n.noPublicationMessage+"<\/h2>":'<h2 class="message">We couldn\'t find any gliphs here... <\/h2>',this.url=n.url,this.publications=new i,this.publications.bind("reset",this.resetPublications,this),this.scrollButtonView=new r,this.scrollable&&$(window).bind("scroll",{view:this},this.scrollTopButton),Handlebars.registerHelper("dateFormat",function(){return new Handlebars.SafeString(new Date(this.PublishedTime))})},e.prototype.render=function(){return this},e.prototype.loadPublications=function(n,t){var i,r;if(i=t!=null?t:this.publications.pageSize!=null?this.publications.pageSize:30,$(window).unbind("scroll",this.scrollNextPage),this.scrollable&&this.publications.totalPages>0&&n!=null&&n>this.publications.totalPages){$(this.el).append('<h2 class="loadings">Looks like you\'ve hit rock bottom!<\/h2>');return}return n!=null&&n===1?$(this.el).empty().html('<div id="loading" class="loading" ><h3>loading gliphs<\/h3><img src="/Content/images/ajax-loader.gif"><\/div>'):$(this.el).append('<img id="loading" class="loadings" src="/Content/images/ajax-loader.gif" />'),this.publications.url=this.url,r=this,this.publications.fetch({data:{pageSize:i,page:n},error:function(n,t){return t.status===401||t.status===403?window.location.href="/home/login":t.status!==0&&alert("Error loading publications."),$(r.el).find("*[id*='loading']").remove()}})},e.prototype.addPublicaton=function(n){var i;return i=new t({model:n,showTopic:this.showTopics,showProfile:this.showProfiles,showCounters:this.showCounters}),$(this.el).append(i.render().el)},e.prototype.resetPublications=function(){return this.publications.each(this.addPublicaton,this),$(this.el).waitForImages(function(n){return setupBlocks(),n.scrollable&&$(window).bind("scroll",{view:n},n.scrollNextPage),$(n.$el).find("*[id*='loading']").remove(),n.publications.totalPages===0?(n.$el.html(n.noPublicationMessage),$(window).unbind("scroll",n.scrollNextPage)):void 0},this),$("time.timeago").timeago()},e.prototype.scrollNextPage=function(n){if($(this).scrollTop()>u()-1500)return n.data.view.loadPublications(n.data.view.publications.currentPage+1)},e.prototype.scrollTopButton=function(n){if($(window).scrollTop()>screen.height){if(!n.data.view.scrollButtonView.onPage)return $("body").append(n.data.view.scrollButtonView.render().el)}else return n.data.view.scrollButtonView.remove()},e}(Backbone.View),u=function(){return $(".colwrapper").height()},f=function(){var n;return n=document,Math.max(Math.max(n.body.scrollHeight,n.documentElement.scrollHeight),Math.max(n.body.offsetHeight,n.documentElement.offsetHeight),Math.max(n.body.clientHeight,n.documentElement.clientHeight))}}).call(this)