var StreamView = View.extend({ action: "/api/stream/", initialize: function (opt) { // opt.parent = parent this.hootform = new HootForm({ parent: this }); this.hootstream = new HootStream({ parent: this }); this.hootfilters = new HootFilters({ parent: this }); }, load: function ({ ...target }) { $("body").addClass("index"); this.target = target; console.log("target", target); $.get(this.action, target, this.populate.bind(this)); }, populate: function (data) { $("body").removeClass("loading"); this.data = data; const { query } = data; const isHomePage = !(query.thread || query.username || query.keyword); this.hootform.toggle(isHomePage); this.hootfilters.load(data, this.target); this.hootstream.load(data, this.hootfilters.state); 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")); } } if (is_desktop) { $(".search_form input").focus(); } }, onComment: function (comment) { if (comment.thread === 1) { this.data.hootbox.push(comment); } else { this.data.comments.push(comment); } this.populate(this.data); }, onFilter: function (filters) { console.log("onfilter"); this.hootstream.build(filters); }, success: function () { window.location.href = "/index"; }, });