var CL=CL||{};CL.Views.Subheader=Backbone.View.extend({initialize:function(){var view=this;this.$wrapper=$(".float-wrapper",this.$el);this.state=new CL.Models.ViewState();this.links=[];$("a",this.$el).each(function(){var link=new CL.Views.SubheaderLink({el:$(this),subheader:view});view.links.push(link);});this.setPosition();$(window).on("scroll",function(){view.setPosition();});this.checkState();this.state.on("change:windowPos",function(){view.checkState();});},setPosition:function(){var windowPos=$(window).scrollTop(),threshold=this.$el.offset().top,isFixed=(windowPos>threshold);this.state.set({windowPos:windowPos,isFixed:isFixed});},checkState:function(){var isFixed=this.state.get("isFixed");if(isFixed&&!this.isFixed){this.setFixed();}else if(!isFixed&&this.isFixed){this.unsetFixed();}},setFixed:function(){this.$el.addClass("fixed");this.isFixed=true;},unsetFixed:function(){this.$el.removeClass("fixed") this.isFixed=false;}});CL.Views.SubheaderLink=Backbone.View.extend({initialize:function(){this.options.animationDuration=500;},events:{"click":function(ev){var offset;this.$target=$(this.$el.attr("href"));offset=typeof this.$target.data("offset")=="number"?this.$target.data("offset"):48;$("html, body").animate({"scrollTop":this.$target.offset().top-this.options.subheader.$wrapper.outerHeight(true)-offset},this.options.animationDuration);ev.preventDefault();}}});