var IndexView = View.extend({
events: {
},
action: "/api/index",
keywordAction: "/api/keyword/",
initialize: function(opt){
// opt.parent = parent
this.hootbox = new HootBox ({ parent: this })
this.threadbox = new ThreadBox ({ parent: this })
this.lastlog = new LastLog ({ parent: this })
},
load: function(keyword){
$("body").addClass("index")
if (keyword) {
$(".subtitle").html('< Home · Keywords')
this.threadbox.options.latest = false
this.threadbox.options.welcome = false
$.get(this.keywordAction + keyword, this.populate.bind(this))
}
else {
this.hootbox.options.required = true
this.threadbox.options.latest = true
this.threadbox.options.welcome = true
$.get(this.action, this.populate.bind(this))
}
},
populate: function(data){
$("body").removeClass('loading')
this.hootbox.load(data.hootbox)
this.threadbox.load(data)
this.lastlog.load(data.lastlog)
if (data.mail.count) {
$(".alert").show().html(
"" +
"You have " +
data.mail.count +
" new message" +
courtesy_s(data.mail.count) +
"!")
if (is_mobile) {
$("#content").prepend( $(".alert") )
}
}
$(".search_form input").focus()
},
success: function(){
window.location.href = "/index"
},
})