$(function(){window.HomePage=Backbone.View.extend({FAVORITES_URL:"//twitter.com/favorites/documentcloud.json?callback=?",el:document.body,events:{"keydown #search_box":"maybeSearch","search #search_box":"search","focus #search_box":"addFocus","blur #search_box":"removeFocus","click .cancel_search":"cancelSearch","click #login_button":"login"},initialize:function(){dc.ui.notifier=new dc.ui.Notifier;this.box=$("#search_box");this.emailInput=$("#account_email");this.passwordInput=$("#account_password");
_.invoke([this.box,this.emailInput,this.passwordInput],"placeholder");$(_.bind(this.loadTweets,this))},login:function(){$("#login_form").submit()},search:function(){var a=this.box.val();if(a)window.location=(window.serverRoot||"")+"/public/search/"+encodeURIComponent(a)},cancelSearch:function(){this.box.val("")},maybeSearch:function(a){a.which==13&&this.search()},addFocus:function(){$("#search_box_wrapper").addClass("focus")},removeFocus:function(){$("#search_box_wrapper").removeClass("focus")},loadTweets:function(){if($(document.body).hasClass("homepage")){var a=
DateUtils.create("%b %e, %Y");$.getJSON(this.FAVORITES_URL,function(b){b=b.slice(0,3);var c="";_.each(b,function(b,d){c+=JST["home/tweet"](_.extend(b,{index:d,date:a(new Date(Date.parse(b.created_at)))}))});$("#tweets").html(c).show()})}}});window.homepage=new HomePage});

